public async Task <TradeOrderStatusResponse> GetOrderStatusAsync(RemoteMarketIdContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "orderNumber", context.RemoteGroupId }, { "currencyPair", context.Market.ToTicker(this) } }; var rRaw = await api.QueryOrderAsync(body).ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); if (r?.order == null) { throw new NoTradeOrderException(context, this); } var isBuy = r.order.type.IndexOf("buy", StringComparison.OrdinalIgnoreCase) >= 0; var isOpen = r.order.status.IndexOf("open", StringComparison.OrdinalIgnoreCase) >= 0; return(new TradeOrderStatusResponse(Network, r.order.id, isBuy, isOpen, false) { TradeOrderStatus = { Rate = r.order.rate, AmountInitial = r.order.initial_amount, AmountRemaining = r.order.amount } }); }
public async Task <TradeOrderStatusResponse> GetOrderStatusAsync(RemoteMarketIdContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "MsgType", "U4" }, { "OrdersReqID", 1 } }; var rActiveOrdersRaw = await api.QueryActiveOrdersAsync(body).ConfigureAwait(false); CheckResponseErrors(rActiveOrdersRaw); var rActiveOrders = rActiveOrdersRaw.GetContent(); var activeOrder = rActiveOrders.OrdListGrp?.FirstOrDefault(x => x.OrderID.Equals(context.RemoteGroupId)); if (activeOrder == null) { throw new NoTradeOrderException(context, this); } var isBuy = activeOrder.Side == 1; return(new TradeOrderStatusResponse(Network, activeOrder.OrderID, isBuy, true, false) { TradeOrderStatus = { Rate = activeOrder.Price, Market = activeOrder.Symbol.ToAssetPair(this) } }); }
public async Task <bool> TestPrivateApiAsync(ApiPrivateTestContext context) { var api = ApiPrivateProvider.GetApi(context); var rRaw = await api.GetBalancesAsync().ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); return(r.result); }
public async Task <bool> TestPrivateApiAsync(ApiPrivateTestContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "MsgType", "U2" }, { "BalanceReqID", 1 } }; var rRaw = await api.GetBalanceAsync(body).ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); return(r != null); }
public async Task <WithdrawalPlacementResult> PlaceWithdrawalAsync(WithdrawalPlacementContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "currency", context.Amount.Asset.ShortCode }, { "amount", context.Amount.ToDecimalValue() }, { "address", context.Address.Address } }; var rRaw = await api.PlaceWithdrawalAsync(body).ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); return(new WithdrawalPlacementResult()); }
public async Task <PlacedOrderLimitResponse> PlaceOrderLimitAsync(PlaceOrderLimitContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "amount", context.Quantity.ToDecimalValue() }, { "rate", context.Rate.ToDecimalValue() }, { "currencyPair", context.Pair.ToTicker(this) } }; var rRaw = await api.NewOrderAsync(context.IsBuy? "buy" : "sell", body).ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); return(new PlacedOrderLimitResponse(null)); }
public async Task <PlacedOrderLimitResponse> PlaceOrderLimitAsync(PlaceOrderLimitContext context) { var api = ApiPrivateProvider.GetApi(context); var body = new Dictionary <string, object> { { "MsgType", "D" }, { "ClOrdID", 1 }, { "Symbol", context.Pair.ToTicker(this) }, { "Side", context.IsBuy ? "1" : "2" }, { "OrdType", "2" }, { "Price", context.Rate.ToInt64(null) }, { "OrderQty", context.Quantity.ToInt32(null) }, { "BrokerID", 5 } }; var rRaw = await api.NewOrderAsync(body).ConfigureAwait(false); CheckResponseErrors(rRaw); var r = rRaw.GetContent(); return(new PlacedOrderLimitResponse(r.OrderID)); }