public void OrderedUpdate(UpdateState state) { this.EnqueueOrderedUpdate(state); }
public static void UpdateState(UpdateState state) { Game.State.Current.Period = state.Period; Game.State.Current.Tick = state.Tick; if (state.AddedOrders != null) { StateManager.AddOrders(state.AddedOrders.ToArray()); } if (state.UpdatedOrders != null) { StateManager.UpdateOrders(state.UpdatedOrders.ToArray()); } if (state.CancelledOrders != null) { StateManager.CancelOrder(state.CancelledOrders.ToArray()); } if (state.UpdatedAssets != null) { StateManager.UpdateAsset(state.UpdatedAssets.ToArray()); } if (state.UnleasedAssets != null) { StateManager.RemoveAsset(state.UnleasedAssets.ToArray()); } if (state.UpdatedPortfolio != null) { foreach (PortfolioUpdateMessage current in state.UpdatedPortfolio.Values) { StateManager.UpdatePortfolio(current); } } if (state.UpdatedTradingLimits != null) { foreach (TradingLimitUpdateMessage current2 in state.UpdatedTradingLimits.Values) { StateManager.UpdateTradingLimits(current2); } } if (state.AddedTransactions != null) { StateManager.MergeTransactions(state.AddedTransactions.ToArray()); } if (state.UpdatedLast != null) { foreach (System.Collections.Generic.KeyValuePair<string, decimal> current3 in state.UpdatedLast) { Game.State.Securities[current3.Key].Last = current3.Value; } } if (state.UpdatedVolume != null) { foreach (System.Collections.Generic.KeyValuePair<string, decimal> current4 in state.UpdatedVolume) { Game.State.Securities[current4.Key].Volume += current4.Value; Game.State.Securities[current4.Key].VolumeChart.AddPoint(Game.State.Current.Period, Game.State.Current.Tick, new SecurityVolumeChartPoint(current4.Value)); } } if (state.UpdatedVWAP != null) { foreach (System.Collections.Generic.KeyValuePair<string, decimal> current5 in state.UpdatedVWAP) { Game.State.Securities[current5.Key].VWAP = current5.Value; } } if (state.UpdatedNLV.HasValue) { Game.State.NLV = state.UpdatedNLV.Value; } if (state.UpdatedSecurityNLV != null) { foreach (System.Collections.Generic.KeyValuePair<string, decimal> current6 in state.UpdatedSecurityNLV) { Game.State.PortfolioTable.Rows.Find(current6.Key)["NLV"] = current6.Value; } } if (state.UpdatedOTC != null) { foreach (OTCUpdateMessage current7 in state.UpdatedOTC) { if (current7.Status == OTCStatus.PENDING) { StateManager.AddOTCOrder(current7.ID, current7.TraderID, current7.Target, current7.Ticker, current7.Volume, current7.Price, current7.SettlePeriod, current7.SettleTick); } else { Game.State.OTCOrderTable.Rows.Find(current7.ID)["Status"] = current7.Status; } } } if (state.UpdatedElectricity != null) { foreach (Tuple<int, double> current8 in state.UpdatedElectricity) { Game.State.ElectricityCharts[current8.Item1].AddPoint(current8.Item2); } } }
private void EnqueueOrderedUpdate(UpdateState update = null) { lock (this.SyncRoot) { if (update != null) { this.OrderedUpdateQueue.Add(update.ID, update); } while (this.IsSynced && this.OrderedUpdateQueue.Count > 0 && this.OrderedUpdateQueue.First<System.Collections.Generic.KeyValuePair<int, UpdateState>>().Key == this.UpdateID) { UpdateState state = this.OrderedUpdateQueue[this.UpdateID]; this.OrderedUpdateQueue.Remove(this.UpdateID); this.UpdateID++; ThreadHelper.MainThread.BeginInvokeIfRequired(delegate { StateManager.UpdateState(state); }); } } }