Back

Change in Stock Price per Minute/Second

Dear all,

Does anyone know how to code here such that the algorithm will help me to calculate and store the change in stock price per minute/second in an array?

Best regards,

Keith

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.


Don't know if minute resolution is possible, but you can create a RollingWindow to store previous periods:

https://www.quantconnect.com/docs/algorithm-reference/rolling-window#Rolling-Window-Rolling-Window

 

0

Hi Keith Xu KaPui ,

You can use the ROCP indicator to calculate the change of stock price and save the results in a RollingWindow:

# In Initialize, create the rolling windows
def Initialize(self):
# Creates an indicator and adds to a rolling window when it is updated
self.ROCP("SPY", 1).Updated += self.RocpUpdated
# Save 10 results
self.returnsWindow = RollingWindow[IndicatorDataPoint](10)

# Adds updated values to rolling window
def RocpUpdated(self, sender, updated):
self.returnsWindow.Add(updated)

For more details, please check out the docs:
Rolling Window - Combining with Indicators

Please note that, in this example, the rate of change follows the subscribed resolution.

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.


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