We stumbled upon impossible to subscribe on data provider live and historical in the same time.
The code is subscribed on data-provider-live well.
Result
Nowadays, we can use 2 command in the same time without exception. The fix is downloaded packages and create dependency references. Additionaly we have opportunity to combine our live and historical providers in different way, look at example bellow ⬇ we use live provider iexcloud.io and historicalpolygon.io
--data-provider-live IEX - iexcloud.io data provider
--data-provider-historical Polygon - polygon.io data provider
If --data-provider-live doesn't have historical oportunity
For istance:
lean live deploy --brokerage Bybit --data-provider-live Bybit ProjectAlgorithmName
The Bybit doesn't have historical option like provider that's mean it will use Local provider by default:
Like this
lean live deploy --brokerage Bybit --data-provider-live Bybit --data-provider-historical Local ProjectAlgorithmName
Feature (user friendly)
If user subscribe on --data-provider-livewithout--data-provider-historical then the code is using the smae data-provider-historical like liveif it is exsist.
For instance:
lean live deploy --brokerage "Paper Trading" --data-provider-live IEX ProjectAlgorithmName
The --data-provider-historical IEX uses this part implicitly for users.
public class IEXAlgo : QCAlgorithm
{
public override void Initialize()
{
SetStartDate(2024, 1, 1); // Set Start Date
SetEndDate(2024, 2, 1); // Set Start Date
SetCash(100_000); //Set Strategy Cash
var plug = AddEquity("AAPL", Resolution.Daily, extendedMarketHours: false);
Log("---------- BEFORE HISTORY ----------");
var histories = History(plug.Symbol, 10, Resolution.Daily);
foreach(var history in histories)
{
Log($"Time: {history.Time}, Data History: {history}");
}
Log("---------- AFTER HISTORY ----------");
}
public override void OnData(Slice slice)
{
if (slice == null) return;
Log($"Time: {slice.Time}");
Log($"data.Bars: {string.Join(",", slice.Bars)}");
Log($"data.QuoteBars: {string.Join(",", slice.QuoteBars)}");
}
}
Description
We stumbled upon impossible to subscribe on data provider live and historical in the same time.
Result
Nowadays, we can use 2 command in the same time without exception. The fix is downloaded packages and create dependency references. Additionaly we have opportunity to combine our
live
andhistorical
providers in different way, look at example bellow ⬇ we uselive
provider iexcloud.io andhistorical
polygon.io--data-provider-live IEX
- iexcloud.io data provider--data-provider-historical Polygon
- polygon.io data providerIf
--data-provider-live
doesn't have historical oportunityFor istance:
The Bybit doesn't have historical option like provider that's mean it will use
Local
provider by default:Like this
Feature (user friendly)
If user subscribe on
--data-provider-live
without--data-provider-historical
then the code is using the smaedata-provider-historical
likelive
if it is exsist.For instance:
Testing
Test Algorithm:
First command:
lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Polygon Project
First Result img:
Second command:
lean live deploy --brokerage "Paper Trading" --data-provider-live IEX Project
Second Result img:
Third command:
lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Local IEXAlgo
Third Result img:
Fourth command:
lean live deploy --brokerage "Coinbase Advanced Trade" --data-provider-live "Coinbase Advanced Trade" CoinApiAlgo
Fourth img:
Fifth command:
If don't have key in our
config.json
lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Polygon IEXAlgo
Fifth img: