Platform to backtest and run a ranking or rotational stock strategy

Discussion in 'Automated Trading' started by Moptop, Aug 10, 2021.

  1. Moptop

    Moptop

    I've been reading about ranking strategies by guys like Alvarez, Clenow, and Radge, but I don't know a good platform to run a strategy like that, it seems like Amibroker maybe one that can do it or using python.

    A strategy like this would have a set of criteria or indicators and run them once a week or once a month (for example) on a basket of stocks like the SP500 and buy the top 10 according to the rankings. I'm kind of a novice and have been automating and backtesting strategies with Trade Navigator but it doesn't seem to have the ability to backtest a basket of stocks for a ranking or rotational strategy. Help!
     
  2. fan27

    fan27

    Amibroker can do it. Tickblaze can do it (I know Tickblaze has strategies that come pre-built with the application that can rank stocks and trade the top ones).
     
    Moptop likes this.
  3. What a coincidence. A few weeks ago I wrote my own software to get historical data on about 150 stocks, calculate a ranking of these stocks for each date, and open/close positions in the top x (x ranging from 5 to 50) at the end of each day. All in all it took me about 2 or 3 days to write this in Java. My message: don't waste too much time searching for an existing platform. You could be having results quicker if you just write the software from scratch. Additional benefit: you can tailor the simulation results exactly how you want to have it represented.
     
  4. jharmon

    jharmon

    What you're talking about is a basic momentum strategy.

    Portfolio backtesting adds a level of complexity that many backtesting packages don't handle (or don't handle well).

    I've used all of the following (and have several others I've used too).

    The following can do handle it out-of-the-box (of course, you'll need to write the rules for rebalancing etc.):
    Amibroker - has a few quirks, but still very good
    Python/Zipline can do it too
    Python/Backtrader - a little harder, but can do it with a fair bit of programming
    R/backtest/quantstrat - requires a fir bit of programming,
    R/Python - no pre-packaged engine (self-written) - even more programming.
    Real Test by Marsten Parker (just got this recently - it's _really_ fast)

    There are others that just can't do it - anything with single-security backtests are obvious but other portfolio backtesting software have significant limtations (Metastock, Ninajtrader).

    The bigger issue is the data - make sure the data you're using doesn't have survivorship bias and you have the ability to incorporate it into your backtesting app.

    It's no good backtesting using today's S&P 500 - it's be like having a crystal ball some time in the past to tell the future's top 500 stocks and give you completely unrealistic results.
     
  5. traider

    traider

    What about quantconnect? I find it hard to deploy zipline if you are not an expert in python.
    Why do you find backtrader harder?
     
  6. As already mentioned, you want to pay for premium data with historical constituents to avoid survivorship bias, Norgate Data.

    RealTest is best and I'd recommend you start there. It's easier and more fun. AmiBroker is also good. Norgate Data hooks into these two nicely. Stay away from the Python stuff, the cloud stuff, and rolling your own.

    Btw:
    • Alvarez: Norgate Data + AmiBroker
    • Clenow: Norgate Data + RightEdge
    • Radge: Norgate Data + AmiBroker
     
    Last edited: Aug 11, 2021
    NorgateData likes this.
  7. jharmon

    jharmon

    Quantconnect looks interesting (well, at least the LEAN environment does). I'm not a fan of uploading my trading systems into the cloud despite assurances that "all is secure" etc. and the "pay per symbol". The last time I looked they used a weird data sampling mechanism (the close price wasn't the actual close), so I'd really want to ingest data that I prefer. I'd have to see if the platform offered me any new advantages though.

    Zipline has become a bit painful to install since Quantopian ghosted their community. Thankfully there are some keeping it running - I now use zipline-reloaded. https://github.com/stefan-jansen/zipline-reloaded

    Backtrader was harder because of various items you had to "implement yourself" such as a backtesting on disparate data sets, forcing exits on delisted positions etc.

    Python allows all sorts of new ways of looking at data - such as Machine Learning algos. On its own, Python it is super slow but the packages that provide the ML framework (tensorflow etc.) - I've been going down this path after watching Howard Bandy present on this last year - still learning. Python does provide an easy way to program-on-the-fly and useful for those times when you just want to do a proof-of-concept and quickly test an idea too.

    Agree on Norgate for daily data and hooks - they're part of why Zipline can be used. I have to jump through hoops to preprocess other data.
     
    NorgateData likes this.
  8. sef88

    sef88

    It may be tough to put a zipline framework into production without a platform such as Quantconnect. It may be also tricky to store backtested parameters in personal databases.

    Also, I'm unsure if tensorflow is appropiate. It's cool to test all the ML algorithms. But when money is on the line, that's a different story.
     
  9. jharmon

    jharmon

    Sef88, what a weird post. You really didn't add anything to the conversation.

    Tough? Not at all. Each day, Zipline ingest and test, I write out any new orders to a Basket File for IB TWS. It's simple.

    Nonsense. The parameters are in my code.

    Tensorflow is just a framework. Perhaps it's "not appropriate" for you. Like anything in life, you need to be prepared to put in the time to learn and achieve a level of competence in any given field. I'm talking several man-months of time here at a minimum.

    It's not "cool" - it's my job. My money is on the line - that's the whole point, and adding disparate trading systems running simultaneously is my goal to complement what already runs.
     
  10. Moptop

    Moptop

    thanks. I was looking at RealTest. It seems to have its own language, I’d it hard to learn?
     
    #10     Aug 14, 2021