trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool

Back

Updating TradeBars indicators using history in Alpha

Hello,

Is it possible to update an indicator (fisher transform in this case) using history? 

I found that history doesn't return TradeBars (Ibasedatabar) object.

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.


Yes, you absolutely can.

Using RegisterIndicator will bind an indicator to a particular consolidator. Any history pushed to this consolidator will then, in turn, update the indicator.

If you show us an example of what you're trying to achieve, it would be easier to guide you.

Also, regarding what History returns - you can normally cast the return of History into what you need.

0

Hi Douglas,

Thank you for the answer! this is what I'm trying to do, fisher is already registered, but how can I make it 'warmup' using a history object?

 

def OnSecuritiesChanged(self, algorithm, changes):

# clean up data for removed securities
symbols = [x.Symbol for x in changes.RemovedSecurities]
if len(symbols) > 0:
for subscription in algorithm.SubscriptionManager.Subscriptions:
if subscription.Symbol in symbols:
self.symbolDataBySymbol.pop(subscription.Symbol, None)
subscription.Consolidators.Clear()

# initialize data for added securities

addedSymbols = [
x.Symbol for x in changes.AddedSecurities if x.Symbol not in self.symbolDataBySymbol]
if len(addedSymbols) == 0:
return

history = algorithm.History(addedSymbols, self.period, self.resolution)

for symbol in addedSymbols:
Fisher = FisherTransform(self.period)
algorithm.RegisterIndicator(symbol, Fisher, self.resolution)

if not history.empty:
ticker = SymbolCache.GetTicker(symbol)

if ticker not in history.index.levels[0]:
Log.Trace(f'FisherAlphaModel.OnSecuritiesChanged: {ticker} not found in history data frame.')
continue

#for tuple in history:
# algorithm.Debug(history)
Fisher.Update()

 

0

I don't have a working alpha environment to test right now but L33 should simply be passing the right information into Update. Check out this example algo and check the auto-complete to see what inputs are required for the Update of Fisher. It's likely to be a QuoteBar (or other bar derived from IBaseDataBar), which you can create from the history tuple.

0

Thank you for the answer!

Yeah it was WIP, the difference between fisher and RSI (in your example) is that fisher requires Ibasedatabar, which i'm still clueless on how to make... 

 

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