Advice on Multi-day strategy systems development

Discussion in 'Automated Trading' started by bridenour, Feb 15, 2009.

  1. Ahh… I missed this other post.

    No TradeStation does not restore levels, stops, profit exit points. They assume your strategy will correctly recompute where you were at in a trade using past data.

    I would love to have the use of a database in trading software (I’m a retired Database Administrator). But I’m afraid that is years away -if ever.

    Wayne has an interesting idea using excel. I may have to take a look at that.
     
    #11     Feb 18, 2009
  2. Yes, ninja trader strategies will "recompute" what your theoretical holdings should be when you restart a strategy, but I have found that to be very ineffective if you want a strategy that manages a basket of positions. I am really looking to develop something that is more robust and reliable. Sounds like a lot of people use excel.

    I am probably going to end up developing something in CSharp using a FIX interface. Are there any packages or frameworks i can leverage to get the basics in terms of indicators, moving averages, etc? I really don't want to recreate the wheel.
     
    #12     Feb 18, 2009
  3. lindq

    lindq

    You question here is regarding InvestorRT.

    The answer is yes, so long as you save the software when you quit and restart. Obviously if you don't save the data, it can't property calculate. But you can also set up automatic saves periodically in case you have a system failure.

    Think of IRT's quote pages as like Excel spreadsheets into which you can program your various rules. Data is input as often as you like. Tick, 1 min, etc. It then tracks your rules and will initiate actions. One of those actions can be to signal when a trade is open, closed, or conditional on other factors, and send that along. Whatever you can code, the rules can look at and make a decision. It can be price levels, time, indicators, other market measures, whatever.

    If you have questions, email them at support@linnsoft.com. They are very good at response.
     
    #13     Feb 19, 2009
  4. heech

    heech

    Hi,

    I'm using NT on a multi-day strategy. And just to make it more complicated, it's a multi-day multi-symbol strategy. I currently trade about 40 symbols for anywhere from 1 week up to a calendar month.

    And you're absolutely right. It's not very well supported, and it's a problem common to all of the auto-trading tools I've looked at. It's in the mindset of the software firms that write this software... they just assumed a market of daytraders/scalpers. Those of us doing something else are slightly SOL.

    Initially, I made my approach work by making sure the re-construction of my hypothetical position always worked out correctly. It limited some of the things I could do, however... because you never *really* know what your real-world fills were. What if you "hypothetically" hit a limit order, but didn't in the real world?

    So, over the last 2-4 weeks I transitioned into a system where I'm saving all of my real-world trades externally. I'm basically skipping NT's support for Trade/Position classes, and built my own versions. When I fill an order, I save it externally. When I start my strategy up every morning, I read-in all of the existing trades and keep going.

    I'm saving my trades in Amazon's SimpleDB system, using a C# class that they provide. In hindsight, Google Data w/ spreadsheet or Base might've been a better choice.
     
    #14     Mar 7, 2009
  5. Kris

    Kris

    +1 for IRT
     
    #15     Mar 7, 2009
  6. Thanks for the responses everyone!


    Heech -- I think you hit the nail on the head, as far as what would work best for me. A solution compatible with NT would be ideal, since I'm already using it.


    The problem i have primarily encountered up to this point is NTs inability to "recalculate" open positions accurately due to differences between real time and historical data.

    A couple of questions for you:

    1) You had only been saving your positions manually for about 3-4 weeks -- how is that working out for you now? Do you still think its a good approach?

    2) You were using Amazon's service, but said you might approach it differently now. What are your current thoughts on this and what led you to believe a non-amazon approach might be better? What about a simple local DB or even file based storage?

    3) How long did it take you to move away from the built in position management features to implement your own version? Do you open a virtual position during start up while in historical mode, so that you can then manage it using the normal NT functions?

    Thanks for your feedback!

    br
     
    #16     Mar 14, 2009
  7. heech

    heech

    That was less of an issue for me previously... because I was dealing only market orders, it was very rare that my positions would be different. (Now I'm using limit orders, that's more of an issue... NT might disagree with me on whether I filled at all or not!)

    But my strategy (as it is written right now at least) is very path dependent... I look at *all* of my previous fills on a particular stock, before deciding how I want to act in the future. So that means it was always important I recreate exactly what my fills were, before. And that was the really hard part.

    Really, really happy about it. It opened up additional perks that I never even considered in advance.

    It's another tool for looking at my executions, beyond depending on NT's executions tab + the broker. I can sort/search/filter, and later on do math on slippage, etc, etc...

    And the best unexpected perk of all... before, if my code was disconnected for even 5 minutes, I could (potentially) be screwed. Historical data would tell me I should've entered/exited, but in reality.. I hadn't. So I would be left scrambling around, trying to fix my real positions to match the hypothetical.

    Now I don't have to do that. If I was disconnected and I didn't trade... no biggie. My hypothetical position will still match actual, and I'll keep going.

    (Another side perk: I had been afraid to modify my strategy heavily, because again, the historical positions would mismatch... not an issue any more.)

    I didn't want a single point of failure, which is why I didn't go with local file or local DBMS. If that computer goes down... how do I startup again? I'll have lost all of my positions.

    Now, even if my computer blows up... as long as Amazon itself doesn't blow up, I'll be able to get back up and going again.

    Amazon's service is working well enough, but it's not really designed for this sort of application. It's meant to be used for high traffic, high availbility data... one downside: it's not always internally consistent (ACID). If you do a write followed immediately by a read, you might not actually get your previous written value back. That hasn't been an issue in reality, but it's something that's always in the back of my mind.

    There's also a lack of good tools for looking at and manipulating SimpleDB data. I use something called SimpleDB Explorer, which works... but is less than ideal.

    Based on what I know now, I think I would recommend the Google Data API. They also have a C# wrapper.. you can write data into Google Base if you need to, or even better, right into a Google Docs Spreadsheet. That'd be so cool! Easy manipulation, and you can probably even setup the spreadsheet with your formulas... and just populate the cells with your trade as they happen. And there's visualization tools for Google Docs too...

    I used the built-in management features for several months. It wasn't until I decided I wanted to think about moving to limit orders that I decided I had to look for an outside version.

    The actual implementation was pretty straight-forward, probably only 3-4 days and a week of testing.

    Yep, that's exactly what I do.

    I make sure I start my strategy on a historical bar (at least two historical bars, actually). And then I read back my positions... and if I'm long, I EnterLong().

    Other than that, I return as long as I'm Historical.

    Hope that helps!
     
    #17     Mar 14, 2009
  8. Heech-

    Greatly appreciate the feedback - this addresses the exact problem I'm having. I only use market orders, but even so, with a multi-instrument, multi-day strategy, it does not rebuild the positions consistently enough to be trustworthy (may be a result of my particular entry criteria and the difference between real time and historical data).

    My original reason for purchasing NT was that I had developed and backtested a long-term equities based multi-day strategy using Amibroker, and had intended to fully automate it. Problem one that i encountered is exactly what we've been discussing, problem two is that the system generates signals based on scanning the SP500 or W1000, and I quickly discovered that NT blows up when you add more than 100-200 instruments. The approach you've outlined, at least, will address point number one. For now, I will probably generate the signals out of amibroker and then use NT to manage and open the position, to avoid the memory management limitations.


    I think, based on your advice, I will see if I can approach this in a way that I can easily wrap the persistence mechanism in a level of abstraction. That way I can start out with simpledb or Google Base or whatever, and relatively easily switch if I decided I am dissatisfied for whatever reason.

    Thanks again for the feedback and guidance...I'm actually much more comfortable developing automated swing trade systems than daytrade systems, but have been forced by the limitations of NT to focus pretty much solely on daytrade systems thus far.

    br
     
    #18     Mar 14, 2009
  9. heech

    heech

    No problem, glad I could help.

    I have a question for you now...

    ... what did this blow up look like? I'm getting to the point where my strategy is getting to the point where I'll have that many instruments, and just curious how I'll know I'll reach the limits of what NT can do... does performance degrade gradually, or will it start crashing on me?

    Right now, I have about 45 instruments, with 4 bars for each (1 min, 5 min, 10 min, 30 min)... so that means a total of 180 Add() calls. Does that mean I'm already in danger of blow up, or is it really the number of distinct instruments that's the issue?

    You probably haven't seen that exact scenario, but just curious whatever experience you might have.
     
    #19     Mar 14, 2009
  10. So, I had a strategy that basically "Scanned" all the instruments in the SP500 each day, adding a day bar and a minute bar (so up to 1000 total adds).

    Basically, during backtesting I would watch the nt process memory utilization just shoot up to 2 gigs or so pretty quickly, and the backtest would never run. I began to scale the number of symbols back to see what it could handle, and ultimately I think I was able to get it to work with about 80 - 100 symbols.

    I tried this on a couple of different computers and both demonstrated the same behavior. It's possibly if you had a heavily maxed out desktop you might get a bit more headroom, but I think that memory management of the historical data is just very poorly optimized, so I'm not sure that having more resources available on your computer would help that much.

    Even though backtesting failed, I was hopeful that i wouldn't see the same results when running the strategy live. Unfortunately, given the way NT starts up processing historical data, it ended up crashing during live testing as well (or, more accurately, never finished starting). I had some back and forth with the support guys on the forums on this point, and they basically said "yes, memory management is a problem, and it will be fixed in version 7." I think that may be their default answer though, so I'm not holding my breath that it will actually be fixed.

    In short, I would guess you are probably near the threshold, but you will definitely see the problem during backtesting if you do add too many instruments. You can also just watch the memory consumption of the NT process to see where you currently stand -- seems to me once all of your available memory is consumed you are basically screwed (swapping seems to not work), so you should be able to get a sense of how close you are that way. Also, I only had two gigs on my desktop, so it would be interesting to see what might happen if you had, say, 4 gigs available.
     
    #20     Mar 15, 2009