Symbol Info Manager -> Margin in Percent
Author: mschneider
Creation Date: 1/4/2012 10:08 AM
profile picture

mschneider

#1
Hi,

how can I set a 1% Margin for a Future Symbol?

As far as I understand it's not possible to override/set this value while executing a strategy. I need it to estimate the position size depending on the actual equity. Is there another way to get the equity before a trade and SetShareSize manually?

I need this for backtesting a CFD strategy, the quote value are between 5000 and 10000 so the margin varies between 50 and 100.


Thanks,
matthias
profile picture

Eugene

#2
Hi Matthias,

Is margin of 1% equivalent to a 100:1 leverage? In this case, you need to maintain a 100:1 relationship between the point value and margin in the Symbol Info Manager. These properties aren't intended to be changed on-the-fly.

Estimating the position size depending on the actual equity is perfectly accomplished in a custom PosSizer.
profile picture

mschneider

#3
Hi Eugene,

thanks for your help, with the custom PosSizer this part works great now.
Another idea would be to implement tax, is there any solution? I've tried a custom commission setting but don't get access to the netprofit value.
profile picture

Eugene

#4
Deposit withdrawals (such as taxes) has never been a strong point of Wealth-Lab simulations.

In your solution, you can go the way I did when creating the Withdrawal PosSizer. The idea is to maintain a "ghost" equity that is susceptible to taxation and is used for position sizing instead of the equity value passed by Wealth-Lab to your PosSizer.

P.S. You need to realize that a PosSizer can't take trades to bite off a piece of equity on an annual basis. This is only a simulation using 'shadow equity'.
profile picture

mschneider

#5
Thanks, I'll try to find out if it matches my needs.

I've tried this in the Community.Commissions...
CODE:
Please log in to see this code.


...in combinattion with this in strategy code...:

CODE:
Please log in to see this code.


...but it's simply being ingnored(OK, at least the entry part works).

profile picture

Eugene

#6
That's right -- it shouldn't work. For an explanation, see the Remarks section of the NetProfitAsOfBar property in the QuickRef.
profile picture

mschneider

#7
Sad but true. But I don't think that NetProfitAsOfBar is the problem since I could use NetProfitAsOfBarPercent and multiply it with the number of shares while calculating the comission. My problem is how to overload the NetProfitAsOfBarPercent into the comission since the only way I can think of is the Bars.Tag which apparently allows only one value per symbol.

Isn't there another way to access the Position values while calculating the commission?
profile picture

Eugene

#8
Using NetProfitAsOfBarPercent makes no difference (same 1 during Strategy execution).

Since .Tag accepts an object, you can "pack" (cast) anything into that object, like an instance of a class/struct that has multiple fields of different types. If that's the problem.
profile picture

Eugene

#9
Re: Deposit withdrawals (such as taxes) has never been a strong point of Wealth-Lab simulations.

With the advent of the new "Transfer fundamental provider" to MS123 Extra Fundamental providers, it becomes pretty easy to backtest the effect of deposits and/or withdrawals on the account. The Withdrawal PosSizer becomes legacy solution. A detailed walkthrough is available in the Wiki:

Backtesting deposits and withdrawals
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).