happydasch / btoandav20

Support for Oanda-V20 API in backtrader
Apache License 2.0
130 stars 52 forks source link

Commission #74

Closed bjoern79de closed 3 years ago

bjoern79de commented 3 years ago

https://github.com/happydasch/btoandav20/blob/0049eb2d6ac67464058693604f03c38bab86ef97/btoandav20/commissions/oandav20comm.py#L46

I don't understand the calculation here. Why isn't the commission just abs(ask - bid) / 2 ? If I calculate profits using the mid-price I have to subtract the half spread in my point of view. This CommissionScheme subtracts just a fraction.

happydasch commented 3 years ago

the bid / ask price may not be available. You can just extend from that commission scheme or create a new one to use bid/ask prices. For now i use just a fixed spread. But some of the latest changes in btoandav20 provides bid / ask close prices in additional lines in the feed.

The spread is configurable. The calculation above is used to calculate a multiplier so a price based on the spread can be calculated. The commission uses half of spread for trade start and half of spread when trade closes.

see also https://community.backtrader.com/topic/525/forex-commission-scheme for the source of this commission