Thanks for the earlier posts on the subject of how to write backtest
programs to characterize the price action of a Market. I would like
to get a better understanding for different ETF's the results of holding
positions just during the day (Buy Open and Sell Close) versus a
Buy and Hold strategy holding a position overnight. However, I have
encountered a problem with the backtesting which I would like to describe
and get feedback on. First here is the program I am using
CODE:
Please log in to see this code.
Since I am just trying to characterizing ETF Price action and not
designing a trading system I set the following settings in Preferences
No Commmissions Applied
No Activation of Slippage
No Selection of Round Lots
I also used the Backtest Raw Profit Mode with a Fixed Dollar amount
of $100,000. The objective was to compare the performance of the
ETF's SPY (1X S&P500) versus SSO (2X leverage of S&P500). The Data
Range I selected was 12/31/08 to 5/1/09. When running the program
I was very surprised to see that the first trade on 1/2/09 for
both ETF's was for an amount greater than $100,000.
SPY trade on 1/2/09 Open was 1108 Shares at 90.44 = $100,207
SSO trade on 1/2/09 Open was 3796 Shares at 26.56 = $100,821
The fact that the total amount invested for each ETF was so different
($100,821 - $100,207 = $614) also reduces the accuracy of comparison testing.
I was expecting a first entry purchase of the following ammounts
SPY expected position size = $100,000/90.44 = 1105 shares (Total = $99,936)
SSO expected position size = $100,000/26.56 = 3765 shares (Total = $99,998)
This leads to my main question. Is there a way via either code or Preference
settings to run a Backtest where the number of shares purchased is the maximum
that can be purchased without exceeding the available cash?
I tried working around this problem using the Portfolio Simulated Mode
using $100,000 of Capital and selecting a Percent of Equity = 50% to avoid
missing trades. However, the number of shares on the first trade exceeded
$50,000 and again the total dollar amounts differed significantly for the ETF's.