bool Construct() { if (_manager != null) { return(false); } StatusSynchronizationEnabled = true; lock (this) { _manager = new MBTradingConnectionManager(this); if (_manager.Quotes != null) { _manager.Quotes.QuoteUpdateEvent += new MBTradingQuote.QuoteUpdateDelegate(Quotes_QuoteUpdateEvent); } DataSourceStub.Initialize(this); OrderExecutionStub.Initialize(_manager.Orders); foreach (string symbol in EquitiesSymbols) { DataSourceStub.AddSuggestedSymbol(new Symbol(string.Empty, symbol)); } foreach (string symbol in ForexSymbols) { DataSourceStub.AddSuggestedSymbol(new Symbol("FX", symbol)); } } return(true); }
void manager_QuoteUpdatedEvent(FXCMConnectionManager manager, string symbolName, DataTick dataTick) { Symbol symbol = new Symbol(Symbol.SymbolGroup.Forex, symbolName); DataSourceStub dataSourceStub = _dataSourceStub; if (dataSourceStub == null) { return; } RuntimeDataSessionInformation sessionInformation = dataSourceStub.GetSymbolSessionInformation(symbol); if (sessionInformation == null) { return; } CombinedDataSubscriptionInformation info = dataSourceStub.GetUnsafeSessionSubscriptions(sessionInformation.Info); if (info != null && info.GetCombinedDataSubscription().QuoteSubscription) { dataSourceStub.UpdateQuote(sessionInformation.Info, new Quote(dataTick.Ask, dataTick.Bid, null, dataTick.DateTime), null); foreach (TimeSpan supportedPeriod in DefaultAvailablePeriods) { dataSourceStub.UpdateDataHistory(sessionInformation.Info, new DataHistoryUpdate(supportedPeriod, new DataTick[] { dataTick })); } } }
/// <summary> /// Constructor. /// </summary> public FXCMAdapter() { DataSourceStub dataSourceStub = new DataSourceStub("FXCM Adapter Data", true); OrderExecutionSourceStub orderExecutionSourceStub = new OrderExecutionSourceStub("FXCM Adapter Execution", true); base.SetInitialParameters(dataSourceStub, orderExecutionSourceStub); Construct(); }
/// <summary> /// Constructor. /// </summary> public FXCMAdapter() { _orderExecutionStub = new OrderExecutionSourceStub("FXCM Adapter Execution", false); _dataSourceStub = new DataSourceStub("FXCM Adapter Data", true); base.SetStub(_dataSourceStub); base.SetStub(_orderExecutionStub); Construct(); }
/// <summary> /// /// </summary> public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo?info) { SystemMonitor.CheckError(session.IsEmtpy == false, "Method needs valid session info assigned to operate."); DataSourceStub dataSourceStub = DataSourceStub; if (dataSourceStub == null) { return; } CombinedDataSubscriptionInformation combined = dataSourceStub.GetUnsafeSessionSubscriptions(session); if (combined == null) { SystemMonitor.OperationError("Update on not existing session."); return; } MBTradingConnectionManager manager = _manager; if (manager == null) { return; } DataSubscriptionInfo combinedInfo = combined.GetCombinedDataSubscription(); if (combinedInfo.QuoteSubscription) { if (manager.Adapter != null) { manager.Quotes.SubscribeSymbolSession(session.Symbol, Commission.GenerateSymbolCommission(manager.Adapter, session.Symbol)); } else { SystemMonitor.OperationError("Failed to perform data subscription update, since manager adapter not assigned."); } GeneralHelper.FireAndForget(delegate() {// Run an async update of quotes. string market; Quote?quote = _manager.Quotes.GetSingleSymbolQuote(session.Symbol.Name, TimeSpan.FromSeconds(10), out market); if (quote.HasValue) { DataSourceStub.UpdateQuote(session, quote, null); } }); } else { manager.Quotes.UnSubscribeSymbolSession(session.Symbol.Name); } }
/// <summary> /// Constructor. /// </summary> public MBTradingAdapter() : base() { DataSourceStub dataSourceStub = new DataSourceStub("MBTrading Adapter Data", true); OrderExecutionSourceStub orderExecutionSourceStub = new OrderExecutionSourceStub("MBTrading Adapter Execution", false); base.SetStub(dataSourceStub); base.SetStub(orderExecutionSourceStub); Construct(); }
/// <summary> /// /// </summary> public Dictionary <Symbol, TimeSpan[]> SearchSymbols(string symbolMatch, int resultLimit) { Dictionary <Symbol, TimeSpan[]> result = new Dictionary <Symbol, TimeSpan[]>(); foreach (Symbol symbol in DataSourceStub.SearchSuggestedSymbols(symbolMatch, resultLimit)) { result.Add(symbol, DefaultAvailablePeriods); } return(result); }
void Quotes_QuoteUpdateEvent(MBTradingQuote keeper, MBTradingQuote.SessionQuoteInformation information) { RuntimeDataSessionInformation session = DataSourceStub.GetSymbolSessionInformation(information.Symbol); if (session != null) { DataSourceStub.UpdateQuote(session.Info, information.Quote, null); } else { SystemMonitor.OperationWarning("Symbol session not found, quote missed."); } }
/// <summary> /// Constructor. /// </summary> public FXCMData(FXCMAdapter adapter, DataSourceStub stub) { _adapter = adapter; _dataSourceStub = stub; _dataSourceStub.Initialize(this); StatusSynchronizationEnabled = true; StatusSynchronizationSource = adapter; foreach (string symbol in ForexSymbols) { _dataSourceStub.AddSuggestedSymbol(new Symbol(Symbol.SymbolGroup.Forex, symbol)); } }
/// <summary> /// /// </summary> public Symbol?EstablishSymbolUsage(Symbol inputSymbol, TimeSpan timeOut) { MBTradingConnectionManager manager = _manager; if (manager == null || manager.Quotes == null) { return(null); } // Filter the baseCurrency trough its name and what symbols we know of. Symbol?knownSymbol = DataSourceStub.MapSymbolToRunningSession(inputSymbol.Name); if (knownSymbol.HasValue == false) { if (DataSourceStub.IsSuggestedSymbol(inputSymbol) && string.IsNullOrEmpty(inputSymbol.Group) == false) { knownSymbol = inputSymbol; } else {// Upper case input baseCurrency. inputSymbol = new Symbol(inputSymbol.Group, inputSymbol.Name.ToUpper()); string symbolMarket; if (manager.Quotes.GetSingleSymbolQuote(inputSymbol.Name, timeOut, out symbolMarket).HasValue) {// BaseCurrency found and established from broker. knownSymbol = new Symbol(symbolMarket, inputSymbol.Name); } else { SystemMonitor.OperationError("Failed to map symbol with this name."); return(null); } } } lock (this) { if (_usedSymbols.ContainsKey(knownSymbol.Value.Name) == false) { _usedSymbols.Add(knownSymbol.Value.Name, knownSymbol.Value); } } return(knownSymbol); }
/// <summary> /// /// </summary> public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo?info) { SystemMonitor.CheckError(session.IsEmtpy == false, "Method needs valid session info assigned to operate."); DataSourceStub dataSourceStub = _dataSourceStub; if (dataSourceStub == null) { return; } CombinedDataSubscriptionInformation combined = dataSourceStub.GetUnsafeSessionSubscriptions(session); if (combined == null) { SystemMonitor.OperationError("Update of a non-existing session."); return; } }
/// <summary> /// /// </summary> public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo?info) { SystemMonitor.CheckError(session.IsEmtpy == false, "Method needs valid session info assigned to operate."); DataSourceStub dataSourceStub = _dataSourceStub; if (dataSourceStub == null) { return; } CombinedDataSubscriptionInformation combined = dataSourceStub.GetUnsafeSessionSubscriptions(session); if (combined == null) { SystemMonitor.OperationError("Update on not existing session."); return; } DataSubscriptionInfo combinedInfo = combined.GetCombinedDataSubscription(); if (combinedInfo.QuoteSubscription) { if (!_subscribedSymbols.ContainsKey(session.Symbol.Name)) { _subscribedSymbols.Add(session.Symbol.Name, session.Symbol); } } else { if (_subscribedSymbols.ContainsKey(session.Symbol.Name)) { _subscribedSymbols.Remove(session.Symbol.Name); } } }
public void ValueIsNotCallable() { Assert.Throws <InvalidOperationException>(() => DataSourceStub.GetPropertyValue <object>(new object(), "Property")); }
public void SourceOfComposableFunctionIsNotCallable() { Assert.Throws <InvalidOperationException>(() => DataSourceStub.GetQueryableSource <object>("Namespace", "Function")); }
public void SourceOfEntityContainerElementIsNotCallable() { Assert.Throws <InvalidOperationException>(() => DataSourceStub.GetQueryableSource <object>("EntitySet")); }
public void ValueIsNotCallable() { Action invalidOperation = () => { DataSourceStub.GetPropertyValue <object>(new object(), "Property"); }; invalidOperation.Should().Throw <InvalidOperationException>(); }
public void SourceOfComposableFunctionIsNotCallable() { Action invalidOperation = () => { DataSourceStub.GetQueryableSource <object>("Namespace", "Function"); }; invalidOperation.Should().Throw <InvalidOperationException>(); }
public void Dispose() { _adapter = null; _dataSourceStub = null; }
public MyReaderClassTest() { _dataSource = new DataSourceStub(); _underTest = new MyReaderClass(_dataSource); }
public void SetUp() { _dataSource = new DataSourceStub(); _underTest = new MyReaderClass(_dataSource); }
public void SourceOfEntityContainerElementIsNotCallable() { Action invalidOperation = () => { DataSourceStub.GetQueryableSource <object>("EntitySet"); }; invalidOperation.Should().Throw <InvalidOperationException>(); }