public void ReturnsCorrectLeanSymbol() { var mapper = new FxcmSymbolMapper(); var symbol = mapper.GetLeanSymbol("EUR/USD", SecurityType.Forex, Market.FXCM); Assert.AreEqual("EURUSD", symbol.Value); Assert.AreEqual(SecurityType.Forex, symbol.ID.SecurityType); Assert.AreEqual(Market.FXCM, symbol.ID.Market); symbol = mapper.GetLeanSymbol("GER30", SecurityType.Cfd, Market.FXCM); Assert.AreEqual("DE30EUR", symbol.Value); Assert.AreEqual(SecurityType.Cfd, symbol.ID.SecurityType); Assert.AreEqual(Market.FXCM, symbol.ID.Market); }
public void ThrowsOnNullOrEmptySymbol() { var mapper = new FxcmSymbolMapper(); Assert.Throws<ArgumentException>(() => mapper.GetLeanSymbol(null, SecurityType.Forex, Market.FXCM)); Assert.Throws<ArgumentException>(() => mapper.GetLeanSymbol("", SecurityType.Forex, Market.FXCM)); var symbol = Symbol.Empty; Assert.Throws<ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); symbol = null; Assert.Throws<ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); symbol = Symbol.Create("", SecurityType.Forex, Market.FXCM); Assert.Throws<ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }
public void ThrowsOnUnknownSymbol() { var mapper = new FxcmSymbolMapper(); Assert.Throws<ArgumentException>(() => mapper.GetLeanSymbol("ABC/USD", SecurityType.Forex, Market.FXCM)); var symbol = Symbol.Create("ABCUSD", SecurityType.Forex, Market.FXCM); Assert.Throws<ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }
public void ThrowsOnNullOrEmptySymbol() { var mapper = new FxcmSymbolMapper(); Assert.Throws <ArgumentException>(() => mapper.GetLeanSymbol(null, SecurityType.Forex, Market.FXCM)); Assert.Throws <ArgumentException>(() => mapper.GetLeanSymbol("", SecurityType.Forex, Market.FXCM)); var symbol = Symbol.Empty; Assert.Throws <ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); symbol = null; Assert.Throws <ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); symbol = Symbol.Create("", SecurityType.Forex, Market.FXCM); Assert.Throws <ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }
public void ThrowsOnInvalidSecurityType() { var mapper = new FxcmSymbolMapper(); Assert.Throws <ArgumentException>(() => mapper.GetLeanSymbol("AAPL", SecurityType.Equity, Market.FXCM)); var symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.FXCM); Assert.Throws <ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }
public void ThrowsOnUnknownSymbol() { var mapper = new FxcmSymbolMapper(); Assert.Throws <ArgumentException>(() => mapper.GetLeanSymbol("ABC/USD", SecurityType.Forex, Market.FXCM)); var symbol = Symbol.Create("ABCUSD", SecurityType.Forex, Market.FXCM); Assert.Throws <ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }
/// <summary> /// MarketDataSnapshot message handler /// </summary> private void OnMarketDataSnapshot(MarketDataSnapshot message) { if (message.getRequestID() == _currentRequest) { var securityType = _symbolMapper.GetBrokerageSecurityType(message.getInstrument().getSymbol()); var symbol = _symbolMapper.GetLeanSymbol(message.getInstrument().getSymbol(), securityType, Market.FXCM); var time = FromJavaDateUtc(message.getDate().toDate()); if (message.getFXCMTimingInterval() == FXCMTimingIntervalFactory.TICK) { var bid = Convert.ToDecimal(message.getBidClose()); var ask = Convert.ToDecimal(message.getAskClose()); var tick = new Tick(time, symbol, bid, ask); //Add tick _currentBaseData.Add(tick); } else // it bars { var open = Convert.ToDecimal((message.getBidOpen() + message.getAskOpen()) / 2); var high = Convert.ToDecimal((message.getBidHigh() + message.getAskHigh()) / 2); var low = Convert.ToDecimal((message.getBidLow() + message.getAskLow()) / 2); var close = Convert.ToDecimal((message.getBidClose() + message.getAskClose()) / 2); var bar = new TradeBar(time, symbol, open, high, low, close, 0); // add bar to list _currentBaseData.Add(bar); } if (message.getFXCMContinuousFlag() == IFixValueDefs.__Fields.FXCMCONTINUOUS_END) { _mapRequestsToAutoResetEvents[_currentRequest].Set(); _mapRequestsToAutoResetEvents.Remove(_currentRequest); } } }
public void ThrowsOnInvalidSecurityType() { var mapper = new FxcmSymbolMapper(); Assert.Throws<ArgumentException>(() => mapper.GetLeanSymbol("AAPL", SecurityType.Equity, Market.FXCM)); var symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.FXCM); Assert.Throws<ArgumentException>(() => mapper.GetBrokerageSymbol(symbol)); }