Calculating overnight fees, interest, and dividends

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #243755 quote
    Anjuna Marine
    Participant
    New

    We add spread to our systems in the PRT platform, but what about overnight broker fees, interest, and the impact of dividends?

    I’ve developed some code that calculates the cost of overnight fees, interest, and the impact of dividends. I use it across all my systems since these factors can really add up over time.

    Below, you’ll find the code based on the DAX 40. It should be simple to integrate into your own systems and customise as needed. The code is designed to work on any intraday time frame, you’ll just need to adjust the CurrentTime = 220000 to match the fee application time in your own time zone.

    This version is designed for the UK, with IG, and assumes an interest rate of 4.75% plus a broker fee of 3.0%. It also includes an approximate calculation for dividends (accounting for both positive values for longs and negatives for shorts). It then plots the results on a graph, and if a position is held on a Friday night, the fee is calculated as three times the standard value.

    IF CurrentTime=220000 AND OpenDayOfWeek>0 then
    
    SONIArate=4.75
    if longonmarket then
    int = (3 + SONIArate) * 0.01
    myrate = - (abs(countoflongshares) * close * int)
    endif
    if shortonmarket then
    int = (3 - SONIArate) * 0.01
    myrate = - (abs(countofshortshares) * close * int)
    endif
    
    if onmarket then
    mymonthrate = myrate / 12
    mydayrate = myrate / 365
    mytotalint=mytotalint+mydayrate
    if opendayofweek=5 then
    mytotalint=mytotalint+(mydayrate*2)
    endif
    endif
    
    // DAX dividend adjustment
    if longonmarket then
    mydiv=(countoflongshares*close*0.0225)/260
    mytotaldiv=mytotaldiv+mydiv
    endif
    if shortonmarket then
    mydiv=-(countofshortshares*close*0.0225)/260
    mytotaldiv=mytotaldiv+mydiv
    endif
    
    // Plot graphs
    graph mytotalint coloured(100,40,100) AS "Interest"
    graph mytotaldiv coloured(100,60,100) AS "Dividends"
    graph mytotalint+mytotaldiv coloured(100,80,100) AS "Combined"
    
    ENDIF
    #243756 quote
    GraHal
    Participant
    Master
    Link to above added as Log 393 here … Snippet Link Library
    Iván González and robertogozzi thanked this post
    #243918 quote
    LucasBest
    Participant
    Average
    Thanks for this nice code. But, it is hard to get accurate results over time as SOFR% (or LIBOR rates) changes every day… Also, note that in IG Markets i found 2 different formula : Sometimes it is written : Nights held x (market closing price x trade size x ( relevant interest rate benchmark+/- admin fee*)) / 365. And sometimes : Number of contracts x value per contract x price x (3% admin fee+/-SOFR%*) ÷ 360 What is the value of the contrat ? Also for the week end it is written in french IG Markets website that 3 days of interest are applied for the week end, not only 2… “Veuillez noter que les positions maintenues ouvertes après 23h (heure de Paris) le vendredi seront ajustées pour trois jours de financement afin de couvrir le week-end.”
    Capture-decran-2025-02-16-153928.png Capture-decran-2025-02-16-153928.png Capture-decran-2025-02-16-154010.png Capture-decran-2025-02-16-154010.png
    #243926 quote
    GraHal
    Participant
    Master
    3 days of interest are applied for the week end, not only 2…
    Friday overnight, Sat overnight and Sun overnight.
    What is the value of the contract ?
    Mid-price x 1?  E.g. Value of 1 Contract on DJI is currently 44503 (DJI mid-price is 44503 as of Friday close).
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Calculating overnight fees, interest, and dividends


General Trading: Market Analysis & Manual Trading

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by GraHal
11 months, 4 weeks ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 02/12/2025
Status: Active
Attachments: 2 files
Logo Logo
Loading...