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

Trading with absolute amount of money allocated for each trade

  • Hi,

    I have checked all the topics involved in sizers but i cannot find how to do things like :

    First, broker.setcash(10000). Then after that i want to allocate 1000 dollar for each trade if the signal is true.

    The money spent on each trade will not shrink regardless of my overall portfolio value (fixed 1000 dollar, not percentages).

    The way i do everytime is to set size = 1000/data0.close[0]-1 for every buy order.

    However it is not fully flexible at several situations.

    Is the any other more formal way offered by Backtrader that i can use?

    Thank for any help!

  • You can probably use target value orders -
    Docs - Target orders

Log in to reply