Compare commits

..

78 Commits
17333 ... 17015

Author SHA1 Message Date
Jhonathan Abreu
f4f7c1c18c Add logs to ProcessedDataProvider 2025-03-20 09:45:19 -04:00
Jhonathan Abreu
8ddf4cb390 Trigger Build 2025-03-20 09:45:18 -04:00
Jhonathan Abreu
759d7207ac Trigger Build 2025-03-20 09:45:18 -04:00
Jhonathan Abreu
aa559ce5cb Trigger Build 2025-03-20 09:45:17 -04:00
Jhonathan Abreu
c1c4501377 Trigger Build 2025-03-20 09:45:17 -04:00
Jhonathan Abreu
e6ae78ad26 Minor fix 2025-03-20 09:45:16 -04:00
Jhonathan Abreu
af5d1458d8 Minor fix 2025-03-20 09:45:16 -04:00
Jhonathan Abreu
0217ed8453 Trigger Build 2025-03-20 09:45:16 -04:00
Jhonathan Abreu
96fa97fa5c Trigger Build 2025-03-20 09:45:15 -04:00
Jhonathan Abreu
3ab160cb37 Trigger Build 2025-03-20 09:45:15 -04:00
Jhonathan Abreu
c4399d3226 Minor changes 2025-03-20 09:45:14 -04:00
Jhonathan Abreu
f399485970 Add initialize method to chain providers classes 2025-03-20 09:45:14 -04:00
Jhonathan Abreu
3f7d1bc36f Minor fix for FakeDataQueue 2025-03-20 09:45:13 -04:00
Jhonathan Abreu
c2af7028e8 Update new regression algorithms data points count 2025-03-20 09:45:13 -04:00
Jhonathan Abreu
686e93165e Add history provider as constructor argument for chain providers 2025-03-20 09:45:12 -04:00
Jhonathan Abreu
04f8bc01d9 Minor fix 2025-03-20 09:45:11 -04:00
Jhonathan Abreu
043f4c42bd Trigger Build 2025-03-20 09:45:11 -04:00
Jhonathan Abreu
82379fce2a Trigger Build 2025-03-20 09:45:10 -04:00
Jhonathan Abreu
f7529bdde2 Trigger Build 2025-03-20 09:45:10 -04:00
Jhonathan Abreu
c84fc2534e Trigger Build 2025-03-20 09:45:10 -04:00
Jhonathan Abreu
a950ef9286 Trigger Build 2025-03-20 09:45:09 -04:00
Jhonathan Abreu
f878a46408 Trigger Build 2025-03-20 09:45:09 -04:00
Jhonathan Abreu
92c0d94d51 Trigger Build 2025-03-20 09:45:08 -04:00
Jhonathan Abreu
ca09f80ec1 Trigger Build 2025-03-20 09:45:08 -04:00
Jhonathan Abreu
9808d8bb46 Trigger Build 2025-03-20 09:45:08 -04:00
Jhonathan Abreu
dacea571bb Trigger Build 2025-03-20 09:45:07 -04:00
Jhonathan Abreu
def8c78ac4 Trigger Build 2025-03-20 09:45:06 -04:00
Jhonathan Abreu
1e57102261 Trigger Build 2025-03-20 09:45:06 -04:00
Jhonathan Abreu
40ca555dbc Trigger Build 2025-03-20 09:45:05 -04:00
Jhonathan Abreu
975434a950 Minor unit test fix 2025-03-20 09:45:05 -04:00
Jhonathan Abreu
7a98c6501a Update FOPs universe file header
Removed greeks and IV columns.
Updated FOPs universe files: removed outdated columns.
2025-03-20 09:45:04 -04:00
Jhonathan Abreu
01daed7075 Minor fix for failing unit tests 2025-03-20 09:45:04 -04:00
Jhonathan Abreu
b14e287959 Improve some regression algorithms 2025-03-20 09:45:04 -04:00
Jhonathan Abreu
476ffb6742 Minor changes 2025-03-20 09:45:03 -04:00
Jhonathan Abreu
6c05df56af Throw from option universe data filters for future options
Future options IV, Open interest and greeks are not supported for future options
2025-03-20 09:45:03 -04:00
Jhonathan Abreu
83bedf703a Sort configs by internal flag
Internals go first
2025-03-20 09:45:02 -04:00
Jhonathan Abreu
341073f5f3 Update regression algorithms stats after rebase
Added HSI futures universe files
2025-03-20 09:45:02 -04:00
Jhonathan Abreu
65b5d52909 Fix: use universe data for market data in FuturesContract 2025-03-20 09:45:01 -04:00
Jhonathan Abreu
bc2cba13bb Refactor FuturesContract data handling
Forward price data from bars and ticks stored in private fields for improved memory usage
2025-03-20 09:45:01 -04:00
Jhonathan Abreu
c5fa27220c Trigger Build 2025-03-20 09:45:00 -04:00
Jhonathan Abreu
1956ff64e6 Trigger Build 2025-03-20 09:45:00 -04:00
Jhonathan Abreu
7c81de0ef7 Minor changes and cleanup 2025-03-20 09:44:59 -04:00
Jhonathan Abreu
74158721eb Remove ZipEntryName other classes and unused code
Removed ZipEntryName class and references across various files.
Removed DataQueueFuturesChainUniverseDataCollectionEnumerator and DataQueueOptionChainUniverseDataCollectionEnumerator classes.
Removed OptionChainUniverseSubscriptionEnumeratorFactory class.
Removed unused code for handling OptionChainUniverse and FuturesChainUniverse in FileSystemDataFeed.cs and LiveTradingDataFeed.cs.
Removed several test files related to enumerator factories and universe data collection.
2025-03-20 09:44:59 -04:00
Jhonathan Abreu
b4b03ddee8 Clean chain provider classes up 2025-03-20 09:44:57 -04:00
Jhonathan Abreu
935746ac62 Trigger Build 2025-03-20 09:44:56 -04:00
Jhonathan Abreu
3246695c95 Trigger Build 2025-03-20 09:44:56 -04:00
Jhonathan Abreu
c00e0f2104 Trigger Build 2025-03-20 09:44:55 -04:00
Jhonathan Abreu
3d555ab510 Trigger Build 2025-03-20 09:44:55 -04:00
Jhonathan Abreu
b1f4b8a78c Add minor fix for future options tickers parsing
Added tests
2025-03-20 09:44:54 -04:00
Jhonathan Abreu
3c850d6d79 Add base class for options and futures contracts
- Introduced `BaseContract` as an abstract base class for contracts, consolidating common properties and methods.
- Removed ISymbolInterface
2025-03-20 09:44:54 -04:00
Jhonathan Abreu
557674a178 Refactor class and interface names for clarity
Renamed `FileBasedUniverse` to `BaseChainUniverseData` and
`IFileBasedUniverse` to `IChainUniverseData`.
2025-03-20 09:44:51 -04:00
Jhonathan Abreu
fa66f348a8 Remove chain cache logic from FuturesChainUniverse 2025-03-20 09:44:49 -04:00
Jhonathan Abreu
fd0cc927a8 Remove specific constructors and indexers from Chain classes
Removed public indexers in `BaseChains` for getting or setting `BaseChain` instances by `ticker` or `Symbol`, which were used for Pythonnet compatibility.
2025-03-20 09:44:49 -04:00
Jhonathan Abreu
5031590155 Refactor data handling in BaseChain and TimeSliceFactory
- Added `AddData` method to `BaseChain` for adding market data
- Refactored `TimeSliceFactory` to use `BaseChain.AddData` method
2025-03-20 09:44:48 -04:00
Jhonathan Abreu
90cc4ca468 Changed _auxiliaryData field to lazily-initialized AuxiliaryData property 2025-03-20 09:44:48 -04:00
Jhonathan Abreu
4ab170c821 Improve resolution handling for history requests 2025-03-20 09:44:48 -04:00
Jhonathan Abreu
66baf97bb4 Add implicit conversion from FuturesContract to Symbol
Modified algorithms to use futures contract objects directly instead of accessing their Symbol property.
Removed unnecessary import statements and redundant lines in various files.
2025-03-20 09:44:47 -04:00
Jhonathan Abreu
1b431480a9 Regression algorithms updates 2025-03-20 09:44:46 -04:00
Jhonathan Abreu
cbd343824d Minor data fixes 2025-03-20 09:44:45 -04:00
Jhonathan Abreu
dbdbd38181 Reduce number of universe files in repo 2025-03-20 09:44:44 -04:00
Jhonathan Abreu
1f24fd610e Minor fixes 2025-03-20 09:44:38 -04:00
Jhonathan Abreu
c8c6eb599e Replace QCAlgorithm.FutureChainProvider usages with new FuturesChain api 2025-03-20 09:44:37 -04:00
Jhonathan Abreu
a35689731d Add regression algorithms 2025-03-20 09:44:36 -04:00
Jhonathan Abreu
2124b92acf Add regression algorithms 2025-03-20 09:44:35 -04:00
Jhonathan Abreu
9b1b7a61cc Add DataFrame property to FuturesChains class 2025-03-20 09:44:34 -04:00
Jhonathan Abreu
7c3d63a87d Add futures chains DataFrame property
Also, remove IDerivativeSecurity interface from Future
2025-03-20 09:44:32 -04:00
Jhonathan Abreu
dab65ca2d1 Minor future chains unit test improvement 2025-03-20 09:44:21 -04:00
Jhonathan Abreu
fd79251c65 Fix failing tests 2025-03-20 09:44:20 -04:00
Jhonathan Abreu
8a441263dd Fix failing tests 2025-03-20 09:44:19 -04:00
Jhonathan Abreu
10e2592d5e Fix failing tests 2025-03-20 09:44:17 -04:00
Jhonathan Abreu
e8c75c08d5 Refactor QuantBook option and future history to use new universes 2025-03-20 09:44:15 -04:00
Jhonathan Abreu
f28318ec99 Update regression algorithms stats 2025-03-20 09:44:14 -04:00
Jhonathan Abreu
4a841aab5e Add FuturesChains API to QC algorithm
Also refactor future chain provider to use the new FutureUniverse instead of zip file names
2025-03-20 09:44:10 -04:00
Jhonathan Abreu
b72adf16d2 Abstraction cleanup 2025-03-20 09:44:09 -04:00
Jhonathan Abreu
d88d30d5f6 Make Future universe selection file-based like option universe 2025-03-20 09:44:08 -04:00
Jhonathan Abreu
ba16399039 Make Future universe selection file-based like option universe 2025-03-20 09:44:04 -04:00
Jhonathan Abreu
8dde62454c Make FOPs option chains universe file based 2025-03-20 09:44:00 -04:00
Jhonathan Abreu
c881d14c4a Make FOPs selection universe file-based for backtesting 2025-03-20 09:43:59 -04:00
1567 changed files with 72524 additions and 106850 deletions

View File

@@ -1,43 +1,33 @@
{
"name": "Lean Development Container",
"workspaceMount": "source=${localWorkspaceFolder},target=/Lean,type=bind",
"workspaceFolder": "/Lean",
// Use devcontainer Dockerfile that is based on Lean foundation image
"build": {
"dockerfile": "Dockerfile"
},
//See https://containers.dev/implementors/json_reference/ for a comprehensive json schema used to define this file.
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csdevkit",
"ms-python.python",
"eamodio.gitlens",
"yzhang.markdown-all-in-one",
"SonarSource.sonarlint-vscode"
],
// Set *default* vscode specific settings.json values on container create.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
}
}
"build": { "dockerfile": "Dockerfile" },
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
}
}
},
//use the same network configuration as the host machine, ensuring no problems with firewalls, proxies etc.
"runArgs": [
"--network=host"
],
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["ms-dotnettools.csharp", "ms-python.python", "ms-python.vscode-pylance", "formulahendry.dotnet-test-explorer", "eamodio.gitlens", "yzhang.markdown-all-in-one"],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created - for example installing curl.
"postCreateCommand": "dotnet nuget add source /Lean/LocalPackages;chmod u+x /Lean/.vscode/launch_research.sh;dos2unix /Lean/.vscode/launch_research.sh",
// Add mounts to docker container
"mounts": [
"mounts": [
// Example data mount from local machine, must use target directory in Config.json
// "source=C:/Users/XXXXXXXXXXXX/Lean/Data,target=/Data,type=bind,consistency=cached"
]

View File

@@ -32,4 +32,4 @@ jobs:
# Build
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
# Run Projects tests
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 7minutes --blame-crash --logger "console;verbosity=detailed" --filter "FullyQualifiedName=QuantConnect.Tests.API.ProjectTests|FullyQualifiedName=QuantConnect.Tests.API.ObjectStoreTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\)
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 300seconds --blame-crash --filter "FullyQualifiedName=QuantConnect.Tests.API.ProjectTests|ObjectStoreTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\)

View File

@@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensures we fetch all history
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
@@ -30,15 +28,9 @@ jobs:
options: --workdir /__w/Lean/Lean -v /home/runner/work:/__w -e GITHUB_REF=${{ github.ref }} -e PYPI_API_TOKEN=${{ secrets.PYPI_API_TOKEN }} -e ADDITIONAL_STUBS_REPOS=${{ secrets.ADDITIONAL_STUBS_REPOS }} -e QC_GIT_TOKEN=${{ secrets.QC_GIT_TOKEN }}
shell: bash
run: |
# Add exception
git config --global --add safe.directory /__w/Lean/Lean
# Get Last Commit of the Current Tag
TAG_COMMIT=$(git rev-parse HEAD) && echo "CURRENT BRANCH LAST COMMIT $TAG_COMMIT"
# Get Last Commit of the master
MASTER_COMMIT=$(git rev-parse origin/master) && echo "MASTER BRANCH LAST COMMIT $MASTER_COMMIT"
# Build
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln && \
# Run Tests
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --blame-hang-timeout 300seconds --blame-crash --filter "TestCategory!=TravisExclude&TestCategory!=ResearchRegressionTests" -- TestRunParameters.Parameter\(name=\"log-handler\", value=\"ConsoleErrorLogHandler\"\) && \
# Generate & Publish python stubs
echo "GITHUB_REF $GITHUB_REF" && if [[ $GITHUB_REF = refs/tags/* && "$TAG_COMMIT" = "$MASTER_COMMIT" ]]; then echo "Generating stubs" && (chmod +x ci_build_stubs.sh && ./ci_build_stubs.sh -t -g -p); else echo "Skipping stub generation"; fi
echo "GITHUB_REF $GITHUB_REF" && if [[ $GITHUB_REF = refs/tags/* ]]; then (chmod +x ci_build_stubs.sh && ./ci_build_stubs.sh -t -g -p); else echo "Skipping stub generation"; fi

View File

@@ -1,32 +0,0 @@
name: Syntax Tests
on:
push:
branches: ['*']
tags: ['*']
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false
- name: Run Syntax Test
uses: addnab/docker-run-action@v3
with:
image: quantconnect/lean:foundation
options: --workdir /__w/Lean/Lean -v /home/runner/work:/__w
shell: bash
run: |
pip install --no-cache-dir quantconnect-stubs types-requests==2.32.* types-pytz==2025.2.0.* mypy==1.15.0 && \
python run_syntax_check.py

View File

@@ -30,11 +30,11 @@ jobs:
# Build
dotnet build /p:Configuration=Release /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln && \
# Python Virtual Environment System Packages
python -m venv /lean-testenv --system-site-packages && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.221 && deactivate && \
python -m venv /lean-testenv --system-site-packages && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.185 && deactivate && \
# Run Virtual Environment Test System Packages
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonVirtualEnvironmentTests.AssertVirtualEnvironment" && \
# Python Virtual Environment
rm -rf /lean-testenv && python -m venv /lean-testenv && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.221 && deactivate && \
rm -rf /lean-testenv && python -m venv /lean-testenv && . /lean-testenv/bin/activate && pip install --no-cache-dir lean==1.0.185 && deactivate && \
# Run Virtual Environment Test
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonVirtualEnvironmentTests.AssertVirtualEnvironment" && \
# Run Python Package Tests
@@ -46,21 +46,17 @@ jobs:
# Run TensorlyTest Python Package Test
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorlyTest" --blame-hang-timeout 120seconds --blame-crash && \
# Run NeuralTangents, Ignite Python Package Test
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.IgniteTest" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.NeuralTangentsTest|IgniteTest" --blame-hang-timeout 120seconds --blame-crash && \
# Run TensorflowTest
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorflowTest" --blame-hang-timeout 120seconds --blame-crash && \
# Run TensorflowProbability
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.TensorflowProbabilityTest" --blame-hang-timeout 120seconds --blame-crash && \
# Run Hvplot Python Package Test
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.RiskparityportfolioTest" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.HvplotTest" --blame-hang-timeout 120seconds --blame-crash && \
# Run Transformers
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Transformers" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.XTransformers" --blame-hang-timeout 120seconds --blame-crash && \
# Run Shap
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.KerasTest|PyvinecopulibTest" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.StatsForecast|Mlforecast" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.MlxtendTest|Thinc" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ModuleVersionTestExplicit" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Neuralforecast" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Tsfel" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ScikitOptimizeTest" --blame-hang-timeout 120seconds --blame-crash
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.ShapTest|KerasTest|PyvinecopulibTest" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.Mlforecast" --blame-hang-timeout 120seconds --blame-crash && \
dotnet test ./Tests/bin/Release/QuantConnect.Tests.dll --filter "FullyQualifiedName=QuantConnect.Tests.Python.PythonPackagesTests.MlxtendTest|Thinc" --blame-hang-timeout 120seconds --blame-crash

3
.gitignore vendored
View File

@@ -279,5 +279,4 @@ QuantConnect.Lean.sln.DotSettings*
Research/Notebooks
#Docker result files
Results/
QuantConnect.Lean.sln.DotSettings
Results/

View File

@@ -115,7 +115,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$26000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "119.89%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d06c26f557b83d8d42ac808fe2815a1e"}
};
}

View File

@@ -151,7 +151,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$120000000.00"},
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
{"Portfolio Turnover", "41.18%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "713c956deb193bed2290e9f379c0f9f9"}
};
}

View File

@@ -41,11 +41,9 @@ namespace QuantConnect.Algorithm.CSharp
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
_contract = OptionChain(aapl)
.OrderBy(symbol => symbol.ID.OptionRight)
.ThenBy(symbol => symbol.ID.StrikePrice)
.ThenBy(symbol => symbol.ID.Date)
.ThenBy(symbol => symbol.ID)
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call);
.OrderBy(x => x.ID.Symbol)
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
&& optionContract.ID.OptionStyle == OptionStyle.American);
AddOptionContract(_contract);
}
@@ -130,7 +128,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -125,7 +125,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -145,8 +145,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$87000.00"},
{"Lowest Capacity Asset", "BTCUSD 2XR"},
{"Portfolio Turnover", "2.22%"},
{"Drawdown Recovery", "139"},
{"OrderListHash", "9fce77ef8817cf0159897fc64d01f5e9"}
{"OrderListHash", "4fcffc45d82203bb6ded8a0e86070b4f"}
};
}
}

View File

@@ -145,7 +145,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$35000000.00"},
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
{"Portfolio Turnover", "1.51%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "1db1ce949db995bba20ed96ea5e2438a"}
};
}

View File

@@ -158,8 +158,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$5500000.00"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "66.80%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "39f1e15c27212d8fdd58aeb7fb2b93cc"}
{"OrderListHash", "579e2e83dd7e5e7648c47e9eff132460"}
};
}
}

View File

@@ -207,7 +207,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$22000000.00"},
{"Lowest Capacity Asset", "ES XFH59UK0MYO1"},
{"Portfolio Turnover", "122.11%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d744fa8beaa60546c84924ed68d945d9"}
};
}

View File

@@ -136,7 +136,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$2600000.00"},
{"Lowest Capacity Asset", "ES 31C3JQS9D84PW|ES XCZJLC9NOB29"},
{"Portfolio Turnover", "495.15%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "85257286f088992d599c1ad0799a6237"}
};
}

View File

@@ -1,145 +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.UniverseSelection;
using QuantConnect.Interfaces;
using QuantConnect.Securities;
using QuantConnect.Securities.Future;
using QuantConnect.Securities.Option;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Algorithm asserting AddFutureOptionContract does not throw even when the underlying security configurations are internal
/// </summary>
public class AddFutureOptionContractWithInternalMappedUnderlyingRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Future _continuousContract;
private Option _fopContract;
public override void Initialize()
{
SetStartDate(2020, 01, 04);
SetEndDate(2020, 01 , 06);
_continuousContract = AddFuture(Futures.Indices.SP500EMini,
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
dataMappingMode: DataMappingMode.LastTradingDay,
contractDepthOffset: 0);
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
if (changes.AddedSecurities.Any(security => security.Symbol == _continuousContract.Symbol))
{
if (SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_continuousContract.Mapped).Count != 0 ||
SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_continuousContract.Mapped, includeInternalConfigs: true).Count == 0)
{
throw new RegressionTestException("Continuous future underlying should only have internal subscription configs");
}
var contract = OptionChain(_continuousContract.Mapped).FirstOrDefault()?.Symbol;
try
{
_fopContract = AddFutureOptionContract(contract);
}
catch (Exception e)
{
throw new RegressionTestException($"Failed to add future option contract {contract}", e);
}
}
else if (_fopContract != null && changes.AddedSecurities.Any(security => security.Symbol == _fopContract.Symbol))
{
var underlyingSubscriptions = SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(_fopContract.Symbol.Underlying);
if (underlyingSubscriptions.Any(x => x.DataNormalizationMode == DataNormalizationMode.Raw))
{
throw new RegressionTestException("Future option underlying should not have raw data normalization mode");
}
}
}
public override void OnEndOfAlgorithm()
{
if (_fopContract == null)
{
throw new RegressionTestException("Failed to add future option contract");
}
}
/// <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 List<Language> Languages { get; } = new() { Language.CSharp };
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 3181;
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 1;
/// <summary>
/// Final status of the algorithm
/// </summary>
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
/// <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 Orders", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "-14.395"},
{"Tracking Error", "0.043"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}
}

View File

@@ -263,7 +263,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$760000.00"},
{"Lowest Capacity Asset", "ES XCZJLDQX2SRO|ES XCZJLC9NOB29"},
{"Portfolio Turnover", "32.31%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "7a04f66a30d793bf187c2695781ad3ee"}
};
}

View File

@@ -1,131 +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.Algorithm.Framework.Selection;
using QuantConnect.Interfaces;
using System;
using QuantConnect.Securities;
using QuantConnect.Data.UniverseSelection;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This example demonstrates how to use the FutureUniverseSelectionModel to select futures contracts for a given underlying asset.
/// The model is set to update daily, and the algorithm ensures that the selected contracts meet specific criteria.
/// This also includes a check to ensure that only future contracts are added to the algorithm's universe.
/// </summary>
public class AddFutureUniverseSelectionModelRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
public override void Initialize()
{
SetStartDate(2013, 10, 08);
SetEndDate(2013, 10, 10);
SetUniverseSelection(new FutureUniverseSelectionModel(
TimeSpan.FromDays(1),
time => new List<Symbol> {
QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME)
}
));
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
if (changes.AddedSecurities.Count > 0)
{
foreach (var security in changes.AddedSecurities)
{
if (security.Symbol.SecurityType != SecurityType.Future)
{
throw new RegressionTestException($"Expected future security, but found '{security.Symbol.SecurityType}'");
}
if (security.Symbol.ID.Symbol != "ES")
{
throw new RegressionTestException($"Expected future symbol 'ES', but found '{security.Symbol.ID.Symbol}");
}
}
}
}
public override void OnEndOfAlgorithm()
{
if (ActiveSecurities.Count == 0)
{
throw new RegressionTestException("No active securities found. Expected at least one active security");
}
}
/// <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 List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 26094;
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
/// <summary>
/// Final status of the algorithm
/// </summary>
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
/// <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 Orders", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "-66.775"},
{"Tracking Error", "0.243"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}
}

View File

@@ -160,8 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$5700000.00"},
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
{"Portfolio Turnover", "0.55%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "fc5ab25181a01ca5ce39212f60eb0ecd"}
{"OrderListHash", "24191a4a3bf11c07622a21266618193d"}
};
}
}

View File

@@ -212,8 +212,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$2800000.00"},
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
{"Portfolio Turnover", "1.14%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "90aa4bf345a6ba5ea2b0b14e32d1598f"}
{"OrderListHash", "cde7b518b7ad6d86cff6e5e092d9a413"}
};
}
}

View File

@@ -159,7 +159,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$5000000.00"},
{"Lowest Capacity Asset", "AAPL VXBK4R62CXGM|AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "22.70%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "29fd1b75f6db05dd823a6db7e8bd90a9"}
};
}

View File

@@ -1,146 +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.Algorithm.Framework.Selection;
using QuantConnect.Interfaces;
using System;
using QuantConnect.Data.UniverseSelection;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This example demonstrates how to use the OptionUniverseSelectionModel to select options contracts based on specified conditions.
/// The model is updated daily and selects different options based on the current date.
/// The algorithm ensures that only valid option contracts are selected for the universe.
/// </summary>
public class AddOptionUniverseSelectionModelRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private int _optionCount;
public override void Initialize()
{
SetStartDate(2014, 06, 05);
SetEndDate(2014, 06, 06);
UniverseSettings.Resolution = Resolution.Minute;
SetUniverseSelection(new OptionUniverseSelectionModel(
TimeSpan.FromDays(1),
SelectOptionChainSymbols
));
}
private static IEnumerable<Symbol> SelectOptionChainSymbols(DateTime utcTime)
{
var newYorkTime = utcTime.ConvertFromUtc(TimeZones.NewYork);
if (newYorkTime.Date < new DateTime(2014, 06, 06))
{
yield return QuantConnect.Symbol.Create("TWX", SecurityType.Option, Market.USA);
}
if (newYorkTime.Date >= new DateTime(2014, 06, 06))
{
yield return QuantConnect.Symbol.Create("AAPL", SecurityType.Option, Market.USA);
}
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
if (changes.AddedSecurities.Count > 0)
{
foreach (var security in changes.AddedSecurities)
{
var symbol = security.Symbol.Underlying == null ? security.Symbol : security.Symbol.Underlying;
if (symbol != "AAPL" && symbol != "TWX")
{
throw new RegressionTestException($"Unexpected security {security.Symbol}");
}
_optionCount += (security.Symbol.SecurityType == SecurityType.Option) ? 1 : 0;
}
}
}
public override void OnEndOfAlgorithm()
{
if (ActiveSecurities.Count == 0)
{
throw new RegressionTestException("No active securities found. Expected at least one active security");
}
if (_optionCount == 0)
{
throw new RegressionTestException("The option count should be greater than 0");
}
}
/// <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 List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 1658167;
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
/// <summary>
/// Final status of the algorithm
/// </summary>
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
/// <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 Orders", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "0"},
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}
}

View File

@@ -120,7 +120,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -248,8 +248,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$4000.00"},
{"Lowest Capacity Asset", "GOOCV 305RBQ2BZBZT2|GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "2.58%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "12037c87de17d6e62eadd99c70a0685e"}
{"OrderListHash", "09f766c470a8bcf4bb6862da52bf25a7"}
};
}
}

View File

@@ -59,7 +59,7 @@ namespace QuantConnect.Algorithm.CSharp
var ticket = MarketOrder("AIG", 1);
if (ticket.Status != OrderStatus.Invalid || aig.HasData || aig.Price != 0)
if (ticket.Status != OrderStatus.Invalid)
{
throw new RegressionTestException("Expected order to always be invalid because there is no data yet!");
}
@@ -126,7 +126,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$830000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "20.49%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "6ebe462373e2ecc22de8eb2fe114d704"}
};
}

View File

@@ -153,8 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$4700000.00"},
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
{"Portfolio Turnover", "29.88%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "f04b3521256c7d6740966bc3df34e7b1"}
{"OrderListHash", "6061ecfbb89eb365dff913410d279b7c"}
};
}
}

View File

@@ -105,7 +105,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$38000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "59.74%"},
{"Drawdown Recovery", "3"},
{"OrderListHash", "5d7657ec9954875eca633bed711085d3"}
};
}

View File

@@ -144,7 +144,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$6200000.00"},
{"Lowest Capacity Asset", "AAPL VXBK4QA5EM92|AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "90.27%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "a111609c2c64554268539b5798e5b31f"}
};
}

View File

@@ -124,7 +124,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$980000000.00"},
{"Lowest Capacity Asset", "FB V6OIPNZEM8V9"},
{"Portfolio Turnover", "25.56%"},
{"Drawdown Recovery", "1"},
{"OrderListHash", "5ee20c8556d706ab0a63ae41b6579c62"}
};
}

View File

@@ -135,7 +135,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$680000000.00"},
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "7.48%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "2c814c55e7d7c56482411c065b861b33"}
};
}

View File

@@ -199,7 +199,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$42000000.00"},
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "99.56%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "60f03c8c589a4f814dc4e8945df23207"}
};
}

View File

@@ -113,7 +113,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -281,7 +281,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$61000000000.00"},
{"Lowest Capacity Asset", "NB R735QTJ8XC9X"},
{"Portfolio Turnover", "3.62%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "0ea806c53bfa2bdca2504ba7155ef130"}
};
}

View File

@@ -119,7 +119,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$16000000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "0.02%"},
{"Drawdown Recovery", "50"},
{"OrderListHash", "685c37df6e4c49b75792c133be189094"}
};
}

View File

@@ -189,7 +189,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$200000000.00"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "351.80%"},
{"Drawdown Recovery", "1"},
{"OrderListHash", "dfd9a280d3c6470b305c03e0b72c234e"}
};
}

View File

@@ -120,7 +120,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -151,7 +151,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$56000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "19.93%"},
{"Drawdown Recovery", "3"},
{"OrderListHash", "3da9fa60bf95b9ed148b95e02e0cfc9e"}
};
}

View File

@@ -162,7 +162,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -1,156 +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;
using QuantConnect.Orders;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm asserting that in backtesting, orders are submitted in the same time step even when asynchronous
/// </summary>
public class BacktestingAsynchronousOrdersRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _symbol;
public override void Initialize()
{
SetStartDate(2013, 10, 07);
SetEndDate(2013, 10, 08);
SetCash(100000);
_symbol = AddEquity("SPY").Symbol;
}
public override void OnData(Slice slice)
{
if (!Portfolio.Invested)
{
var marketOrderTicket = MarketOrder(_symbol, 100, asynchronous: false);
AssertMarketOrderStatus(marketOrderTicket);
var asyncMarketOrderTicket = MarketOrder(_symbol, -100, asynchronous: true);
AssertMarketOrderStatus(asyncMarketOrderTicket);
var limitPrice = Securities[_symbol].Price * 0.95m;
var limitOrderTicket = LimitOrder(_symbol, 100, limitPrice, asynchronous: false);
AssertLimitOrderStatus(limitOrderTicket);
var asyncLimitOrderTicket = LimitOrder(_symbol, -100, limitPrice, asynchronous: true);
AssertLimitOrderStatus(asyncLimitOrderTicket);
}
}
private static void AssertMarketOrderStatus(OrderTicket ticket)
{
// In backtesting the order should be submitted and filled right away.
// Note that OrderSet event will not be fired if there is an error when processing the order submission,
// but this is a happy case
if (!ticket.OrderSet.WaitOne(0))
{
throw new RegressionTestException("Order was not submitted immediately in backtesting mode");
}
if (!ticket.OrderClosed.WaitOne(0))
{
throw new RegressionTestException("Order was not filled immediately in backtesting mode");
}
if (ticket.Status != OrderStatus.Filled)
{
throw new RegressionTestException($"Order status is not filled: {ticket.Status}");
}
}
private static void AssertLimitOrderStatus(OrderTicket ticket)
{
// In backtesting the order should be submitted right away but not filled since price hasn't moved even when asynchronous
// Note that OrderSet event will not be fired if there is an error when processing the order submission,
// but this is a happy case
if (!ticket.OrderSet.WaitOne(0))
{
throw new RegressionTestException("Asynchronous limit order was not submitted immediately in backtesting mode");
}
if (ticket.OrderClosed.WaitOne(0))
{
throw new RegressionTestException("Asynchronous limit order was filled immediately in backtesting mode when it shouldn't");
}
if (ticket.Status != OrderStatus.Submitted)
{
throw new RegressionTestException($"Order status is not submitted: {ticket.Status}");
}
}
/// <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 List<Language> Languages { get; } = new() { Language.CSharp };
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 1582;
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
/// <summary>
/// Final status of the algorithm
/// </summary>
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
/// <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 Orders", "4"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100168.20"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "0"},
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$3.00"},
{"Estimated Strategy Capacity", "$22000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "21.72%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "65f010e904a929e5383f0920a3c5b797"}
};
}
}

View File

@@ -339,8 +339,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "17.02%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "a7ce5ff2bbe0fe273cf1631ea5a73fa6"}
{"OrderListHash", "b1e5e72fb766ab894204bc4b1300912b"}
};
}
}

View File

@@ -115,7 +115,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "€85000.00"},
{"Lowest Capacity Asset", "BTCEUR 2XR"},
{"Portfolio Turnover", "107.64%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "6819dc936b86af6e4b89b6017b7d5284"}
};
}

View File

@@ -85,7 +85,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "€85000.00"},
{"Lowest Capacity Asset", "BTCEUR 2XR"},
{"Portfolio Turnover", "107.64%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "3d450fd418a0e845b3eaaac17fcd13fc"}
};
}

View File

@@ -118,7 +118,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$56000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "19.93%"},
{"Drawdown Recovery", "3"},
{"OrderListHash", "3da9fa60bf95b9ed148b95e02e0cfc9e"}
};
}

View File

@@ -112,7 +112,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$150000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "4.98%"},
{"Drawdown Recovery", "3"},
{"OrderListHash", "8774049eb5141a2b6956d9432426f837"}
};
}

View File

@@ -160,8 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$7100000.00"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "2.33%"},
{"Drawdown Recovery", "37"},
{"OrderListHash", "223735440010fcec5889bb7becacfa82"}
{"OrderListHash", "04670183a0a4c9160167415aa5102499"}
};
}
}

View File

@@ -166,8 +166,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$890000000.00"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "2.32%"},
{"Drawdown Recovery", "34"},
{"OrderListHash", "1504a8892da8d8c0650018732f315753"}
{"OrderListHash", "f60fc7dcba2c1ff077afeb191aee5008"}
};
}
}

View File

@@ -240,7 +240,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "BTCEUR 2XR"},
{"Portfolio Turnover", "118.08%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "26b9a07ace86b6a0e0eb2ff8c168cee0"}
};
}

View File

@@ -276,7 +276,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$500000000.00"},
{"Lowest Capacity Asset", "ADAUSDT 18R"},
{"Portfolio Turnover", "0.16%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "dcc4f964b5549c753123848c32eaee41"}
};
}

View File

@@ -239,7 +239,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$370000000.00"},
{"Lowest Capacity Asset", "ADAUSDT 18R"},
{"Portfolio Turnover", "0.12%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "50a51d06d03a5355248a6bccef1ca521"}
};
}

View File

@@ -109,7 +109,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$1200000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "10.01%"},
{"Drawdown Recovery", "1"},
{"OrderListHash", "70f21e930175a2ec9d465b21edc1b6d9"}
};
}

View File

@@ -233,7 +233,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "€2300000000.00"},
{"Lowest Capacity Asset", "FESX YJHOAMPYKRS5"},
{"Portfolio Turnover", "0.40%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "ac9acc478ba1afe53993cdbb92f8ec6e"}
};
}

View File

@@ -130,7 +130,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$27000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "59.86%"},
{"Drawdown Recovery", "3"},
{"OrderListHash", "f209ed42701b0419858e0100595b40c0"}
};
}

View File

@@ -219,8 +219,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "0.13%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "a6ccce3a1a7f549f887d83e84bfa878d"}
{"OrderListHash", "7c8700a9baa24f6f76d866e7d88cc19c"}
};
}
}

View File

@@ -192,7 +192,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$14000.00"},
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
{"Portfolio Turnover", "9912.69%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "6e0f767a46a54365287801295cf7bb75"}
};
}

View File

@@ -170,8 +170,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
{"Portfolio Turnover", "0.92%"},
{"Drawdown Recovery", "69"},
{"OrderListHash", "ddaa9dd20647fdbc4811d6e64bb30a40"}
{"OrderListHash", "c0713abdc4fb059c2be797fce36e4f36"}
};
}
}

View File

@@ -179,7 +179,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$17000000.00"},
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
{"Portfolio Turnover", "43.23%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "c0fc1bcdc3008a8d263521bbc9d7cdbd"}
};
}

View File

@@ -74,7 +74,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$52000000.00"},
{"Lowest Capacity Asset", "GC VL5E74HP3EE5"},
{"Portfolio Turnover", "43.77%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "dcdaafcefa47465962ace2759ed99c91"}
};
}

View File

@@ -183,7 +183,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -90,7 +90,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -69,8 +69,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$8000.00"},
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
{"Portfolio Turnover", "20.14%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "f6482c8757f82cb9f4c058e3ed6bc494"}
{"OrderListHash", "dedcc487d64e2f601990fc70393c89ed"}
};
}
}

View File

@@ -192,7 +192,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$130000.00"},
{"Lowest Capacity Asset", "GC VOFJUCDY9XNH"},
{"Portfolio Turnover", "32523.20%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "0664a72652a19956ea3c4915269cc4b9"}
};
}

View File

@@ -69,8 +69,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
{"Portfolio Turnover", "0.87%"},
{"Drawdown Recovery", "69"},
{"OrderListHash", "741a26424d2210171ad849d92fc75d23"}
{"OrderListHash", "8b8b733248a21fc717079be54b2e844c"}
};
}
}

View File

@@ -74,8 +74,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$3000.00"},
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
{"Portfolio Turnover", "56.73%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "6ce7812de5c98744cc35169a86a24325"}
{"OrderListHash", "424536177e9be5895bab50638ef43a9d"}
};
}
}

View File

@@ -118,8 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$110000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "19.96%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "60747dce5c2aed393b7dccc258d2c9b5"}
{"OrderListHash", "966f8355817adbc8c724d1062691a60b"}
};
}
}

View File

@@ -170,7 +170,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$3000.00"},
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
{"Portfolio Turnover", "23.97%"},
{"Drawdown Recovery", "9"},
{"OrderListHash", "51f1bc2ea080df79748dc66c2520b782"}
};
}

View File

@@ -149,7 +149,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
{"Portfolio Turnover", "2.42%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "61e8517ac3da6bed414ef23d26736fef"}
};
}

View File

@@ -66,8 +66,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$300000.00"},
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
{"Portfolio Turnover", "24.63%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "5595ab834c2584c1d124ad575e88cc1a"}
{"OrderListHash", "44325fc1fdebb8e54f64a3f6e8a4bcd7"}
};
}
}

View File

@@ -110,8 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "SPX XL80P59H5E6M|SPX 31"},
{"Portfolio Turnover", "0.00%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "8340619d603921c1ce261287890b9c1c"}
{"OrderListHash", "285cec32c0947f0e8cf90ccb672cfa43"}
};
}
}

View File

@@ -81,8 +81,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "SPX XL80P59H5E6M|SPX 31"},
{"Portfolio Turnover", "0.00%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "1c5f424cfe62777733ee68a20320bb8d"}
{"OrderListHash", "75e6584cb26058b09720c3a828b9fbda"}
};
}
}

View File

@@ -128,8 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₹61000000000.00"},
{"Lowest Capacity Asset", "YESBANK UL"},
{"Portfolio Turnover", "0.00%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "06f782c83dd633dac6f228b91273ba26"}
{"OrderListHash", "7a0257f08e3bb9143b825e07ab47fea0"}
};
}
}

View File

@@ -152,8 +152,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₹84000.00"},
{"Lowest Capacity Asset", "JUNIORBEES UL"},
{"Portfolio Turnover", "0.04%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "8790bec8175539e6d92e01608ac57733"}
{"OrderListHash", "79ab9ec506959c562be8b3cdbb174c39"}
};
}
}

View File

@@ -145,7 +145,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$69000.00"},
{"Lowest Capacity Asset", "GOOCV W78ZERHAOVVQ|GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "61.31%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "35d406df401e5b27244e20f5ec57346e"}
};
}

View File

@@ -155,7 +155,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$4000.00"},
{"Lowest Capacity Asset", "GOOCV W78ZFMEBBB2E|GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "338.60%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "301c15063f6e269023d144ca69a765da"}
};
}

View File

@@ -152,7 +152,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$1300000.00"},
{"Lowest Capacity Asset", "GOOCV 30AKMEIPOSS1Y|GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "10.71%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "8a36462ee0349c04d01d464e592dd347"}
};
}

View File

@@ -145,7 +145,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

View File

@@ -165,8 +165,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$72000.00"},
{"Lowest Capacity Asset", "AAPL W78ZEO2985GM|AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "0.02%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "5e20fad3461ac9998afe8d76ad43b25c"}
{"OrderListHash", "b3125e0af79da0f5eea4cfda09806324"}
};
}
}

View File

@@ -142,8 +142,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
{"Portfolio Turnover", "15.08%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "f68f6d64a5721ee148bc3c643f8d1b7f"}
{"OrderListHash", "db6a1134ad325bce31c2bdd2e87ff5f4"}
};
}
}

View File

@@ -182,8 +182,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "13.50%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "d40c84371facba5dac8a2c919ea75807"}
{"OrderListHash", "cf14a7ce9c86e6844051820fd4c9394c"}
};
}
}

View File

@@ -152,7 +152,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$1000.00"},
{"Lowest Capacity Asset", "AAPL 2ZTXYMUAHCIAU|AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "2.28%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "7804b3dcf20d3096a2265a289fa81cd3"}
};
}

View File

@@ -146,8 +146,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$580000.00"},
{"Lowest Capacity Asset", "SPXW 31K54PVWHUJHQ|SPX 31"},
{"Portfolio Turnover", "0.40%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "db5e3681c5fa1888262f2370a9b14c11"}
{"OrderListHash", "07a085baedb37bb7c8d460558ea77e88"}
};
}
}

View File

@@ -152,8 +152,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$13000000.00"},
{"Lowest Capacity Asset", "SPXW XKX6S2GM9PGU|SPX 31"},
{"Portfolio Turnover", "0.28%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "17764ae9e216d003b1f3ce68d15b68ef"}
{"OrderListHash", "c1a9bc141ae25c9542b93a887e79dafe"}
};
}
}

View File

@@ -89,7 +89,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$3000.00"},
{"Lowest Capacity Asset", "SPX XL80P3GHDZXQ|SPX 31"},
{"Portfolio Turnover", "24.03%"},
{"Drawdown Recovery", "9"},
{"OrderListHash", "fcd6fddb0a315e21095c2b35eb633e2b"}
};
}

View File

@@ -84,7 +84,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₮220000.00"},
{"Lowest Capacity Asset", "BTCUSDT 18N"},
{"Portfolio Turnover", "22.80%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "80711e4c1e3c0da20152da8fafc3fd66"}
};
}

View File

@@ -84,7 +84,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₮12000000.00"},
{"Lowest Capacity Asset", "BTCUSDT 18N"},
{"Portfolio Turnover", "22.80%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "80711e4c1e3c0da20152da8fafc3fd66"}
};
}

View File

@@ -83,7 +83,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$2000.00"},
{"Lowest Capacity Asset", "BTCUSD E3"},
{"Portfolio Turnover", "0.28%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "899ef4e299a6cc73c1bd96fb9993db0e"}
};
}

View File

@@ -83,7 +83,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$640000.00"},
{"Lowest Capacity Asset", "BTCUSD E3"},
{"Portfolio Turnover", "0.28%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "899ef4e299a6cc73c1bd96fb9993db0e"}
};
}

View File

@@ -119,7 +119,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$2600000.00"},
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
{"Portfolio Turnover", "69.06%"},
{"Drawdown Recovery", "2"},
{"OrderListHash", "44a85134cd1c91c9720549bc0e007f80"}
};
}

View File

@@ -264,7 +264,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$200000000.00"},
{"Lowest Capacity Asset", "BTCUSDT 2V3"},
{"Portfolio Turnover", "1.08%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "0157a5c7c2c8a8c13e984b72721aa0ca"}
};
}

View File

@@ -154,7 +154,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "117171.12"},
{"End Equity", "117244.52"},
{"End Equity", "117244.50"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
@@ -173,8 +173,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₮560000.00"},
{"Lowest Capacity Asset", "BTCUSDT 2UZ"},
{"Portfolio Turnover", "44.04%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "47580e88a8cc54b04f3b2bcb5d501150"}
{"OrderListHash", "7426da82dca9e493acbc53c7b9f449f0"}
};
}
}

View File

@@ -185,7 +185,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "₮0"},
{"Lowest Capacity Asset", "BTCUSDT.CustomCryptoData 2US"},
{"Portfolio Turnover", "34.30%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "52ddb7dfcaaf1ea4f70cc614c49f0cd0"}
};
}

View File

@@ -117,7 +117,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$130000000.00"},
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
{"Portfolio Turnover", "37.56%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "e9e8a07dc58bff7198181f9fafb58834"}
};
}

View File

@@ -168,7 +168,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$370000.00"},
{"Lowest Capacity Asset", "ETHUSD 2XR"},
{"Portfolio Turnover", "104.59%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "5277847166fcd10cde634e3986e1d285"}
};
}

View File

@@ -116,7 +116,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "€670000.00"},
{"Lowest Capacity Asset", "DE30EUR 8I"},
{"Portfolio Turnover", "1062.25%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d5d15485c8fc6d412e5e73d40d9afd60"}
};
}

View File

@@ -158,7 +158,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$2500000000.00"},
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
{"Portfolio Turnover", "7.91%"},
{"Drawdown Recovery", "105"},
{"OrderListHash", "2668157409450ab9949a71716a5dbc2e"}
};
}

View File

@@ -1,52 +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.Data.Consolidators;
using QuantConnect.Data.Market;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This algorithm tests the Classic Renko Consolidator with future and default tick data.
/// If consolidation does not happen, a RegressionTestException is thrown
/// </summary>
public class ClassicRenkoConsolidatorWithFuturesAndDefaultTickTypeRegressionAlgorithm : ClassicRenkoConsolidatorWithFuturesTickTypesRegressionAlgorithm
{
protected override ClassicRenkoConsolidator GetConsolidator()
{
Func<IBaseData, decimal> selector = data =>
{
var tick = data as Tick;
if (tick.TickType != TickType.Quote)
{
throw new RegressionTestException("The tick type should be quote");
}
WasSelectorExecuted = true;
return tick.AskPrice * 10;
};
var consolidator = new ClassicRenkoConsolidator(BucketSize, selector);
return consolidator;
}
public override void AddConsolidator(ClassicRenkoConsolidator consolidator)
{
SubscriptionManager.AddConsolidator(GoldFuture.Mapped, consolidator);
}
}
}

View File

@@ -1,67 +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.Data.Consolidators;
using QuantConnect.Data.Market;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This algorithm tests the Classic Renko Consolidator with future quote tick data.
/// It checks if valid quote data (non-zero Bid/Ask prices) is received during the algorithm's execution.
/// If consolidation does not happen, a RegressionTestException is thrown
/// </summary>
public class ClassicRenkoConsolidatorWithFuturesQuoteTickTypeRegressionAlgorithm : ClassicRenkoConsolidatorWithFuturesTickTypesRegressionAlgorithm
{
private bool _hasNonZeroBidPrice;
private bool _hasNonZeroAskPrice;
protected override TickType TickType => TickType.Quote;
protected override ClassicRenkoConsolidator GetConsolidator()
{
Func<IBaseData, decimal> selector = data =>
{
var tick = data as Tick;
_hasNonZeroBidPrice |= tick.BidPrice != 0;
_hasNonZeroAskPrice |= tick.AskPrice != 0;
if (tick.TickType != TickType)
{
throw new RegressionTestException("The tick type should be quote");
}
WasSelectorExecuted = true;
return tick.AskPrice * 10;
};
var consolidator = new ClassicRenkoConsolidator(BucketSize, selector);
return consolidator;
}
public override void AddConsolidator(ClassicRenkoConsolidator consolidator)
{
SubscriptionManager.AddConsolidator(GoldFuture.Mapped, consolidator, TickType);
}
public override void OnEndOfAlgorithm()
{
if (!_hasNonZeroBidPrice || !_hasNonZeroAskPrice)
{
throw new RegressionTestException("No valid Quote tick data found: fields (Bid/Ask) were zero.");
}
base.OnEndOfAlgorithm();
}
}
}

View File

@@ -1,159 +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.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Interfaces;
using QuantConnect.Securities.Future;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This algorithm tests the functionality of the Classic Renko Consolidator with future trade tick data.
/// It checks if data consolidation occurs as expected for the given time period. If consolidation does not happen, a RegressionTestException is thrown.
/// </summary>
public class ClassicRenkoConsolidatorWithFuturesTickTypesRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Dictionary<Symbol, ClassicRenkoConsolidator> _consolidators = new Dictionary<Symbol, ClassicRenkoConsolidator>();
private bool _itWasConsolidated;
protected Future GoldFuture { get; set; }
protected virtual TickType TickType => TickType.Trade;
protected decimal BucketSize { get; set; }
protected bool WasSelectorExecuted { get; set; }
public override void Initialize()
{
SetStartDate(2013, 10, 7);
SetEndDate(2013, 10, 9);
GoldFuture = AddFuture("GC", Resolution.Tick, Market.COMEX);
GoldFuture.SetFilter(0, 180);
BucketSize = 2000m;
}
private void OnConsolidated(object sender, TradeBar bar)
{
_itWasConsolidated = true;
}
public override void OnData(Slice slice)
{
if (!_consolidators.ContainsKey(GoldFuture.Mapped))
{
var consolidator = GetConsolidator();
consolidator.DataConsolidated += OnConsolidated;
AddConsolidator(consolidator);
_consolidators[GoldFuture.Mapped] = consolidator;
}
}
public virtual void AddConsolidator(ClassicRenkoConsolidator consolidator)
{
SubscriptionManager.AddConsolidator(GoldFuture.Mapped, consolidator, TickType);
}
protected virtual ClassicRenkoConsolidator GetConsolidator()
{
Func<IBaseData, decimal> selector = data =>
{
var tick = data as Tick;
if (tick.TickType != TickType)
{
throw new RegressionTestException("The tick type should be trade");
}
WasSelectorExecuted = true;
return tick.Quantity * tick.Price;
};
var consolidator = new ClassicRenkoConsolidator(BucketSize, selector);
return consolidator;
}
public override void OnEndOfAlgorithm()
{
if (!_itWasConsolidated)
{
throw new RegressionTestException("ClassicRenko did not consolidate any data.");
}
if (!WasSelectorExecuted)
{
throw new RegressionTestException("The selector was not executed");
}
}
/// <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 List<Language> Languages { get; } = new() { Language.CSharp };
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 1082920;
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
/// <summary>
/// Final status of the algorithm
/// </summary>
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
/// <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 Orders", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "5.524"},
{"Tracking Error", "0.136"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}
}

View File

@@ -202,7 +202,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$81000000.00"},
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
{"Portfolio Turnover", "6.65%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "4eaacdd341a5be0d04cb32647d931471"}
};
}

View File

@@ -205,7 +205,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$5000000.00"},
{"Lowest Capacity Asset", "AOL R735QTJ8XC9X"},
{"Portfolio Turnover", "17.64%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "a8605c1f5a9c67f60f1ddc963ec45542"}
};
}

View File

@@ -154,7 +154,6 @@ namespace QuantConnect.Algorithm.CSharp
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", ""},
{"Portfolio Turnover", "0%"},
{"Drawdown Recovery", "0"},
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
};
}

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