- ago
I got unexpected equity sizing values for a signal issued today (Saturday ET) to buy a single symbol at market at next bar. I had option "Use broker reported equity" checked with a BI paper account of ~$1,053,000. These are the position size values I got for running strategy with various equity %'s:

100% : $905,000
95% : $779,973
90% : $669, 289
80% : $486,090
60% : $239,606
40% : $102,809
20% : $32,397

To remove the broker connect from the troubleshooting, I shut down TWS, connected to Dummy Broker, unchecked "Use Broker Reported equity...", restarted WL8, but these values are unchanged for setup equity of $100,000.

The initial values with TWS connect are way off, and I can't seem to get WL8 to use setting for strategy when disconnecting from Broker. Do you have an idea what is could be happening?

0
324
Solved
22 Answers

Reply

Bookmark

Sort
- ago
#1
What tool is this, Strategy window or S.Monitor?
Have you checked the position sizing of the strategy, perhaps the starting value comes from user input?
0
- ago
#2
QUOTE:
What tool is this, Strategy window or S.Monitor?

Both but with different results.

The Accounts tab correctly shows that I have cash of 1,053,380.01 in my IB paper account, which WL is connected to. I have two current signals for two symbols, and I have the % Equity set at 50% in SM and SW.

SM: signal is for quantity $1,039,087.01 for each symbol.
SW signal is for quantity $1,970,936 for each symbol

QUOTE:
Have you checked the position sizing of the strategy, perhaps the starting value comes from user input?

There is no user input to size strategy. The only Position Sizing I'm aware of is the % Equity settings in SM and SW, which are set at 50%.
0
Cone7
- ago
#3
Does the Strategy assign a value to Transaction.Quantity?

QUOTE:
// Like this?
Transaction t = PlaceTrade(bars, TransactionType.Buy, OrderType.Market);
t.Quantity = something;
0
- ago
#4
no
0
Cone7
- ago
#5
We're going to have to find what's causing that facility to fail... and after switching to my IB paper account, I think I've found something.. stay tuned.
0
Cone7
- ago
#6
Found it. Notice how only "Cash" is showing up in the Accounts tool. A request for account info was inadvertently changed to use a "lightweight" method that wasn't returning the account's Buying Power. Fixed for the next IB Provider, Build 7.
0
Best Answer
- ago
#7
QUOTE:
Found it.

I'm glad you found it. I guess I'll have to wait for the update to trade through API, at least for % Equity trades? I can enter paper trade manually into TWS, but then I assume I'll have to manage the trade manually (not through API) until it closes because I don't know that there is a way to sync strategy Active Positions? (I'm assuming that WL8 only process trades based on signals it generates, not by syncing active positions from BI.)
0
Cone7
- ago
#8
This bug shouldn't hold you back if you want to trade. Just calculate the % of equity size each day and enter it for Fixed Value Sizing.

Example:
If your account is $100K, and you want 10% sizing, just enter $10K Fixed Value. Then repeat the process each day.
0
- ago
#9
Great suggestion. Thank you. Placed it through API and worked fine (got Qty correct).

Look forward to the update!
1
- ago
#10
I am running the latest versions of WL8 (10) and IB extension (8). I am still getting strange calculations for % of equity calculation when running strategy in SM during after-market hours. Paper acct balance is 995K and setting is 50% equity for each of 2 positions. Each position staged has value of 783K. (Expecting ~500K.)

To eliminate the Paper Account as a possible cause, I ran again in a live account with a $500 balance and got the same $783K allocation per position for 50% of equity.

0
- ago
#11
Can you please confirm that this problem with equity sizing is on a bug list to be fixed? I wanted to make sure that WL is aware that this issue still persists (see Post #9 above). despite the "lightweight" fix that was put in IB API B7 (see Post #6 above.)
0
Cone7
- ago
#12
I confirm that it's working, however in the process of checking, I found that it does not work when the Basis Price is set to the [non-standard] "Market Open next bar".

I can't think of a reason why it shouldn't work for that setting, so for now we'll consider that a bug!
0
- ago
#13
Mystery solved. Thanks.

While we're on the topic, I'd like to understand how the sizing algorithm *should* work. 1. If I place an MOO order with % equity selected and Next Bar, will the algorithm detect the opening price and make changes to the quantity placed (particularly useful in the case of an overnight gap move)?
2. If there is Margin available in the account, will the Equity Sizer use all available Margin or will it use the Margin (1, 1.5, 2, etc.) setting to determine how much margin to use?
0
Cone7
- ago
#14
QUOTE:
will the algorithm detect the opening price and make changes to the quantity placed (particularly useful in the case of an overnight gap move)?
Definitely not. The predetermined size is sent with the signals and if the account can't handle the order it will probably result in an order error and failed.
0
- ago
#15
Then Market Close This/Next Bar is only meaningful for backtesting results?
0
Cone7
- ago
#16
Either setting is meaningful. Please see: F1 > Strategy > Strategy Settings > Basis Price. It's covered there and I can't really explain it any better.

Edit - Pay attention to: Important Notes for Market Open Basis, especially -
3. Signal Quantity is always Staged or Placed with the number of shares using the Market Closing price basis.

It turns out that even though the $ signal display is not currently taking into account the broker account value, that changes when the orders are Staged/Placed. The share value of the trade, which is always based on the last closing price, is correctly using broker account value for % Equity sizing when that preference is enabled.

The other part of the trading equation is the Preference: "Use Fractional Shares when Possible". The only broker adapter that supports this at the moment is Alpaca. So you won't get fractional shares with IB (yet).
0
- ago
#17
Thanks, Cone for the doc reference.

QUOTE:
The share value of the trade, which is always based on the last closing price, is correctly using broker account value for % Equity sizing when that preference is enabled.

I placed some trades with IB/TWS outside market hours to test various settings and I confirmed that this is the case.

I realized that live trading does not take into account margin or buying power in sizing trades, only current equity (as named). In order to buy shares using margin I found I could accomplish that by increasing the % of Equity value to buy more shares.

For example, if I am buying two symbols and just wanted to use all my cash, I would enter 50%. If I wanted to use 2x equity (1/2 cash, 1/2 margin loan) for two positions I set the % of Equity to 100% and WL buys twice as many positions of each symbol.



0
- ago
#18
For today's auto trading with IB, the sizing numbers are all over the place. Account equity is $~3,200. I want to trade 2x equity including margin, so I set % equity at 100% for 2 positions.

I ran the strategy multiple times from the SM, and each time got a different sizing number. Note that $$ are correctly getting converted into shares, but the $$ amounts are wrong. Each run result is separated by comma below.

Pos #1 $3,693, $4,785, $3,206, $4,847, $4,813
Pos #2 $3,693, $4,785, $3,206, $4,847, $4,813

The correct sizing would be =< $3,200 for each position.

If I set to Use Closing Price This Bar, I get similar erroneous results, except in shares instead of $$.

If you think this is a bizarre behavior that you haven't seen, then please note that my IB account window no longer shows the equity value since I added a second BI account. It only shows active position values. I wonder if it's related to having 2 IB accounts running in the Accounts Window.

BTW, which data provider is used to get the close price of the Current Bar? Is it the same provider designated for the DataSet that the strategy runs against?
0
Cone7
- ago
#19
Above, we confirmed the bug that the % of Equity sizing when using Basis "Market Open Next Bar" is based on the simulated equity, always. So it's expected that the value is going to change if your simulation has NSF Positions and doesn't assign Transaction.Weight.

If you want to see the correct sizes for Account Equity (we use the IB Account's Net Liquidation Value), then you need to either:

1. Place the order with the broker. If the Trading Preference for broker account equity is checked, you'll see that the proper size is used (shares x last close).
- or -
2. Use Basis "Market Close This Bar". Frankly, unless there's a good reason not to, you should always use this anyway.

QUOTE:
Is it the same provider designated for the DataSet that the strategy runs against
Yes.
1
- ago
#20
HI Cone,

Thank you for the response and the additional information. I'm not intending to repeat a problem you already know about. However, your explanation made me wonder if you noticed one piece of information in the above post I provided about this problem.

QUOTE:
If I set to Use Closing Price current Bar, I get similar erroneous results, except in shares instead of $$.


In other words, I also tested with Market Close This Bar (because I had the "bug" in mind) and got the same random sizing from one run to another, only in shares instead of dollars. (I can post a run sequence in shares using Market Close This Bar, if that would be helpful.) Unless I didn't completely understand your explanation, this issue does not appear to be limited to selecting Closing Price Next Bar.

Also, My Strategy Backtest Metrics Report does not show any NSF positions, even though I have selected to retain them.

Another new behavior I noted above is the disappearance of the Account Equity data for IB accounts from the Accounts page, once I linked a second IB account at IB. Both accounts automatically showed up the Accounts page after linking. Do you think linking the second account is related to this happening? It hasn't changed for TDA or Tradier, both of which have only one account.
0
Cone7
- ago
#21
If you're not seeing the equity on the Accounts page, it must have something to do with the linked accounts, so give me some time to link my two IB accounts and then we can directly determine the problem. Thanks.
0
- ago
#22
And the position sizing when This Bar is selected? That also?
0

Reply

Bookmark

Sort