Understanding Margin Factor
Author: kyokushin
Creation Date: 5/17/2014 7:06 AM
profile picture

kyokushin

#1
I need some help using margin in WL 6.

I'm performing Multi Symbol Backtests with US stocks and want to simulate Reg T margin rules. I have assigned position priority and I'm holding stocks over night.

Does the WL show every alert but drops some of them when calculating performance? How do I know how many of the alerts I can buy in my real account?
profile picture

Cone

#2
QUOTE:
Does the WL show every alert
Of course.

QUOTE:
but drops some of them
See User Guide: Strategy Window > Backtesting Strategies > How Trades Are Chosen

QUOTE:
want to simulate Reg T margin rules.
Do you mean Reg T margin for a cash account?

QUOTE:
How do I know how many of the alerts I can buy in my real account?
If you know the buying power of your account and how much your buying and selling, isn't it straightforward?

Just a comment at this point.. Wealth-Lab doesn't support margin calls by adding funds or liquidating positions. The best you can do is identify where a margin call might have occurred by adding the Equity and Cash columns of the equity curve data. If it goes below zero, you're broker probably would have let you know about it. You can largely avoid the situation by using something less than 2:1 margin to allow leeway for losing positions.
profile picture

kyokushin

#3
QUOTE:
Do you mean Reg T margin for a cash account?

I have a Reg T Margin account with my broker.

QUOTE:
If you know the buying power of your account and how much your buying and selling, isn't it straightforward?

Yes it is. But is there a way to figure out what trades are chosen in Wealth-Lab?

What does it mean if I get a buying alert with qty 0?
profile picture

Eugene

#4
QUOTE:
What does it mean if I get a buying alert with qty 0?

It may mean, for example, that the PosSizer a) had trouble in sizing a position due to a live bug in WL or b) has its own bug. Could you provide more information?

QUOTE:
But is there a way to figure out what trades are chosen in Wealth-Lab?

Have you followed the link "How Trades Are Chosen"?
profile picture

kyokushin

#5
QUOTE:
Could you provide more information?

What information exactly do you need?

QUOTE:
Have you followed the link "How Trades Are Chosen"?

Yes I did. I assigned position priority and chose Margin Factor 1.9 : 1. Today for example I got 27 buying alerts and do not have enough buying power to buy all of them on Monday under Reg T margin rules since I will keep them over night. How can I find out what trades are chosen?
profile picture

Eugene

#6
QUOTE:
What information exactly do you need?

Everything regarding your position sizing settings, of course.
QUOTE:
How can I find out what trades are chosen?

The ones with the highest priority.
profile picture

kyokushin

#7
QUOTE:
The ones with the highest priority.

I know that. But which ones exactly? Can I find this out?
profile picture

Eugene

#8
How about adding the priority string to your Alert/Position (the EntrySignal property)?
profile picture

Cone

#9
Suggestion for enhancement:
Add a Position.Priority column by default to the Alerts and WealthSignals Publisher views.

Eugene, could you experiment with that? It seems like such an obvious solution, maybe there was a practical reason not to have done this long ago.
profile picture

Eugene

#10
Robert, it's impossible. Alert does not contain a Priority property and the closest thing - the Alert.Position property (assumed to have .Priority) - is null (which is quite natural).
profile picture

kyokushin

#11
QUOTE:
How about adding the priority string to your Alert/Position (the EntrySignal property)?

I'm afraid this is beyond my capabilities of coding so far. What I did is to pass the priority value as the signalName parameter in the entry signal, as suggested in the manual. Could you help me with that?

Tomorrow I should be able to see what trades were chosen by looking into the trades column. This would be one day too late though for adapting it to real trading...

QUOTE:
Everything regarding your position sizing settings, of course.

My settings are: PosSizer: Avg Down with Pct Equity Limit, Pct of Equity 4, Max % of Equity 10, MF 1.9 : 1.
profile picture

Eugene

#12
QUOTE:
My settings are: PosSizer: Avg Down with Pct Equity Limit, Pct of Equity 4, Max % of Equity 10, MF 1.9 : 1.

Your starting capital is probably set too small with regard to the instrument's price. This is why the PosSizer is coming up with a fractional share (less than 1). Try to bump it up by an order of magnitude, for example.

QUOTE:
What I did is to pass the priority value as the signalName parameter in the entry signal, as suggested in the manual.

You must be talking about something like this:
CODE:
Please log in to see this code.

So the RSI should now appear on the Signal Name column. That's it. Note: the Signal Name column sort order is alphabetical, this is by design -- don't be confused if the numbers aren't lining up there as you'd expect them to.
profile picture

kyokushin

#13
CODE:
Please log in to see this code.


This is what I did. I can sort them by the signal name column to see the priority. But in the end I do not know how many of the trades are used by WL to calculate performance and which ones are dropped. I just see the number.
profile picture

Eugene

#14
If you have the need to view all trades, you can switch to Raw Profit mode.
profile picture

kyokushin

#15
I know that I can use Raw Profit mode to view all trades. Perhaps I did not make it clear what I meant. What I'm trying to figure out is what trades exactly are dropped by the program if I do not have sufficient buying power to buy all the trade alerts.

QUOTE:
Your starting capital is probably set too small with regard to the instrument's price.

I dont think that this is the problem. My capital is around 10K with margin factor 1.9 : 1.
profile picture

Eugene

#16
QUOTE:
My capital is around 10K with margin factor 1.9 : 1.

4% of equity (10K) with MF 1.9 : 1 (19K) is $760. From your problem description, we have no idea which stocks you're following. But that sum is not enough, for example, to purchase a single share of SEB, PCLN, NVR or AAMC, let alone BRK-A. Bump it up to e.g. 100K to see if it alleviates the problem. Otherwise please provide a simple test case for troubleshooting that includes all information and settings required to reproduce it on our end.
profile picture

Cone

#17
QUOTE:
what trades exactly are dropped by the program
You'd have to compare the Trades list between Raw Profit and Port Sim modes. But more generally (and apart from what Eugene said about needing sufficient buying power for at least 1 share), you can locate the dates surrounding rejected trades by finding the dates of highest exposure in the Equity Curve.

profile picture

kyokushin

#18
Today for example I had two alerts with qty = 0 with equity 11K: GOOG and PCLN.

QUOTE:
Otherwise please provide a simple test case for troubleshooting that includes all information and settings required to reproduce it on our end.


What exactly do you need?
profile picture

Eugene

#19
To start with, this should be enough to reproduce the case from the ground up:

1. Strategy code + applied parameters (if different from default)
2. DataSet (symbols), bar scale, data provider
3. Data loading range
4. Position sizing settings
5. Wealth-Lab Preferences: Commissions, Backtest Settings, Slippage & Round Lots
profile picture

kyokushin

#20
You once wrote WL always shows all alerts. Could it be that it shows me an alert with qty = 0 because due to my strategy I should not rebuy a particular stock?
profile picture

Eugene

#21
It can be anything including a known (or new) PosSizer bug. If you want further assistance, please provide the details as per my checklist in post #19 dated 6/6/2014 1:02 AM. Appreciate if you start a new thread since this issue doesn't have in common with "Understanding Margin Factor"
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).