Back

Slice Object

Hello,

I am really new to QuantConnect and I am having a little bit of a hard time understanding the Slice object. I need to be able to analyse TradeBars, one TradeBar at a time. So my questions are as follow:

1) Does Slice.Bars contain more than one TradeBar object?

2) What is the length (in time) of a Slice? Does it depend on my data resolution? Say I choose to have data in seconds and I want to analyze one second bars, how do I access the one second bar from the Slice object?

 

Thank you

Update Backtest








Please checkout the docs, under Handling Data, for detailed information about the Slice object.
1) Slice.Bars refers to a TradeBars object. A TradeBars is a dictionary of TradeBar, where the key is the Symbol and the value is a TradeBar. For instance, if you subscribed to SPY and IBM, you will be able to get their bar like this:

spy_bar = slice.Bars["SPY"]
ibm_bar = slice.Bars["IBM"]

 Note that you can get their bars directly from the Slice object:

spy_bar = slice["SPY"]
ibm_bar = slice["IBM"]

2) Yes, Slice depends on the data resolution. OnData is called with the hightest resolution we have subcribed to. For example, we asked for minute-resolution data from SPY and second-resolution data from IBM: OnData will teiggered every second. In the Slice object we will have different IBM bars every second, but SPY will only change every minute. 

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