Percentage Margin for Futures
In the futures I am interested in both Margin and Commission including taxes are a percentage of the turnover than fixed.
I am currently trying to achieve this in Backtrader as following but orders are failing with
# set commission scheme cerebro.broker.setcommission( commtype=bt.CommInfoBase.COMM_PERC, percabs=True, commission=0.0001, automargin=0.09, )
That's unfortunately not enough information. If you fail with
Marginit's because you don't have money enough.
Thank you @backtrader
I found the issue. I am trying to go all in and calculating the order size based on previous close which may be lower than todays open and the margin money will not be enough then...
For now I am only going 95% in to avoid margin call if the price gaps up.
For those absolutely non-realistic scenarios you can use
Thank you for the Suggestion. It helped.
By the way, how do we get the PnL of an active existing position/trade on each bar (inside next method)?
Yelloww last edited by
broker.get_value()gives fund value.
broker.get_cash()gives currently available cash.