示例#1
0
文件: TickData.cs 项目: herohut/elab
 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;
 }
示例#2
0
        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();
        }
示例#3
0
        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);
        }