Back

Getting started. Need help/guidance in writing a simple algo below..

Every day scan S&P 500 portfolio with following criteria to prepare for the potential stocks to trade
    Previous day volume by $ greater than USD 100 million
    Previous day volatility less than 1
    Volatility  = ((high-low)*100)/((high+low)/2)
    
Observe the first 15 minutes candlestick for the qualified stocks from above stock selection criteria and 
    If  condition [[  First candle close(15 min) > previous day high
                  and First candle close > (high+low)/2                       
                  and high*0.99 < low   ]]  is met 
        Put Order as below 
            Stock - qualified stock
            Buy price = first candle high * 1.001
            Quantity = floor($10000/bid) #fixed amount for now!.

IF order placed then Sell at price = buy price *1.015 or first candle low*0.9995 or end of the day 
      (whichever is earlier)

      
Profit = (sell price - buy price)*quantity-2.5

This is to get started so I can start buildilng stuff around it. Ultimately I intend to execute couple of similar algos on interactive brokers. 

Will greatly appreciate your help!. 

Update Backtest







Welcome to the community! This strategy can definitely be implemented using LEAN. Here are a couple of things to help get you started:

Universe Selection: For the universe selection part of the algorithm, you can use both CoarseFundamental and FineFundamental data in order to filter the stocks, as well as the QC500 model that QuantConnect engineers created to mimic the S&P500. This selection will occur every day and will add all relevant stocks to self.Securities, which holds Security objects for each asset in the algorithm.

In order to observe a 15 minute candlestick, look into implementing a Consolidator. This provides the ability to combine smaller data points (in this example Resolution.Minute bars) into a larger 15-minute bar. The consolidated bar can then be used to determine the trading signals.

With regards to trading orders, this link shows the various orders that can be made. It seems like limit orders and stop orders are going to be used for this algorithm.

Hope this helps! QuantConnect's documentation is extremely detailed and there are examples for almost every possible implementation so if you have any other questions be sure to look there! Good luck!

1

Thanks Guru, Let me give it a go !

0

Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed