Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (22 sloc) 1.18 KB
<meta name="tag" content="data event handlers"/>
<meta name="tag" content="tradebars event"/>
<p>
$[TradeBar,T:QuantConnect.Data.Market.TradeBar] provides Open, High, Low, Close and Volume properties for a given period of time. TradeBars are only supported for Equity, Options, and Futures asset types (NOT Forex or CFD).
</p>
<img src="https://cdn.quantconnect.com/docs/i/dataformat-tradebar.png" class="img-responsive" />
<div class="section-example-container">
<pre class="python">
self.AddEquity("IBM", Resolution.Hour) ## Subscribe to hourly TradeBars
def OnData(self, data):
## You can access the TradeBar dictionary in the slice object and then subset by symbol
## to get the TradeBar for IBM
tradeBars = data.Bars
ibmTradeBar = tradeBars['IBM']
ibmOpen = ibmTradeBar.Open ## Open price
ibmClose = ibmTradeBar.Close ## Close price
## Or you can access the IBM TradeBar by directly subsetting the slice object
## (since you are subscribed to IBM equity data, this will return a TradeBar rather than a QuoteBar)
ibmOpen = data['IBM'].Open ## Open price
imbClose = data['IBM'].Close ## Close price
</pre>
</div>
You can’t perform that action at this time.