Compare commits
25 Commits
10992
...
feature-py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be6ead75e9 | ||
|
|
25f7ccf0c2 | ||
|
|
afb0a86291 | ||
|
|
f5c5faa3d4 | ||
|
|
c471d1ced0 | ||
|
|
5c345faea7 | ||
|
|
11bed1f0c3 | ||
|
|
ec57799a5d | ||
|
|
4c8aa638eb | ||
|
|
7c3caec07f | ||
|
|
45f71543bd | ||
|
|
13b9d91ecb | ||
|
|
f239018e77 | ||
|
|
f1c98b848a | ||
|
|
2c7bde422a | ||
|
|
9e95bfea90 | ||
|
|
b820ff4de8 | ||
|
|
8218a2be99 | ||
|
|
9e3031c562 | ||
|
|
2cf9239b6e | ||
|
|
4c63c60a89 | ||
|
|
9a2e47b05c | ||
|
|
711d46d6e2 | ||
|
|
5d6625c1ea | ||
|
|
0a70611d81 |
31
.github/workflows/gh-actions.yml
vendored
31
.github/workflows/gh-actions.yml
vendored
@@ -1,31 +0,0 @@
|
||||
name: Build & Test Lean
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['*']
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-16.04
|
||||
container:
|
||||
image: quantconnect/lean:foundation
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Restore nuget dependencies
|
||||
run: |
|
||||
nuget restore QuantConnect.Lean.sln -v quiet
|
||||
nuget install NUnit.Runners -Version 3.11.1 -OutputDirectory testrunner
|
||||
|
||||
- name: Build
|
||||
run: msbuild /p:Configuration=Release /p:VbcToolExe=vbnc.exe /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
|
||||
|
||||
- name: Run Tests
|
||||
run: mono ./testrunner/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe ./Tests/bin/Release/QuantConnect.Tests.dll --where "cat != TravisExclude" --labels=Off --params:log-handler=ConsoleErrorLogHandler
|
||||
|
||||
- name: Generate & Publish python stubs
|
||||
run: |
|
||||
chmod +x ci_build_stubs.sh
|
||||
./ci_build_stubs.sh -d -t -g #Ignore Publish as of since credentials are missing on CI
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -144,7 +144,6 @@ $tf/
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding addin-in
|
||||
|
||||
4
.idea/workspace.xml
generated
4
.idea/workspace.xml
generated
@@ -3,7 +3,7 @@
|
||||
<component name="RunManager" selected="Python Debug Server.Debug in Container">
|
||||
<configuration name="Debug Local" type="PyRemoteDebugConfigurationType" factoryName="Python Remote Debug">
|
||||
<module name="LEAN" />
|
||||
<option name="PORT" value="6000" />
|
||||
<option name="PORT" value="5678" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
@@ -16,7 +16,7 @@
|
||||
</configuration>
|
||||
<configuration name="Debug in Container" type="PyRemoteDebugConfigurationType" factoryName="Python Remote Debug">
|
||||
<module name="LEAN" />
|
||||
<option name="PORT" value="6000" />
|
||||
<option name="PORT" value="5678" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
sudo: required
|
||||
language: csharp
|
||||
dotnet: 5.0
|
||||
mono:
|
||||
- 5.12.0
|
||||
solution: QuantConnect.Lean.sln
|
||||
before_install:
|
||||
- export PATH="$HOME/miniconda3/bin:$PATH"
|
||||
- wget -q https://cdn.quantconnect.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh
|
||||
- wget https://cdn.quantconnect.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh
|
||||
- bash Miniconda3-4.5.12-Linux-x86_64.sh -b
|
||||
- rm -rf Miniconda3-4.5.12-Linux-x86_64.sh
|
||||
- sudo ln -s $HOME/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6m.so
|
||||
@@ -17,10 +16,12 @@ before_install:
|
||||
- conda install -y cython=0.29.15
|
||||
- conda install -y scipy=1.4.1
|
||||
- conda install -y wrapt=1.12.1
|
||||
- pip install pyarrow==1.0.1
|
||||
install:
|
||||
- nuget restore QuantConnect.Lean.sln
|
||||
- nuget install NUnit.Runners -Version 3.11.1 -OutputDirectory testrunner
|
||||
script:
|
||||
- dotnet build /p:Configuration=Release /p:VbcToolExe=vbnc.exe /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
|
||||
- mono ./testrunner/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe ./Tests/bin/Release/QuantConnect.Tests.dll --where "cat != TravisExclude" --labels=Off --params:log-handler=ConsoleErrorLogHandler
|
||||
- msbuild /p:Configuration=Release /p:VbcToolExe=vbnc.exe QuantConnect.Lean.sln
|
||||
- mono ./testrunner/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe ./Tests/bin/Release/QuantConnect.Tests.dll --where "cat != TravisExclude" --labels=Off
|
||||
- chmod +x ci_build_stubs.sh
|
||||
- sudo -E ./ci_build_stubs.sh -d -t -g -p
|
||||
|
||||
17
.vscode/readme.md
vendored
17
.vscode/readme.md
vendored
@@ -13,7 +13,7 @@ Before anything we need to ensure a few things have been done:
|
||||
|
||||
|
||||
1. Get [Visual Studio Code](https://code.visualstudio.com/download)
|
||||
* Get the Extension [Mono Debug **15.8**](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) for C# Debugging
|
||||
* Get the Extension [Mono Debug](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) for C# Debugging
|
||||
* Get the Extension [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for Python Debugging
|
||||
|
||||
2. Get [Docker](https://docs.docker.com/get-docker/):
|
||||
@@ -35,8 +35,7 @@ Before anything we need to ensure a few things have been done:
|
||||
* Download the repo or clone it using: _git clone[ https://github.com/QuantConnect/Lean](https://github.com/QuantConnect/Lean)_
|
||||
* Open the folder using VS Code
|
||||
|
||||
**NOTES**:
|
||||
- Mono Extension Version 16 and greater fails to debug the docker container remotely, please install **Version 15.8**. To install an older version from within VS Code go to the extensions tab, search "Mono Debug", and select "Install Another Version...".
|
||||
|
||||
<br />
|
||||
|
||||
<h1>Develop Algorithms Locally, Run in Container</h1>
|
||||
@@ -67,7 +66,7 @@ Before we can use this method with Windows or Mac OS we need to share the Lean d
|
||||
|
||||
Next we need to be sure that our Lean configuration at **.\Launcher\config.json** is properly set. Just like running lean locally the config must reflect what we want Lean to run.
|
||||
|
||||
Your configuration file should look something like this for the following languages:
|
||||
You configuration file should look something like this for the following languages:
|
||||
|
||||
<h3>Python:</h3>
|
||||
|
||||
@@ -113,12 +112,6 @@ In VS Code click on the debug/run icon on the left toolbar, at the top you shoul
|
||||
|
||||
As defaults these are all great! Feel free to change them as needed for your setup.
|
||||
|
||||
**NOTE:** VSCode may try and throw errors when launching this way regarding build on `QuantConnect.csx` and `Config.json` these errors can be ignored by selecting "*Debug Anyway*". To stop this error message in the future select "*Remember my choice in user settings*".
|
||||
|
||||
If using C# algorithms ensure that msbuild can build them successfully.
|
||||
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
<h3>Option 2</h3>
|
||||
@@ -201,6 +194,4 @@ _Figure 2: Python Debugger Messages_
|
||||
<h1>Common Issues</h1>
|
||||
Here we will cover some common issues with setting this up. This section will expand as we get user feedback!
|
||||
|
||||
* Any error messages about building in VSCode that point to comments in JSON. Either select **ignore** or follow steps described [here](https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json) to remove the errors entirely.
|
||||
* `Errors exist after running preLaunchTask 'run-docker'`This VSCode error appears to warn you of CSharp errors when trying to use `Debug in Container` select "Debug Anyway" as the errors are false flags for JSON comments as well as `QuantConnect.csx` not finding references. Neither of these will impact your debugging.
|
||||
* `The container name "/LeanEngine" is already in use by container "****"` This Docker error implies that another instance of lean is already running under the container name /LeanEngine. If this error appears either use Docker Desktop to delete the container or use `docker kill LeanEngine` from the command line.
|
||||
* Error messages about build in VSCode points to comments in JSON. Either select **ignore** or follow steps described [here](https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json) to remove the errors entirely.
|
||||
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@@ -20,34 +20,6 @@
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "rebuild",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"/p:Configuration=Debug",
|
||||
"/p:DebugType=portable",
|
||||
"/t:rebuild",
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "clean",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"/t:clean",
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "force build linux",
|
||||
"type": "shell",
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.212"},
|
||||
{"Treynor Ratio", "-2.13"},
|
||||
{"Total Fees", "$199.00"},
|
||||
{"Estimated Strategy Capacity", "$280000000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
@@ -114,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "54.5455%"},
|
||||
{"Rolling Averaged Population Direction", "59.8056%"},
|
||||
{"Rolling Averaged Population Magnitude", "59.8056%"},
|
||||
{"OrderListHash", "0a28eedf6304023f5002ef672b489b88"}
|
||||
{"OrderListHash", "1256341962"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.367"},
|
||||
{"Treynor Ratio", "-4.079"},
|
||||
{"Total Fees", "$14.33"},
|
||||
{"Estimated Strategy Capacity", "$29000000.00"},
|
||||
{"Fitness Score", "0.408"},
|
||||
{"Kelly Criterion Estimate", "16.447"},
|
||||
{"Kelly Criterion Probability Value", "0.315"},
|
||||
@@ -150,7 +149,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "100%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "506e9fe18984ba6e569b2e327030de3a"}
|
||||
{"OrderListHash", "-887015098"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$7.40"},
|
||||
{"Estimated Strategy Capacity", "$28000000.00"},
|
||||
{"Fitness Score", "1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -205,7 +204,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "35738733ff791eeeaf508faec804cab0"}
|
||||
{"OrderListHash", "1074366800"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.044"},
|
||||
{"Treynor Ratio", "0.479"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$12000.00"},
|
||||
{"Fitness Score", "0.41"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -239,7 +238,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "9347e3b610cfa21f7cbd968a0135c8af"}
|
||||
{"OrderListHash", "1532330301"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,15 +131,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.92"},
|
||||
{"Alpha", "-0.021"},
|
||||
{"Beta", "-0.01"},
|
||||
{"Alpha", "-0.023"},
|
||||
{"Beta", "0.005"},
|
||||
{"Annual Standard Deviation", "0.006"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-3.374"},
|
||||
{"Tracking Error", "0.058"},
|
||||
{"Treynor Ratio", "2.133"},
|
||||
{"Information Ratio", "-3.424"},
|
||||
{"Tracking Error", "0.057"},
|
||||
{"Treynor Ratio", "-4.775"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$6400000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -159,7 +158,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "486118a60d78f74811fe8d927c2c6b43"}
|
||||
{"OrderListHash", "-1185639451"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.042"},
|
||||
{"Treynor Ratio", "0.286"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$1400000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -211,7 +210,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "ae0b430e9c728966e3736fb352a689c6"}
|
||||
{"OrderListHash", "721476625"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -250,7 +249,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "cf8f76fa441c2a5e3b2dbbabcab32cd2"}
|
||||
{"OrderListHash", "731140098"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.072"},
|
||||
{"Treynor Ratio", "2.933"},
|
||||
{"Total Fees", "$26.39"},
|
||||
{"Estimated Strategy Capacity", "$2200000.00"},
|
||||
{"Fitness Score", "0.374"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -151,7 +150,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "5f7ba8b5defb310a2eaf98b11abd3b74"}
|
||||
{"OrderListHash", "1779055144"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.006"},
|
||||
{"Treynor Ratio", "2.029"},
|
||||
{"Total Fees", "$9.77"},
|
||||
{"Estimated Strategy Capacity", "$28000000.00"},
|
||||
{"Fitness Score", "0.747"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
@@ -104,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "54.5455%"},
|
||||
{"Rolling Averaged Population Direction", "59.8056%"},
|
||||
{"Rolling Averaged Population Magnitude", "59.8056%"},
|
||||
{"OrderListHash", "0b8cbbafdb77bae2f7abe3cf5e05ac5c"}
|
||||
{"OrderListHash", "-887190565"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.376"},
|
||||
{"Treynor Ratio", "-0.084"},
|
||||
{"Total Fees", "$13.98"},
|
||||
{"Estimated Strategy Capacity", "$31000000.00"},
|
||||
{"Fitness Score", "0.146"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
@@ -123,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "8971c92ba163cec8526379865d9b9ee4"}
|
||||
{"OrderListHash", "1917702312"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.194"},
|
||||
{"Treynor Ratio", "-0.962"},
|
||||
{"Total Fees", "$25.92"},
|
||||
{"Estimated Strategy Capacity", "$16000000.00"},
|
||||
{"Fitness Score", "0.004"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
@@ -130,7 +129,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "ce59e51c8e404b5dbbc02911473aed1c"}
|
||||
{"OrderListHash", "-1674230481"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Brokerages;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Shortable;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests filtering in coarse selection by shortable quantity
|
||||
/// </summary>
|
||||
public class AllShortableSymbolsCoarseSelectionRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private static readonly DateTime _20140325 = new DateTime(2014, 3, 25);
|
||||
private static readonly DateTime _20140326 = new DateTime(2014, 3, 26);
|
||||
private static readonly DateTime _20140327 = new DateTime(2014, 3, 27);
|
||||
private static readonly DateTime _20140328 = new DateTime(2014, 3, 28);
|
||||
private static readonly DateTime _20140329 = new DateTime(2014, 3, 29);
|
||||
|
||||
private static readonly Symbol _aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
private static readonly Symbol _bac = QuantConnect.Symbol.Create("BAC", SecurityType.Equity, Market.USA);
|
||||
private static readonly Symbol _gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
|
||||
private static readonly Symbol _goog = QuantConnect.Symbol.Create("GOOG", SecurityType.Equity, Market.USA);
|
||||
private static readonly Symbol _qqq = QuantConnect.Symbol.Create("QQQ", SecurityType.Equity, Market.USA);
|
||||
private static readonly Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
|
||||
private DateTime _lastTradeDate;
|
||||
|
||||
private static readonly Dictionary<DateTime, bool> _coarseSelected = new Dictionary<DateTime, bool>
|
||||
{
|
||||
{ _20140325, false },
|
||||
{ _20140326, false },
|
||||
{ _20140327, false },
|
||||
{ _20140328, false },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<DateTime, Symbol[]> _expectedSymbols = new Dictionary<DateTime, Symbol[]>
|
||||
{
|
||||
{ _20140325, new[]
|
||||
{
|
||||
_bac,
|
||||
_qqq,
|
||||
_spy
|
||||
}
|
||||
},
|
||||
{ _20140326, new[]
|
||||
{
|
||||
_spy
|
||||
}
|
||||
},
|
||||
{ _20140327, new[]
|
||||
{
|
||||
_aapl,
|
||||
_bac,
|
||||
_gme,
|
||||
_qqq,
|
||||
_spy,
|
||||
}
|
||||
},
|
||||
{ _20140328, new[]
|
||||
{
|
||||
_goog
|
||||
}
|
||||
},
|
||||
{ _20140329, new Symbol[0] }
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 3, 25);
|
||||
SetEndDate(2014, 3, 29);
|
||||
SetCash(10000000);
|
||||
|
||||
AddUniverse(CoarseSelection);
|
||||
UniverseSettings.Resolution = Resolution.Daily;
|
||||
|
||||
SetBrokerageModel(new AllShortableSymbolsRegressionAlgorithmBrokerageModel());
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Time.Date == _lastTradeDate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var symbol in ActiveSecurities.Keys)
|
||||
{
|
||||
if (!Portfolio.ContainsKey(symbol) || !Portfolio[symbol].Invested)
|
||||
{
|
||||
if (!Shortable(symbol))
|
||||
{
|
||||
throw new Exception($"Expected {symbol} to be shortable on {Time:yyyy-MM-dd}");
|
||||
}
|
||||
|
||||
// Buy at least once into all Symbols. Since daily data will always use
|
||||
// MOO orders, it makes the testing of liquidating buying into Symbols difficult.
|
||||
MarketOrder(symbol, -(decimal)ShortableQuantity(symbol));
|
||||
_lastTradeDate = Time.Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<Symbol> CoarseSelection(IEnumerable<CoarseFundamental> coarse)
|
||||
{
|
||||
var shortableSymbols = AllShortableSymbols();
|
||||
var selectedSymbols = coarse
|
||||
.Select(x => x.Symbol)
|
||||
.Where(s => shortableSymbols.ContainsKey(s) && shortableSymbols[s] >= 500)
|
||||
.OrderBy(s => s)
|
||||
.ToList();
|
||||
|
||||
var expectedMissing = 0;
|
||||
if (Time.Date == _20140327)
|
||||
{
|
||||
var gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
|
||||
if (!shortableSymbols.ContainsKey(gme))
|
||||
{
|
||||
throw new Exception("Expected unmapped GME in shortable symbols list on 2014-03-27");
|
||||
}
|
||||
if (!coarse.Select(x => x.Symbol.Value).Contains("GME"))
|
||||
{
|
||||
throw new Exception("Expected mapped GME in coarse symbols on 2014-03-27");
|
||||
}
|
||||
|
||||
expectedMissing = 1;
|
||||
}
|
||||
|
||||
var missing = _expectedSymbols[Time.Date].Except(selectedSymbols).ToList();
|
||||
if (missing.Count != expectedMissing)
|
||||
{
|
||||
throw new Exception($"Expected Symbols selected on {Time.Date:yyyy-MM-dd} to match expected Symbols, but the following Symbols were missing: {string.Join(", ", missing.Select(s => s.ToString()))}");
|
||||
}
|
||||
|
||||
_coarseSelected[Time.Date] = true;
|
||||
return selectedSymbols;
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (!_coarseSelected.Values.All(x => x))
|
||||
{
|
||||
throw new AggregateException($"Expected coarse selection on all dates, but didn't run on: {string.Join(", ", _coarseSelected.Where(kvp => !kvp.Value).Select(kvp => kvp.Key.ToStringInvariant("yyyy-MM-dd")))}");
|
||||
}
|
||||
}
|
||||
|
||||
private class AllShortableSymbolsRegressionAlgorithmBrokerageModel : DefaultBrokerageModel
|
||||
{
|
||||
public AllShortableSymbolsRegressionAlgorithmBrokerageModel() : base()
|
||||
{
|
||||
ShortableProvider = new RegressionTestShortableProvider();
|
||||
}
|
||||
}
|
||||
|
||||
private class RegressionTestShortableProvider : LocalDiskShortableProvider
|
||||
{
|
||||
public RegressionTestShortableProvider() : base(SecurityType.Equity, "testbrokerage", Market.USA)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "5"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "36.294%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.340%"},
|
||||
{"Sharpe Ratio", "21.2"},
|
||||
{"Probabilistic Sharpe Ratio", "99.990%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.274"},
|
||||
{"Beta", "0.138"},
|
||||
{"Annual Standard Deviation", "0.011"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "7.202"},
|
||||
{"Tracking Error", "0.068"},
|
||||
{"Treynor Ratio", "1.722"},
|
||||
{"Total Fees", "$307.50"},
|
||||
{"Estimated Strategy Capacity", "$710000.00"},
|
||||
{"Fitness Score", "0.173"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0.173"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6b1b205e5a6461ffd5bed645099714cd"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -19,27 +19,28 @@ using QuantConnect.Indicators;
|
||||
using QuantConnect.Orders.Fees;
|
||||
using QuantConnect.Data.Custom;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Algorithm.Framework;
|
||||
using QuantConnect.Algorithm.Framework.Alphas;
|
||||
using QuantConnect.Algorithm.Framework.Execution;
|
||||
using QuantConnect.Algorithm.Framework.Portfolio;
|
||||
using QuantConnect.Algorithm.Framework.Risk;
|
||||
using QuantConnect.Algorithm.Framework.Selection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
///<summary>
|
||||
/// This Alpha Model uses Wells Fargo 30-year Fixed Rate Mortgage data from Quandl to
|
||||
/// generate Insights about the movement of Real Estate ETFs. Mortgage rates can provide information
|
||||
/// regarding the general price trend of real estate, and ETFs provide good continuous-time instruments
|
||||
/// to measure the impact against. Volatility in mortgage rates tends to put downward pressure on real
|
||||
/// estate prices, whereas stable mortgage rates, regardless of true rate, lead to stable or higher real
|
||||
/// estate prices. This Alpha model seeks to take advantage of this correlation by emitting insights
|
||||
/// based on volatility and rate deviation from its historic mean.
|
||||
///
|
||||
/// This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open
|
||||
/// <summary>
|
||||
/// This Alpha Model uses Wells Fargo 30-year Fixed Rate Mortgage data from Quandl to
|
||||
/// generate Insights about the movement of Real Estate ETFs. Mortgage rates can provide information
|
||||
/// regarding the general price trend of real estate, and ETFs provide good continuous-time instruments
|
||||
/// to measure the impact against. Volatility in mortgage rates tends to put downward pressure on real
|
||||
/// estate prices, whereas stable mortgage rates, regardless of true rate, lead to stable or higher real
|
||||
/// estate prices. This Alpha model seeks to take advantage of this correlation by emitting insights
|
||||
/// based on volatility and rate deviation from its historic mean.
|
||||
|
||||
/// This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open
|
||||
/// sourced so the community and client funds can see an example of an alpha.
|
||||
///</summary>
|
||||
public class MortgageRateVolatilityAlgorithm : QCAlgorithm
|
||||
/// <summary>
|
||||
public class MortgageRateVolatilityAlgorithm : QCAlgorithmFramework
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -50,8 +51,8 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
SetSecurityInitializer(security => security.FeeModel = new ConstantFeeModel(0));
|
||||
|
||||
// Basket of 6 liquid real estate ETFs
|
||||
Func<string, Symbol> toSymbol = x => QuantConnect.Symbol.Create(x, SecurityType.Equity, Market.USA);
|
||||
var realEstateETFs = new[] { "VNQ", "REET", "TAO", "FREL", "SRET", "HIPS" }.Select(toSymbol).ToArray();
|
||||
Func<string, Symbol> ToSymbol = x => QuantConnect.Symbol.Create(x, SecurityType.Equity, Market.USA);
|
||||
var realEstateETFs = new[] { "VNQ", "REET", "TAO", "FREL", "SRET", "HIPS" }.Select(ToSymbol).ToArray();
|
||||
SetUniverseSelection(new ManualUniverseSelectionModel(realEstateETFs));
|
||||
|
||||
SetAlpha(new MortgageRateVolatilityAlphaModel(this));
|
||||
@@ -63,6 +64,8 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
SetRiskManagement(new NullRiskManagementModel());
|
||||
|
||||
}
|
||||
|
||||
public void OnData(QuandlMortgagePriceColumns data) { }
|
||||
|
||||
private class MortgageRateVolatilityAlphaModel : AlphaModel
|
||||
{
|
||||
@@ -76,7 +79,7 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
private readonly StandardDeviation _mortgageRateStd;
|
||||
|
||||
public MortgageRateVolatilityAlphaModel(
|
||||
QCAlgorithm algorithm,
|
||||
QCAlgorithmFramework algorithm,
|
||||
int indicatorPeriod = 15,
|
||||
double insightMagnitude = 0.0005,
|
||||
int deviations = 2,
|
||||
@@ -99,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
WarmUpIndicators(algorithm);
|
||||
}
|
||||
|
||||
public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data)
|
||||
public override IEnumerable<Insight> Update(QCAlgorithmFramework algorithm, Slice data)
|
||||
{
|
||||
var insights = new List<Insight>();
|
||||
|
||||
@@ -138,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
|
||||
return insights;
|
||||
}
|
||||
|
||||
private void WarmUpIndicators(QCAlgorithm algorithm)
|
||||
private void WarmUpIndicators(QCAlgorithmFramework algorithm)
|
||||
{
|
||||
// Make a history call and update the indicators
|
||||
algorithm.History(new[] { _mortgageRate }, _indicatorPeriod, _resolution).PushThrough(bar =>
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm to test the behaviour of ARMA versus AR models at the same order of differencing.
|
||||
/// In particular, an ARIMA(1,1,1) and ARIMA(1,1,0) are instantiated while orders are placed if their difference
|
||||
/// is sufficiently large (which would be due to the inclusion of the MA(1) term).
|
||||
/// </summary>
|
||||
public class AutoRegressiveIntegratedMovingAverageRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private AutoRegressiveIntegratedMovingAverage _arima;
|
||||
private AutoRegressiveIntegratedMovingAverage _ar;
|
||||
private decimal _last;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 1, 07);
|
||||
SetEndDate(2013, 12, 11);
|
||||
|
||||
EnableAutomaticIndicatorWarmUp = true;
|
||||
AddEquity("SPY", Resolution.Daily);
|
||||
_arima = ARIMA("SPY", 1, 1, 1, 50);
|
||||
_ar = ARIMA("SPY", 1, 1, 0, 50);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (_arima.IsReady)
|
||||
{
|
||||
if (Math.Abs(_ar.Current.Value - _arima.Current.Value) > 1) // Difference due to MA(1) being included.
|
||||
{
|
||||
if (_arima.Current.Value > _last)
|
||||
{
|
||||
MarketOrder("SPY", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MarketOrder("SPY", -1);
|
||||
}
|
||||
}
|
||||
|
||||
_last = _arima.Current.Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "65"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "0.145%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "2.190"},
|
||||
{"Net Profit", "0.134%"},
|
||||
{"Sharpe Ratio", "0.993"},
|
||||
{"Probabilistic Sharpe Ratio", "49.669%"},
|
||||
{"Loss Rate", "29%"},
|
||||
{"Win Rate", "71%"},
|
||||
{"Profit-Loss Ratio", "3.50"},
|
||||
{"Alpha", "0.001"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-2.168"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-5.187"},
|
||||
{"Total Fees", "$65.00"},
|
||||
{"Estimated Strategy Capacity", "$2300000000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "1.51"},
|
||||
{"Return Over Maximum Drawdown", "1.819"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "c4c9c272037cfd8f6887052b8d739466"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.441"},
|
||||
{"Treynor Ratio", "-0.008"},
|
||||
{"Total Fees", "$20.35"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Fitness Score", "0.138"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -188,7 +187,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "7c841ca58a4385f42236838e5bf0c382"}
|
||||
{"OrderListHash", "-1453269600"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.922"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$15000000.00"},
|
||||
{"Fitness Score", "0.248"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -150,7 +149,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "25885f979ca8c7b44f5d0f7daf00b241"}
|
||||
{"OrderListHash", "491919591"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -303,40 +303,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.323%"},
|
||||
{"Sharpe Ratio", "-11.098"},
|
||||
{"Sharpe Ratio", "-0.888"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.002"},
|
||||
{"Beta", "0.099"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Alpha", "0.035"},
|
||||
{"Beta", "0.183"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "9.899"},
|
||||
{"Tracking Error", "0.019"},
|
||||
{"Treynor Ratio", "-0.23"},
|
||||
{"Information Ratio", "12.058"},
|
||||
{"Tracking Error", "0.017"},
|
||||
{"Treynor Ratio", "-0.018"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.213"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-73.456"},
|
||||
{"Portfolio Turnover", "0.426"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "72a6ced0ed0c2da7136f3be652eb4744"}
|
||||
{"OrderListHash", "904167951"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$85000.00"},
|
||||
{"Fitness Score", "0.506"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -108,7 +107,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "18dc611407abec4ea47092e71f33f983"}
|
||||
{"OrderListHash", "-1575550889"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.922"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$15000000.00"},
|
||||
{"Fitness Score", "0.248"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -117,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "25885f979ca8c7b44f5d0f7daf00b241"}
|
||||
{"OrderListHash", "491919591"}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$85.34"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.5"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -243,7 +242,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "1bf1a6d9dd921982b72a6178f9e50e68"}
|
||||
{"OrderListHash", "956597072"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.221"},
|
||||
{"Treynor Ratio", "-13.568"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$130000000.00"},
|
||||
{"Fitness Score", "0.111"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -108,7 +107,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "82fee25cd17100c53bb173834ab5f0b2"}
|
||||
{"OrderListHash", "1268340653"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.002"},
|
||||
{"Treynor Ratio", "1.839"},
|
||||
{"Total Fees", "$9.77"},
|
||||
{"Estimated Strategy Capacity", "$20000000.00"},
|
||||
{"Fitness Score", "0.747"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
@@ -129,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "54.5455%"},
|
||||
{"Rolling Averaged Population Direction", "59.8056%"},
|
||||
{"Rolling Averaged Population Magnitude", "59.8056%"},
|
||||
{"OrderListHash", "17e29d58e5dabd93569da752c4552c70"}
|
||||
{"OrderListHash", "951346025"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.504"},
|
||||
{"Treynor Ratio", "1.011"},
|
||||
{"Total Fees", "$15207.00"},
|
||||
{"Estimated Strategy Capacity", "$8800000.00"},
|
||||
{"Fitness Score", "0.033"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -167,7 +166,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "35b3f4b7a225468d42ca085386a2383e"}
|
||||
{"OrderListHash", "-1197265007"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.188"},
|
||||
{"Treynor Ratio", "-3.318"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Fitness Score", "0.009"},
|
||||
{"Kelly Criterion Estimate", "-112.972"},
|
||||
{"Kelly Criterion Probability Value", "0.671"},
|
||||
@@ -175,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "18ffd3a774c68da83d867e3b09e3e05d"}
|
||||
{"OrderListHash", "-1624258832"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -160,7 +160,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -180,7 +179,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$778.00"},
|
||||
{"Estimated Strategy Capacity", "$180000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -154,7 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "5484aef1443064c826e0071f757cb0f7"}
|
||||
{"OrderListHash", "-702975961"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -151,7 +150,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "9d9f9248ee8fe30d87ff0a6f6fea5112"}
|
||||
{"OrderListHash", "1130102123"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "2"},
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
@@ -122,7 +122,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -142,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "92d8a50efe230524512404dab66b19dd"}
|
||||
{"OrderListHash", "687310345"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$3.00"},
|
||||
{"Estimated Strategy Capacity", "$74000.00"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0.327"},
|
||||
{"Kelly Criterion Probability Value", "1"},
|
||||
@@ -181,7 +180,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "50.0482%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "ce06ddfa4b2ffeb666a8910ac8836992"}
|
||||
{"OrderListHash", "352959406"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.09"},
|
||||
{"Treynor Ratio", "0.82"},
|
||||
{"Total Fees", "$41.70"},
|
||||
{"Estimated Strategy Capacity", "$2000000.00"},
|
||||
{"Fitness Score", "0.634"},
|
||||
{"Kelly Criterion Estimate", "13.656"},
|
||||
{"Kelly Criterion Probability Value", "0.228"},
|
||||
@@ -114,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "50%"},
|
||||
{"Rolling Averaged Population Direction", "12.6429%"},
|
||||
{"Rolling Averaged Population Magnitude", "12.6429%"},
|
||||
{"OrderListHash", "3edd51956c7c97af4863aa6059c11f1a"}
|
||||
{"OrderListHash", "-2004493274"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Custom.CBOE;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the consolidation of custom data with random data
|
||||
/// </summary>
|
||||
public class CBOECustomDataConsolidationRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _vix;
|
||||
private BollingerBands _bb;
|
||||
private bool _invested;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the algorithm with fake VIX data
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 7);
|
||||
SetEndDate(2013, 10, 11);
|
||||
SetCash(100000);
|
||||
|
||||
_vix = AddData<IncrementallyGeneratedCustomData>("VIX", Resolution.Daily).Symbol;
|
||||
_bb = BB(_vix, 30, 2, MovingAverageType.Simple, Resolution.Daily);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (_bb.Current.Value == 0)
|
||||
{
|
||||
throw new Exception("Bollinger Band value is zero when we expect non-zero value.");
|
||||
}
|
||||
|
||||
if (!_invested && _bb.Current.Value > 0.05m)
|
||||
{
|
||||
MarketOrder(_vix, 1);
|
||||
_invested = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incrementally updating data
|
||||
/// </summary>
|
||||
private class IncrementallyGeneratedCustomData : CBOE
|
||||
{
|
||||
private const decimal _start = 10.01m;
|
||||
private static decimal _step;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source of the subscription. In this case, we set it to existing
|
||||
/// equity data so that we can pass fake data from Reader
|
||||
/// </summary>
|
||||
/// <param name="config">Subscription configuration</param>
|
||||
/// <param name="date">Date we're making this request</param>
|
||||
/// <param name="isLiveMode">Is live mode</param>
|
||||
/// <returns>Source of subscription</returns>
|
||||
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
|
||||
{
|
||||
return new SubscriptionDataSource(Path.Combine(Globals.DataFolder, "equity", "usa", "minute", "spy", $"{date:yyyyMMdd}_trade.zip#{date:yyyyMMdd}_spy_minute_trade.csv"), SubscriptionTransportMedium.LocalFile, FileFormat.Csv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the data, which in this case is fake incremental data
|
||||
/// </summary>
|
||||
/// <param name="config">Subscription configuration</param>
|
||||
/// <param name="line">Line of data</param>
|
||||
/// <param name="date">Date of the request</param>
|
||||
/// <param name="isLiveMode">Is live mode</param>
|
||||
/// <returns>Incremental BaseData instance</returns>
|
||||
public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
|
||||
{
|
||||
var vix = new CBOE();
|
||||
_step += 0.10m;
|
||||
var open = _start + _step;
|
||||
var close = _start + _step + 0.02m;
|
||||
var high = close;
|
||||
var low = open;
|
||||
|
||||
return new IncrementallyGeneratedCustomData
|
||||
{
|
||||
Open = open,
|
||||
High = high,
|
||||
Low = low,
|
||||
Close = close,
|
||||
Time = date,
|
||||
Symbol = new Symbol(
|
||||
SecurityIdentifier.GenerateBase(typeof(IncrementallyGeneratedCustomData), "VIX", Market.USA, false),
|
||||
"VIX"),
|
||||
Period = vix.Period,
|
||||
DataType = vix.DataType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Unable to be tested in Python, due to pythonnet not supporting overriding of methods from Python
|
||||
/// </remarks>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0.029%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0.000%"},
|
||||
{"Sharpe Ratio", "28.4"},
|
||||
{"Probabilistic Sharpe Ratio", "88.597%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-7.067"},
|
||||
{"Tracking Error", "0.193"},
|
||||
{"Treynor Ratio", "7.887"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "918912ee4f64cd0290f3d58deca02713"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$370000.00"},
|
||||
{"Fitness Score", "0.501"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -167,7 +166,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "aea2e321d17414c1f3c6fa2491f10c88"}
|
||||
{"OrderListHash", "1349023435"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests capacity by trading SPY (beast) alongside a small cap stock ABUS (penny)
|
||||
/// </summary>
|
||||
public class BeastVsPenny : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spy;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 1);
|
||||
SetEndDate(2020, 3, 31);
|
||||
SetCash(10000);
|
||||
|
||||
_spy = AddEquity("SPY", Resolution.Hour).Symbol;
|
||||
var penny = AddEquity("ABUS", Resolution.Hour).Symbol;
|
||||
|
||||
Schedule.On(DateRules.EveryDay(_spy), TimeRules.AfterMarketOpen(_spy, 1, false), () =>
|
||||
{
|
||||
SetHoldings(_spy, 0.5m);
|
||||
SetHoldings(penny, 0.5m);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "70"},
|
||||
{"Average Win", "0.07%"},
|
||||
{"Average Loss", "-0.51%"},
|
||||
{"Compounding Annual Return", "-89.548%"},
|
||||
{"Drawdown", "49.900%"},
|
||||
{"Expectancy", "-0.514"},
|
||||
{"Net Profit", "-42.920%"},
|
||||
{"Sharpe Ratio", "-0.797"},
|
||||
{"Probabilistic Sharpe Ratio", "9.019%"},
|
||||
{"Loss Rate", "57%"},
|
||||
{"Win Rate", "43%"},
|
||||
{"Profit-Loss Ratio", "0.13"},
|
||||
{"Alpha", "-0.24"},
|
||||
{"Beta", "1.101"},
|
||||
{"Annual Standard Deviation", "1.031"},
|
||||
{"Annual Variance", "1.063"},
|
||||
{"Information Ratio", "-0.351"},
|
||||
{"Tracking Error", "0.836"},
|
||||
{"Treynor Ratio", "-0.747"},
|
||||
{"Total Fees", "$81.45"},
|
||||
{"Estimated Strategy Capacity", "$21000.00"},
|
||||
{"Fitness Score", "0.01"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-1.284"},
|
||||
{"Return Over Maximum Drawdown", "-1.789"},
|
||||
{"Portfolio Turnover", "0.038"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "67c9083f604ed16fb68481e7c26878dc"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests an illiquid asset that has bursts of liquidity around 11:00 A.M. Central Time
|
||||
/// with an hourly in and out strategy.
|
||||
/// </summary>
|
||||
public class CheeseMilkHourlyRebalance : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
private Symbol _contract;
|
||||
private DateTime _lastTrade;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 2, 17);
|
||||
SetTimeZone(TimeZones.Chicago);
|
||||
SetCash(100000);
|
||||
SetWarmup(1000);
|
||||
|
||||
var dc = AddFuture("DC", Resolution.Minute, Market.CME);
|
||||
dc.SetFilter(0, 10000);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var contract = data.FutureChains.Values.SelectMany(c => c.Contracts.Values)
|
||||
.OrderBy(c => c.Symbol.ID.Date)
|
||||
.FirstOrDefault()?
|
||||
.Symbol;
|
||||
|
||||
if (contract == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_contract != contract || (_fast == null && _slow == null))
|
||||
{
|
||||
_fast = EMA(contract, 600);
|
||||
_slow = EMA(contract, 1200);
|
||||
_contract = contract;
|
||||
}
|
||||
|
||||
if (!_fast.IsReady || !_slow.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time - _lastTrade <= TimeSpan.FromHours(1) || Time.TimeOfDay <= new TimeSpan(10, 50, 0) || Time.TimeOfDay >= new TimeSpan(12, 30, 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Portfolio.ContainsKey(contract) || (Portfolio[contract].Quantity <= 0 && _fast > _slow))
|
||||
{
|
||||
SetHoldings(contract, 0.5);
|
||||
_lastTrade = Time;
|
||||
}
|
||||
else if (Portfolio.ContainsKey(contract) && Portfolio[contract].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(contract, -0.5);
|
||||
_lastTrade = Time;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "19"},
|
||||
{"Average Win", "39.16%"},
|
||||
{"Average Loss", "-8.81%"},
|
||||
{"Compounding Annual Return", "-99.857%"},
|
||||
{"Drawdown", "82.900%"},
|
||||
{"Expectancy", "-0.359"},
|
||||
{"Net Profit", "-57.725%"},
|
||||
{"Sharpe Ratio", "-0.555"},
|
||||
{"Probabilistic Sharpe Ratio", "10.606%"},
|
||||
{"Loss Rate", "88%"},
|
||||
{"Win Rate", "12%"},
|
||||
{"Profit-Loss Ratio", "4.45"},
|
||||
{"Alpha", "-1.188"},
|
||||
{"Beta", "0.603"},
|
||||
{"Annual Standard Deviation", "1.754"},
|
||||
{"Annual Variance", "3.075"},
|
||||
{"Information Ratio", "-0.759"},
|
||||
{"Tracking Error", "1.753"},
|
||||
{"Treynor Ratio", "-1.612"},
|
||||
{"Total Fees", "$2558.55"},
|
||||
{"Estimated Strategy Capacity", "$20000.00"},
|
||||
{"Fitness Score", "0.351"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-0.602"},
|
||||
{"Return Over Maximum Drawdown", "-1.415"},
|
||||
{"Portfolio Turnover", "14.226"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "4f5fd2fb25e957bd0cb7cb6d275ddb97"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests a wide variety of liquid and illiquid stocks together, with bins
|
||||
/// of 20 ranging from micro-cap to mega-cap stocks.
|
||||
/// </summary>
|
||||
public class EmaPortfolioRebalance100 : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
public List<SymbolData> Data;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 1);
|
||||
SetEndDate(2020, 2, 5);
|
||||
SetWarmup(1000);
|
||||
SetCash(100000);
|
||||
|
||||
Data = new List<SymbolData> {
|
||||
new SymbolData(this, AddEquity("AADR", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAMC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAU", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ABDC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ABIO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ABUS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACER", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACES", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACGLO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACH", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACHV", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACIO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACIU", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACNB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACRS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACSI", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACT", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACT", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACTG", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZYNE", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZYME", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZUO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZUMZ", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZTR", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZSL", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZSAN", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZROZ", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZLAB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZIXI", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZIV", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZIOP", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZGNX", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZG", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZEUS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZAGG", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("YYY", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("YRD", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("YRCW", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("YPF", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AA", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAN", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAP", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAXN", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ABB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ABC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACAD", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACGL", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACIW", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACWV", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ACWX", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ADM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ADPT", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ADS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ADUS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AEM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AEO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AEP", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ZTS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("YUM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLY", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLV", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLRE", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLP", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLNX", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLF", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XLB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XEL", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("XBI", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("X", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WYNN", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WW", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WORK", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WMB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WELL", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("WEC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AAPL", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("ADBE", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AGG", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AMD", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("AMZN", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("BA", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("BABA", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("BAC", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("BMY", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("C", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("CMCSA", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("CRM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("CSCO", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("DIS", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("EEM", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("EFA", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("FB", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("GDX", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("GE", Resolution.Minute).Symbol),
|
||||
new SymbolData(this, AddEquity("SPY", Resolution.Minute).Symbol)
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var fastFactor = 0.005m;
|
||||
|
||||
foreach (var sd in Data)
|
||||
{
|
||||
if (!Portfolio.Invested && sd.Fast * (1 + fastFactor) > sd.Slow)
|
||||
{
|
||||
SetHoldings(sd.Symbol, 0.01);
|
||||
}
|
||||
else if (Portfolio.Invested && sd.Fast * (1 - fastFactor) < sd.Slow)
|
||||
{
|
||||
Liquidate(sd.Symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SymbolData
|
||||
{
|
||||
public Symbol Symbol;
|
||||
public ExponentialMovingAverage Fast;
|
||||
public ExponentialMovingAverage Slow;
|
||||
public bool IsCrossed => Fast > Slow;
|
||||
|
||||
public SymbolData(QCAlgorithm algorithm, Symbol symbol) {
|
||||
Symbol = symbol;
|
||||
Fast = algorithm.EMA(symbol, 20);
|
||||
Slow = algorithm.EMA(symbol, 300);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1015"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "-12.674%"},
|
||||
{"Drawdown", "1.400%"},
|
||||
{"Expectancy", "-0.761"},
|
||||
{"Net Profit", "-1.328%"},
|
||||
{"Sharpe Ratio", "-12.258"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "95%"},
|
||||
{"Win Rate", "5%"},
|
||||
{"Profit-Loss Ratio", "3.67"},
|
||||
{"Alpha", "-0.142"},
|
||||
{"Beta", "0.038"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-4.389"},
|
||||
{"Tracking Error", "0.123"},
|
||||
{"Treynor Ratio", "-3.359"},
|
||||
{"Total Fees", "$1125.52"},
|
||||
{"Estimated Strategy Capacity", "$300.00"},
|
||||
{"Fitness Score", "0.007"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-14.315"},
|
||||
{"Return Over Maximum Drawdown", "-9.589"},
|
||||
{"Portfolio Turnover", "0.406"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "4c165e8d648d54a85bb7b564050a6f85"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps SPY using an EMA cross strategy at minute resolution.
|
||||
/// This tests equity strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result.
|
||||
/// </summary>
|
||||
public class IntradayMinuteScalping : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spy;
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 1);
|
||||
SetEndDate(2020, 1, 30);
|
||||
SetCash(100000);
|
||||
SetWarmup(100);
|
||||
|
||||
_spy = AddEquity("SPY", Resolution.Minute).Symbol;
|
||||
_fast = EMA(_spy, 20);
|
||||
_slow = EMA(_spy, 40);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Portfolio[_spy].Quantity <= 0 && _fast > _slow)
|
||||
{
|
||||
SetHoldings(_spy, 1);
|
||||
}
|
||||
else if (Portfolio[_spy].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(_spy, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "150"},
|
||||
{"Average Win", "0.16%"},
|
||||
{"Average Loss", "-0.11%"},
|
||||
{"Compounding Annual Return", "-19.320%"},
|
||||
{"Drawdown", "3.900%"},
|
||||
{"Expectancy", "-0.193"},
|
||||
{"Net Profit", "-1.730%"},
|
||||
{"Sharpe Ratio", "-1.606"},
|
||||
{"Probabilistic Sharpe Ratio", "21.397%"},
|
||||
{"Loss Rate", "67%"},
|
||||
{"Win Rate", "33%"},
|
||||
{"Profit-Loss Ratio", "1.45"},
|
||||
{"Alpha", "-0.357"},
|
||||
{"Beta", "0.635"},
|
||||
{"Annual Standard Deviation", "0.119"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "-4.249"},
|
||||
{"Tracking Error", "0.106"},
|
||||
{"Treynor Ratio", "-0.302"},
|
||||
{"Total Fees", "$449.14"},
|
||||
{"Estimated Strategy Capacity", "$27000000.00"},
|
||||
{"Fitness Score", "0.088"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-3.259"},
|
||||
{"Return Over Maximum Drawdown", "-7.992"},
|
||||
{"Portfolio Turnover", "14.605"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "f5a0e9547f7455004fa6c3eb136534e9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps BTCETH using an EMA cross strategy at minute resolution.
|
||||
/// This tests crypto strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result. This also tests
|
||||
/// that currency conversions are handled properly in the strategy capacity
|
||||
/// calculation class.
|
||||
/// </summary>
|
||||
public class IntradayMinuteScalpingBTCETH : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _ethbtc;
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 1, 30);
|
||||
SetCash(100000);
|
||||
SetWarmup(100);
|
||||
|
||||
var ethbtc = AddCrypto("ETHBTC", Resolution.Minute, Market.GDAX);
|
||||
ethbtc.BuyingPowerModel = new BuyingPowerModel();
|
||||
_ethbtc = ethbtc.Symbol;
|
||||
|
||||
_fast = EMA(_ethbtc, 20);
|
||||
_slow = EMA(_ethbtc, 40);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Portfolio[_ethbtc].Quantity <= 0 && _fast > _slow)
|
||||
{
|
||||
SetHoldings(_ethbtc, 1);
|
||||
}
|
||||
else if (Portfolio[_ethbtc].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(_ethbtc, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1005"},
|
||||
{"Average Win", "0.96%"},
|
||||
{"Average Loss", "-0.33%"},
|
||||
{"Compounding Annual Return", "76.267%"},
|
||||
{"Drawdown", "77.100%"},
|
||||
{"Expectancy", "-0.012"},
|
||||
{"Net Profit", "4.768%"},
|
||||
{"Sharpe Ratio", "1.01909630017278E+24"},
|
||||
{"Probabilistic Sharpe Ratio", "93.814%"},
|
||||
{"Loss Rate", "75%"},
|
||||
{"Win Rate", "25%"},
|
||||
{"Profit-Loss Ratio", "2.95"},
|
||||
{"Alpha", "1.3466330963256E+25"},
|
||||
{"Beta", "25.59"},
|
||||
{"Annual Standard Deviation", "13.214"},
|
||||
{"Annual Variance", "174.61"},
|
||||
{"Information Ratio", "1.02164274756513E+24"},
|
||||
{"Tracking Error", "13.181"},
|
||||
{"Treynor Ratio", "5.2622435344112E+23"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$1300000.00"},
|
||||
{"Fitness Score", "0.38"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-0.239"},
|
||||
{"Return Over Maximum Drawdown", "-1.385"},
|
||||
{"Portfolio Turnover", "81.433"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6a779e7a8d12b4808845c75b88d43b3a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps EURUSD using an EMA cross strategy at minute resolution.
|
||||
/// This tests FOREX strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result.
|
||||
/// </summary>
|
||||
public class IntradayMinuteScalpingEURUSD : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _eurusd;
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 1, 30);
|
||||
SetCash(100000);
|
||||
SetWarmup(100);
|
||||
|
||||
_eurusd = AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol;
|
||||
_fast = EMA(_eurusd, 20);
|
||||
_slow = EMA(_eurusd, 40);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Portfolio[_eurusd].Quantity <= 0 && _fast > _slow)
|
||||
{
|
||||
SetHoldings(_eurusd, 1);
|
||||
}
|
||||
else if (Portfolio[_eurusd].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(_eurusd, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "671"},
|
||||
{"Average Win", "0.07%"},
|
||||
{"Average Loss", "-0.04%"},
|
||||
{"Compounding Annual Return", "-80.820%"},
|
||||
{"Drawdown", "12.200%"},
|
||||
{"Expectancy", "-0.447"},
|
||||
{"Net Profit", "-12.180%"},
|
||||
{"Sharpe Ratio", "-13.121"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "79%"},
|
||||
{"Win Rate", "21%"},
|
||||
{"Profit-Loss Ratio", "1.61"},
|
||||
{"Alpha", "-0.746"},
|
||||
{"Beta", "-0.02"},
|
||||
{"Annual Standard Deviation", "0.057"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-4.046"},
|
||||
{"Tracking Error", "0.161"},
|
||||
{"Treynor Ratio", "37.346"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$44000000.00"},
|
||||
{"Fitness Score", "0.025"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-16.609"},
|
||||
{"Return Over Maximum Drawdown", "-7.115"},
|
||||
{"Portfolio Turnover", "52.476"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "74ee44736b9300c0262dc75c0cd140e1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps ES futures contracts (E-mini SP500) using an EMA cross strategy at minute resolution.
|
||||
/// This tests futures strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The insanely high capacity estimate of this strategy is realistic.
|
||||
/// ES notional contract value traded is around $600 Billion USD per day (!!!), which
|
||||
/// is what the capacity is set to.
|
||||
/// </remarks>
|
||||
public class IntradayMinuteScalpingFuturesES : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
private Symbol _contract;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 1, 31);
|
||||
SetCash(100000);
|
||||
SetWarmup(1000);
|
||||
|
||||
var a = AddFuture("ES", Resolution.Minute, Market.CME);
|
||||
a.SetFilter(0, 10000);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
var contract = data.FutureChains.Values.SelectMany(c => c.Contracts.Values)
|
||||
.OrderBy(c => c.Symbol.ID.Date)
|
||||
.FirstOrDefault()?
|
||||
.Symbol;
|
||||
|
||||
if (contract == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_contract != contract || (_fast == null && _slow == null))
|
||||
{
|
||||
_fast = EMA(contract, 10);
|
||||
_slow = EMA(contract, 20);
|
||||
_contract = contract;
|
||||
}
|
||||
|
||||
if (!_fast.IsReady || !_slow.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Portfolio.ContainsKey(contract) || (Portfolio[contract].Quantity <= 0 && _fast > _slow))
|
||||
{
|
||||
SetHoldings(contract, 1);
|
||||
}
|
||||
else if (Portfolio.ContainsKey(contract) && Portfolio[contract].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(contract, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1217"},
|
||||
{"Average Win", "2.69%"},
|
||||
{"Average Loss", "-0.93%"},
|
||||
{"Compounding Annual Return", "-99.756%"},
|
||||
{"Drawdown", "77.200%"},
|
||||
{"Expectancy", "-0.047"},
|
||||
{"Net Profit", "-40.013%"},
|
||||
{"Sharpe Ratio", "-0.52"},
|
||||
{"Probabilistic Sharpe Ratio", "19.865%"},
|
||||
{"Loss Rate", "75%"},
|
||||
{"Win Rate", "25%"},
|
||||
{"Profit-Loss Ratio", "2.88"},
|
||||
{"Alpha", "-1.279"},
|
||||
{"Beta", "-3.686"},
|
||||
{"Annual Standard Deviation", "1.85"},
|
||||
{"Annual Variance", "3.422"},
|
||||
{"Information Ratio", "-0.463"},
|
||||
{"Tracking Error", "1.895"},
|
||||
{"Treynor Ratio", "0.261"},
|
||||
{"Total Fees", "$19843.10"},
|
||||
{"Estimated Strategy Capacity", "$560000000.00"},
|
||||
{"Fitness Score", "0.334"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-0.837"},
|
||||
{"Return Over Maximum Drawdown", "-1.402"},
|
||||
{"Portfolio Turnover", "1174.125"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "f353843132df7b0604eff3a37b134ca2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps GBPJPY using an EMA cross strategy at minute resolution.
|
||||
/// This tests FOREX strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result. This test also
|
||||
/// tests that currency conversion rates are applied and calculated correctly.
|
||||
/// </summary>
|
||||
public class IntradayMinuteScalpingGBPJPY : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _gbpjpy;
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 1, 30);
|
||||
SetCash(100000);
|
||||
SetWarmup(100);
|
||||
|
||||
_gbpjpy = AddForex("GBPJPY", Resolution.Minute, Market.Oanda).Symbol;
|
||||
_fast = EMA(_gbpjpy, 20);
|
||||
_slow = EMA(_gbpjpy, 40);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Portfolio[_gbpjpy].Quantity <= 0 && _fast > _slow)
|
||||
{
|
||||
SetHoldings(_gbpjpy, 1);
|
||||
}
|
||||
else if (Portfolio[_gbpjpy].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(_gbpjpy, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "735"},
|
||||
{"Average Win", "0.08%"},
|
||||
{"Average Loss", "-0.05%"},
|
||||
{"Compounding Annual Return", "-93.946%"},
|
||||
{"Drawdown", "19.900%"},
|
||||
{"Expectancy", "-0.592"},
|
||||
{"Net Profit", "-19.794%"},
|
||||
{"Sharpe Ratio", "-10.054"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "84%"},
|
||||
{"Win Rate", "16%"},
|
||||
{"Profit-Loss Ratio", "1.56"},
|
||||
{"Alpha", "-0.895"},
|
||||
{"Beta", "0.068"},
|
||||
{"Annual Standard Deviation", "0.09"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "-4.929"},
|
||||
{"Tracking Error", "0.164"},
|
||||
{"Treynor Ratio", "-13.276"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$49000000.00"},
|
||||
{"Fitness Score", "0.049"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-10.846"},
|
||||
{"Return Over Maximum Drawdown", "-4.904"},
|
||||
{"Portfolio Turnover", "58.921"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "66f04c9622ab242993c8ce951418e6d9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Scalps TRYJPY using an EMA cross strategy at minute resolution.
|
||||
/// This tests FOREX strategies that trade at a higher frequency, which
|
||||
/// should have a reduced capacity estimate as a result. This tests that
|
||||
/// currency conversions are applied properly to the capacity estimate calculation.
|
||||
/// </summary>
|
||||
public class IntradayMinuteScalpingTRYJPY : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _tryjpy;
|
||||
private ExponentialMovingAverage _fast;
|
||||
private ExponentialMovingAverage _slow;
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2021, 1, 1);
|
||||
SetEndDate(2021, 1, 30);
|
||||
SetCash(100000);
|
||||
SetWarmup(100);
|
||||
|
||||
_tryjpy = AddForex("TRYJPY", Resolution.Minute, Market.Oanda).Symbol;
|
||||
_fast = EMA(_tryjpy, 20);
|
||||
_slow = EMA(_tryjpy, 40);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Portfolio[_tryjpy].Quantity <= 0 && _fast > _slow)
|
||||
{
|
||||
SetHoldings(_tryjpy, 1);
|
||||
}
|
||||
else if (Portfolio[_tryjpy].Quantity >= 0 && _fast < _slow)
|
||||
{
|
||||
SetHoldings(_tryjpy, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "603"},
|
||||
{"Average Win", "0.20%"},
|
||||
{"Average Loss", "-0.26%"},
|
||||
{"Compounding Annual Return", "-100.000%"},
|
||||
{"Drawdown", "73.200%"},
|
||||
{"Expectancy", "-0.849"},
|
||||
{"Net Profit", "-73.118%"},
|
||||
{"Sharpe Ratio", "-2.046"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "91%"},
|
||||
{"Win Rate", "9%"},
|
||||
{"Profit-Loss Ratio", "0.75"},
|
||||
{"Alpha", "-0.95"},
|
||||
{"Beta", "0.541"},
|
||||
{"Annual Standard Deviation", "0.489"},
|
||||
{"Annual Variance", "0.239"},
|
||||
{"Information Ratio", "-1.863"},
|
||||
{"Tracking Error", "0.487"},
|
||||
{"Treynor Ratio", "-1.849"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$4400000.00"},
|
||||
{"Fitness Score", "0.259"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-2.135"},
|
||||
{"Return Over Maximum Drawdown", "-1.389"},
|
||||
{"Portfolio Turnover", "49.501"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "4eb4d703a9f200b6bb3d8b0ebbc9db7f"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Rebalances ultra-liquid stocks monthly, testing
|
||||
/// bursts of orders centered around the start of the month at Daily resolution
|
||||
/// </summary>
|
||||
public class MonthlyRebalanceDaily : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 12, 31);
|
||||
SetEndDate(2020, 4, 5);
|
||||
SetCash(100000);
|
||||
|
||||
var spy = AddEquity("SPY", Resolution.Daily).Symbol;
|
||||
AddEquity("GE", Resolution.Daily);
|
||||
AddEquity("FB", Resolution.Daily);
|
||||
AddEquity("DIS", Resolution.Daily);
|
||||
AddEquity("CSCO", Resolution.Daily);
|
||||
AddEquity("CRM", Resolution.Daily);
|
||||
AddEquity("C", Resolution.Daily);
|
||||
AddEquity("BAC", Resolution.Daily);
|
||||
AddEquity("BABA", Resolution.Daily);
|
||||
AddEquity("AAPL", Resolution.Daily);
|
||||
|
||||
Schedule.On(DateRules.MonthStart(spy), TimeRules.Noon, () =>
|
||||
{
|
||||
foreach (var symbol in Securities.Keys)
|
||||
{
|
||||
SetHoldings(symbol, 0.10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "35"},
|
||||
{"Average Win", "0.07%"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "-68.407%"},
|
||||
{"Drawdown", "32.400%"},
|
||||
{"Expectancy", "-0.309"},
|
||||
{"Net Profit", "-25.901%"},
|
||||
{"Sharpe Ratio", "-1.503"},
|
||||
{"Probabilistic Sharpe Ratio", "2.878%"},
|
||||
{"Loss Rate", "64%"},
|
||||
{"Win Rate", "36%"},
|
||||
{"Profit-Loss Ratio", "0.90"},
|
||||
{"Alpha", "-0.7"},
|
||||
{"Beta", "-0.238"},
|
||||
{"Annual Standard Deviation", "0.386"},
|
||||
{"Annual Variance", "0.149"},
|
||||
{"Information Ratio", "-0.11"},
|
||||
{"Tracking Error", "0.712"},
|
||||
{"Treynor Ratio", "2.442"},
|
||||
{"Total Fees", "$38.99"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Fitness Score", "0.003"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-2.021"},
|
||||
{"Return Over Maximum Drawdown", "-2.113"},
|
||||
{"Portfolio Turnover", "0.014"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "76d8164a3c0d4a7d45e94367c4ba5be1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Rebalances ultra-liquid stocks monthly, testing
|
||||
/// bursts of orders centered around the start of the month at Hourly resolution
|
||||
/// </summary>
|
||||
public class MonthlyRebalanceHourly : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2019, 12, 31);
|
||||
SetEndDate(2020, 4, 5);
|
||||
SetCash(100000);
|
||||
|
||||
var spy = AddEquity("SPY", Resolution.Hour).Symbol;
|
||||
AddEquity("GE", Resolution.Hour);
|
||||
AddEquity("FB", Resolution.Hour);
|
||||
AddEquity("DIS", Resolution.Hour);
|
||||
AddEquity("CSCO", Resolution.Hour);
|
||||
AddEquity("CRM", Resolution.Hour);
|
||||
AddEquity("C", Resolution.Hour);
|
||||
AddEquity("BAC", Resolution.Hour);
|
||||
AddEquity("BABA", Resolution.Hour);
|
||||
AddEquity("AAPL", Resolution.Hour);
|
||||
|
||||
Schedule.On(DateRules.MonthStart(spy), TimeRules.Noon, () =>
|
||||
{
|
||||
foreach (var symbol in Securities.Keys)
|
||||
{
|
||||
SetHoldings(symbol, 0.10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "35"},
|
||||
{"Average Win", "0.05%"},
|
||||
{"Average Loss", "-0.10%"},
|
||||
{"Compounding Annual Return", "-72.444%"},
|
||||
{"Drawdown", "36.500%"},
|
||||
{"Expectancy", "-0.449"},
|
||||
{"Net Profit", "-28.406%"},
|
||||
{"Sharpe Ratio", "-1.369"},
|
||||
{"Probabilistic Sharpe Ratio", "4.398%"},
|
||||
{"Loss Rate", "64%"},
|
||||
{"Win Rate", "36%"},
|
||||
{"Profit-Loss Ratio", "0.51"},
|
||||
{"Alpha", "-0.175"},
|
||||
{"Beta", "0.892"},
|
||||
{"Annual Standard Deviation", "0.503"},
|
||||
{"Annual Variance", "0.253"},
|
||||
{"Information Ratio", "-0.822"},
|
||||
{"Tracking Error", "0.138"},
|
||||
{"Treynor Ratio", "-0.772"},
|
||||
{"Total Fees", "$38.83"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Fitness Score", "0.004"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-2.033"},
|
||||
{"Return Over Maximum Drawdown", "-2.079"},
|
||||
{"Portfolio Turnover", "0.018"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "1de9bcf6cda0945af6ba1f74c4dcb22c"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests that splits do not cause the algorithm to report capacity estimates
|
||||
/// above or below the actual capacity due to splits. The stock HTGM is illiquid,
|
||||
/// trading only $1.2 Million per day on average with sparse trade frequencies.
|
||||
/// </summary>
|
||||
public class SplitTestingStrategy : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _htgm;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 11, 1);
|
||||
SetEndDate(2020, 12, 5);
|
||||
SetCash(100000);
|
||||
|
||||
var htgm = AddEquity("HTGM", Resolution.Hour);
|
||||
htgm.SetDataNormalizationMode(DataNormalizationMode.Raw);
|
||||
_htgm = htgm.Symbol;
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings(_htgm, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHoldings(_htgm, -1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "162"},
|
||||
{"Average Win", "0.10%"},
|
||||
{"Average Loss", "-0.35%"},
|
||||
{"Compounding Annual Return", "-94.432%"},
|
||||
{"Drawdown", "30.400%"},
|
||||
{"Expectancy", "-0.564"},
|
||||
{"Net Profit", "-23.412%"},
|
||||
{"Sharpe Ratio", "-1.041"},
|
||||
{"Probabilistic Sharpe Ratio", "12.971%"},
|
||||
{"Loss Rate", "66%"},
|
||||
{"Win Rate", "34%"},
|
||||
{"Profit-Loss Ratio", "0.29"},
|
||||
{"Alpha", "-4.827"},
|
||||
{"Beta", "1.43"},
|
||||
{"Annual Standard Deviation", "0.876"},
|
||||
{"Annual Variance", "0.767"},
|
||||
{"Information Ratio", "-4.288"},
|
||||
{"Tracking Error", "0.851"},
|
||||
{"Treynor Ratio", "-0.637"},
|
||||
{"Total Fees", "$2655.91"},
|
||||
{"Estimated Strategy Capacity", "$11000.00"},
|
||||
{"Fitness Score", "0.052"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-2.2"},
|
||||
{"Return Over Maximum Drawdown", "-3.481"},
|
||||
{"Portfolio Turnover", "0.307"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "54f571c11525656e9b383e235e77002e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Rebalances between SPY and BND. Tests capacity of the weakest link, which in this
|
||||
/// case is BND, dragging down the capacity estimate.
|
||||
/// </summary>
|
||||
public class SpyBondPortfolioRebalance : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spy;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2020, 1, 1);
|
||||
SetEndDate(2020, 3, 31);
|
||||
SetCash(10000);
|
||||
|
||||
_spy = AddEquity("SPY", Resolution.Hour).Symbol;
|
||||
var bnd = AddEquity("BND", Resolution.Hour).Symbol;
|
||||
|
||||
Schedule.On(DateRules.EveryDay(_spy), TimeRules.AfterMarketOpen(_spy, 1, false), () =>
|
||||
{
|
||||
SetHoldings(_spy, 0.5m);
|
||||
SetHoldings(bnd, 0.5m);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "21"},
|
||||
{"Average Win", "0.02%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "-33.564%"},
|
||||
{"Drawdown", "19.700%"},
|
||||
{"Expectancy", "-0.140"},
|
||||
{"Net Profit", "-9.655%"},
|
||||
{"Sharpe Ratio", "-0.99"},
|
||||
{"Probabilistic Sharpe Ratio", "13.754%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0.72"},
|
||||
{"Alpha", "-0.022"},
|
||||
{"Beta", "0.538"},
|
||||
{"Annual Standard Deviation", "0.309"},
|
||||
{"Annual Variance", "0.096"},
|
||||
{"Information Ratio", "0.826"},
|
||||
{"Tracking Error", "0.269"},
|
||||
{"Treynor Ratio", "-0.569"},
|
||||
{"Total Fees", "$21.00"},
|
||||
{"Estimated Strategy Capacity", "$1100000.00"},
|
||||
{"Fitness Score", "0.005"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-1.524"},
|
||||
{"Return Over Maximum Drawdown", "-1.688"},
|
||||
{"Portfolio Turnover", "0.02"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "95a130426900aaf227a08a5d1c617b2b"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.5"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -115,7 +114,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6ea6184a2a8d0d69e552ad866933bfb6"}
|
||||
{"OrderListHash", "1456907343"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.149"},
|
||||
{"Treynor Ratio", "-1.405"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Fitness Score", "0.076"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -201,7 +200,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "edd9e9ffc8a1cdfb7a1e6ae601e61b12"}
|
||||
{"OrderListHash", "-1465929889"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "3.579"},
|
||||
{"Treynor Ratio", "383485597312030"},
|
||||
{"Total Fees", "$13.00"},
|
||||
{"Estimated Strategy Capacity", "$3000000.00"},
|
||||
{"Fitness Score", "0.232"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -184,7 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "12470afd9a74ad9c9802361f6f092777"}
|
||||
{"OrderListHash", "1630141557"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.126"},
|
||||
{"Treynor Ratio", "-0.607"},
|
||||
{"Total Fees", "$11.63"},
|
||||
{"Estimated Strategy Capacity", "$13000000.00"},
|
||||
{"Fitness Score", "0.013"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -156,7 +155,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "3d1ae61492b34c39115b76757510c058"}
|
||||
{"OrderListHash", "-1623759093"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.096"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -134,7 +133,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "1.667"},
|
||||
{"Total Fees", "$2.91"},
|
||||
{"Estimated Strategy Capacity", "$96000000.00"},
|
||||
{"Fitness Score", "0.141"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -140,7 +139,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "718d73fbddccb63aeacbf4659938b4b8"}
|
||||
{"OrderListHash", "-1959413055"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.101"},
|
||||
{"Treynor Ratio", "5.409"},
|
||||
{"Total Fees", "$67.00"},
|
||||
{"Estimated Strategy Capacity", "$2400000.00"},
|
||||
{"Fitness Score", "0.501"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -111,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "ba44309886ea8ff515ef593a24456c47"}
|
||||
{"OrderListHash", "-28636839"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.009"},
|
||||
{"Treynor Ratio", "1.575"},
|
||||
{"Total Fees", "$22.77"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Fitness Score", "0.999"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
@@ -105,7 +104,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "54.5455%"},
|
||||
{"Rolling Averaged Population Direction", "59.8056%"},
|
||||
{"Rolling Averaged Population Magnitude", "59.8056%"},
|
||||
{"OrderListHash", "e0f388bf9e88b34388c866150b292573"}
|
||||
{"OrderListHash", "-1225025518"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.165"},
|
||||
{"Treynor Ratio", "1.212"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000.00"},
|
||||
{"Fitness Score", "0.063"},
|
||||
{"Kelly Criterion Estimate", "38.64"},
|
||||
{"Kelly Criterion Probability Value", "0.229"},
|
||||
@@ -114,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "54.5455%"},
|
||||
{"Rolling Averaged Population Direction", "59.8056%"},
|
||||
{"Rolling Averaged Population Magnitude", "59.8056%"},
|
||||
{"OrderListHash", "07eb3e2c199575b547459a534057eb5e"}
|
||||
{"OrderListHash", "501060991"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.441"},
|
||||
{"Treynor Ratio", "-0.008"},
|
||||
{"Total Fees", "$20.35"},
|
||||
{"Estimated Strategy Capacity", "$19000000.00"},
|
||||
{"Fitness Score", "0.138"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -184,7 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "7c841ca58a4385f42236838e5bf0c382"}
|
||||
{"OrderListHash", "-1453269600"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.176"},
|
||||
{"Treynor Ratio", "-1.46"},
|
||||
{"Total Fees", "$7.82"},
|
||||
{"Estimated Strategy Capacity", "$6000000.00"},
|
||||
{"Fitness Score", "0.1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -210,7 +209,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "71984e154883ece4aef1d71bafbfccaf"}
|
||||
{"OrderListHash", "-611289773"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +144,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Annual Variance", "0.027"},
|
||||
{"Information Ratio", "-0.391"},
|
||||
{"Tracking Error", "0.239"},
|
||||
{"Treynor Ratio", "-1.435"},
|
||||
{"Treynor Ratio", "-1.416"},
|
||||
{"Total Fees", "$755.29"},
|
||||
{"Estimated Strategy Capacity", "$150000000.00"},
|
||||
{"Fitness Score", "0.024"},
|
||||
{"Kelly Criterion Estimate", "-0.84"},
|
||||
{"Kelly Criterion Probability Value", "0.53"},
|
||||
@@ -166,7 +165,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "48.2217%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "95f34359f25a7a7a2725f0343a75a105"}
|
||||
{"OrderListHash", "1370210213"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// Find more symbols here: http://quantconnect.com/data
|
||||
AddSecurity(SecurityType.Equity, "SPY", Resolution.Second);
|
||||
|
||||
// Disabling the benchmark / setting to a fixed value
|
||||
// SetBenchmark(time => 0);
|
||||
|
||||
// Set the benchmark to AAPL US Equity
|
||||
SetBenchmark("AAPL");
|
||||
}
|
||||
|
||||
@@ -99,7 +95,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.168"},
|
||||
{"Treynor Ratio", "2.38"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$75000000.00"},
|
||||
{"Fitness Score", "0.245"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -119,7 +114,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "9cd604d2c1e3c273697e2ff2cc7faef1"}
|
||||
{"OrderListHash", "2069976135"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0.988"},
|
||||
{"Total Fees", "$7.78"},
|
||||
{"Estimated Strategy Capacity", "$2200000.00"},
|
||||
{"Fitness Score", "0.031"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -116,7 +115,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "be3334e4aeb9dd7cca4ecc07419d0f95"}
|
||||
{"OrderListHash", "519536519"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "1.04"},
|
||||
{"Treynor Ratio", "5.073"},
|
||||
{"Total Fees", "$30.00"},
|
||||
{"Estimated Strategy Capacity", "$2800000.00"},
|
||||
{"Fitness Score", "0.418"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -133,7 +132,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "b88362c462e9ab2942cbcb8dfddc6ce0"}
|
||||
{"OrderListHash", "639761089"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.112"},
|
||||
{"Treynor Ratio", "-6.121"},
|
||||
{"Total Fees", "$3.50"},
|
||||
{"Estimated Strategy Capacity", "$6900000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -139,7 +138,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6b05339bfcb5bd93bfd66e32a1d2181a"}
|
||||
{"OrderListHash", "559673838"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.112"},
|
||||
{"Treynor Ratio", "-6.121"},
|
||||
{"Total Fees", "$3.50"},
|
||||
{"Estimated Strategy Capacity", "$6900000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -144,7 +143,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "6b05339bfcb5bd93bfd66e32a1d2181a"}
|
||||
{"OrderListHash", "559673838"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.19"},
|
||||
{"Treynor Ratio", "2.159"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$14000000.00"},
|
||||
{"Fitness Score", "0.1"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -151,7 +150,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "214f38f9084bc350c93010aa2fb69822"}
|
||||
{"OrderListHash", "1531253381"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression test to demonstrate setting custom Symbol Properties and Market Hours for a custom data import
|
||||
/// </summary>
|
||||
/// <meta name="tag" content="using data" />
|
||||
/// <meta name="tag" content="custom data" />
|
||||
/// <meta name="tag" content="crypto" />
|
||||
/// <meta name="tag" content="regression test" />
|
||||
public class CustomDataPropertiesRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private string _ticker = "BTC";
|
||||
private Security _bitcoin;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2011, 9, 13);
|
||||
SetEndDate(2015, 12, 01);
|
||||
|
||||
//Set the cash for the strategy:
|
||||
SetCash(100000);
|
||||
|
||||
// Define our custom data properties and exchange hours
|
||||
var properties = new SymbolProperties("Bitcoin", "USD", 1, 0.01m, 0.01m, _ticker);
|
||||
var exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork);
|
||||
|
||||
// Add the custom data to our algorithm with our custom properties and exchange hours
|
||||
_bitcoin = AddData<Bitcoin>(_ticker, properties, exchangeHours);
|
||||
|
||||
//Verify our symbol properties were changed and loaded into this security
|
||||
if (_bitcoin.SymbolProperties != properties)
|
||||
{
|
||||
throw new Exception("Failed to set and retrieve custom SymbolProperties for BTC");
|
||||
}
|
||||
|
||||
//Verify our exchange hours were changed and loaded into this security
|
||||
if (_bitcoin.Exchange.Hours != exchangeHours)
|
||||
{
|
||||
throw new Exception("Failed to set and retrieve custom ExchangeHours for BTC");
|
||||
}
|
||||
|
||||
// For regression purposes on AddData overloads, this call is simply to ensure Lean can accept this
|
||||
// with default params and is not routed to a breaking function.
|
||||
AddData<Bitcoin>("BTCUSD");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Handler for Bitcoin Data Events: These Bitcoin objects are created from our
|
||||
/// "Bitcoin" type below and fired into this event handler.
|
||||
/// </summary>
|
||||
/// <param name="data">One(1) Bitcoin Object, streamed into our algorithm synchronized in time with our other data streams</param>
|
||||
public void OnData(Bitcoin data)
|
||||
{
|
||||
//If we don't have any bitcoin "SHARES" -- invest"
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
//Bitcoin used as a tradable asset, like stocks, futures etc.
|
||||
if (data.Close != 0)
|
||||
{
|
||||
//Access custom data symbols using <ticker>.<custom-type>
|
||||
Order("BTC.Bitcoin", Portfolio.MarginRemaining / Math.Abs(data.Close + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
// Reset our Symbol property value, for testing purposes.
|
||||
SymbolPropertiesDatabase.SetEntry(Market.USA, MarketHoursDatabase.GetDatabaseSymbolKey(_bitcoin.Symbol), SecurityType.Base,
|
||||
SymbolProperties.GetDefault("USD"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "155.262%"},
|
||||
{"Drawdown", "84.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "5123.242%"},
|
||||
{"Sharpe Ratio", "2.067"},
|
||||
{"Probabilistic Sharpe Ratio", "68.833%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.732"},
|
||||
{"Beta", "0.037"},
|
||||
{"Annual Standard Deviation", "0.841"},
|
||||
{"Annual Variance", "0.707"},
|
||||
{"Information Ratio", "1.902"},
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "46.992"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "2.238"},
|
||||
{"Return Over Maximum Drawdown", "1.832"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "1f54fb75ebcc0daafa5d45bfbaa4fbcb"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Custom Data Type: Bitcoin data from Quandl - http://www.quandl.com/help/api-for-bitcoin-data
|
||||
/// </summary>
|
||||
public class Bitcoin : BaseData
|
||||
{
|
||||
[JsonProperty("timestamp")]
|
||||
public int Timestamp = 0;
|
||||
[JsonProperty("open")]
|
||||
public decimal Open = 0;
|
||||
[JsonProperty("high")]
|
||||
public decimal High = 0;
|
||||
[JsonProperty("low")]
|
||||
public decimal Low = 0;
|
||||
[JsonProperty("last")]
|
||||
public decimal Close = 0;
|
||||
[JsonProperty("bid")]
|
||||
public decimal Bid = 0;
|
||||
[JsonProperty("ask")]
|
||||
public decimal Ask = 0;
|
||||
[JsonProperty("vwap")]
|
||||
public decimal WeightedPrice = 0;
|
||||
[JsonProperty("volume")]
|
||||
public decimal VolumeBTC = 0;
|
||||
public decimal VolumeUSD = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 1. DEFAULT CONSTRUCTOR: Custom data types need a default constructor.
|
||||
/// We search for a default constructor so please provide one here. It won't be used for data, just to generate the "Factory".
|
||||
/// </summary>
|
||||
public Bitcoin()
|
||||
{
|
||||
Symbol = "BTC";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2. RETURN THE STRING URL SOURCE LOCATION FOR YOUR DATA:
|
||||
/// This is a powerful and dynamic select source file method. If you have a large dataset, 10+mb we recommend you break it into smaller files. E.g. One zip per year.
|
||||
/// We can accept raw text or ZIP files. We read the file extension to determine if it is a zip file.
|
||||
/// </summary>
|
||||
/// <param name="config">Configuration object</param>
|
||||
/// <param name="date">Date of this source file</param>
|
||||
/// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
|
||||
/// <returns>String URL of source file.</returns>
|
||||
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
|
||||
{
|
||||
if (isLiveMode)
|
||||
{
|
||||
return new SubscriptionDataSource("https://www.bitstamp.net/api/ticker/", SubscriptionTransportMedium.Rest);
|
||||
}
|
||||
|
||||
//return "http://my-ftp-server.com/futures-data-" + date.ToString("Ymd") + ".zip";
|
||||
// OR simply return a fixed small data file. Large files will slow down your backtest
|
||||
return new SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.RemoteFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3. READER METHOD: Read 1 line from data source and convert it into Object.
|
||||
/// Each line of the CSV File is presented in here. The backend downloads your file, loads it into memory and then line by line
|
||||
/// feeds it into your algorithm
|
||||
/// </summary>
|
||||
/// <param name="line">string line from the data source file submitted above</param>
|
||||
/// <param name="config">Subscription data, symbol name, data type</param>
|
||||
/// <param name="date">Current date we're requesting. This allows you to break up the data source into daily files.</param>
|
||||
/// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
|
||||
/// <returns>New Bitcoin Object which extends BaseData.</returns>
|
||||
public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
|
||||
{
|
||||
var coin = new Bitcoin();
|
||||
if (isLiveMode)
|
||||
{
|
||||
//Example Line Format:
|
||||
//{"high": "441.00", "last": "421.86", "timestamp": "1411606877", "bid": "421.96", "vwap": "428.58", "volume": "14120.40683975", "low": "418.83", "ask": "421.99"}
|
||||
try
|
||||
{
|
||||
coin = JsonConvert.DeserializeObject<Bitcoin>(line);
|
||||
coin.EndTime = DateTime.UtcNow.ConvertFromUtc(config.ExchangeTimeZone);
|
||||
coin.Value = coin.Close;
|
||||
}
|
||||
catch { /* Do nothing, possible error in json decoding */ }
|
||||
return coin;
|
||||
}
|
||||
|
||||
//Example Line Format:
|
||||
//Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
|
||||
//2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356
|
||||
try
|
||||
{
|
||||
string[] data = line.Split(',');
|
||||
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
|
||||
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
|
||||
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
|
||||
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
|
||||
coin.Close = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
|
||||
coin.VolumeBTC = Convert.ToDecimal(data[5], CultureInfo.InvariantCulture);
|
||||
coin.VolumeUSD = Convert.ToDecimal(data[6], CultureInfo.InvariantCulture);
|
||||
coin.WeightedPrice = Convert.ToDecimal(data[7], CultureInfo.InvariantCulture);
|
||||
coin.Value = coin.Close;
|
||||
}
|
||||
catch { /* Do nothing, skip first title row */ }
|
||||
|
||||
return coin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.848"},
|
||||
{"Treynor Ratio", "46.996"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -121,7 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "0e7d560d0db2829adb19d3e403c30d97"}
|
||||
{"OrderListHash", "-541549381"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -141,7 +141,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.726"},
|
||||
{"Treynor Ratio", "0.142"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.127"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -161,7 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "1c319ae4b15416184a247bb47b31aabc"}
|
||||
{"OrderListHash", "-1014157203"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -212,7 +212,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.118"},
|
||||
{"Treynor Ratio", "-0.591"},
|
||||
{"Total Fees", "$62.24"},
|
||||
{"Estimated Strategy Capacity", "$100000000.00"},
|
||||
{"Fitness Score", "0.147"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -232,7 +231,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "71c17655bd0731eb25433727526e95ba"}
|
||||
{"OrderListHash", "852026186"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.251"},
|
||||
{"Treynor Ratio", "9.323"},
|
||||
{"Total Fees", "$3.26"},
|
||||
{"Estimated Strategy Capacity", "$220000000.00"},
|
||||
{"Fitness Score", "0.201"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -123,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "82fee25cd17100c53bb173834ab5f0b2"}
|
||||
{"OrderListHash", "1268340653"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.211"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -213,7 +212,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.183"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -138,7 +137,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.212"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -138,7 +137,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
@@ -16,6 +16,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NodaTime;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Interfaces;
|
||||
@@ -44,26 +45,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
for (int i = 0; i < _symbols.Length; i++)
|
||||
{
|
||||
var symbol = _symbols[i];
|
||||
IEnumerable<BaseData> history;
|
||||
if (symbol.SecurityType == SecurityType.Equity)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
history = History<QuoteBar>(symbol, 10, Resolution.Daily).Select(bar => bar as BaseData);
|
||||
throw new Exception("We were expecting an argument exception to be thrown. Equity does not have daily QuoteBars!");
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
history = History<TradeBar>(symbol, 10, Resolution.Daily).Select(bar => bar as BaseData);
|
||||
}
|
||||
else
|
||||
{
|
||||
history = History<QuoteBar>(symbol, 10, Resolution.Daily)
|
||||
.Select(bar => bar as BaseData);
|
||||
}
|
||||
var history = History<QuoteBar>(symbol, 10, Resolution.Daily);
|
||||
|
||||
var duplications = history
|
||||
.GroupBy(k => k.Time)
|
||||
@@ -111,7 +93,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -131,7 +112,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -156,7 +155,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,26 +100,25 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "1.300%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "1.634%"},
|
||||
{"Sharpe Ratio", "2.495"},
|
||||
{"Probabilistic Sharpe Ratio", "92.298%"},
|
||||
{"Sharpe Ratio", "2.476"},
|
||||
{"Probabilistic Sharpe Ratio", "92.194%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.006"},
|
||||
{"Beta", "0.158"},
|
||||
{"Annual Standard Deviation", "0.033"},
|
||||
{"Annual Standard Deviation", "0.032"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "-4.942"},
|
||||
{"Information Ratio", "-4.89"},
|
||||
{"Tracking Error", "0.08"},
|
||||
{"Treynor Ratio", "0.517"},
|
||||
{"Treynor Ratio", "0.509"},
|
||||
{"Total Fees", "$3.70"},
|
||||
{"Estimated Strategy Capacity", "$38000000.00"},
|
||||
{"Fitness Score", "0.019"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "1.362"},
|
||||
{"Return Over Maximum Drawdown", "9.699"},
|
||||
{"Portfolio Turnover", "0.023"},
|
||||
{"Portfolio Turnover", "0.022"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -133,7 +132,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "00d6dc8775da38f7f79defad06de240a"}
|
||||
{"OrderListHash", "-1252326142"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetEndDate(2007, 05, 25); //Set End Date
|
||||
SetCash(100000); //Set Strategy Cash
|
||||
// Find more symbols here: http://quantconnect.com/data
|
||||
AddSecurity(SecurityType.Equity, "AAA.1", Resolution.Daily);
|
||||
AddSecurity(SecurityType.Equity, "AAA", Resolution.Daily);
|
||||
AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_dataCount += data.Bars.Count;
|
||||
if (Transactions.OrdersCount == 0)
|
||||
{
|
||||
SetHoldings("AAA.1", 1);
|
||||
SetHoldings("AAA", 1);
|
||||
Debug("Purchased Stock");
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
// the slice can also contain delisting data: data.Delistings in a dictionary string->Delisting
|
||||
|
||||
var aaa = Securities["AAA.1"];
|
||||
var aaa = Securities["AAA"];
|
||||
if (aaa.IsDelisted && aaa.IsTradable)
|
||||
{
|
||||
throw new Exception("Delisted security must NOT be tradable");
|
||||
@@ -160,7 +160,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.155"},
|
||||
{"Treynor Ratio", "1.589"},
|
||||
{"Total Fees", "$55.05"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -180,7 +179,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "61f4d3c109fc4b6b9eb14d2e4eec4843"}
|
||||
{"OrderListHash", "-2022527947"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm reproducing issue #5160 where delisting order would be cancelled because it was placed at the market close on the delisting day
|
||||
/// </summary>
|
||||
public class DelistingFutureOptionRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private bool _traded;
|
||||
private int _lastMonth;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2012, 1, 1);
|
||||
SetEndDate(2013, 1, 1);
|
||||
SetCash(10000000);
|
||||
|
||||
var dc = AddFuture(Futures.Dairy.ClassIIIMilk, Resolution.Minute, Market.CME);
|
||||
dc.SetFilter(1, 120);
|
||||
|
||||
AddFutureOption(dc.Symbol, universe => universe.Strikes(-2, 2));
|
||||
_lastMonth = -1;
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
if (Time.Month != _lastMonth)
|
||||
{
|
||||
_lastMonth = Time.Month;
|
||||
var investedSymbols = Securities.Values
|
||||
.Where(security => security.Invested)
|
||||
.Select(security => security.Symbol)
|
||||
.ToList();
|
||||
|
||||
var delistedSecurity = investedSymbols.Where(symbol => symbol.ID.Date.AddDays(1) < Time).ToList();
|
||||
if (delistedSecurity.Count > 0)
|
||||
{
|
||||
throw new Exception($"[{UtcTime}] We hold a delisted securities: {string.Join(",", delistedSecurity)}");
|
||||
}
|
||||
Log($"Holdings({Time}): {string.Join(",", investedSymbols)}");
|
||||
}
|
||||
|
||||
if (Portfolio.Invested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var chain in data.OptionChains.Values)
|
||||
{
|
||||
foreach (var contractsValue in chain.Contracts.Values)
|
||||
{
|
||||
MarketOrder(contractsValue.Symbol, 1);
|
||||
_traded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (!_traded)
|
||||
{
|
||||
throw new Exception("We expected some FOP trading to happen");
|
||||
}
|
||||
if (Portfolio.Invested)
|
||||
{
|
||||
throw new Exception("We shouldn't be invested anymore");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "16"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.02%"},
|
||||
{"Compounding Annual Return", "-0.111%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "-0.679"},
|
||||
{"Net Profit", "-0.112%"},
|
||||
{"Sharpe Ratio", "-1.052"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "80%"},
|
||||
{"Win Rate", "20%"},
|
||||
{"Profit-Loss Ratio", "0.61"},
|
||||
{"Alpha", "-0.001"},
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.187"},
|
||||
{"Tracking Error", "0.115"},
|
||||
{"Treynor Ratio", "1.545"},
|
||||
{"Total Fees", "$37.00"},
|
||||
{"Estimated Strategy Capacity", "$58000.00"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "-0.128"},
|
||||
{"Return Over Maximum Drawdown", "-0.995"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "de309ab56d2fcd80ff03df2802d9feda"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.204"},
|
||||
{"Treynor Ratio", "-8.165"},
|
||||
{"Total Fees", "$46.75"},
|
||||
{"Estimated Strategy Capacity", "$96000000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -206,7 +205,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "7c4fcd79dd817a9cd3bf44525eaed96c"}
|
||||
{"OrderListHash", "-807056289"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.171"},
|
||||
{"Treynor Ratio", "-1.761"},
|
||||
{"Total Fees", "$8669.41"},
|
||||
{"Estimated Strategy Capacity", "$170000.00"},
|
||||
{"Fitness Score", "0.675"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -224,7 +223,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "0b6746b5759ecd45ab21360fd40858bb"}
|
||||
{"OrderListHash", "-75671425"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.171"},
|
||||
{"Treynor Ratio", "-1.971"},
|
||||
{"Total Fees", "$6806.67"},
|
||||
{"Estimated Strategy Capacity", "$150000.00"},
|
||||
{"Fitness Score", "0.694"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -197,7 +196,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "a7a893a17a5afa7c2f73a444a7aea507"}
|
||||
{"OrderListHash", "1142077166"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.193"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -130,7 +129,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$14.92"},
|
||||
{"Estimated Strategy Capacity", "$85000.00"},
|
||||
{"Fitness Score", "0.258"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -111,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "21ac8e4179b36d9658f0080868c0e552"}
|
||||
{"OrderListHash", "1296183675"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.29"},
|
||||
{"Treynor Ratio", "4.005"},
|
||||
{"Total Fees", "$18.28"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Fitness Score", "0.052"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -151,7 +150,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "17245c38f1b192d2041ca1f3e88250be"}
|
||||
{"OrderListHash", "1300818910"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.204"},
|
||||
{"Treynor Ratio", "-1.424"},
|
||||
{"Total Fees", "$16.26"},
|
||||
{"Estimated Strategy Capacity", "$250000000.00"},
|
||||
{"Fitness Score", "0.003"},
|
||||
{"Kelly Criterion Estimate", "12.539"},
|
||||
{"Kelly Criterion Probability Value", "0.367"},
|
||||
@@ -147,7 +146,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "50%"},
|
||||
{"Rolling Averaged Population Direction", "50%"},
|
||||
{"Rolling Averaged Population Magnitude", "50%"},
|
||||
{"OrderListHash", "4178a84209934b1eb6d03c2267654f32"}
|
||||
{"OrderListHash", "-218498072"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "1.441"},
|
||||
{"Treynor Ratio", "-0.15"},
|
||||
{"Total Fees", "$33.30"},
|
||||
{"Estimated Strategy Capacity", "$4200000.00"},
|
||||
{"Fitness Score", "0.079"},
|
||||
{"Kelly Criterion Estimate", "-9.366"},
|
||||
{"Kelly Criterion Probability Value", "0.607"},
|
||||
@@ -168,7 +167,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "25.058%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "f4c4b763b5ade918cfb7932e276d069f"}
|
||||
{"OrderListHash", "-1105779454"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,11 +85,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Trades", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.12%"},
|
||||
{"Compounding Annual Return", "-9.062%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-0.500%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Net Profit", "-0.121%"},
|
||||
{"Net Profit", "-0.006%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
@@ -103,13 +103,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.22"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$6.41"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0.249"},
|
||||
{"Fitness Score", "0.248"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-79.031"},
|
||||
{"Portfolio Turnover", "0.498"},
|
||||
{"Return Over Maximum Drawdown", "-82.815"},
|
||||
{"Portfolio Turnover", "0.497"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
@@ -123,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "af92d7f4e0810bc4a95d5ccb5542b438"}
|
||||
{"OrderListHash", "1213851303"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.123"},
|
||||
{"Treynor Ratio", "-1.288"},
|
||||
{"Total Fees", "$669.76"},
|
||||
{"Estimated Strategy Capacity", "$8100000.00"},
|
||||
{"Fitness Score", "0.021"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -204,7 +203,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "2cd87d138f8f9f5fcab28b6f983f68b1"}
|
||||
{"OrderListHash", "1040964928"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.049"},
|
||||
{"Treynor Ratio", "-0.934"},
|
||||
{"Total Fees", "$22.26"},
|
||||
{"Estimated Strategy Capacity", "$3600000.00"},
|
||||
{"Fitness Score", "0.002"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -167,7 +166,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "9f381f81ea9939f285b432207fa0d024"}
|
||||
{"OrderListHash", "-1961710414"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.186"},
|
||||
{"Treynor Ratio", "1.557"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$1400000.00"},
|
||||
{"Fitness Score", "0.012"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -142,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "ee79a87e6a386f5ee620d77b7bfbd964"}
|
||||
{"OrderListHash", "1717552327"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$804.33"},
|
||||
{"Estimated Strategy Capacity", "$21000.00"},
|
||||
{"Fitness Score", "0.504"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -194,7 +193,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "c84d1ceacb0da30c1c1c0314f9fc850c"}
|
||||
{"OrderListHash", "-1116140375"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression test algorithm simply fetch and compare data of minute resolution around daylight saving period
|
||||
/// reproduces issue reported in GB issue GH issue https://github.com/QuantConnect/Lean/issues/4925
|
||||
/// related issues https://github.com/QuantConnect/Lean/issues/3707; https://github.com/QuantConnect/Lean/issues/4630
|
||||
/// </summary>
|
||||
public class FillForwardEnumeratorOutOfOrderBarRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private decimal _exptectedClose = 84.09m;
|
||||
private DateTime _exptectedTime = new DateTime(2008, 3, 10, 9, 30, 0);
|
||||
private Symbol _shy;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2008, 3, 7);
|
||||
SetEndDate(2008, 3, 10);
|
||||
_shy = AddEquity("SHY", Resolution.Minute).Symbol;
|
||||
// just to make debugging easier, less subscriptions
|
||||
SetBenchmark(time => 1);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
var trackingBar = slice.Bars.Values.FirstOrDefault(s => s.Time.Equals(_exptectedTime));
|
||||
|
||||
if (trackingBar != null)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings(_shy, 1);
|
||||
}
|
||||
|
||||
if (trackingBar.Close != _exptectedClose)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Bar at {_exptectedTime.ToStringInvariant()} closed at price {trackingBar.Close.ToStringInvariant()}; expected {_exptectedClose.ToStringInvariant()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$5.93"},
|
||||
{"Estimated Strategy Capacity", "$200000.00"},
|
||||
{"Fitness Score", "0.499"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "-105.726"},
|
||||
{"Portfolio Turnover", "0.998"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "5315f54b62b2eaf9d587602137d641a5"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities.Option;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm checks FillForwardEnumerator should FF the data until it reaches the delisting date
|
||||
/// replicates GH issue https://github.com/QuantConnect/Lean/issues/4872
|
||||
/// </summary>
|
||||
public class FillForwardUntilExpiryRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private DateTime _realEndDate = new DateTime(2014, 06, 07);
|
||||
private SecurityExchange _exchange;
|
||||
private Dictionary<Symbol, HashSet<DateTime>> _options;
|
||||
|
||||
private string[] _contracts =
|
||||
{
|
||||
"TWX 140621P00067500",
|
||||
"TWX 140621C00067500",
|
||||
"TWX 140621C00070000",
|
||||
"TWX 140621P00070000"
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 06, 05);
|
||||
SetEndDate(2014, 06, 30);
|
||||
|
||||
_options = new Dictionary<Symbol, HashSet<DateTime>>();
|
||||
var _twxOption = AddOption("TWX", Resolution.Minute);
|
||||
_exchange = _twxOption.Exchange;
|
||||
_twxOption.SetFilter((x) => x
|
||||
.Contracts(c => c.Where(s => _contracts.Contains(s.Value))));
|
||||
SetBenchmark(t => 1);
|
||||
}
|
||||
|
||||
public override void OnData(Slice data)
|
||||
{
|
||||
foreach (var value in data.OptionChains.Values)
|
||||
{
|
||||
foreach (var contact in value.Contracts)
|
||||
{
|
||||
BaseData bar = null;
|
||||
QuoteBar quoteBar;
|
||||
if (bar == null && value.QuoteBars.TryGetValue(contact.Key, out quoteBar))
|
||||
{
|
||||
bar = quoteBar;
|
||||
}
|
||||
TradeBar tradeBar;
|
||||
if (bar == null && value.TradeBars.TryGetValue(contact.Key, out tradeBar))
|
||||
{
|
||||
bar = tradeBar;
|
||||
}
|
||||
if (bar.IsFillForward)
|
||||
{
|
||||
_options[contact.Key].Add(value.Time.Date);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var security in changes.AddedSecurities.OfType<Option>())
|
||||
{
|
||||
_options.Add(security.Symbol, new HashSet<DateTime>());
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_options.Count != _contracts.Length)
|
||||
{
|
||||
throw new Exception($"Options weren't setup properly. Expected: {_contracts.Length}");
|
||||
}
|
||||
|
||||
foreach (var option in _options)
|
||||
{
|
||||
for (DateTime date = _realEndDate; date < option.Key.ID.Date; date = date.AddDays(1))
|
||||
{
|
||||
if (_exchange.Hours.IsDateOpen(date) &&
|
||||
!option.Value.Contains(date))
|
||||
{
|
||||
throw new Exception("Delisted security should be FF until expiry date");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public Language[] Languages { get; } = { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Trades", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
{"Sortino Ratio", "79228162514264337593543950335"},
|
||||
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
|
||||
{"Portfolio Turnover", "0"},
|
||||
{"Total Insights Generated", "0"},
|
||||
{"Total Insights Closed", "0"},
|
||||
{"Total Insights Analysis Completed", "0"},
|
||||
{"Long Insight Count", "0"},
|
||||
{"Short Insight Count", "0"},
|
||||
{"Long/Short Ratio", "100%"},
|
||||
{"Estimated Monthly Alpha Value", "$0"},
|
||||
{"Total Accumulated Estimated Alpha Value", "$0"},
|
||||
{"Mean Population Estimated Insight Value", "$0"},
|
||||
{"Mean Population Direction", "0%"},
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.394"},
|
||||
{"Treynor Ratio", "-5.313"},
|
||||
{"Total Fees", "$5.40"},
|
||||
{"Estimated Strategy Capacity", "$59000000.00"},
|
||||
{"Fitness Score", "0.244"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -125,7 +124,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "189eee984d524162b9676b83dab4d73c"}
|
||||
{"OrderListHash", "-423205673"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.107"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -173,7 +172,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.107"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Fitness Score", "0"},
|
||||
{"Kelly Criterion Estimate", "0"},
|
||||
{"Kelly Criterion Probability Value", "0"},
|
||||
@@ -177,7 +176,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Mean Population Magnitude", "0%"},
|
||||
{"Rolling Averaged Population Direction", "0%"},
|
||||
{"Rolling Averaged Population Magnitude", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
{"OrderListHash", "371857150"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user