Chabah on Automated Trading

Discussion in 'Automated Trading' started by Chabah, Oct 2, 2006.

  1. Thanks Chabah for clearing it up.

    I thought either it's what you said or that you had used data on 4k different issues.


    What software are you using to run the test?
     
    #51     Oct 16, 2006
  2. Chabah

    Chabah

    We used my buddy's custom TradeStation strategy.

    My TradeStation learning has been going pretty well. I entered the position sizing function from Professional Stock Trading, and the EasyLanguage editor is pretty nice. It shows you the keywords in the language as you type so it is easy to spot typos. I may test it a bit soon with some array processing but it looks promising.

    OK, time for some weekend reading. We'll go from a little bit more theory to some pseudo-coding. Next week we should start having some actual TradeStation strategies to discuss. I won't post anything straight out of the book for copyright reasons, but anything I code can and (mostly) will be shared.

    Chabah
     
    #52     Oct 20, 2006
  3. Chabah

    Chabah

    Please excuse the formatting - the bullets are one level deep and the little o's are two levels deep.
    _______________________________________________

    The Language of Models

    Models interact with their strategic components to make trading decisions. Communication between the Model and the components is conducted through function calls. Strategies “signal” the Model, while the Model “polls” strategies. The Model serves as the final aggregator and processor of information; therefore, information is not simplified before being sent to the Model. A general “rating” is a return value from 0-100, where 100 indicates perfect agreement or confidence, 50 indicates no opinion or confidence, and 0 indicates an explicit disagreement or lack of confidence.

    Polling Functions:

    • Confidence(symbol): Queries a Research strategy to test the input
    • RiskReward(symbol): Queries a Research strategy to provide a risk/reward ratio
    • PositionSize(symbol, initial stop, priority): Queries an Entry strategy to provide a position size
    • CloseRating(position): Queries an Unwinding strategy to test the nearness to closing a portion of the position
    • Check(position): Processes a position against the Checklist rules
    • Filter(position): Processes a position against the Filters


    Model Processing

    Each model has a time specific time frame and executes the main processing loop on the end of the respective time bar. The high level processing loop is as follows:

    • Clear Orders – Updates the Orders and Positions tables based on bar results
    • Evaluate Positions – Determines if current positions should be unwound
    • Process Signals – Processes Signals to create pending Positions
    • Filter Positions – Processes pending Positions against Filters
    • Position Checklist – Processes pending Positions against Checklist
    • Place Orders – Generates and places Orders
    • Log Activity – Logs all activity for the bar
    • Clear Tables – Clears closed, aborted, and cancelled entries in the tables

    Clear Orders
    This function updates the Model variables based on the results of the last bar, including the orders that were filled:

    • For each Order executed:
    o Mark pending Order as executed or cancelled
    o Mark Position as open, cancelled, or closed
    • Update Available Capital and Cash Available variables

    Evaluate Positions
    This function examines all open positions to evaluate if they should be unwound.

    • For each open Position:
    o Poll Research Strategies to derive a new Adjusted Confidence, Risk/Reward, and Timeline values
    o Poll Unwinding Strategies to determine Sell rating
    o Call specific Unwinding Strategy to create Orders

    Process Signals
    This function processes the Signals table to determine which should become orders. This section may contain a significant amount of custom code. The basic structure is:

    • Combine/Update/Cancel signals for the same symbol
    • For each Signal
    o Poll Research Strategies to derive Adjusted Confidence, Risk/Reward, and Timeline values
    • Assign Priority ratings to each Signal
    • Rank Signals based on Model-specific criteria
    • Determine which Signals to use for new Orders (mark as pending)
    • Call Entry Strategy to create pending Positions
    • Mark processed Signals

    Filter Positions
    This function executes the Filter strategies against each pending Position, marking them as aborted or adjusting the position size as indicated.

    Position Checklist
    This function executes the Checklist strategies against each pending Position

    • For each pending Position
    o Execute Checklist
    o Update Position variables or mark aborted
    o If variables changed, repeat Checklist

    Place Orders
    This function submits the Pending orders to the brokerage.

    • For each pending Position
    o Create Order
    o Place Order
    o Mark Order as pending
    o Mark Position as ordered

    Log Activity
    Each function should log its own actions for review and analysis. The Log Activity process step writes a complete record of the Model status, including all variables and the contents of each table.

    Clear Tables
    This function is executed manually, not on each bar. This function processes the Signals, Positions, and Orders tables, removing closed, aborted, or cancelled entries.

    ____________________________________________

    This doesn't fit precisely into TradeStation, but I think the importance lies in the logical progression through each phase of processing. Each step is simple yet in combination they become powerful. One thing I haven't covered yet is how we define our stock universe for the Model - that is something I haven't figured out yet.

    Enjoy,

    Chabah
     
    #53     Oct 20, 2006
  4. Chabah

    Chabah

    I entered the Acme R (Rectangle Breakout) and Trade Manager systems, along with all their supporting functions, into TradeStation over the weekend. I was able to backtest the system over several stocks and time periods and was pretty surprised by what I found.

    My preliminary indication is that the system seems to work best in one particular direction for a stock, with the other direction breaking even. Also, each stock seems to have a happiest timeframe, with most working well with 60 minute bars while a few prefer shorter timeframes. Longer timeframes seem to generate too few trades, although I will have to tweak some of the parameters to see if I can generate more trades on longer time periods.

    I did not do any optimization.

    Here the the highlights:

    GOOG, 60 minute, 2 years, SHORT, 2.05 Profit Factor (1.8 with commissions)

    AAPL, 60 minute, 2 years, SHORT, 1.29 PF w/ commissions(I have too say this strategy does not suit AAPL)

    XMSR, 60 minute, 2 years, SHORT, 1.38 PF (1.15 with commissions)

    HANS, 15 minute, 5 years, SHORT, 1.32 PF w/ commissions

    HPQ, 60 minute, 5 year, LONG, 4.2 PF (WOW)

    AMZN, 60 minute, 4 year, SHORT, 3.8 PF

    EBAY, 60 minute, 5 year, SHORT, 1.57 PF

    Note that this strategy does not produce that many trades, so it will certainly need to be used in combination with other strategies.

    More to come.

    Chabah
     
    #54     Oct 22, 2006
  5. Chabah

    Chabah

    Yesterday I got the Acme M System coded, using my modified position sizing algorithm. The main difference is that my algorithm won't return more than you can afford based on the Equity input. It also rounds to the nearest 5 shares instead of 100 shares. I'll post it next time I have TradeStation up.

    As for the Acme M System, it definitely does not produce many signals, especially in the default setting. However, for certain situations, it is a really powerful strategy. I tested about 100 different stocks using daily charts, and a couple really stood out.

    The strategy absolutely crushes the SPY for some reason, going 12-3 over the last 5 years and 23-7 over the last 10. Obviously that is not a lot of trades so this is a complimentary system. The gains were very solid though (PF over 7).

    It also does a great job on INTL, although the performance is limited by the Acme Trade Manager. A little optimization there can really juice the returns, but in general I am trying not to over-optimize. The 5-year record on INTL was 10-0 for a 100% win rate and Sharpe Ratio over 1.0.

    A couple stocks absolutely killed the strategy, including WFMI (0-6), MSFT (0-6), and AMED. Quite a few stocks had perfect records but only 2 or 3 trades, so I didn't count those results as significant.

    I definitely see some room for expansion and adjustment in the system, but it is good to have for now. I plan to use it for daily signals for the few stocks that it really dominates.

    Enjoy,

    Chabah
     
    #55     Oct 24, 2006
  6. Chabah

    Chabah

    Yesterday I coded the Acme F system, which is a Float Channel Breakout and Pullback system. The initial tests on AAPL, COH, and GOOG look very promising, providing a very high win rate and huge profit factor. The RINA scores were over 1600, although I don't really understand that indicator :D

    One pain with the system is that you have to manually enter all the float numbers. I know the book was published in 2002, so if this part has been automated somehow, please let me know. The continuing maintenance on the float during stock buybacks and splits and such could be a problem if I can't automate it.

    In terms of manual/visual trading I used the consolidation and rectangle breakout to hit on COH pretty well yesterday and this morning for a nice 2.5% gain. Fun but I definitely want to stick to automated trading - staring at charts is time consuming.

    More to come.

    Chabah
     
    #56     Oct 25, 2006
  7. Quick post.

    You're doing a heck-of-a-lot of work here.

    Be sure to keep all of the relevant stats for each parameter (STOPS, PROFIT TAKING, TYPE OF TRADE, etc.) of your system, this will give you a pretty good benchmark for the overall average system performance as well as the individual stats for each category.

    Keeping tabs on them will:

    a) tell you when your system is outperforming

    b) tell you when your system(s) is right on track

    c) most importantly, tell you when a technique or method is underperforming, and you might need to do some tweaking.

    Regards,

    JJ
     
    #57     Oct 25, 2006
  8. Chabah

    Chabah

    Thanks JJ, I definitely plan to keep a trade log. The analysis you are referring to is covered pretty well in that arcary forum, and I plan to do the same sort of analysis to measure system performance. Turning off a system when you hit your maximum theoretical drawdown is a start, along with all the other analysis you can do to measure correlation and such.

    Back to the Acme system, I should mention that most of the system code is on the TradeStation forums, so it is not necessary to type it in if you have TS. I like typing it in because it ensures I review all the code and have improved understanding of what is happening.

    I entered a bunch more floats last night and ran the Acme F. It is profitable on a fair number of them, but certainly not 3-for-3 like my first night of testing. I just happened to randomly pick three very good candidates.

    Again, COH (Coach) is the big winner. It is strange that this one stock seems to fit the Acme systems so well. I have it set up on daily and 90-minute charts. The record on the daily over 5 years is 33-9 and the 90-minute is 17-2-2. Very high RINA, although the Sharpe doesn't look good because they are barely in the market (3% of the time). That's great though because it means I can mix those trades in with other systems without sucking up the funds.

    By comparision, a winning system on INTL was in the market 10% of the time.

    More to come. Enjoy,

    Chabah
     
    #58     Oct 26, 2006
  9. Assuming you go both long and short, are there any times you may not be able to get short at your system prices because of uptick rule.
     
    #59     Oct 26, 2006
  10. BDGBDG

    BDGBDG

    Interesting thread. Keep up the hardwork, and you'll be profitable beyond your wildest dreams.
     
    #60     Oct 26, 2006