Ejemplo n.º 1
0
 /// <summary>
 /// </summary>
 /// <param name="openPrice"></param>
 /// <param name="game"></param>
 public void Open(Quotation openPrice, Game game)
 {
     if (openPrice == null)
     {
         throw new ArgumentNullException(nameof(openPrice));
     }
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     if (game.Symbol == null)
     {
         throw new ArgumentException("Game can't be null.");
     }
     Game            = game;
     ConfirmDateTime = DateTime.Now;
     OpenInfo.Price  = openPrice;
     CloseTime       = Game.GetCloseTime(openPrice.ArrivedTime.DateTime);
     Status          = OrderStatus.Opening;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="closePrice"></param>
        public void Close(Quotation closePrice)
        {
            if (closePrice == null)
            {
                throw new ArgumentNullException(nameof(closePrice));
            }

            CloseInfo.Price        = closePrice;
            CloseInfo.CompleteTime = DateTime.Now;
            Status = OrderStatus.Completed;

            if (closePrice == OpenInfo.Price)
            {
                Profit = 0;
            }
            else if (closePrice.Bid > OpenInfo.Price.Bid)
            {
                Profit = Direction == Direction.Down ? -Volume : Volume * Game.Rate;
            }
            else
            {
                Profit = Direction == Direction.Up ? -Volume : Volume * Game.Rate;
            }
        }