/// <summary> /// Initializes a new instance of the <see cref="OandaBrokerage"/> class. /// </summary> /// <param name="orderProvider">The order provider.</param> /// <param name="securityProvider">The holdings provider.</param> /// <param name="aggregator">consolidate ticks</param> /// <param name="environment">The Oanda environment (Trade or Practice)</param> /// <param name="accessToken">The Oanda access token (can be the user's personal access token or the access token obtained with OAuth by QC on behalf of the user)</param> /// <param name="accountId">The account identifier.</param> /// <param name="agent">The Oanda agent string</param> public OandaBrokerage(IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator, Environment environment, string accessToken, string accountId, string agent = OandaRestApiBase.OandaAgentDefaultValue) : base("Oanda Brokerage") { if (environment != Environment.Trade && environment != Environment.Practice) { throw new NotSupportedException("Oanda Environment not supported: " + environment); } _api = new OandaRestApiV20(_symbolMapper, orderProvider, securityProvider, aggregator, environment, accessToken, accountId, agent); // forward events received from API _api.OrderStatusChanged += (sender, orderEvent) => OnOrderEvent(orderEvent); _api.AccountChanged += (sender, accountEvent) => OnAccountChanged(accountEvent); _api.Message += (sender, messageEvent) => OnMessage(messageEvent); }
/// <summary> /// Initializes a new instance of the <see cref="OandaBrokerage"/> class. /// </summary> /// <param name="orderProvider">The order provider.</param> /// <param name="securityProvider">The holdings provider.</param> /// <param name="aggregator">consolidate ticks</param> /// <param name="environment">The Oanda environment (Trade or Practice)</param> /// <param name="accessToken">The Oanda access token (can be the user's personal access token or the access token obtained with OAuth by QC on behalf of the user)</param> /// <param name="accountId">The account identifier.</param> /// <param name="agent">The Oanda agent string</param> public OandaBrokerage(IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator, Environment environment, string accessToken, string accountId, string agent = OandaRestApiBase.OandaAgentDefaultValue) : base("Oanda Brokerage") { if (environment != Environment.Trade && environment != Environment.Practice) { throw new NotSupportedException("Oanda Environment not supported: " + environment); } // Use v20 REST API only if you have a v20 account // Use v1 REST API if your account id contains only digits(ie. 2534253) as it is a legacy account _api = IsLegacyAccount(accountId) ? (OandaRestApiBase) new OandaRestApiV1(_symbolMapper, orderProvider, securityProvider, aggregator, environment, accessToken, accountId, agent) : new OandaRestApiV20(_symbolMapper, orderProvider, securityProvider, aggregator, environment, accessToken, accountId, agent); // forward events received from API _api.OrderStatusChanged += (sender, orderEvent) => OnOrderEvent(orderEvent); _api.AccountChanged += (sender, accountEvent) => OnAccountChanged(accountEvent); _api.Message += (sender, messageEvent) => OnMessage(messageEvent); }