# Working out Margin Requirements Thread

Yes, I think that’s sensible. This topic is long enough as it is!

Whatever you wish! Could be cleaner.

2 Likes

Your calculator is working well for the examples I’ve tried. We need more confidence that the calculations are correct though.

@Richard.W, are you planning to test the calculator some more? Your input would be invaluable.

We need to add a disclaimer which says that the calculator will definitely not work for anybody who has anything other than stocks in their CFD portfolio. I wonder how many people that will prevent from using it? I imagine that a lot of people will have commodities, FOREX, indexes (or is it indices?) such as SPX 500 (the S&P 500), etc.

We should probably also add a disclaimer that says something about we don’t offer any guarantees that the results are accurate!

Good idea, I’ll add that in.

I don’t think this works yet.

Whereas

1 Like

Thanks for the testing.

@obrienciaran, can you check your implementation please? I believe my formula also gives a result of 90.

Yes I’m still not entirely confident on the formula used (just lack of understanding from me!).

for under 50%
fr = ( tm * 0.05 * bf ) - av

for over 50%:
fr = ((2.5 * bf) / ((1 / (tm / 100)) - 1)) - av

This is whats in place now. If these need to be adjusted I will do so.

edit: fr = ( tm * 0.05 * bf ) - av
This does give me 90 actually doing it on the calculator. Let me check my code.

1 Like

So formula is as given in Out[295].

Or actually, in case both x and y are negative:

1 Like

That is witchcraft! I don’t know how to read it.

Before we have to, can we see what happens once we fix the issue with your previous example?

Spotted an error right as I posted my last post. Made the updates to the calculator. I forgot to add in the condition that says ‘if the margin is less that 50% do xyz’

Here is my working out:

1 Like

Does it give the expected 90 now? Have you uploaded it?

Yes take a look now. It’s uploaded.

If you’re using it and it drops out, just refresh, I’m dropping in an update on some wording in it.

1 Like

What software is this? Mathematica? I’m guessing?

If you could take a look at the updated calculations now that would be great. If they’re still not up to scratch I can drop in yours.

1 Like

Yes, the calculator is giving correct answers now. I don’t know what code you are using, but we have a simple formula

ADD = MAX [ 0 , -CT + 5 CB TM Max[1, 1/(2 - 2 TM) ]

Yes, I produced this with Mathematica.

1 Like

Can you change the disclaimer to be all in bold (or at least in a bigger font), stating:

THIS CALCULATOR ONLY WORKS WITH CFD PORTFOLIOS THAT ONLY CONTAIN STOCKS. IF YOUR PORTFOLIO CONTAINS ANY OTHER TYPE OF INSTRUMENT (e.g. Commodities, Indexes or FOREX) THE RESULTS WILL BE INACCURATE SO THE CALCULATOR SHOULD NOT BE USED.

IT IS YOUR RESPONSIBILITY TO CONFIRM THAT THE OUTPUT OF THIS CALCULATOR IS ACCURATE!

Are overnight fees changed accordingly as less leverage is being used? so less money borrowed?

1 Like

I used the two formulae above given by @Supraman. Honestly, I still don’t fully understand them, but if they work, I dare not change them!

This is the one liner I was looking for. I wouldn’t have gotten this in a million years.
ADD = MAX [ 0 , -CT + 5 CB TM Max[1, 1/(2 - 2 TM) ]

Yes! I’ll add that in now, give me 5 mins.

1 Like

Overnight fees (interest) has actually gone up, but that’s a separate issue!

1 Like