Exemplo n.º 1
0
        public OutParameter ForeCastNextPrice()
        {
            MovingAverage ma = new EMA();

            try{
                float current = this.LiveMarketPrice();
                float avg     = ma.OneTimeUpdate(current, coinUpdate[parameters.Coin].Predicted, parameters.Period);
                if ((parameters.Strategy.Equals("EMADC")))
                {
                    current = ma.OneTimeUpdate(current, coinUpdate[parameters.Coin].Predicted, parameters.Period_1);
                    coinUpdate[parameters.Coin] = Builder <OutParameter> .CreateNew().With(x => x.Coin = parameters.Coin)
                                                  .With(x => x.Current  = current).With(x => x.Predicted = avg)
                                                  .With(x => x.Decision = this.Decision(avg, current)).Build();
                }
                else
                {
                    coinUpdate[parameters.Coin] = Builder <OutParameter> .CreateNew().With(x => x.Coin = parameters.Coin)
                                                  .With(x => x.Current  = current).With(x => x.Predicted = avg)
                                                  .With(x => x.Decision = this.Decision(current, avg)).Build();
                }
            }
            catch (Exception ex) {
                Console.WriteLine("Exception: " + ex);
            }
            return(coinUpdate[parameters.Coin]);
        }
        public void TestOneTimeUpdate()
        {
            MovingAverage ma = new EMA();

            Assert.Equal(6672.21f, ma.OneTimeUpdate(6672.21f, 1.34f, 1));
        }