Beispiel #1
0
        public Publisher()
        {
            Random random = new Random();

            Dictionary <long, string> symbols = new Dictionary <long, string>();

            symbols.Add(1, "VOD LN");
            symbols.Add(2, "IBIC LN");
            symbols.Add(3, "SEM FP");
            symbols.Add(4, "KAR GY");
            symbols.Add(5, "EO9F GY");

            DateTime mkdtDate = DateTime.UtcNow;
            PriceBar pBar     = new PriceBar();

            pBar.Close  = 99;
            pBar.High   = 102;
            pBar.Low    = 98;
            pBar.Open   = 100;
            pBar.Volume = 50;
            pBar.Date   = mkdtDate;

            _pub = Observable.Interval(TimeSpan.FromMilliseconds(250))
                   .Select(t => {
                GeneratePrices.GenerateRandomBar(pBar);
                return(pBar);
            });
        }
Beispiel #2
0
        public static void GenerateRandomBar(PriceBar newBar)
        {
            double fluct    = 0.025;
            double volFluct = 0.40;

            //Open is equal to the previous close
            newBar.Open   = newBar.Close;
            newBar.Close  = GetRandomNumber(newBar.Close - newBar.Close * fluct, newBar.Close + newBar.Close * fluct);
            newBar.High   = GetRandomNumber(Math.Max(newBar.Close, newBar.Open), Math.Max(newBar.Close, newBar.Open) + Math.Abs(newBar.Close - newBar.Open) * fluct);
            newBar.Low    = GetRandomNumber(Math.Min(newBar.Close, newBar.Open), Math.Min(newBar.Close, newBar.Open) - Math.Abs(newBar.Close - newBar.Open) * fluct);
            newBar.Volume = (long)GetRandomNumber(newBar.Volume - newBar.Volume * volFluct, newBar.Volume + newBar.Volume * volFluct);
        }
Beispiel #3
0
 private void OnNext(PriceBar priceBar)
 {
     PriceQueue.Add(priceBar);
 }