protected override void OnStarted() { _subscriptions.ForEach(s => s.Value.Where(p => p.Value > 0).ForEach(v => Subscribe(s.Key, v.Key))); lock (_syncRoot) { _elementsBySeries .Keys .Distinct() .ForEach(StartSeries); } this .WhenOrderRegistered() .Do(ProcessOrder) .Apply(this); this .WhenNewMyTrades() .Do(ProcessTrades) .Apply(this); this.GetCandleManager().Processing += Process; base.OnStarted(); }
protected override void OnClosed(EventArgs e) { _quotesWindows.SyncDo(d => d.Values.ForEach(w => { w.DeleteHideable(); w.Close(); })); var trader = MainWindow.Instance.Trader; if (trader != null) { if (_initialized) { trader.MarketDepthChanged -= TraderOnMarketDepthChanged; } _quotesWindows.ForEach(pair => { trader.UnRegisterMarketDepth(pair.Key); DeleteHideableAndClose(pair.Value); }); _historyTicksWindows.ForEach(pair => DeleteHideableAndClose(pair.Value)); _historyCandlesWindows.ForEach(pair => DeleteHideableAndClose(pair.Value)); } base.OnClosed(e); }
protected override void OnClosed(EventArgs e) { var trader = MainWindow.Instance.Trader; if (trader != null) { if (_initialized) { trader.ValuesChanged -= TraderOnValuesChanged; trader.MarketDepthsChanged -= TraderOnMarketDepthsChanged; } _quotesWindows.ForEach(pair => { trader.UnRegisterMarketDepth(pair.Key); DeleteHideableAndClose(pair.Value); }); _level1Windows.ForEach(pair => { trader.UnRegisterSecurity(pair.Key); DeleteHideableAndClose(pair.Value); }); _historyLevel1Windows.ForEach(pair => DeleteHideableAndClose(pair.Value)); _historyCandlesWindows.ForEach(pair => DeleteHideableAndClose(pair.Value)); } base.OnClosed(e); }
private decimal CalcPosDelta() { decimal delta = 0M; delta += _futuresPosition; delta += DeltaBuffer; _optionsPositions.ForEach(pair => { decimal?futPrice = null; if (pair.Value > 0) { futPrice = Security.BestBid?.Price; } if (pair.Value < 0) { futPrice = Security.BestAsk?.Price; } var bs = new BlackScholes(pair.Key, Security, Connector); delta += bs.Delta(DateTimeOffset.Now, null, futPrice).CheckIfValueNullThenZero() * pair.Value; }); return(delta); }
private void AddCacheMappings(AssemblyBuilder builder) { var mappings = new Dictionary <CacheKey, string>(); typeCache.ForEach((key, value) => { // NOTE: using == returns invalid results. // we need to use Equals here for it to work properly if (builder.Equals(value.Assembly)) { mappings.Add(key, value.FullName); } }); CacheMappingsAttribute.ApplyTo(builder, mappings); }