Back

During the algorithm initialization, the following exception has occurred: Unable to locate exchange hours for Future-cmeglobex-BRRV18

I don't know how to fix this error:  "During the algorithm initialization, the following exception has occurred: Unable to locate exchange hours for Future-cmeglobex-BRRV18"  The message doesn't tell me which statement causes it, but I was able to nail that down by commenting out various statements. 

Have I done something wrong with the symbol, or do I just not understand how to properly use this API or what?

 

public class BasicTemplateAlgorithm : QCAlgorithm
    {
        private Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
        private Symbol _bct = QuantConnect.Symbol.Create("BRRV18", SecurityType.Future, Market.Globex);

..

    }

       public override void Initialize()
        {
            SetStartDate(2018, 1, 07);  //Set Start Date
            SetEndDate(2018, 10, 11);    //Set End Date
            SetCash(100000);             //Set Strategy Cash
            AddEquity("SPY", Resolution.Minute);
            AddFutureContract(_bct,Resolution.Hour,true);   //<--this guy causes the error
        }

Update Backtest







Before requesting the future contract data with AddFutureContract(), you should first fetch a list of available future contracts with 

var futureChains = FutureChainProvider.GetFutureContractList(symbol, Time);

 

Then you can choose the contract to trade from this future chains.

This symbol argument here should be the symbol object. For example S&P500 Mini futures, you can get the symbol object with 

public Symbol SP500 = QuantConnect.Symbol.Create("ES", SecurityType.Future, Market.USA);

You can search for the available future string tickers like "ES" in data explorer. "BRRV18" is not an available future ticker to use. Are you looking for US dollar / Brazilian Real(USD/BRL) cash Settle Future? The ticker should be "BRL" for US dollar / Brazilian Real(USD/BRL) cash Settle Future.

 Please see the attached algorithm

Instead of using the future chain provider, you can also request the futures data with AddFuture(symbol). You can find this example on Github.

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 don't understand what I am supposed to do.  The "data explorer" is only helpful if you already know the symbol.  When I type BRR it doesn't find. 

I was trying for the CME bitcoin futures contract.

I also don't understand what Market.USA means exactly.  I used Market.Globex, because this contract trades on Globex.  What is the distinction?

Is this stuff explained anywhere?

0

There is so much here that is unclear to me.  When you write

public Symbol SP500 = QuantConnect.Symbol.Create("ES", SecurityType.Future, Market.USA);

I don't understand what is going on because ES is NOT the symbol for a futures contract.  It is the symbol BASE for a family of futures contracts.  So are you saying I have to start with the symbol base and then go from there?  If so, what do I do to specify the specific futures contract?

0

I finally found some words in the API docs explaining that you default to the near contract.  One down... many to go.

0

The string ticker here represents a family of future contracts. They are the standardized symbol ticker assigned by the exchange. You can search for them on this website.

We also mapped some of the Futures symbols in this class (as there are thousands of symbols, these are only commonly used futures):

https://github.com/QuantConnect/Lean/blob/master/Common/Securities/Future/Futures.cs

Unlike equity, the futures contract is an agreement that has the expiration. After the contract expires, it is no longer traded in the market. Therefore, you need to add the futures with the generalized string ticker and select the contract available to trade in the market at the current time. For example, you want to trade SP500 Emini futures, you get a list of all the available contract with FutureChainProvider.GetFutureContractList(SP500, Time) and then select the contract from this list.  To find the specific contract, you need to use the expiration date(see the attached algorithm) or the specific symbol.


var contracts = (from symbol in futureChains
where symbol.Value == "StringTickerOfSpecificFutureContract"
select symbol);

However, using the contract string ticker to filter the contract might give zero contract when this contract expires and not available in the market.

The string ticker of Bitcoin futures is "BTC". We use Market.USA for all futures traded in the United States. There's no need to specify the exchange when adding the futures.  

 

public Symbol btc = QuantConnect.Symbol.Create("BTC", SecurityType.Future, Market.USA);
// get a list of all available future contracts at the current time
var futureChains = FutureChainProvider.GetFutureContractList(btc, Time);

 

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