Пример #1
0
        private double MakeBuySpread()
        {
            IGenericFactory <double> factory =
                new BuySpreadFactory(this.leftLeg, this.rightLeg, this.quotesProvider);

            return(factory.Make());
        }
        public void CalculateSpreadOnQuotesUpdate(string symbol)
        {
            if (!arbitrageSettings.HasSymbol(symbol))
            {
                return;
            }

            double buySpreadPrice  = new BuySpreadFactory(this.arbitrageSettings.LeftLeg, this.arbitrageSettings.RightLeg, this.orderBook).Make();
            double sellSpreadPrice = new SellSpreadFactory(this.arbitrageSettings.LeftLeg, this.arbitrageSettings.RightLeg, this.orderBook).Make();

            if (buySpreadPrice == 0 || sellSpreadPrice == 0)
            {
                return;
            }

            SpreadValue lastSpread = GetLastSpreadValue();

            if (lastSpread != null &&
                lastSpread.BuyBeforePrice == buySpreadPrice &&
                lastSpread.SellAfterPrice == sellSpreadPrice)
            {
                return;
            }

            SpreadValue spreadValue = new SpreadValue(arbitrageSettings.Id, BrokerDateTime.Make(DateTime.Now), sellSpreadPrice, buySpreadPrice);

            this.logger.Log(String.Format("{0:dd/MM/yyyy H:mm:ss.fff}, {1}, выполнено вычисление нового значения {2}.", DateTime.Now, this.GetType().Name, spreadValue.ToString()));

            this.tradingData.Get <ObservableCollection <SpreadValue> >().Add(spreadValue);
        }
Пример #3
0
        public void BuySpreadFactory_returns_zero()
        {
            this.orderBook.Update(0, "Si-12.13_FT", 32000, 85, 32001, 25);
            this.orderBook.Update(0, "Eu-12.13_FT", 43800, 200, 43805, 210);

            IGenericFactory <double> factory =
                new BuySpreadFactory(this.leftLeg, this.rightLeg, this.orderBook);

            Assert.AreEqual(0, factory.Make());
        }