public StockTickerData(StockTickerData stockData) { this.Open = stockData.Open; this.High = stockData.High; this.Low = stockData.Low; this.Close = stockData.Close; this.Volume = stockData.Volume; this.Date = stockData.Date; }
public StockTickerData ToStockData() { var stockData = new StockTickerData(); stockData.Close = LastTradeAmount; stockData.Open = Open; stockData.High = DailyHigh; stockData.Low = DailyLow; stockData.Volume = Volume; stockData.Date = LastUpdate; return(stockData); }
public void UpdateStockPrices() { var twoSecIndex = DateTime.Now.Second % 2; //we're in the same 2-sec interval, just update values if (oldTwoSecIndex == twoSecIndex) { TickerSellData.Close = this.Bid; if (TickerSellData.High < this.Bid) { TickerSellData.High = this.Bid; } if (TickerSellData.Low > this.Bid) { TickerSellData.Low = this.Bid; } TickerBuyData.Close = this.Ask; if (TickerBuyData.High < this.Ask) { TickerBuyData.High = this.Ask; } if (TickerBuyData.Low > this.Ask) { TickerBuyData.Low = this.Ask; } } //change of interval, add current data to buffers, initialize new ticker data else { //oldTwoSec is -1 the first time a position is updated, so insert the ticker data if it's different from -1 if (oldTwoSecIndex != -1) { TickerBuyDataList.Add(TickerBuyData); TickerSellDataList.Add(TickerSellData); //keep track of the last minute of real-time data //30 2-sec intervals = one minutes worth of data //remove the oldest data point once data for more than a minute is accumulated if (TickerBuyDataList.Count == 31) { TickerBuyDataList.RemoveAt(0); } if (TickerSellDataList.Count == 31) { TickerSellDataList.RemoveAt(0); } } oldTwoSecIndex = twoSecIndex; TickerSellData = new StockTickerData(); TickerSellData.Date = DateTime.Now; TickerSellData.Open = this.Bid; TickerSellData.Close = this.Bid; TickerSellData.High = this.Bid; TickerSellData.Low = this.Bid; TickerBuyData = new StockTickerData(); TickerBuyData.Date = DateTime.Now; TickerBuyData.Open = this.Ask; TickerBuyData.Close = this.Ask; TickerBuyData.High = this.Ask; TickerBuyData.Low = this.Ask; } }