Overnight fees calculation for ProOrder strategies

In order to calculate the overnight broker fees while testing an automated strategy, I made this little code snippet, that can be “plug” in any Probacktest code.Parameters to change are between lines 1 and 4:

“Capital”, set it accordingly to your starting balance in money (10.000€  in this case).

The “overnightfee” variable, that must be set to the correct broker’s fee (0.8€ per position in this case).

Overnight fees calculation, the code:

// --- parameters
Capital = 10000 // initial capital of account
overnightfee = 0.8 //broker overnight fee of a position (in money) 
// ---

equity = Capital + StrategyProfit
ONCE BrokerProfit=0
FourHoursChart=5 //can be set to bar qu
once countofdays=0

if  not onmarket then
 countofdays=0
elsif onmarket and Intradaybarindex =FourHoursChart then
 countofdays=countofdays+1
 BrokerProfit=BrokerProfit+countofdays*overnightfee*countofposition
else
 countofdays=countofdays
 BrokerProfit=BrokerProfit
endif

trueEquity=Equity-BrokerProfit

graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit" 
graph trueEquity COLOURED(0,0,255) AS "trueEquity"
graph countofdays COLOURED(0,0,0) AS "countofdays"

 

How to interpret results?

Results are displayed on chart when you run a backtest with Probacktest, they are “graphed” with 3 different curves:

  • BrokerProfit in red, tell you how much are the overnight fees of the broker, for the current instrument and for the whole strategy period.
  • trueEquity in blue, is the real strategy without the overnight fees, which is slightly different from the equity curve Probacktest give you (compare this blue line to the equity curve above).
  • countofdays in black, is the final count of days when an overnight fees were encountered.

In this example, the calculation were made with the Pathfinder strategy, as you can see, only 6% of profit is wiped out of the whole strategy performance.

This blog post is related to the discussions of this topic: https://www.prorealcode.com/topic/brokers-overnight-interest-rate/

Share this

  1. Elsborgtrading • 54 days ago #

    trueEquity in blue, is actually WITH the overnight fees, as they are deducted from the back tested equity

  2. Elsborgtrading • 54 days ago #

    ..and then again. With or without, I guess It’s how you look on it 🙂

  3. manel • 49 days ago #

    Thanks very much for this. I usually make an educated guess on funding costs taking into account average position size and holding periods etc but it’s very useful to have a much more accurate way to calculate this as sometimes the costs can be significant. Cheers !

avatar
Register or

Top