Exemplo n.º 1
0
        public override void RevertEffect()
        {
            MarkAsProcessed();

            orderBook.RemoveOrder(Effect.OrderId);

            var decodedId = OrderIdConverter.Decode(order.OrderId);

            if (decodedId.Side == OrderSide.Buy)
            {
                order.AccountWrapper.Account.GetBalance(0).UpdateLiabilities(-order.QuoteAmount);
            }
            else
            {
                order.AccountWrapper.Account.GetBalance(decodedId.Asset).UpdateLiabilities(-order.Amount);
            }
        }
Exemplo n.º 2
0
        public override void CommitEffect()
        {
            MarkAsProcessed();
            if (!orderbook.RemoveOrder(Effect.OrderId))
            {
                throw new Exception($"Unable to remove order with id {Effect.OrderId}");
            }

            var decodedId = OrderIdConverter.Decode(Effect.OrderId);

            if (decodedId.Side == OrderSide.Buy)
            {
                Effect.AccountWrapper.Account.GetBalance(0).UpdateLiabilities(-Effect.QuoteAmount);
            }
            else
            {
                Effect.AccountWrapper.Account.GetBalance(decodedId.Asset).UpdateLiabilities(-Effect.Amount);
            }
        }