private void SetInstrumentForFloatingPLCalc() { InstrumentForFloatingPLCalc instrumentForPL = this._ChangePriceGrid.ActiveCell.Row.Data as InstrumentForFloatingPLCalc; if (instrumentForPL == null) { return; } instrumentForPL.Bid = this.BidText.Text; ExchangeSettingManager settingManager = App.MainFrameWindow.ExchangeDataManager.GetExchangeSetting(this._ExchangCode); InstrumentClient instrument = settingManager.GetInstrument(instrumentForPL.InstrumentId); if (instrument == null) { return; } int spread = int.Parse(this.SpreadText.Text); Price bidPrice = new Price(instrumentForPL.Bid, instrument.NumeratorUnit, instrument.Denominator); Price askPrice = bidPrice + spread; instrumentForPL.Ask = askPrice.ToString(); instrumentForPL.SpreadPoint = spread; }
public override void init() { base.init(); registerHeartbeatListener((s, a) => { string heartbeat = Encoding.UTF8.GetString(a.Message.Data, 0, a.Message.Data.Length); var found_list = _clients.Where((participant) => participant.id.Equals(heartbeat)).ToList(); //we dont have a client for the heartbeat we just saw //so create one if (found_list.Count == 0) { IClient client; //create a client for this participant and add to list client = new Client(heartbeat, Role.None, ECOMMS_Entity.Type.None); client.connect(server); client.init(); //use this base client to find out the role of the client that //just connected //if its an instrument then create an instrument client //and add it //if we have a factory instance then use it otherwise //create a base class entity _clients.Add(client); client.addObserver(new ObserverAdapter((o, h) => { switch (h as string) { case "INITIALIZED": if (client.role == Role.Instrument && _clientFactory == null) { var instrumentClient = new InstrumentClient(heartbeat, client.type); instrumentClient.connect(server); instrumentClient.init(); client = instrumentClient; } else if (_clientFactory != null) { IClient tempClient = _clientFactory.getClientFor(heartbeat, client.role, client.type, SubType.None); if (tempClient != null) { tempClient.connect(server); tempClient.init(); client = tempClient; } } notify("CLIENTS_CHANGED"); notify("CONNECTED", client); break; case "ONLINE_CHANGED": if (!client.online) { _clients.Remove(client); notify("CLIENTS_CHANGED"); client.removeAllObservers(); client.removeAllListeners(); } break; } })); } }); }