Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Brain limitations: position sizing for forex

    General Discussion
    2
    5
    1177
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nooby_mcnoob last edited by nooby_mcnoob

      This is tough, I think because the "size" has to be different if you want to convert 100% of the amount back to your base currency.

      So say my base currency is USD and I am trading USD/GBP (I know this isn't a real pair). If I convert $100 to £75, the order could look like this:

      self.buy_bracket(price=.75,limitprice=.78,stopprice=0.74)

      The sizer is called once, and lets say the idea is to always trade a size of $100, so we configured bt.sizers.FixedSizer,stake=100

      Now say the profit limit is hit, that means we will convert £100 into $133. But we only had £75 which means we will be taking some sort of a position instead of closing it out.

      I'm trying to figure out how we would size this properly, but it seems to be a limitation in my brain.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        Imho you approach the problem from the wrong side. You convert the price, but you want to convert the size

        self.buy_bracket(price=100, ...)
        

        The Sizer (a custom one) will then say that the maximum size is 75.

        The position will be closed with the right size because the take-profit and stop-loss sizes are the same as that from the main order.

        N 2 Replies Last reply Reply Quote 1
        • N
          nooby_mcnoob @backtrader last edited by

          @backtrader oh that's very interesting and makes perfect sense, thank you!

          1 Reply Last reply Reply Quote 0
          • N
            nooby_mcnoob @backtrader last edited by nooby_mcnoob

            @backtrader Actually, I'm unable to see how to apply this.

            If we have

            self.buy_bracket(price=100,...)
            

            But the actual price is $.75, the order will go to the broker at $100... I'm very confused. Maybe the right thing to do is to manually create the bracket orders.

            1 Reply Last reply Reply Quote 0
            • B
              backtrader administrators last edited by

              See this other thread: Community - Backtesting oanda/forex

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
              $(document).ready(function () { app.coldLoad(); }); }