Back

Custom Data with Alphas

I'm trying to create and test an alpha offline providing custom data to it. I have the custom data working with an algorithm, but am struggling to get it working with an alpha. Can you use custom data with an alpha?

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.


Hey Sam,

It is possible to use custom data with AlphaModels. There are two ways to do it.

  1. Call AddData in the main class and pass its symbols to ManualUniverseSelectionModel
  2. Pass algorithm into the AlphaModel and call algorithm.AddData in the AlphaModel constructor.
class Main(QCAlgorithm):
def Initialize(self):
...
self.SetAlpha(MyAlphaModel(self))

class MyAlphaModel(AlphaModel):
def __init__(self, algorithm):
algorithm.AddData(MyCustomData, "CustomDataTicker")

 

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.


That did it for me :) I originally had it as 

AddData<CryptoData>("BTCUSDT", Resolution.Minute)
var symbols = new[] { "BTCUSDT" }
.Select(x => QuantConnect.Symbol.Create(x, SecurityType.Crypto, Market.GDAX));
SetUniverseSelection(new ManualUniverseSelectionModel(symbols));

Which would throw some kind of error that it couldn't find "BTCUSDT". I think it threw the error because the data was labeled as "BTCUSDT.CRYPTODATA" and the Universe Symbol was "BTCUSDT". 

I realized my error when I carefully read your 

1. Call AddData in the main class and pass its symbols to ManualUniverseSelectionModel

The error went away when I changed it to:

var s = AddData<CryptoData>("BTCUSDT", Resolution.Minute);
SetUniverseSelection(new ManualUniverseSelectionModel(new Symbol[] { s.Symbol }));

Big thank you!

1

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