Skip to content

Crypto algorithm error - No conversion rate for the following cash #5751

@dominiclapointe

Description

@dominiclapointe

Hi all,

I am quite new to lean.io and trying to get started with a minimal setup to trade crypto. This simple code keep throwing the below error. Even the BasicTemplateCryptoAlgorithm does throw the same error.

I did validate and the data seems to exists if looking here : https://www.quantconnect.com/data/tree/crypto/bitfinex/minute/btcusdt

Is that error normal or some error got introduced in the AddCrypto at some point?

Thank you

Expected Behavior

Get the market data for BTCUSDT in algo using AddCrypto("BTCUSDT", Resolution.Minute);

Actual Behavior

ERROR:: Failed to assign conversion rates for the following cash: USDT,BTC. Attempting to request daily resolution history to resolve conversion rate

Potential Solution

Reproducing the Problem

public override void Initialize()
        {
            SetStartDate(2020, 10, 07);  //Set Start Date
            SetEndDate(2020, 10, 08);    //Set End Date
            SetCash("USDT", 1000);           //Set Strategy Cash

            SetBrokerageModel(Brokerages.BrokerageName.Bitfinex, AccountType.Cash);
            AddCrypto("BTCUSDT", Resolution.Minute);      
        }

        /// <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)
        {
            var rsi = RSI("BTCUSDT", 14, Indicators.MovingAverageType.Simple);

            if (rsi <= 35)
            {
                MarketOrder("BTCUSDT", 0.0001);
            }
            else
            {
                if (Portfolio.Invested == true && Portfolio.CashBook["BTCUSDT"].Amount > 0)
                {
                    MarketOrder("BTCUSDT", -0.0001);
                }
            }
        }

System Information

Lean master branch running on windows 10 and VS 2022 preview 1

Checklist

  • [x ] I have completely filled out this template
  • [x ] I have confirmed that this issue exists on the current master branch
  • [x ] I have confirmed that this is not a duplicate issue by searching issues
  • [x ] I have provided detailed steps to reproduce the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions