For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Coins balance in backtesting
Rodrigo Brito last edited by
I'm using the backtrader with Binance, through CCXT Store lib. The CCXT broker give me my coin balance with
self.broker.get_wallet_balance("BTC"). But, in simulations only the cash values is available with
self.broker.get_cash(). How I can access the coin amount in backtests?
The second question is: I'm using the follow code to use all my funds to buy with 100% of the value. There is a different way to define an automatic size to use all my funds do buy coins?
P.S: 0.99 is used to avoid decimal precision issues.
price = self.data0.close amount = (self.broker.get_cash() / price) * 0.99 self.buy(size=amount)