Running out of cash using Override mode
Author: flroots
Creation Date: 6/29/2014 7:31 AM
profile picture

flroots

#1
I'm using SetShareSize() in Override mode so that I can control the percent of equity on each buy/sell. My strategy rebalances between a stock ETF and bond ETF. I'm always fully invested. It seems I have to sell all ETF positions and then buy back the desired ratio of stock and bond ETFs (ie, there's no way to sell a portion of a position). Before I sell, I must calculate the current equity so that I know how much I can afford to re-purchase. Not sure of the most efficient way to calculate existing equity. Right now I use the following function:
CODE:
Please log in to see this code.

The problem is that I have to specify more starting capital then my code uses. For example, I start out in code with $100,000, but I have to set the Override capital to 105,000. If I don't I get a warning that some trades were not executed. Can't figure out why? I do issue debug statements and I'm always selling and buying less than 100,000. Any hints on what I may be doing wrong?
profile picture

Eugene

#2
In Portfolio Simulation mode (to which Override mode belongs), there may be not enough capital to execute a trade. The reason behind it is called "basis price" and is documented in the Wealth-Lab User Guide, Strategy Window > Backtesting Strategies > 100% of Equity Sizing.

Using MS123 PosSizer Library, it's possible to automatically adjust the number of shares to work around the difference of basis price vs. next open. The "Skipped trade solution" applies to AtMarket orders exclusively (i.e. it won't work for AtClose orders). If you wish to install this or any other extension, please create a support ticket for account verification.

Another possible workaround for skipped signals is to set a Margin Factor slightly greater than 1:1 e.g. 1.05:1.
profile picture

flroots

#3
Thanks Eugene. Your reference to the User Guide was very helpful. I got things working in two different ways:
1. Set margin rate to a minimum of 1.06:1
2. When rebalancing SellAtClose[bar] and buy at BuyAtClose[bar+1] with margin basis = 1:1

The 2nd option was based upon the writeup which said the basis price for an 'AtClose' order is the Closing price which seems to eliminate the problem.

You've sure helped me jump a few hurdles. Thanks again.

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).