public static TickData RandomATick(double high, double low, DateTime time) { var open = low + Random.NextDouble() * (high - low); var close = low + Random.NextDouble() * (high - low); var t = new TickData("M$", high, low, open, close, time); return t; }
public void Run() { var timer = new Timer(1000); var current = 10.2; const int deltaChange = 50; const int maxRange = 400; var time = DateTime.Now; timer.Elapsed += (s, a) => { _lastTick = TickData.RandomATicks2(current, deltaChange, maxRange, 60, 30, time); var msg = BuildTransferMessage(_lastTick); SendToAll(msg); var msg2 = BuildTransferMessage(new ChatMessage { From = "System", To = "AllClients", Content = "Welcome", Time = DateTime.Now }); SendToAll(msg2); current = Math.Max(Math.Min(TickData.Random.NextDouble() > 0.5 ? -TickData.Random.NextDouble() * deltaChange + current : TickData.Random.NextDouble() * deltaChange + current, maxRange), 0); time = time.AddSeconds(20); }; timer.Start(); }
public static TickData RandomATick(double high, double low, DateTime time) { var open = low + Random.NextDouble() * (high - low); var close = low + Random.NextDouble() * (high - low); var t = new TickData("M$", high, low, open, close, time); return(t); }