/// <summary> /// Generate new StockMarketDataPoint based on the passed StockMarketDataPoint /// </summary> /// <param name="dataPoint"></param> /// <returns></returns> public static StockMarketDataPoint GenerateDataPoint(StockMarketDataPoint dataPoint) { double open = GenerateStockOpen(dataPoint.Close); //double open = GenerateStockOpen(dataPoint.Low, dataPoint.High); //double open = GenerateStockRandom(); double high = GenerateStockHigh(open); double low = GenerateStockLow(open); double close = GenerateStockClose(low, high); double volume = GenerateStockVolume(dataPoint.Volume); DateTime date = dataPoint.Date.Add(Settings.DateInterval); int index = dataPoint.Index + 1; LastDataPoint = new StockMarketDataPoint { Index = index, Date = date, Open = open, Close = close, High = high, Low = low, Volume = volume }; return(LastDataPoint); }
public void OnStockMarketDataReceived(StockMarketDataPoint data) { if (StockMarketDataReceived != null) { StockMarketDataReceived(this, new StockMarketDataReceivedEventArgs(data)); } }
public StockMarketDataPoint(StockMarketDataPoint dataPoint) { _date = dataPoint.Date; _open = dataPoint.Open; _high = dataPoint.High; _low = dataPoint.Low; _close = dataPoint.Close; _volume = dataPoint.Volume; _index = dataPoint.Index; }
/// <summary> /// Generate List of StockMarketDataPoint based on the Settings /// </summary> /// <returns></returns> public static List <StockMarketDataPoint> GenerateData() { List <StockMarketDataPoint> data = new List <StockMarketDataPoint>(); StockMarketDataPoint dataPoint = new StockMarketDataPoint { Index = -1, Close = Settings.PriceStart, Volume = Settings.VolumeStart, Date = Settings.DateStart }; CurrentRandomValue = Settings.PriceStart; for (int i = 0; i < Settings.DataPoints; i++) { dataPoint = GenerateDataPoint(dataPoint); data.Add(dataPoint); } return(data); }
/// <summary> /// Generate new StockMarketDataPoint based on the last StockMarketDataPoint in List of StockMarketDataPoint /// </summary> /// <returns></returns> public static StockMarketDataPoint GenerateDataPoint() { StockMarketDataPoint newDataPoint = GenerateDataPoint(LastDataPoint); return(newDataPoint); }
public StockMarketDataReceivedEventArgs(StockMarketDataPoint data) { this.NewDataPoint = data; }
private void OnTimerTick(object sender, EventArgs e) { // generate new StockMarketData using StockMarketGenerator _lastDataPoint = StockMarketGenerator.GenerateDataPoint(_lastDataPoint); OnStockMarketDataReceived(_lastDataPoint); }