Not all trades taken when equity reaches HUGE numbers
Author: wl64bit
Creation Date: 12/29/2009 2:35 PM
profile picture

wl64bit

#1
It looks like when Equity reaches huge numbers, as $500,000,000,000 Simulator does not use all trades in the simulations.
profile picture

Eugene

#2
I'm at a loss trying to decipher what does "does not use all trades" mean.
profile picture

wl64bit

#3
After equity reaches huge numbers, simulator stops working properly and does not include additional trades in the simulation. Try to set pretty big Starting Capital in Portfolio Simulation mode and run a script which brings your equity to something like $500,000,000,000. You will notice that at the end of the Equity Curve you goanna miss many trades in the simulation in comparison to Raw Profit Mode. After switching the starting capital to a smaller one, like $500 for example, you will see that simulation includes all the appropriate trades, and nothing is missing. It because in the second case, the equity did not reach the huge numbers.
profile picture

DaveAronow

#4
If your system earns you that much money, I'd think you'd stop trading and buy an island (England maybe?). So this is a very realistic simulator :P
profile picture

Eugene

#5
While I generally agree with Dave on how realistic this number is (exceeding Fidelity's own revenues by a several dozen times :P), my support duty is to ask for the position sizing option in use.

I modified a moving average crossover system to peek in the future to guarantee inflated results, set the starting capital to $10 bln (the max. figure WL5.6 allows me to start with), and "traded" it to $68 bln., allocating 2.5% per position. There were just 6 (six!) skipped trades on this Dow 30 portfolio - compared to 2,321 trades, it's a low rate. Most likely, this can be explained if we dig deeper into these omitted trades.
profile picture

Cone

#6
Let me take a guess - we're using 100% of equity sizing?

That's probably what I would do if I had all the money in the world - let it ride on one big bet! :)

Actually though, once I owned 100% of the stock in MSFT and XOM and privatized them, I guess I wouldn't have much trouble living off the dividends.
profile picture

wl64bit

#7
The issue is not whether these numbers are realistic or not, but rather to check if the software works properly. Do whatever you want to bring the equity to the numbers, including high starting capital and high % of the equity sizing, and you will see that there is a bug in the program.
profile picture

Eugene

#8
We're asking if you're using 100% of equity sizing? See the Wealth-Lab User Guide > Strategy Window > Backtesting Strategies > 100% of Equity Sizing.
profile picture

Cone

#9
Sure there are bugs, but it's not likely this is one of them. There are good reasons why trades are rejected for Porfolio Simulations. You're not helping by just saying that there's a bug with big numbers. It's more likely that trades are being rejected by design, per the User Guide: Strategy Window > Backtesting Strategies > How Trades Are Chosen
profile picture

wl64bit

#10
No, I am not using 100% of equity sizing but only 16.6%. Therefore, there almost no chances that there is not enough money to take these trades. Another way to explain it is that when I decrease the Starting Capital to a smaller one like $500 with the same 16.6% equity sizing, the equity does not reach these numbers and all trades are included.
profile picture

Cone

#11
Please, let's get all the parameters (data range, symbols, sizing, interest, margin, and commission settings, futures settings if applicable, etc.) required from your simulation so we can tell you what's happening.
profile picture

Eugene

#12
+ Is it a multi-symbol or single-symbol backtest (WL can skip trades in MSB even with a smaller value e.g. 2.5% - but that depends on DataSet composition).
profile picture

wl64bit

#13
20 years of 15000 stocks, no commissions, no interest, Margin Factor 1:1. I remember reading about the same problem with WL4, but I cannot find it on the forum right now.
profile picture

Cone

#14
15000 stocks? What exchange is that?

Where's the strategy?
profile picture

wl64bit

#15
Here is the same problem with WL4. It is described at the end of the thread.
/Forum/Posts/SimuScript-vs-Percent-of-Equity-25931
profile picture

Cone

#16
Again, we expect simulations to skip trades; they're supposed to when the Portfolio doesn't have the buying power to take on additional Position. To see always see all trades, use Raw Profit mode.

Also, especially with the use of double precision numbers (15 digits) in Version 5, a number in the range of $500,000,000,000 doesn't present any problem at all. In Version 4, it shouldn't have been a problem either, but at single precision trade values in that range could have easily lost $50K due to rounding errors.

So, please, if this is really a problem for you (it won't be for 99.99% of our clientele), please create a support ticket with all the details for further investigation.
profile picture

Eugene

#17
We found out that the issue was actually not caused by huge equity numbers.

The culprit that makes WL5 stop taking trades is the maximum value a signed 32-bit integer number can hold i.e. 2,147,483,647.

Call it a design limitation, but as of current version, plan your trade size so it won't exceed 2 billion shares/contracts.
profile picture

Cone

#18
QUOTE:
Call it a design limitation
I think we'll have to call it a "feature". My broker rejects all of my orders for more than 2 billion shares too :)
profile picture

Eugene

#19
Actually there's more to it than that.

1. There are exchanges in the world where some stocks are priced so low that the typical daily volume of a single stock is several dozen billions of shares. Having said that, buying 2 bln shares is actually possible and is not a daydream.

2. Although WL5 hits the System.Int32 limitation (+2,147,483,647) here, in my humble opinion, Fidelity could have worked around that by changing the variable type that holds quantity from int to uint. This is also a 32-bit data type which isn't "sign-aware" - on the contrast with int that ranges from -2 bln to +2 bln. If you give it a thought, the choice of integer might not be optimal because trade quantity just can not go negative (can't trade negative shares).

So, without eating up any extra memory (which is both unacceptable and unpractical) by using a long (64-bit variable that allows for really huge quantities), switching to uint could have allowed quantity to reach 4,294,967,295.
profile picture

Eugene

#20
QUOTE:
Having said that, buying 2 bln shares is actually possible and is not a daydream.

Of course, they'd have to break the order into pieces anyway ;)
profile picture

Wall

#21
There was some tongue-in-cheek discussion of this integer limit in the forums over 3 years ago; see this thread: /Forum/Posts/Data-download-from-yahoo-21518#97174
profile picture

Eugene

#22
Good point, but actually, the kind of issue you're pointing to is fixed in WL5.

AFAIR, web-based downloads were affected by the inability of storing/displaying large volume over 2 bln shares, but this is no longer an issue with WL5.
profile picture

Cone

#23
So, 2 billion shares isn't sufficient, but 4 billion is? Are we sure about that?
profile picture

Eugene

#24
If a trade takes 2 bln shares, who can bet it's not going to consume all the 4 bln and more, hitting the wall again?
profile picture

Eugene

#25
Follow-up.

While working with PosSizers, I recalled that a PosSizer's SizePosition method returns a double (not integer) value and thought about a possible workaround through the usage of a PosSizer:
CODE:
Please log in to see this code.

Sadly, this doesn't work. Returning anything over 2,147,483,647 shares from a custom PosSizer will cause the trade to be skipped. So, doubles are being internally casted to integers anyway.
profile picture

wl64bit

#26
May be there is a way to bypass that casting?
profile picture

Eugene

#27
Nope, that's hidden too deep and hence is beyond our control.
profile picture

Cone

#28
I really cannot believe this would be a problem, even for Warren Buffett. Despite what Eugene said about super-low price stocks, is attempting to trade/simulate a single order for more than 2 billion shares have any scent of realism?
profile picture

Eugene

#29
Ditto.
profile picture

wl64bit

#30
Wealth Lab Developer is a trading system development tool. It is used for testing of theoretical trading ideas, which sometimes are not realistic at all. Ultimate trading software should not limit position size to certain number of shares, just because it could be not very convenient for system development. Thus, the word “realism” does not pertain to the context.
profile picture

Cone

#31
I can appreciate the theoretical and pushing the limits, but sorry, this isn't going to change because one customer is trying to use huge numbers. The solution is simple for the one person that requires it. Scale down. Start with 1 or 2 less zeros and pretend that they're there when your your done. It will be less precise, but it shouldn't matter since realism does not pertain.

Fact: About 3.6 billion options contracts exchanged hands in all of 2009.
profile picture

wl64bit

#32
The simple solution to scale a starting capital down is not an option, since you cannot scale down beyond certain limit like $500 for example. If you scale it down to $50, the simulator will not be able to take any trades if the share price is over $50.
Another way to deal with it is to brake the testing period to two or three parts, but in this case you will have to perform more test and you goanna lose the Performance Results of the overall equity curve.
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).