-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds QuantBook Support/Example (#22)
* Adds QuantBook Support/Example * Fixes GitHub CI Space
- Loading branch information
1 parent
8c138b4
commit 37b7611
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
# CLRImports is required to handle Lean C# objects for Mapped Datasets (Single asset and Universe Selection) | ||
# Requirements: | ||
# python -m pip install clr-loader==0.1.7 | ||
# python -m pip install pythonnet==3.0.0a2 | ||
# This script must be executed in ./bin/Debug/net6.0 after the follwing command is executed | ||
# dotnet build .\DataProcessing\ | ||
import os | ||
from CLRImports import * | ||
|
||
# To use QuantBook, we need to set its internal handlers | ||
# We download LEAN confif with the default settings | ||
with open("quantbook.json", 'w') as fp: | ||
from requests import get | ||
response = get("https://raw.githubusercontent.com/QuantConnect/Lean/master/Launcher/config.json") | ||
fp.write(response.text) | ||
|
||
Config.SetConfigurationFile("quantbook.json") | ||
Config.Set("composer-dll-directory", os.path.dirname(os.path.realpath(__file__))) | ||
|
||
# Set the data folder | ||
Config.Set("data-folder", '<path-to-data-folder>') | ||
|
||
# To generate the Security Identifier, we need to create and initialize the Map File Provider | ||
# and call the SecurityIdentifier.GenerateEquity method | ||
mapFileProvider = LocalZipMapFileProvider() | ||
mapFileProvider.Initialize(DefaultDataProvider()) | ||
sid = SecurityIdentifier.GenerateEquity("BAC", Market.USA, True, mapFileProvider, datetime(2022, 3, 1)) | ||
sid = SecurityIdentifier.GenerateEquity("SPY", Market.USA, True, mapFileProvider, datetime(2022, 3, 1)) | ||
|
||
qb = QuantBook() | ||
symbol = Symbol(sid, "SPY") | ||
history = qb.History(symbol, 3600, Resolution.Daily) | ||
print(history) |