LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I am currently trying to train a model inside the algorithm environment on a given symbol's daily close, volume and various indicators. Ideally, I want to convert all this data to a dataframe. self.History() provides this data however I can't figure out how to join, say, a 20 day Simple Moving Average onto the dataframe.
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.
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.
Corey Davis
39
,
As an added note, this is easy to do in the research environemnt with the following commands:
qb = QuantBook()
sma = SimpleMovingAverage(20)
smadf = qb.Indicator(sma,"SPY",3600,Resolution.Daily)
smadf.head(n=2)
I see no easy translation however to the Algo environment
0
HanByul P
8.1k
,
Hi Corey Davis, QC historical dataframe is multi-layered, which is not easy to play with (as far as for me - -;). It would be much easier to re-create dataframes of data that you want, and then combine them (if you want). I attached a sample algo how to re-create and cobine DFs. Please check 'Logs'. Hope this helps. Thank you.
1
Corey Davis
39
,
Thank you HanByul P - this is very helpful! My one question is how would I maintain the index of "time" in this new table in order to maintain the time series component?
0
HanByul P
8.1k
,
Corey Davis, I'm glad that it was helpful. You mentioned "..in order to maintain the time series component". I'm sorry I don't understand what exactly you want. The new table could be a multi-indexed df or a panel or something else. Can you clearly describe what your goal is or can you show us what your desired output is so that we can help you better?. BTW, I attached a sample algo where the new table has 'datetime' info as a column. I think if you want to work with dataframes, it'll be much easier to work with single-indexed dataframes. Thank you.
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...
To unlock posting to the community forums please complete at least 30% of Boot Camp. You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!