Back

Asset price is $0. If using custom data make sure you've set the 'Value' property.

Hi,

Occasionally, we get the following error in the algorithm even though we're not using any custom data: "asset price is $0. If using custom data make sure you've set the 'Value' property". Any thoughts or ideas of where to start exploring the issue?

Thanks.

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.


Could you attach the algorithm which has such error? 

0

It is normally when you place a trade before there is data for the asset. This generally open happens at the very start of the algorithm.

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.


Problem is that the assets are loaded dynamically every day. I guess I can introduce a delay until the price is available.

0

Hello Quantithmar, how did you solve this issue?

Thanks,

Nicolas

0

also running into this issue when using LEAN with custom data.  Has anybody made any progress on this? or is there a way to delay/pause/delay an order until the data is loaded?

0

If you dont set a value for the custom data it'll always be 0. I think you're referring to a different thing?

The OP was saying that when adding securities dynamically there can be a few minutes at the start before they have data. You need to wait for the first tick to have the price set accurately.

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.


Thanks for the reply Jared!  I'm dynamically loading options.  Trying to migrate to OptionChainProvider to speed up things but it seems that the data doesn't load right away.  Is there a way to 'wait'?  I tried to force it so that the data is loaded and doesn't have a 0 value (setting bidPrice of Option to 0) before placing a MarketOrder, but it doesn't work.  

any suggestions would be great.

code snippet below:

 

def OptionsFilter(self,slice):
        self.underlyingPrice = self.Securities[self.equity_symbol].Price
        contracts = self.OptionChainProvider.GetOptionContractList(self.equity_symbol, slice.Time)  
        puts = [i for i in contracts if i.ID.OptionRight == OptionRight.Put and 
                                             i.ID.StrikePrice - self.underlyingPrice >= 0 and 
                                             30 < (i.ID.Date - slice.Time).days < 60]

         return puts[0]

 

def OnData(self, slice):

     contract=self.OptionsFilter(slice)

      if contract:

                for chain in slice.OptionChains.Values:
                    for c in chain:
                        if c.Symbol==atm_put:
                            bid=c.BidPrice
                            if bid!=0:
                                atm_strike = float(contract.ID.StrikePrice)
                                amount = -int((float(self.Portfolio.TotalPortfolioValue/atm_strike)/self.multiplier))
                                self.MarketOrder(contractt,amount)
       

0

Hi Andrew Chan ,

In the code snippet, there is no AddOptionContract call.
Could you please share a backtest that reproduces the issue?

A common mistake is adding a contract with AddOptionContract method and placing an order at the same time iteration. In other words, if the algorithm adds a contract in OnData, it will need to until the next time OnData is triggered to place an order.

You can set a security initializer that will fetch the last know price and warm up the security:

self.SetSecurityInitializer(lambda x: x.SetMarketPrice(self.GetLastKnownPrice(x)))

Please note that it can get the closing price of the previous trading session depending on the time AddOptionContract was called and the liquidity of the contract.

P.S.: Since GetLastKnowPrice makes a history request, it may slow the algorithm down.

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.


I'm having a similar issue.  However, I'm trying to run/call the options functions outside of OnData.  I tried to use the 

self.SetSecurityInitializer(lambda x: x.SetMarketPrice(self.GetLastKnownPrice(x)))

but it said that it couldn't be used beyond the initialize portion of the Algorithm and threw errors when I moved it there too.  Is this able to be modified to be able to use it in a spot application?

0

Hi Brad Hearne ,

SetSecurityInitializer must be called in Initialize.
Could you please share the code that we can use to reproduce the errors when you move it there?

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.


Alexandre thanks for replying,  I found that using AddOptionContract skips to the next step and can't wait.  whereas AddOption pre-loads so it doesn't skip.  would love to know if there is a way to ressolve this. 

 

for contract in contractList:
                    if contract not in self.contractsAdded:
                        self.contractsAdded.add(contract)
                        self.AddOptionContract(contract, Resolution.Minute)
                        self.Securities[contract].SetFillModel(CustomFillMarketMid(self))
 

#### want it to wait here - but it doesn't wait, it goes to the next step                    for chain in slice.OptionChains.Values:
                    for c in chain:
                        if c.Symbol in contractList:
                            bid=c.BidPrice
                            if bid!=0:
                                self.MarketOrder(c.Symbol,amount)
                                self.monthStartEOD=False
                            else:
                                self.Log(str(self.Time.date())+"bid is 0:"+str(bid))

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