private void PriceUpdateHandler(IPriceService sender, uint instrumentID, IPrices prices) { Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate() { Instruments[(int)instrumentID].UpdatePrices(prices); }); }
/// <summary> /// used to receive updates /// </summary> private void _priceUpdateService_NewPricesArrived(IPriceService sender, uint instrumentID, IPrices prices) { var price = new Price() { AskPx = prices.AskPx, AskQty = prices.AskQty, BidPx = prices.BidPx, BidQty = prices.BidQty, Volume = prices.Volume, LastUpdatedDate = DateTime.Now, InstrumentID = instrumentID }; _bgWorkerTask.ContinueWith(new Action<Task>((t)=>UpdateToLastPrice(price)), TaskContinuationOptions.PreferFairness); }
private void PriceUpdateHandler(IPriceService sender, uint instrumentID, IPrices prices) { if (_resetFlag) { _queue.Add(new Instrument() { InstrumentId = instrumentID, AskPx = prices.AskPx, AskQty = prices.AskQty, BidPx = prices.BidPx, BidQty = prices.BidQty, Volume = prices.Volume }); } }
public void UpdatePrices(IPrices newPrices) { if (_stopwatch.Elapsed > RefreshPeriod) { DeltaBidPx = ComputeDelta(BidPx, newPrices.BidPx); DeltaAskPx = ComputeDelta(AskPx, newPrices.AskPx); BidPx = newPrices.BidPx; BidQty = newPrices.BidQty; AskPx = newPrices.AskPx; AskQty = newPrices.AskQty; Volume = newPrices.Volume; _stopwatch.Restart(); } }
public async Task <IActionResult> Prices([FromServices] IPrices prices, string securityId, DateTime?forDate = null, int dayCount = 5) { try { var runDate = forDate ?? DateTime.Today.Date; Logger.LogInformation(default(EventId), message: $"Retrieving Prices for {runDate}; security: {securityId}; for days: {dayCount}."); var result = await prices .GetPriceRecords(securityId, runDate, dayCount) .ConfigureAwait(false); Logger.LogInformation(default(EventId), message: $"Exit Prices: retrieved {result.Count} records."); return(new OkObjectResult(result)); } catch (Exception ex) { Logger.LogError(default(EventId), message: "Unexpected Exception:", exception: ex); return(this.StatusCode(500, $"Unexpected Exception: {ex}")); } }
static void PriceUpdateHandler(IPriceService sender, uint instrumentID, IPrices prices) { Console.WriteLine("{0}: BidPx: {1:#.##}, AskPx: {2:#.##}, BidQty: {3}, AskQty: {4}, Vol: {5}", instrumentID, prices.BidPx, prices.AskPx, prices.BidQty, prices.AskQty, prices.Volume); }
/// <summary> /// Changes the content of our collection of Instruments /// This handler is invoked 20 times a second /// </summary> /// <param name="sender"></param> /// <param name="instrumentID"></param> /// <param name="prices"></param> void PriceUpdateHandler(IPriceService sender, uint instrumentID, IPrices prices) { int instruId = (int)instrumentID; Prices newPrices = (Prices)prices; if (tradeItems.ContainsKey(instruId)) { tradeItemsCollection[instruId].AskPx = newPrices.AskPx; tradeItemsCollection[instruId].AskQty = newPrices.AskQty; tradeItemsCollection[instruId].BidPx = newPrices.BidPx; tradeItemsCollection[instruId].BidQty = newPrices.BidQty; tradeItemsCollection[instruId].Volume = newPrices.Volume; // Also set dirty flag to true tradeItemsCollection[instruId].IsBidPxDirty = true; tradeItemsCollection[instruId].IsAskPxDirty = true; } else { tradeItems.Add((int)instrumentID, (Prices)prices); } }
public GroceryCart(IPrices prices) { _cart = new Dictionary <Item, double>(); _prices = prices; // This will be our pretend db }
public PriceChange(string name_, IPrices underlying_) { m_name = name_; m_underlying = underlying_; m_underlying.PropertyChanged += handleUnderlyingChanged; }
public PriceController(IPrices price) { _price = price; }