Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Intraday "high" frequency basket trading strategy

An adaptation of paper http://dspace.mit.edu/handle/1721.1/59122 on minute bars. Could someone please help me close out positions at market close and avoid trading before market hours so that the results are more accurate?

11 responses

Nice

It looks very interesting !

I took a shot and as soon we set spread and fee, the balance is getting eaten alive by enormous volume (approx 6M$ daily volume with a 100K$ account).

Anyway, do you plan to improve the algo with a cash monitoring and realistic numbers from Interactive Brokers for a small/medium account or is it limited to Hedge Funds ?

Very cool, this version closes out at the end of the day. For the last 10 minutes, it cancels any open orders and submits a new limit order for the current price, one of them should get triggered. It looks like there were only a couple of cases where a position got held overnight. It can't trade before market hours because handle_data only gets called during market hours, so that shouldn't be an issue.

Mat has a good point about the transaction costs for HFT strategies like this. It makes 235601 transactions at ~$1 each (with IB) in 9 months. Unless you have access to a really deep equity pool and can take on a lot of leverage, it will get eaten alive by fees. There must be a way to lower the frequency without compromising the strategy.

Here is a daily strategy with 0.005 per share as IB fees.

With some position sizing/portfolio code, this looks like it could be a very feasible strategy.

I agree, I like this idea, it just needs some TLC. I switched it back to minute mode and had it trade at the open with a 10 day holding period, $30K.

Hello David,

I don't yet understand the details of the algo, but I'm wondering if your 'buy and hold' approach may be overly restrictive. It seems like it should be applied on an individual security basis, so that each security has its own timer. There is no advantage in batch trading of multiple securities, since the commissions are charged per security.

Grant

Updated strategy in intraday mode with transaction costs (1 cent) and other bug fixes in core algorithm

Hi.. I'm new around here so I apologize if my question seems obvious for some of you. How do I know from backtestings, which instrument was traded? is it trading the SPY? Thanks

Hi Henry, there are 3 ways to reference securities in an algorithm:

  1. Manual lookup using symbol or sid
  2. Call set_universe to create a basket of securities
  3. Import your own list via Fetcher

You can look for any of these methods in the initialize() function. If the source code uses Symbol, you'll be see the trading ticker. Otherwise, if it uses sids, you'll see a number which gets mapped to a security. SIDs are security ID numbers and are unique to our platform. Since symbols may be reused among exchanges, this prevents any confusion and verifies you are calling the desired security. This particular algorithm is trading:

context.sids =  [sid(14848),  
                     sid(3766),  
                     sid(24),  
                     sid(5061),  
                     sid(5692),  
                     sid(23709),  
                     sid(25006),  
                     sid(357),  
                     sid(2190),  
                     sid(698),  
                     sid(8229),  
                     sid(3496),  
                     sid(39942),  
                     sid(20088),  
                     sid(16841),  
                     sid(26169),  
                     sid(24832),  
                     sid(1582),  
                     sid(4922),  
                     sid(23112),  
                     sid(4151)]  

If you clone the algorithm, it bring you to the IDE and you can hover over the number to see the ticker.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks Alisa