Working out Margin Requirements Thread

Just taking a look at this now with some figures:
bf = 100
tm = 80
av = 200

fr = ((2.5 * bf) / ((1 / (tm / 100)) - 1)) - av

fr = 800

Seems a bit high.

I will say I am struggling to get the calculation into a one liner considering all elements.

You’ve done the calculation correctly. I think it works for your scenario at least. We won’t know for sure until @Richard.W weighs in though!

It can be done. I just had to do some coding gymnastics to get to the answer which I’m not happy with.

What I’m saying is:

  • If the new revised margin > users target margin, no funds need to be added/no action needed by the user.

  • If the new revised margin < users target margin, the user needs to take action in the form of

Is it available to test yet?

Did you use my formula?

You no longer need to ask the user for their current margin percentage. You can calculate it from the blocked funds and available funds.

I suggest you default the slider for the “margin you want to end up at” to the current margin.

Check out the link now. At the moment it is using your formula to calculate. I still think there is a tidier way though.

Very good question. I want to know the answer to this too.

I can’t remember if it’s already been covered in this topic.

1 Like

It doesn’t show 800 for the example you gave earlier.

I don’t think my formula works for margin percentages less than 50. I think I need a different formula for that.

Did you see my post about defaulting the target margin to the original margin?

Sorry, I didn’t deploy it properly, that’s changed now.

Yes, all along I had defaulted the target to the original.

Essentially its just trying to find the find the extra the user needs to input to their account. e.g. after the change, they might be left at 75% margin but would rather be at a 80% target margin. the formula just needs to capture that 5% deficit in a neat way, while bearing in mind their free funds.

Something like this could be the best way:

  • revised margin = [Total funds]/([Total funds]+[New Blocked funds]) = 78.3%
    revised margin = 9000/(9000+2500) = 78.3%

  • The user wants 80% margin

  • The difference is 1.7%

  • 1.7% of 2500 (the new blocked fund figure) is what they need to add to their free funds.

Yet also somehow capturing their current free funds.

Does that make sense? @Richard.W am I gone crazy?

If tm is less than or equal to 50, the formula should be:

fr = (tm / 100) * 2 * 2.5 * bf) - av

simplified to:

fr = (tm * 0.05 * bf) - av

Alrighty, lets try that. Updated the formulas.
Edit: certainly not correct on the over 50% formula. I’m getting wild high numbers.

This is amazing Rapid Application Development (RAD)!

I tried a few quick examples and the results are what I expect. I might be completely wrong though. We need a community of people who understand CFD margin percentages to see if they can find any flaws.

Can you swap the order of blocked funds and available funds so that they match the order in the app?

I haven’t seen any evidence of the slider moving to reflect changes to the blocked and available funds. Even when the app opens, it doesn’t reflect the percentage of the default figures. By the way, that should be 67.77…%, which begs the question can you also support a way of showing (and maybe even entering) the percentage with 2 decimal places?

Can you give me an example please?

1 Like

Yes done.

Oh I see what you mean now. That may be a bit tricky to do and at this point would be a ‘nice to have’ with regard to the default. The reason being just the way the code is structured at the moment. The decimal places have been added however.

The reason I think the calculation is wrong is that I’m looking at my own account which has 7353.27 free funds, 2494.28 blocked funds, and a margin of 80%. To maintain the margin, the calculation is telling me I need 17k!

I don’t know how I missed this, but your app is asking for “current available funds” and I need it to ask for “account value”.

Is your account value 9847.55?

I believe that ACCOUNT VALUE = FREE FUNDS + BLOCKED FUNDS anyway, so you could allow them to enter whatever two values you think make most sense and then calculate the third for display purposes and confirmation.

I’ve changed my mind about the decimal places in the slider! Is there any chance you could display the current margin to 2 decimal places above the slider?

Yes, I think you’re right. This is where the confusion was. So this should be account value!

Updated now. Lets try it and see.

It still seems a bit high but maybe that is correct afterall. Hmm yeah maybe that is correct. Looking at my own account figures, to maintain 80% margin would need 15k. I can reduce the target margin to 61% and not have to deposit anything. That sounds about right.

Just saw the changes, I’ll meet you half way and go to one decimal point on the slider.

Current margin above the slider could be doable, let me give it a try, it may take a bit thinking.

I edited my post above. Did you notice the additions?

Just edited my last post. Changes made.

Would you guys mind if I moved all your posts into a separate thread of it’s own?
Yay or nay ?