Brain limitations: position sizing for forex
-
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.
-
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 is75
.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.
-
@backtrader oh that's very interesting and makes perfect sense, thank you!
-
@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.
-
See this other thread: Community - Backtesting oanda/forex