Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Downloader Data Provider #423

Closed

Conversation

Romazes
Copy link
Contributor

@Romazes Romazes commented Feb 16, 2024

Description

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 historical polygon.io

 lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Polygon ProjectAlgorithmName
  • --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-live without --data-provider-historical then the code is using the smae data-provider-historical like live if 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.

 lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical IEX ProjectAlgorithmName

Testing

Test Algorithm:

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

First command:

  • lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Polygon Project

First Result img:

111

Second command:

  • lean live deploy --brokerage "Paper Trading" --data-provider-live IEX Project

Second Result img:

111

Third command:

  • lean live deploy --brokerage "Paper Trading" --data-provider-live IEX --data-provider-historical Local IEXAlgo

Third Result img:

image

Fourth command:

  • lean live deploy --brokerage "Coinbase Advanced Trade" --data-provider-live "Coinbase Advanced Trade" CoinApiAlgo

Fourth img:

image
image

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:

image

Romazes and others added 30 commits February 16, 2024 23:59
* feat: add new config of CoinApi

* feat: CoinApi configs for backtest/research/optimize
refactor: assertion in test with different version of py
refactor: assertion in test with different version of py
@Romazes Romazes closed this Feb 20, 2024
@Romazes Romazes deleted the fix-configure-data-provider-in-live branch February 20, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant