Hello,
I'm new to QuantConnect. I try to deploy an algorithm live with Oanda but get systematic the same error:
During the algorithm initialization, the following exception has occurred: System.Exception: No default market set for security type: Futureat QuantConnect.Algorithm.QCAlgorithm.AddFuture (System.String symbol, QuantConnect.Resolution resolution, System.String market, System.Boolean fillDataForward, System.Decimal leverage) [0x00039] in <948b718a188a4ba2994823a9f477c87e>:0
at QuantConnect.Algorithm.CSharp.FuturesMomentumAlgorithm.Initialize () [0x00085] in <37a8d66406484b15b9222918d3dbc502>:0
at QuantConnect.Lean.Engine.Setup.BrokerageSetupHandler+<>c__DisplayClass24_0.<Setup>b__1 () [0x000fb] in <bc4479b96615496c83f0743fe1039576>:0 No default market set for security type: Futureand here is the Code:using System;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Orders;
using QuantConnect.Securities;
using QuantConnect.Indicators;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// EMA cross with SP500 E-mini futures
/// In this example, we demostrate how to trade futures contracts using
/// a equity to generate the trading signals
/// It also shows how you can prefilter contracts easily based on expirations.
/// It also shows how you can inspect the futures chain to pick a specific contract to trade.
/// </summary>
/// <meta name="tag" content="using data" />
/// <meta name="tag" content="futures" />
/// <meta name="tag" content="indicators" />
/// <meta name="tag" content="strategy example" />
public class FuturesMomentumAlgorithm : QCAlgorithm
{
private const string RootSP500 = Futures.Indices.SP500EMini;
public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.Oanda);
private const decimal _tolerance = 0.001m;
private const int _fastPeriod = 20;
private const int _slowPeriod = 50;
private ExponentialMovingAverage _fast;
private ExponentialMovingAverage _slow;
public bool IsReady { get { return _fast.IsReady && _slow.IsReady; } }
public bool IsUpTrend { get { return IsReady && _fast > _slow * (1 + _tolerance); } }
public bool IsDownTrend { get { return IsReady && _fast < _slow * (1 + _tolerance); } }
public override void Initialize()
{
SetStartDate(2016, 1, 1);
SetEndDate(2018, 3, 15);
SetCash(10000);
SetWarmUp(Math.Max(_fastPeriod, _slowPeriod));
// Adds SPY to be used in our EMA indicators
var equity = AddEquity("SPY", Resolution.Daily);
_fast = EMA(equity.Symbol, _fastPeriod, Resolution.Daily);
_slow = EMA(equity.Symbol, _slowPeriod, Resolution.Daily);
// Adds the future that will be traded and
// set our expiry filter for this futures chain
var futureSP500 = AddFuture(RootSP500);
futureSP500.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182));
}
I saw on quantconnect.com/data that SP500 with Oanda is a Cfd; has this maybe to do with the error?Thanks for your help! ;=)NB: I'm not a programmer, just a guy trying to find a solution to automate my trades. ;=)