Exemplo n.º 1
0
        /// <summary>Convert a Poloniex order into an order</summary>
        private Order OrderFrom(global::Poloniex.API.DomainObjects.Order order, DateTimeOffset updated)
        {
            var order_id   = order.OrderId;
            var fund_id    = OrderIdToFund(order_id);
            var ot         = EOrderType.Limit;
            var tt         = Misc.TradeType(order.Type);
            var pair       = Pairs.GetOrAdd(order.Pair.Base, order.Pair.Quote);
            var amount_in  = tt.AmountIn(order.AmountBase._(pair.Base), order.PriceQ2B._(pair.RateUnits));
            var amount_out = tt.AmountOut(order.AmountBase._(pair.Base), order.PriceQ2B._(pair.RateUnits));
            var created    = order.Created;

            return(new Order(order_id, fund_id, pair, ot, tt, amount_in, amount_out, amount_in, created, updated));
        }
Exemplo n.º 2
0
        /// <summary>Convert an exchange specific open order result into an order</summary>
        private Order OrderFrom(global::Bittrex.API.DomainObjects.Order order, DateTimeOffset updated)
        {
            // Get the associated trade pair (add the pair if it doesn't exist)
            var order_id     = ToIdPair(order.OrderId).OrderId;
            var fund_id      = OrderIdToFund(order_id);
            var ot           = EOrderType.Limit;
            var tt           = Misc.TradeType(order.Type);
            var pair         = Pairs.GetOrAdd(order.Pair.Base, order.Pair.Quote);
            var amount_in    = tt.AmountIn(order.AmountBase._(pair.Base), order.LimitQ2B._(pair.RateUnits));
            var amount_out   = tt.AmountOut(order.AmountBase._(pair.Base), order.LimitQ2B._(pair.RateUnits));
            var remaining_in = tt.AmountIn(order.RemainingBase._(pair.Base), order.LimitQ2B._(pair.RateUnits));
            var created      = order.Created;

            return(new Order(order_id, fund_id, pair, ot, tt, amount_in, amount_out, remaining_in, created, updated));
        }
Exemplo n.º 3
0
        /// <summary>Convert a Cryptopia trade history result into a position object</summary>
        private TradeCompleted TradeCompletedFrom(global::Bittrex.API.DomainObjects.Trade his, DateTimeOffset updated)
        {
            // Get the associated trade pair (add the pair if it doesn't exist)
            // Bittrex doesn't use trade ids. Make them up using the Remaining
            // volume so that each trade for a given order is unique (ish).
            var ids             = ToIdPair(his.OrderId);
            var order_id        = ids.OrderId;
            var trade_id        = ids.TradeId;
            var tt              = Misc.TradeType(his.Type);
            var pair            = Pairs.GetOrAdd(his.Pair.Base, his.Pair.Quote);
            var amount_in       = tt.AmountIn(his.FilledBase._(pair.Base), his.PricePerUnit._(pair.RateUnits));
            var amount_out      = tt.AmountOut(his.FilledBase._(pair.Base), his.PricePerUnit._(pair.RateUnits));
            var commission      = his.Commission._(pair.Quote);
            var commission_coin = pair.Quote;
            var created         = his.Created;

            return(new TradeCompleted(order_id, trade_id, pair, tt, amount_in, amount_out, commission, commission_coin, created, updated));
        }