Hello, My Live Algorithm was running fine on a live node and I have been running it on and off for a couple of months now. I stopped the algo and restarted it without changing any code and I have been getting a runtime error:
During the algorithm initialization, the following exception has occurred: Error getting cash balance from brokerage: An item with the same key has already been added. Key: XXBTAn item with the same key has already been added. Key: XXBT in BrokerageSetupHandler.cs:line 364 An item with the same key has already been added. Key: XXBT: StackTrace: An item with the same key has already been added. Key: XXBT in BrokerageSetupHandler.cs:line 364 An item with the same key has already been added. Key: XXBT
I am not adding any securities called XXBT. I am only adding BTCUSD. Did anyone get this error?
Tried redeploying several times but still same issue
#region imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Drawing;
using QuantConnect;
using QuantConnect.Algorithm.Framework;
using QuantConnect.Algorithm.Framework.Selection;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Execution;
using QuantConnect.Algorithm.Framework.Risk;
using QuantConnect.Parameters;
using QuantConnect.Benchmarks;
using QuantConnect.Brokerages;
using QuantConnect.Util;
using QuantConnect.Interfaces;
using QuantConnect.Algorithm;
using QuantConnect.Indicators;
using QuantConnect.Data;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Custom;
using QuantConnect.DataSource;
using QuantConnect.Data.Fundamental;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Notifications;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
using QuantConnect.Orders.Fills;
using QuantConnect.Orders.Slippage;
using QuantConnect.Scheduling;
using QuantConnect.Securities;
using QuantConnect.Securities.Equity;
using QuantConnect.Securities.Future;
using QuantConnect.Securities.Option;
using QuantConnect.Securities.Forex;
using QuantConnect.Securities.Crypto;
using QuantConnect.Securities.Interfaces;
using QuantConnect.Storage;
using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm;
using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm;
#endregion
namespace QuantConnect.Algorithm.CSharp
{
public class AlertTanParrot : QCAlgorithm
{
public override void Initialize()
{
SetAccountCurrency("USD");
DefaultOrderProperties = new KrakenOrderProperties
{
TimeInForce = TimeInForce.GoodTilCanceled,
PostOnly = false,
FeeInBase = false,
FeeInQuote = true,
NoMarketPriceProtection = true
};
// EnableAutomaticIndicatorWarmUp = true;
try{
SetBrokerageModel(BrokerageName.Kraken, AccountType.Margin);
}
catch(Exception x)
{
Log("Exception During Setbrokerage Model "+ x.Message);
}
var a = AddCrypto("BTCUSD", Resolution.Minute, Market.Kraken );
Securities["BTCUSD"].FeeModel = new KrakenFeeModel();
SetCash(100000); //Set Strategy Cash
var startime = new DateTime(2023,01,01);
SetStartDate(startime);
SetEndDate(2022,11,8);
SetEndDate(startime.AddDays(5)); // Set end date to last week
Portfolio.MarginCallModel = MarginCallModel.Null;
SetCash(100000);
SetStartDate(2022, 8, 11);
SetCash(100000);
}
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// Slice object keyed by symbol containing the stock data
public override void OnData(Slice data)
{
if (!Portfolio.Invested)
{
// SetHoldings("SPY", 0.33);
// SetHoldings("BND", 0.33);
.// SetHoldings("AAPL", 0.33);
}
}
}
}
Alexandre Catarino
Hi Ahmed Elmiligui ,
This issue has been fixed by the following pull request:
Removes Mapping to Inexistent XBT #38
For live trading issues, please contact support@quantconnect.com.
Ahmed Elmiligui
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!