Chabah on Automated Trading Redux

Discussion in 'Automated Trading' started by Chabah, Jan 8, 2010.

  1. Chabah

    Chabah

    Got a ton of function coding done last night. Regarding the previous post, I have changed my Direction indicator from a text value ("Long", "Short") to +1/-1, just like MarketPosition. This shortens the test above to "if Direction = MarketPosition" which is more compact and familiar to EL coders (as opposed to readers who don't know EL).

    Account is funded now, so I'll be debugging the functions and posting them over the next week or so. One tenet of Agile programming is the use of automated testing tools, so I'll share some simple automated testing methods. It's one thing to know your code compiles and something else to know it will do exactly what you want (or at least to understand exactly what it will do).

    Good times,

    Damien
     
    #31     Feb 5, 2010
  2. Chabah

    Chabah

    #32     Feb 5, 2010
  3. Chabah

    Chabah

    I found something I've been looking for - a way to verify that a strategy matches an actual position. This of course only works if the only trades being made are automated through the strategy - if you try to manually trade the same symbol this function will close out your position anytime you call it.

    The GetPositionQuantity function is reportedly a processor hog, so this function only calls it if CurrentShares is nonzero. This leaves a pretty big hole for instances where your actual position is NOT closed, but the strategy is closed. I plan to have a version of this that runs only on the first and last bar of the day that also checks that condition to ensure closed positions are really closed. Performance testing may also show that calling GetPositionQuantity on every bar is just fine.

    Here is the code, again for illustration as it is not compiled or tested yet.

    dzd_sg_ValidatePos { Closes a position if the actual shares don't match the strategy }

    Variables:
    ActualShares (0);

    if CurrentShares > 0 then begin
    ActualShares = GetPositionQuantity (GetSymbolName, GetAccountID) ; { save processing by only calling when necessary}
    if ActualShares <> 0 and {careful about dividing by zero }
    (CurrentShares * MarketPosition) / ActualShares <> 1 then
    dzd_sg_ClosePos ; { just close, because trying to adjust by delta will not cure misalignment }
    end;
    dzd_sg_ValidatePos = 0;


    Enjoy,

    Damien
     
    #33     Feb 7, 2010
  4. Chabah

    Chabah

    I'm doing some option analysis. I don't see a good way to automate option strategies yet, but perhaps something will coalesce after further analysis. My plan is to dedicate a small percentage of my portfolio, perhaps 5% or 10%, to high reward option strategies. On initial inspection AAPL out of the money calls for next January look pretty good, but I am still running numbers. On the contrary, inverse treasury (TBT) options don't have a very nice return, as the out of money options seem quite expensive (maybe a lot of people are bearish on treasuries?).

    So this is a little break from strict automation, but pertinent to my overall strategies. It may end up that for stocks I like I'll use options if they are priced right, otherwise use automated strategies on the stocks. Likewise for shorts.

    I'm also looking at the options to implement portfolio insurance. The set-up there is to have two windows, one for the stock w/ automated strategy, a second with a selection option for the same issue (or two if the strategy trades both long and short). At the end of the day, the option strategy would query the stock strategy to determine exposure, then check the system setting for maximum exposure. If necessary, it would open an insurance position in case of market disaster. I'm not sure when this position would be closed.

    That's the general outline. Any ideas?

    By the way, I should receive Dynamic Hedging any day now. I have that queued up after The Black Swan. Hopefully that will shed some light on strategies.

    Damien
     
    #34     Feb 8, 2010
  5. How are you processing price feeds?

    Are you verifying your Broker supplied feed against any 3rd party feed?
    ie IB e-signal


    Are you filtering ticks?
    Rules based ie.
    Ask > bid and bid > 0 and
    bid size > 1 and
    ask size > 1
    Latency < 100 ms

    Consider building an "Executable" feed off of level II:
    Just Calculating the Bid/ask to fill a fixed order size ie. 10 lots.
    Will give you a much different price action foot print.

    What frequency are you processing data updates?
    What time is required to place and verify orders?
    What kinds of orders do you intend to use?

    Food for thought.
     
    #35     Feb 8, 2010
  6. Chabah

    Chabah

    PocketChange,

    My strategies aren't very dependent on the details you mentioned. I prefer strategies that trade infrequently - an ideal case would be catching a trending stock as it crosses the 50 day MA and then following it (adjusting stops) for a couple months (e.g. lots of stocks at the end of 2009). Likewise on the short side, I'd be looking at long term opportunities. In these cases most orders are Market, with a few Stops and perhaps the occasional Limit order as a matter tactics (e.g. to limit overtrading around inflection points).

    For timeframe, I will probably use 15 or 30 minute charts. This gives an adequate amount of time to make manual adjustments during the last bar while being tight enough to keep the market from running away. I plan to keep stop orders on the server so that my exits aren't always on the end of a bar.

    Again keep in mind that my expertise is programming, not stock strategies. Therefore I use pretty simple strategies. If you look back at my Dying Company attachment, that gives a pretty good idea (keep in mind that is an example, not something I've traded).

    Based on the experiences of friends, I think the TradeStation data is reliable, at least on a 15 or 30 minute timeframe. So I don't plan to verify with another broker (though I do some manual research using other online sources, e.g. Yahoo, Google).

    Thanks for posting, and I will give some thought as to whether those pieces of information are relevant to my trading.

    Damien
     
    #36     Feb 9, 2010
  7. For your time frames processing high frequency data has little value.
     
    #37     Feb 9, 2010
  8. Hey guys,
    I've been reviewing Forex trading software for quite some time too,
    nevertheless, I didn't found many forex robots that were adecuate for
    me.
    Eventually, I started to run out of money to throw to the different
    forex robots and see which one was for real (in order to give it
    serious
    money to manage). Nevertheless, a year ago or so I found this site
    http://www.forex-robots.com; they were doing forex robots test on
    Real Money accounts and sharing their results for free.
    Since then, I don't have to try every EA with my money to see which
    one is worth something, I just follow their results and settings
    without
    paying for anything.
    I would definetely recommend you to check it guys, I've been doing
    quite
    well on Forex since.
    Rgds

    Dennis
     
    #38     Feb 10, 2010
  9. Chabah

    Chabah

    Thanks for the completely irrelevant post. I'm not trading Forex or using other people's robots.

    Most of the system functions are coded now, and I don't want to go too much further before I can compile and test things in the actual platform. Access there is still another 10 days or so away, unfortunately.

    In the meantime I am continuing with The Black Swan. I can't think of a book that I was reading as aggressively taking this long to finish. Maybe Atlas Shrugged 19 years ago. For having almost no numbers this is a dense book. I doubt that most people who read it really read it - especially the "required reading" set on Wall Street. This is actually a good thing.

    I am also doing some strategy work. My stock strategies are pretty simple - I plan to start with versions of Dying Company, Fad Follower, and a 50 Day Moving Average system with long and short biases (controlled by how we act around inflection points). Those will be coded using the decision matrix I posted earlier.

    Interesting point, I was inspired to create the Decision Matrix after doing some big Excel craziness to implement targeted marketing at my full time job. I developed it for stock trading. Lo and behold, I found a new application for the same logic back at work. So my two activities feed each other. It's fun when that happens.

    Since those systems are pretty simple and just need to be played around with on actual charts (on the platform), I am working on options strategies. Wow, this is a complicated area. I am trying to come up with my approach rather than get locked into conventional wisdom. Most of the strategies I read sound "effing retarded" to coin a phrase :) so I don't mind skipping them.

    One thing I have noticed is that certain stocks have much better option payoffs than others. Also, calls seem to be a lot better than puts on the stocks I've looked at (AAPL, LULU, SBUX). So the first decision for any stock is whether to go the option route or the stock route. While I don't like puts as much as calls, I do like them better than pure shorts, so I probably will use them in my Dying Company strategy and perhaps in the Fad Follower.

    The other aspect of options is betting on unlikely events, sort of collecting lottery tickets that can only pay off big. Obviously I am not the first one to think of this, but I like working through things on my own. My efforts there include coming up with a list of world events that I will need to model through options and then evaluate for good "ticket" prices. These include (in no particular order):

    - Israel attack/war (oil, Israeli stocks)
    - Hyperinflation
    - Housing crash (phase II)
    - US debt default
    - China currency devaluation
    - European Union currency break/dissolution
    - Apple more than double in price
    - Google Breakup
    - Doomed companies: BBI, NYT, other papers
    - Fedex Unionization
    - GM/Chevy bankruptcies

    The idea with these is that the payoff if the event happens needs to be really high, like 50-1 or so. Not so much for Doomed Companies - 100% there would be good.

    So that's what's up.

    Damien
     
    #39     Feb 10, 2010
  10. I am just curious.. You like the Taleb opus that much (which says - all the statistical based analysis is rubbish) and in the same way you put your 401K money into a system based on conventional statistical TA tools (those tools - in the whole world the only few polar bears and the blind panda from China didnt try them to automate money making)...

    Am I getting it right?
     
    #40     Feb 13, 2010