For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Oanda setcommision and size



  • Hi ! Hoping everyone is keeping safe in these times.

    Need some help with forex oanda commision. I cannot fully understand the docs.
    The commission is in the spread, but under a million shares traded, the commision is $50. Lets say $5 per trade for easy calculation.
    Margin for my country is 5% and so I believe leverage is 20x.

    Can I ask how do you set cerebro broker is this case?

    #This code cannot work... meaning no orders executed, beleive commtype=bt.CommInfo.COMM_FIXED is the issue?
    cerebro.broker.setcommission(leverage=20, mult=1.0, stocklike=False, automargin=0.05, commtype=bt.CommInfoBase.COMM_FIXED, commission=5.0)
    

    a few more questions

    1. whats the difference between mult and leverage?
    2. how do you set the size to buy. Should size include the 20x leverage?
      as objective is to trade live on oanda, hence hoping to get this right
    amount_to_invest = (0.5 * self.broker.cash)
    self.size_to_exe = math.floor(amount_to_invest / self.data0.close)
    

    Thanks a million!



  • @J-T said in Oanda setcommision and size:

    whats the difference between mult and leverage?

    mult - multiplyer for the price, specific for futures contracts, pointvalue. For example, you bought 1 contract at 10.0, sold at 12.0 and mult = 100.0. Then your profit is (12.0 - 10.0) x 100.0 = 200.0

    leverage - this is multiplier on your cash. If you use leverage of 2.0, than you can buy on 2.0 x cash. bt has

    @J-T said in Oanda setcommision and size:

    how do you set the size to buy. Should size include the 20x leverage?

    Since the question sitting unanswered for quite long time, than better to try and check what will you have as a results by yourself. I used to use different way of applying leverage, so I don't use it for bt and can't give any solid advice.



  • you may try out the commando object committed lately.


Log in to reply
 

});