Crypto Momentum algo

Back

Does anyone know why the algo is throwing this error?

I have modified and cloned the algo from another thread where Daniel Chen, staff wrote this:

"Thank you for your question, and sorry for the late reply. To implement your idea, we recommend you use ManualUniverseSelectionModel here. First, from crypto data library, we can find all pairs containing *BTC among all 346 Cryptocurrency Pairs in Bitfinex. Then, for each pair, we create Symbol object using Symbol.Create(symbol, SecurityType.Crypto, Market.Bitfinex) and add all Symbols to a List. Finally, we use self.SetUniverseSelection(ManualUniverseSelectionModel(Symbols)) to manually add them to Universe.

Currently, there is an issue when adding Crypto pairs (see GitHub issue here). Please note that for some crypto pairs (e.g. FUNBTC) we should add a subscription for the corresponding Forex pair (e.g. FUNUSD) since we need to maintain cash in the crypto (e.g. FUN). Therefore, when creating Symbol objects for crypto pairs, we do self.AddForex() as well. Please see the following backtest for details, thank you!"

Source: 

https://www.quantconnect.com/forum/discussion/6171/dynamic-crypto-universe-portfolio/p1

It started to throw errors once i added this line:

self.SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Margin)

I added that line of code because before the compiler where telling me that it could not take short positions. It was also complaining that i did not have any of the cryptos it where trying to trade in my portfolio.

Update Backtest








 
0

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.


During the algorithm initialization, the following exception has occurred: ArgumentException : Invalid security type: Forex
Parameter name: security
at QuantConnect.Brokerages.BitfinexBrokerageModel.GetLeverage (QuantConnect.Securities.Security security) [0x00049] in :0
at QuantConnect.Securities.BrokerageModelSecurityInitializer.Initialize (QuantConnect.Securities.Security security) [0x00000] in :0
at QuantConnect.Securities.SecurityService.CreateSecurity (QuantConnect.Symbol symbol, System.Collections.Generic.List`1[T] subscriptionDataConfigList, System.Decimal leverage, System.Boolean addToSymbolCache) [0x0032d] in :0
at QuantConnect.Securities.SecurityManager.CreateSecurity (QuantConnect.Symbol symbol, System.Collections.Generic.List`1[T] subscriptionDataConfigList, System.Decimal leverage, System.Boolean addToSymbolCache) [0x00000] in :0
at QuantConnect.Algorithm.QCAlgorithm.AddSecurity[T] (QuantConnect.SecurityType securityType, System.String ticker, System.Nullable`1[T] resolution, System.String market, System.Boolean fillDataForward, System.Decimal leverage, System.Boolean extendedMarketHours) [0x000a6] in <5e5418119b824022a87c190195092daa>:0
at QuantConnect.Algorithm.QCAlgorithm.AddForex (System.String ticker, System.Nullable`1[T] resolution, System.String market, System.Boolean fillDataForward, System.Decimal leverage) [0x00001] in <5e5418119b824022a87c190195092daa>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0

 

0

Hi David,

This error will go away if you use AddCrypto() instead of AddForex() when creating the other pairs. Using the Bitfinex brokerage model forces it to only recognize Crypto assets. Previously, it was attempting to add them as Forex be added but they aren't valid Forex tickers.

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed