Customized Trade Algos

For over a couple years now I have been a beta-tester with Quantopian. They do TA backtesting. The platform signup and all backtesting is free. Their data starts in 2002, minute bars or price and volume, and you can share/clone algos if you like. They have nifty ways of simulating realiastic fill prices and volume. They are linked to IB and I think when I looked into live automated trading it was $150 per month or something like that. Flat rate regardless of portfolio size and on top of that just your standard IB brokerage + commission fees.

So this got me thinking that a platform like that and P123 is a match made in heaven. I am thinking that there is a huge amount of alpha left on the table for the taking.

So P123 gets daily re-ranking. We build a model and test it with daily data using open + slip, daily hi/low, etc. etc. Then our trade list is fed into Quantopian without execution prices, just the list of stocks to be traded on those days (or possilby throught the week if using weekly re-ranking). From there we have a playground of intra-week or intra-day algos to backtest to see if we can squeeze more returns with intelligent intraday algos. Also, we could have a very realistic view of slippage based on capital being traded. But here is the real kicker…

What if we could use Quantopians pricing data to synthetically update ranking systems intra-day? You have a mean-reversion system that buys pullbacks. Maybe you have a few short-term TA indicators in your ranking system. So a buy is triggered based on Friday’s closing price - but is Monday’s open still a buy? What about at 11am? Just before the close? Is Tuesday a better buy than Monday? Now you can buy throughout the day at exactly the point in time that the stock ranks are highest.

This has many applications. For instance, perhaps you want a portfolio of 20 stocks which is rank=>98 in the Russell 1000. You sell as ranks go below 95. But what if instead you selected stocks ranked greater than 99.5 (keep your sell rank the same), which means you only buy the top 5 ranked stocks at first - and then as soon as a new stock makes the top 5 you buy it until you have 20 stocks. Even with weekly re-ranking of P123, we have a synthetic intra-day re-ranking system that allows for some pretty interesting portfolio strategies. P123 becomes the cornerstone of the strategy while Quantopian partners up to be the trading execution platform.

There are algos in there that allow you to go long/short and it will even ensure the $ amounts are balanced as you accumulate or distribute…all kinds of stuff. You need to know Python programming language though.

Any thoughts on this?

I think marrying P123 with Quantopia would be very unique and open up new opportunities for P123. I’m not sure about the intraday rankings though. Price is a leading indicator with P123 financials trailing. Could end up being a problem as you are no longer looking at value situations but end up buying into companies with serious issues.
Steve

Steve,
Good point. I meant to say that factors or ratios - such as current dividend yield or EV could be recalculated using select intra-day pricing instead of yesterdays close (or previous week Friday’s) closing price. Daily re-ranking is on its way but this would even give a little more edge than that. It would still be P123s ranking system as we have now - but with fine-tuned ratios that are current. We have a true point in time ranking score at the time of buying/selling.

Not sure about intra-day, it’s hard enough to make end-of-day as realistic as possible. But let’s assume Quantopian did a good job, what you are proposing is marrying ranking with tic data rebalances.

Let’s call it 5-min data for simplicity. So a 5Y backtest would be

(7h * 60min / 5min) = 84 rebalances/day

84rebalances * 251 bars * 5Y = 105,420 rebalances for a 5Y backtest

Currently a 5Y weekly backtest takes ~7 seconds for 52 weeks * 5 Years = 260 rebalances

Therefore a 5Y 5-min backtest with our current hardware would take 105,420/260 * 7 sec = 2,838 sec = 47 min

We’d have to increase our computational capacity 10 fold to get us down to 5 min sims. It’s doable of course, 11 servers would become 110 servers, but that is a serious server room.

But… Interactive Brokers would love it! :slight_smile:

I am not suggesting we go that far. Quantopian already does minute bar backtesting from 2002 onward. We need to create a trade list python can read and feed it into their system. Instead of Quantopian screening among thousands of stocks it already knows the exact ones to trade and which days to do so. So their servers are not even that taxed at this point. We use their servers to generate trade data based on their community of algorithm builders and export that data back to P123. Even keep our ranking weekly to give their algos a full week to trade the product and give us the best average fill price. We don’t need intraday reranking for this. We get a pretty awesome service and the Quantopian community has a group of investors willing to lease their algo, and the upside us we generate the stock picks and general time frame to trade.

I guess I was thinking more about live trading with the reranking feature than doing a massive back tests with one minute bars. If we matched reversion algos to reversion P123 models and momentum algos to momentum models we should be alright without the reranking though.

I was thinking more about this…what we need is to have Quantopian take their top algos and run it across every stock in the Russell 3000 universe over the past 10 years and provide us with a big database of fill prices for each algo. They are not handing us average daily fill prices based on their algos - so no issue with their data vendor.

Sims would have the option of using a variety of simulated fill prices. If we like the algo - we can lease it. Our orders run from P123 to Quantopian to IB. An extra leg for the algo execution (which they already have).

The algo could have various levels of aggressiveness for filling:

1 day fill prices (run at 10% turn, 20% turn and 30% turn of stock)
2 - 5 day fill prices (run at 10% daily turn of stock)
Execute in first hour of trading
Execute in first and last hour of trading

This won’t take any extra computing power by P123 other than integrating a database of fill prices. We could run a pilot project with on simple algo to start to work out the bugs. The benefit is that we will have excellent information on slippage including bid/ask spread and how trading volume affects performance. We will have the ability to test multiple day accumulation and distribution of stock or buy at the open. This shouldn’t add any extra burden on the P123 servers and will make the P123 platform the ‘go to guy’ for not only model development but precision execution of strategies.

The other perk is that we can also lease our ranking systems (or the PIT top 100 stocks list for each ranking system) to the Quantopian community.

Kurtis - I think you have too much time on your hands :slight_smile:

Kurtis,

which realistic performance (traded, not backtested!) have good Quantopian algos in the long run (10 years at least)? I have not yet seen purely technical systems, which have been traded profitably for 10 years (and if they are profitable, is this only coincidentally (see older thread with Olikea)?). I only see small avg. returns / trade, which makes them difficult to trade, and often adventurous levarages, which is necessary to reach competitive performances.

Sharing strategies (ranks e.g., even more technical algos) with many others means diluting the performance.

Matthias

I am not suggesting we use technical abosolute return systems. All we get is an execution algo for the day(s) we want to trade. Your P123 model currently enters the fill price based on average of hi plus low. But will you get that when trading? Is there a simple algo that will improve execution prices either through intra-day timing or by managing slippage? IB has algos to use such as VWAP or better - and others. Why not have more than these - and have the ability to backtest as to whether these algos really help or harm us?

To be clear, Quantopian users have no access to our models. They are desingers which we simply use their algos to improve our fill prices the day(s) of trading.

The only thing we would notice in P123 is that in the ‘transaction price’ drop-down box in a P123 sim would have more options instead of open or close or avg of hi and low. We could add the fill price as Mondays VWAP or Mondays ‘accumulate on dips’ or Monday’s first hour VWAP or whatever. And you could use it in live trading as well.

We are simply outsourcing a portion of P123 that we don’t have data for - and a gaping hole which could provide a lot of additional alpha - particularly in high turn systems. We have realistic fill prices and knowledge of which trading practices help us and which harm us.

Thank you, Kurtis, for the quick answer.

Nothing against additional options for trade execution, if the price performance ratio is clearly advantageous (no price is best [;)] ).

Matthias

Kurtis - I believe there would be a lot of problems with this approach. First off, is their Russell3000 Universe historically correct? Second, it won’t match P123’s PRussell3000 which is an estimation. There will be significant effort in trying to match up symbols i.e. P123s standard for defunct stocks XXX^09.

This also makes the assumption that intraday trade algorithms have the same entry and exit goals that a buy and hold system would have. This is probably not correct. Intraday systems are trying to make a quick turn profit, whereas P123 systems want the lowest cost of entry for holding at least a week. P123 could go to a lot of effort only to find out there is no significant advantage.

There is also the assumption that these algorithms trade each stock every day. I would think that the Quantopian algorithms are very selective about trades especially if they have 3000 stocks to choose from. These algos may not trade specific stocks for days at a time (I have no knowledge of Quantopia - I’m only speculating). It also isn’t clear to me how some of your suggested strategies (such as buying 20% per day) fit in with the concept of P123. i.e. how do you coordinate buying and selling simultaneously.

Then there are the business and legal aspects. P123 has spent a lot of time/resources developing Trade. Where is the future of Trade given this approach? Are there enough P123 users to justify going down this path? What is the benefit to Quantopia in the initial phase? If P123 discovers an algo that dramatically improves P123 results then what is to stop P123 from implementing their own real-time platform by expanding Trade. Who has legal ownership of the algos?

Anyways, there are at least 100 feature requests I’d like to see implemented before adding this sort of functionality.

Steve

Steve,

Sorry - I probably was unclear.

They have a point in time database so no issue there. They can do the top 3500 mcap stocks to be sure we have the same list. I think re-naming delisted stocks shouldn’t be too tough for a programmer.

I am not suggesting that we use intra-day trading systems at all - just an advanced order type to buy or sell. Currently we buy with a limit order. IB has various algos to buy or sell throughout the course of a day to get better fill prices - supposedly.
https://www.interactivebrokers.com/en/index.php?f=4985
Wouldn’t it be nice if you could select the ‘IB VWAP algo’ as a Monday fill price in your sims to know if there is any benefit to doing so?

For instance, our sims assume average of hi and low. But what does that mean? When the market opens - how do you know what the high and low is for the day? This creates a problem…do you trade first thing in the morning? Set a limit or Friday’s close? Monday’s open? Buy first and last half hour? Every 30 minutes? It is hard to know what to do and how to determine when to trade during Monday. The answer is very simple, have algos that can be backtested and used going forward.

One algo can be buy every 30 minutes until filled. Another simply buys if prices fall below VWAP. Another can be buy when share prices have risen less than the market on that day. Or any other simplistic signal that will generally fill your dailly order. This is all done in Quantopian and they hand P123 a database of daily fill prices for every stock in the market using a batch of simple simple algos. They have no idea how we are going to use that data and on what model. Marco feeds this data into our system and the only thing we see is a few more options in the ‘price for transaction’ setting.

Right now there is previous close, next open, next close, and avg of hi and low. But this isn’t real trading data - you cannot trade the first print for your whole portfolio - it might open at $10 and fall to $5 in 2 seconds - you didn’t get the open or the mid-point but close to the close. Another stock might stay at $10 for half the day and drop to $5 at the last half. This time you were filled at the open but not mid-point or the close. With a simple algo you get fairly realistic fill prices - which is the main perk here. So very little changes in the sim except a few extra ‘fill price’ options.

As for trade - it too stays the same. Nothing changes as the algos do not replace this. You simply have other ‘fill my order’ algos - the same ones you used as simulated fill prices in the sim.

If Quantopian was willing to provide a fill price database for two or three simple order algos - it would probably be very little work indeed for Marco to incorporate these as optional fill prices. Maybe Marco can tell us how much work this would really be…I don’t know.

Quantopian benefits as some will test their algos and notice a significant benefit - perhaps in very illiquid trading environments. If you save an average of 0.5% in market impact on trading day - you’ll likely pay $25 a month to use their algo. So they can lease the code. Trade simply routes orders through Quantopian. This means that there is a seamless transition between sims and live trading models.

This can be an amazing leap in time. First, it is nothing more than realistic fill prices and accuracy of data. Next, its about having a few different order types that can be backtested and used for better fill prices going forward. There are some crazy amazing things that this can be used for past this - but lets not run ahead of ourselves. We are not talking about just lowering market impact or having more realistic fills - we are talking about having entry-level investors trade a small-cap illiquid portfolio without crazy amounts of risk. We have better testing, better forward models and investors make more money. I don’t think this is a big project - maybe I am wrong - but I see mostly upsides to this.

OK - I see what you are talking about now. I thought you were referring to algorithms that subscribers design for intraday trading.

Steve

I think it shouldn’t be too hard to go the other way: export P123 backtest results to a CSV file and use that in Quantopian to try out different trading strategies. This should be possible without any changes to P123. But of course it’s not nearly as easy as selecting another option in a dropdown list.

Quantopian offers a function (fetch_csv) that can read data from any website, including google drive, dropbox, etc. So you run a backtest in P123, download all transactions to CSV, place it in dropbox, and run your algorithms in Quantopian. Developing the algorithms in Quantopian is the hard part, but it does offer tremendous flexibility. For example, you could use a 20 stock portfolio size in the P123 backtest, and then only trade the first 10 stocks that actually get filled in Quantopian. Or use position sizing based on volume.

If you only use Quantopian to backtest algorithms, then it’s completely free as far as I understand. You only start paying when you want to use their autotrading.