Exemple #1
0
        public void ProcessQuotation(Quotation quotation)
        {
            double newSpread = 0;

            foreach (var item in this.InstrumentModels)
            {
                if (item.InstrumentID == quotation.InstrumentID)
                {
                    item.Price = quotation.GetPrice(item.Direction);
                }
                if (item.Direction == this.InstrumentModels[0].Direction)
                {
                    newSpread += item.Volume * item.Price;
                }
                else
                {
                    newSpread -= item.Volume * item.Price;
                }
            }
            this.Spread = newSpread;
            if (!this.IsWork)
            {
                return;
            }
            if (this.Symbol == RelativeSymbol.GreaterOrEqual && this.Spread >= this.TriggerPrice ||
                this.Symbol == RelativeSymbol.LessOrEqual && this.Spread <= this.TriggerPrice)
            {
                this.IsWork = false;
                this.DoArbiOrder();
            }
        }
 public Quotation AddQuotation(Quotation qoutation)
 {
     qoutation.Id = ObjectId.GenerateNewId().ToString(); // TODO: Add calculation
     qoutation.GetPrice();
     qoutation.LastModified = DateTime.UtcNow;
     _quotations.Insert(qoutation);
     return(qoutation);
 }
Exemple #3
0
        public void Get_Correct_QuatationPrice()
        {
            // arrange
            _quotation.LivingArea       = 100;
            _quotation.DistanceInKm     = 10;
            _quotation.ExtraStorageArea = 0;
            var expected = 3300;

            // act
            var actual = _quotation.GetPrice();

            // assert
            Assert.AreEqual(expected, actual);
        }