Compare commits

..

25 Commits

Author SHA1 Message Date
Gerardo Salazar
be6ead75e9 Revert some changes and adds pandas memory allocator 2020-12-06 19:15:38 -08:00
Gerardo Salazar
25f7ccf0c2 Performance improvements 2020-12-06 19:15:38 -08:00
Gerardo Salazar
afb0a86291 Faster double casting than CLR implementation 2020-12-06 19:14:48 -08:00
Gerardo Salazar
f5c5faa3d4 Remove bindingRedirect in Tests and re-adds pyarrow to DockerfileLeanFoundation 2020-12-06 19:14:48 -08:00
Gerardo Salazar
c471d1ced0 Adds unit tests and fixes various bugs in PandasConverter 2020-12-06 19:14:48 -08:00
Gerardo Salazar
5c345faea7 Revert changes to DockerfileLeanFoundation 2020-12-06 19:14:24 -08:00
Gerardo Salazar
11bed1f0c3 Address self-review: Adds explanitory comments and cleans up code 2020-12-06 19:14:24 -08:00
Gerardo Salazar
ec57799a5d Reverts changes and deletes unused classes 2020-12-06 19:14:24 -08:00
Gerardo Salazar
4c8aa638eb Fixes failing unit tests by converting filter mask to PyObject[] 2020-12-06 19:13:54 -08:00
Gerardo Salazar
7c3caec07f Use external NuGet package for Arrow
* Updates CI for Arrow
  * Updates DockerfileLeanFoundation
  * Adds Arrow to Python packages tests
2020-12-06 19:13:54 -08:00
Gerardo Salazar
45f71543bd Filters duplicates more efficiently, fixes warning on removal of dupes
* Commit includes behind the scenes testing and validation of the data
    and performance as a result of modifying the dupe removal process
2020-12-06 19:13:54 -08:00
Gerardo Salazar
13b9d91ecb Memory leak fixes for options and performance improvement for NA replace 2020-12-06 19:13:54 -08:00
Gerardo Salazar
f239018e77 Tames the wild beast of memory leaks, for QuoteBar data 2020-12-06 19:13:54 -08:00
Gerardo Salazar
f1c98b848a Partially fixes memory leak in PandasConverter 2020-12-06 19:13:54 -08:00
Gerardo Salazar
2c7bde422a Reuses MemoryStream to avoid having to reallocate consistently
* Cleans up .csproj and packages.config
  * Adds IDisposable to PandasConverter, PandasArrowMemoryAllocator
2020-12-06 19:13:54 -08:00
Gerardo Salazar
9e95bfea90 Fixes various bugs and matches previous version for backwards compat 2020-12-06 19:13:35 -08:00
Gerardo Salazar
b820ff4de8 EOD commit; Attempts to implement alt. data support 2020-12-06 19:13:35 -08:00
Gerardo Salazar
8218a2be99 Fixes bug with options and refactors code
* Option index is now 1-1 with existing impl
  * Begin adding support for custom data
2020-12-06 19:13:35 -08:00
Gerardo Salazar
9e3031c562 Fixes options support
* 1 bug remaining: Get index to be ''
2020-12-06 19:13:35 -08:00
Gerardo Salazar
2cf9239b6e Improves performance by ~10% of Arrow implementation
* New allocator improves performance by reusing allocated buffers
2020-12-06 19:13:35 -08:00
Gerardo Salazar
4c63c60a89 Adds option expiry support 2020-12-06 19:13:35 -08:00
Gerardo Salazar
9a2e47b05c Adds support for future expiry and proper indexing 2020-12-06 19:13:35 -08:00
Gerardo Salazar
711d46d6e2 Fixes bugs with index and handling of no data 2020-12-06 19:13:35 -08:00
Gerardo Salazar
5d6625c1ea Adds support for Tick, OpenInterest
* Performance improvement for Symbol creation in TimeSliceFactory for
    futures
2020-12-06 19:13:34 -08:00
Gerardo Salazar
0a70611d81 MVP of Apache Arrow in-memory pandas DataFrame construction 2020-12-06 19:13:16 -08:00
1198 changed files with 33646 additions and 45743 deletions

View File

@@ -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

3
.gitignore vendored
View File

@@ -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
@@ -196,7 +195,6 @@ publish/
# NuGet Packages
*.nupkg
!LocalPackages/*
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
@@ -205,7 +203,6 @@ publish/
#!**/packages/repositories.config
# ignore sln level nuget
.nuget/
!.nuget/NuGet.config
# Windows Azure Build Output
csx/

4
.idea/workspace.xml generated
View File

@@ -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">

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="true" />
<add key="automatic" value="true" />
</packageRestore>
<packageSources>
<add key="LocalPackages" value="../LocalPackages" />
</packageSources>
</configuration>

View File

@@ -1,13 +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"
- export PYTHONNET_PYDLL="$HOME/miniconda3/lib/libpython3.6m.so"
- 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
@@ -18,11 +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 nuget add source $TRAVIS_BUILD_DIR/LocalPackages
- 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
View File

@@ -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
View File

@@ -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",

View File

@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.212"},
{"Treynor Ratio", "-2.13"},
{"Total Fees", "$199.00"},
{"Estimated Strategy Capacity", "$23000000.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"}
};
}
}

View File

@@ -130,7 +130,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.367"},
{"Treynor Ratio", "-4.079"},
{"Total Fees", "$14.33"},
{"Estimated Strategy Capacity", "$38000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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", "$45000000.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"}
};
}
}

View File

@@ -191,7 +191,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.042"},
{"Treynor Ratio", "0.286"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$2800000.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"}
};
}
}

View File

@@ -79,19 +79,19 @@ namespace QuantConnect.Algorithm.CSharp
// things like manually added, auto added, internal, and any other boolean state we need to track against a single security)
throw new Exception("The underlying equity data should NEVER be removed in this algorithm because it was manually added");
}
if (_expectedSecurities.AreDifferent(Securities.Keys.ToHashSet()))
if (_expectedSecurities.AreDifferent(LinqExtensions.ToHashSet(Securities.Keys)))
{
var expected = string.Join(Environment.NewLine, _expectedSecurities.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, Securities.Keys.OrderBy(s => s.ToString()));
throw new Exception($"{Time}:: Detected differences in expected and actual securities{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
}
if (_expectedUniverses.AreDifferent(Securities.Keys.ToHashSet()))
if (_expectedUniverses.AreDifferent(LinqExtensions.ToHashSet(UniverseManager.Keys)))
{
var expected = string.Join(Environment.NewLine, _expectedUniverses.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, UniverseManager.Keys.OrderBy(s => s.ToString()));
throw new Exception($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
}
if (_expectedData.AreDifferent(Securities.Keys.ToHashSet()))
if (_expectedData.AreDifferent(LinqExtensions.ToHashSet(data.Keys)))
{
var expected = string.Join(Environment.NewLine, _expectedData.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, data.Keys.OrderBy(s => s.ToString()));
@@ -183,7 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
if (changes.RemovedSecurities
.Where(x => x.Symbol.SecurityType == SecurityType.Option)
.ToHashSet(s => s.Symbol)
.AreDifferent(_expectedContracts.ToHashSet()))
.AreDifferent(LinqExtensions.ToHashSet(_expectedContracts)))
{
throw new Exception("Expected removed securities to equal expected contracts added");
}
@@ -230,7 +230,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$6.00"},
{"Estimated Strategy Capacity", "$1500.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"}
};
}
}

View File

@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.072"},
{"Treynor Ratio", "2.933"},
{"Total Fees", "$26.39"},
{"Estimated Strategy Capacity", "$4400000.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"}
};
}
}

View File

@@ -84,7 +84,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.006"},
{"Treynor Ratio", "2.029"},
{"Total Fees", "$9.77"},
{"Estimated Strategy Capacity", "$37000000.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"}
};
}
}

View File

@@ -103,7 +103,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.376"},
{"Treynor Ratio", "-0.084"},
{"Total Fees", "$13.98"},
{"Estimated Strategy Capacity", "$61000000.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"}
};
}
}

View File

@@ -110,7 +110,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.194"},
{"Treynor Ratio", "-0.962"},
{"Total Fees", "$25.92"},
{"Estimated Strategy Capacity", "$69000000.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"}
};
}
}

View File

@@ -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", "$2800000.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"}
};
}
}

View File

@@ -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 =>

View File

@@ -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", "$16000000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -130,7 +130,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.001"},
{"Treynor Ratio", "1.922"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$58000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -97,7 +97,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.001"},
{"Treynor Ratio", "1.922"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$58000000.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"}
};
}
}
}

View File

@@ -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"}
};
}
}

View File

@@ -88,7 +88,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.221"},
{"Treynor Ratio", "-13.568"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$890000000.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"}
};
}
}

View File

@@ -109,7 +109,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.002"},
{"Treynor Ratio", "1.839"},
{"Total Fees", "$9.77"},
{"Estimated Strategy Capacity", "$27000000.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"}
};
}
}

View File

@@ -147,7 +147,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.504"},
{"Treynor Ratio", "1.011"},
{"Total Fees", "$15207.00"},
{"Estimated Strategy Capacity", "$7700.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"}
};
}
}

View File

@@ -155,7 +155,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.188"},
{"Treynor Ratio", "-3.318"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$52000000.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"}
};
}
}

View File

@@ -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"}
};
}
}
}

View File

@@ -1,157 +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 System.Collections.Generic;
using QuantConnect.Indicators;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This example demonstrates how to add index asset types.
/// </summary>
/// <meta name="tag" content="using data" />
/// <meta name="tag" content="benchmarks" />
/// <meta name="tag" content="indexes" />
public class BasicTemplateIndexAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _spx;
private Symbol _spxOption;
private ExponentialMovingAverage _emaSlow;
private ExponentialMovingAverage _emaFast;
/// <summary>
/// Initialize your algorithm and add desired assets.
/// </summary>
public override void Initialize()
{
SetStartDate(2021, 1, 4);
SetEndDate(2021, 1, 15);
SetCash(1000000);
// Use indicator for signal; but it cannot be traded
_spx = AddIndex("SPX", Resolution.Minute).Symbol;
// Trade on SPX ITM calls
_spxOption = QuantConnect.Symbol.CreateOption(
_spx,
Market.USA,
OptionStyle.European,
OptionRight.Call,
3200m,
new DateTime(2021, 1, 15));
AddIndexOptionContract(_spxOption, Resolution.Minute);
_emaSlow = EMA(_spx, 80);
_emaFast = EMA(_spx, 200);
}
/// <summary>
/// Index EMA Cross trading underlying.
/// </summary>
public override void OnData(Slice slice)
{
if (!slice.Bars.ContainsKey(_spx) || !slice.Bars.ContainsKey(_spxOption))
{
return;
}
// Warm up indicators
if (!_emaSlow.IsReady)
{
return;
}
if (_emaFast > _emaSlow)
{
SetHoldings(_spxOption, 1);
}
else
{
Liquidate();
}
}
public override void OnEndOfAlgorithm()
{
if (Portfolio[_spx].TotalSaleVolume > 0)
{
throw new Exception("Index is not tradable.");
}
}
/// <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", "4"},
{"Average Win", "0%"},
{"Average Loss", "-53.10%"},
{"Compounding Annual Return", "-96.172%"},
{"Drawdown", "10.100%"},
{"Expectancy", "-1"},
{"Net Profit", "-9.915%"},
{"Sharpe Ratio", "-4.217"},
{"Probabilistic Sharpe Ratio", "0.052%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0.139"},
{"Annual Variance", "0.019"},
{"Information Ratio", "-4.217"},
{"Tracking Error", "0.139"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Fitness Score", "0.044"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-1.96"},
{"Return Over Maximum Drawdown", "-10.171"},
{"Portfolio Turnover", "0.34"},
{"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", "52521ab779446daf4d38a7c9bbbdd893"}
};
}
}

View File

@@ -1,180 +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 System.Collections.Generic;
using QuantConnect.Indicators;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This example demonstrates how to add index asset types and trade index options on SPX.
/// </summary>
public class BasicTemplateIndexOptionsAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _spx;
private ExponentialMovingAverage _emaSlow;
private ExponentialMovingAverage _emaFast;
/// <summary>
/// Initialize your algorithm and add desired assets.
/// </summary>
public override void Initialize()
{
SetStartDate(2021, 1, 4);
SetEndDate(2021, 2, 1);
SetCash(1000000);
// Use indicator for signal; but it cannot be traded.
// We will instead trade on SPX options
_spx = AddIndex("SPX", Resolution.Minute).Symbol;
var spxOptions = AddIndexOption(_spx, Resolution.Minute);
spxOptions.SetFilter(filterFunc => filterFunc.CallsOnly());
_emaSlow = EMA(_spx, 80);
_emaFast = EMA(_spx, 200);
}
/// <summary>
/// Index EMA Cross trading index options of the index.
/// </summary>
public override void OnData(Slice slice)
{
if (!slice.Bars.ContainsKey(_spx))
{
Debug($"No SPX on {Time}");
return;
}
// Warm up indicators
if (!_emaSlow.IsReady)
{
Debug($"EMA slow not ready on {Time}");
return;
}
foreach (var chain in slice.OptionChains.Values)
{
foreach (var contract in chain.Contracts.Values)
{
if (contract.Expiry.Month == 3 && contract.Symbol.ID.StrikePrice == 3700m && contract.Right == OptionRight.Call && slice.QuoteBars.ContainsKey(contract.Symbol))
{
Log($"{Time} {contract.Strike}{(contract.Right == OptionRight.Call ? 'C' : 'P')} -- {slice.QuoteBars[contract.Symbol]}");
}
if (Portfolio.Invested)
{
continue;
}
if (_emaFast > _emaSlow && contract.Right == OptionRight.Call)
{
Liquidate(InvertOption(contract.Symbol));
MarketOrder(contract.Symbol, 1);
}
else if (_emaFast < _emaSlow && contract.Right == OptionRight.Put)
{
Liquidate(InvertOption(contract.Symbol));
MarketOrder(contract.Symbol, 1);
}
}
}
}
public override void OnEndOfAlgorithm()
{
if (Portfolio[_spx].TotalSaleVolume > 0)
{
throw new Exception("Index is not tradable.");
}
if (Portfolio.TotalSaleVolume == 0)
{
throw new Exception("Trade volume should be greater than zero by the end of this algorithm");
}
}
public Symbol InvertOption(Symbol symbol)
{
return QuantConnect.Symbol.CreateOption(
symbol.Underlying,
symbol.ID.Market,
symbol.ID.OptionStyle,
symbol.ID.OptionRight == OptionRight.Call ? OptionRight.Put : OptionRight.Call,
symbol.ID.StrikePrice,
symbol.ID.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; } = 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, 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", "8220"},
{"Average Win", "0.00%"},
{"Average Loss", "0.00%"},
{"Compounding Annual Return", "-100.000%"},
{"Drawdown", "13.500%"},
{"Expectancy", "-0.818"},
{"Net Profit", "-13.517%"},
{"Sharpe Ratio", "-2.678"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "89%"},
{"Win Rate", "11%"},
{"Profit-Loss Ratio", "0.69"},
{"Alpha", "4.398"},
{"Beta", "-0.989"},
{"Annual Standard Deviation", "0.373"},
{"Annual Variance", "0.139"},
{"Information Ratio", "-12.816"},
{"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"},
{"Sortino Ratio", "-8.62"},
{"Return Over Maximum Drawdown", "-7.81"},
{"Portfolio Turnover", "302.321"},
{"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", "35b3f4b7a225468d42ca085386a2383e"}
};
}
}

View File

@@ -134,7 +134,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$778.00"},
{"Estimated Strategy Capacity", "$720.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"}
};
}
}

View File

@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$1300000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.09"},
{"Treynor Ratio", "0.82"},
{"Total Fees", "$41.70"},
{"Estimated Strategy Capacity", "$3000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -181,7 +181,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.149"},
{"Treynor Ratio", "-1.405"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$42000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -136,7 +136,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.126"},
{"Treynor Ratio", "-0.607"},
{"Total Fees", "$11.63"},
{"Estimated Strategy Capacity", "$46000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -120,7 +120,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.105"},
{"Treynor Ratio", "1.667"},
{"Total Fees", "$2.91"},
{"Estimated Strategy Capacity", "$670000000.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"}
};
}
}

View File

@@ -91,7 +91,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.101"},
{"Treynor Ratio", "5.409"},
{"Total Fees", "$67.00"},
{"Estimated Strategy Capacity", "$3200000.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"}
};
}
}

View File

@@ -85,7 +85,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.009"},
{"Treynor Ratio", "1.575"},
{"Total Fees", "$22.77"},
{"Estimated Strategy Capacity", "$22000000.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"}
};
}
}

View File

@@ -94,7 +94,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.165"},
{"Treynor Ratio", "1.212"},
{"Total Fees", "$6.00"},
{"Estimated Strategy Capacity", "$42000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -190,7 +190,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.176"},
{"Treynor Ratio", "-1.46"},
{"Total Fees", "$7.82"},
{"Estimated Strategy Capacity", "$12000000.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"}
};
}
}

View File

@@ -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", "$1100000000.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"}
};
}
}

View File

@@ -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", "$300000000.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"}
};
}
}

View File

@@ -96,7 +96,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0.988"},
{"Total Fees", "$7.78"},
{"Estimated Strategy Capacity", "$8700000.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"}
};
}
}

View File

@@ -43,7 +43,7 @@ namespace QuantConnect.Algorithm.CSharp
security.SetBuyingPowerModel(new CustomBuyingPowerModel());
}
public override void OnData(Slice slice)
public void OnData(Slice slice)
{
if (Portfolio.Invested)
{
@@ -113,7 +113,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "1.04"},
{"Treynor Ratio", "5.073"},
{"Total Fees", "$30.00"},
{"Estimated Strategy Capacity", "$20000000.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"}
};
}
}

View File

@@ -119,7 +119,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.112"},
{"Treynor Ratio", "-6.121"},
{"Total Fees", "$3.50"},
{"Estimated Strategy Capacity", "$48000000.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"}
};
}
}

View File

@@ -124,7 +124,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.112"},
{"Treynor Ratio", "-6.121"},
{"Total Fees", "$3.50"},
{"Estimated Strategy Capacity", "$48000000.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"}
};
}
}

View File

@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.19"},
{"Treynor Ratio", "2.159"},
{"Total Fees", "$1.00"},
{"Estimated Strategy Capacity", "$58000000.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"}
};
}
}

View File

@@ -58,9 +58,7 @@ namespace QuantConnect.Algorithm.CSharp
//Weather used as a tradable asset, like stocks, futures etc.
if (data.Close != 0)
{
// It's only OK to use SetHoldings with crypto when using custom data. When trading with built-in crypto data,
// use the cashbook. Reference https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/BasicTemplateCryptoAlgorithm.py
SetHoldings("BTC", 1);
Order("BTC", (Portfolio.MarginRemaining / Math.Abs(data.Close + 1)));
}
Console.WriteLine("Buying BTC 'Shares': BTC: " + data.Close);
}
@@ -119,7 +117,7 @@ namespace QuantConnect.Algorithm.CSharp
//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);
return new SubscriptionDataSource("https://www.quandl.com/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc", SubscriptionTransportMedium.RemoteFile);
}
/// <summary>
@@ -156,7 +154,6 @@ namespace QuantConnect.Algorithm.CSharp
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.EndTime = coin.Time.AddDays(1);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);

View File

@@ -61,7 +61,7 @@ namespace QuantConnect.Algorithm.CSharp
/// "Nifty" type below and fired into this event handler.
/// </summary>
/// <param name="data">One(1) Nifty Object, streamed into our algorithm synchronised in time with our other data streams</param>
public override void OnData(Slice data)
public void OnData(Slice data)
{
if (data.ContainsKey("USDINR"))
{
@@ -77,7 +77,7 @@ namespace QuantConnect.Algorithm.CSharp
{
_today.NiftyPrice = Convert.ToDouble(data["NIFTY"].Close);
if (_today.Date == data["NIFTY"].Time)
if (_today.Date == data["NIFTY"].EndTime)
{
_prices.Add(_today);
@@ -91,7 +91,7 @@ namespace QuantConnect.Algorithm.CSharp
var quantity = (int)(Portfolio.MarginRemaining * 0.9m / data["NIFTY"].Close);
var highestNifty = (from pair in _prices select pair.NiftyPrice).Max();
var lowestNifty = (from pair in _prices select pair.NiftyPrice).Min();
if (Time.DayOfWeek == DayOfWeek.Wednesday) //prices.Count >= minimumCorrelationHistory &&
{
//List<double> niftyPrices = (from pair in prices select pair.NiftyPrice).ToList();
@@ -181,7 +181,6 @@ namespace QuantConnect.Algorithm.CSharp
//2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78
var data = line.Split(',');
index.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
index.EndTime = index.Time.AddDays(1);
index.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
index.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
index.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
@@ -248,7 +247,6 @@ namespace QuantConnect.Algorithm.CSharp
{
var data = line.Split(',');
currency.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
currency.EndTime = currency.Time.AddDays(1);
currency.Close = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
currency.Symbol = "USDINR";
currency.Value = currency.Close;

View File

@@ -1,262 +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", "157.498%"},
{"Drawdown", "84.800%"},
{"Expectancy", "0"},
{"Net Profit", "5319.081%"},
{"Sharpe Ratio", "2.086"},
{"Probabilistic Sharpe Ratio", "69.456%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.736"},
{"Beta", "0.136"},
{"Annual Standard Deviation", "0.84"},
{"Annual Variance", "0.706"},
{"Information Ratio", "1.925"},
{"Tracking Error", "0.846"},
{"Treynor Ratio", "12.904"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "2.269"},
{"Return Over Maximum Drawdown", "1.858"},
{"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", "0d80bb47bd16b5bc6989a4c1c7aa8349"}
};
/// <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.EndTime = coin.Time.AddDays(1);
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;
}
}
}
}

View File

@@ -84,29 +84,28 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "157.497%"},
{"Compounding Annual Return", "155.262%"},
{"Drawdown", "84.800%"},
{"Expectancy", "0"},
{"Net Profit", "5319.007%"},
{"Sharpe Ratio", "2.086"},
{"Probabilistic Sharpe Ratio", "69.456%"},
{"Net Profit", "5123.170%"},
{"Sharpe Ratio", "2.066"},
{"Probabilistic Sharpe Ratio", "68.832%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.736"},
{"Beta", "0.136"},
{"Annual Standard Deviation", "0.84"},
{"Annual Variance", "0.706"},
{"Information Ratio", "1.925"},
{"Tracking Error", "0.846"},
{"Treynor Ratio", "12.903"},
{"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.996"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "2.269"},
{"Return Over Maximum Drawdown", "1.858"},
{"Sortino Ratio", "2.238"},
{"Return Over Maximum Drawdown", "1.832"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -121,7 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "50faa37f15732bf5c24ad1eeaa335bc7"}
{"OrderListHash", "-541549381"}
};
/// <summary>
@@ -213,7 +212,6 @@ namespace QuantConnect.Algorithm.CSharp
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.EndTime = coin.Time.AddDays(1);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
@@ -229,4 +227,4 @@ namespace QuantConnect.Algorithm.CSharp
}
}
}
}
}

View File

@@ -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>

View File

@@ -212,7 +212,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.118"},
{"Treynor Ratio", "-0.591"},
{"Total Fees", "$62.24"},
{"Estimated Strategy Capacity", "$49000000.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"}
};
}
}

View File

@@ -103,7 +103,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.251"},
{"Treynor Ratio", "9.323"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$890000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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", "$270000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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", "$400000.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"}
};
}
}

View File

@@ -186,7 +186,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.204"},
{"Treynor Ratio", "-8.165"},
{"Total Fees", "$46.75"},
{"Estimated Strategy Capacity", "$670000000.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"}
};
}
}

View File

@@ -204,7 +204,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.171"},
{"Treynor Ratio", "-1.761"},
{"Total Fees", "$8669.41"},
{"Estimated Strategy Capacity", "$320000.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"}
};
}
}

View File

@@ -177,7 +177,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.171"},
{"Treynor Ratio", "-1.971"},
{"Total Fees", "$6806.67"},
{"Estimated Strategy Capacity", "$320000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -131,7 +131,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.29"},
{"Treynor Ratio", "4.005"},
{"Total Fees", "$18.28"},
{"Estimated Strategy Capacity", "$500000000.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"}
};
}
}

View File

@@ -127,7 +127,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.204"},
{"Treynor Ratio", "-1.424"},
{"Total Fees", "$16.26"},
{"Estimated Strategy Capacity", "$590000000.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"}
};
}
}

View File

@@ -148,7 +148,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "1.441"},
{"Treynor Ratio", "-0.15"},
{"Total Fees", "$33.30"},
{"Estimated Strategy Capacity", "$17000000.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"}
};
}
}

View File

@@ -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"}
};
}
}

View File

@@ -184,7 +184,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.123"},
{"Treynor Ratio", "-1.288"},
{"Total Fees", "$669.76"},
{"Estimated Strategy Capacity", "$210000.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"}
};
}
}

View File

@@ -147,7 +147,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.049"},
{"Treynor Ratio", "-0.934"},
{"Total Fees", "$22.26"},
{"Estimated Strategy Capacity", "$360000.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"}
};
}
}

View File

@@ -122,7 +122,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.186"},
{"Treynor Ratio", "1.557"},
{"Total Fees", "$4.00"},
{"Estimated Strategy Capacity", "$5200000.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"}
};
}
}

View File

@@ -174,7 +174,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$804.33"},
{"Estimated Strategy Capacity", "$11000.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"}
};
}
}

Some files were not shown because too many files have changed in this diff Show More