Here are the problematic parts of my code. I'm just trying to implement a basic stop loss/take profit based off of my entry price.
self.stopLossPercent = 0.99
self.profitTargetPercent = 1.02
self.btcbusd = self.AddCrypto("BTCBUSD", Resolution.Minute, Market.Binance).Symbol
self.currentPrice = self.AddCrypto("BTCBUSD", Resolution.Minute, Market.Binance)
marketOrderTicket = self.StopMarketOrder(self.btcbusd, -1, self.currentPrice * (self.stopLossPercent)) limitOrderTicket = self.LimitOrder(self.btcbusd, -1, self.currentPrice * (self.profitTargetPercent))
Runtime Error: Trying to perform a summation, subtraction, multiplication or division between 'Crypto' and 'float' objects throws a TypeError exception. To prevent the exception, ensure that both values share the same type.
at OnData
marketOrderTicket = self.StopMarketOrder(self.btcbusd in main.py: line 30 (Open Stacktrace)
Cole S
Hi Victoria,
When you call self.AddCrypto it's returning a Crypto Security object, not a price. That's why when you add you are getting the error it can't add to a Crypto object. The below line is the problem. You need to set it to the price, not add the Crypto security (which you did in the prior step).
We need
Fred Painchaud
Hi Victoria,
You are also adding the same crypto (BTCBUSD) twice with:
with the same resolution. You would have issues with that… Just so you know that in your future algos/tests.
Fred
Vladimir
Victoria Butler,
The following back-test can help you get your algorithm up and running using UnrealizedProfit.
Victoria Butler
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!