public static Infrastructure.Common.Models.Market.CurrencyPair ToOuterModel(this MarketInstrument source) { var target = new Infrastructure.Common.Models.Market.CurrencyPair { Id = source.Figi, BaseCurrencyId = source.Ticker, QuoteCurrencyId = source.Currency.ToString(), QuantityIncrement = source.MinPriceIncrement, TickSize = source.Lot, FeeCurrencyId = source.Currency.ToString() }; return(target); }
public static Infrastructure.Common.Models.Market.CurrencyPair ToOuterModel(this CurrencyPair source) { var target = new Infrastructure.Common.Models.Market.CurrencyPair { Id = source.Id, BaseCurrencyId = source.BaseCurrencyId, QuoteCurrencyId = source.QuoteCurrencyId, QuantityIncrement = source.QuantityIncrement, TickSize = source.TickSize, TakeLiquidityRate = source.TakeLiquidityRate, ProvideLiquidityRate = source.ProvideLiquidityRate, FeeCurrencyId = source.FeeCurrencyId }; return(target); }
public async Task SubscribeOrders(Infrastructure.Common.Models.Market.CurrencyPair targetCurrencyPair, Action <Infrastructure.Common.Models.Trading.Order> callback) { var request = new SocketSubscriptionRequest <EmptyRequestParameters> { RequestMethodName = "subscribeReports", SnapshotMethodName = null, NotificationMethodName = "activeOrders", UnsubscribeMethodName = null, RequestParameters = new EmptyRequestParameters() }; await _connection.Subscribe <Order[]>(request, orders => { foreach (var order in orders) { if (order.CurrencyPairId != targetCurrencyPair.Id) { continue; } var result = order.ToOuterModel(targetCurrencyPair); callback(result); } }); request = new SocketSubscriptionRequest <EmptyRequestParameters> { RequestMethodName = "subscribeReports", SnapshotMethodName = null, NotificationMethodName = "report", UnsubscribeMethodName = null, RequestParameters = new EmptyRequestParameters() }; await _connection.Subscribe <Order>(request, order => { if (order.CurrencyPairId != targetCurrencyPair.Id) { return; } var result = order.ToOuterModel(targetCurrencyPair); callback(result); }); }
public async Task<Infrastructure.Common.Models.Trading.Order> GetOrderFromHistory(Guid clientOrderId, Infrastructure.Common.Models.Market.CurrencyPair currencyPair) { var connection = new HitBtcConnection(); var request = new RestRequest("history/order", Method.GET); request.ConfigureRequest(); request.AddParameter("clientOrderId", clientOrderId.ToString("N")); var exchangeConnectionSettings = _configurationService.GetExchangeConnectionSettings(); var response = await connection.DoRequest( request, exchangeConnectionSettings.ApiKey, exchangeConnectionSettings.SecretKey); var order = response .ExtractResponseData<Order[]>() .Select(entity => entity.ToOuterModel(currencyPair)) .FirstOrDefault(); return order; }
public async Task<IList<Infrastructure.Common.Models.Trading.Order>> GetActiveOrders(Infrastructure.Common.Models.Market.CurrencyPair currencyPair) { var connection = new HitBtcConnection(); var request = new RestRequest("order", Method.GET); request.ConfigureRequest(); var exchangeConnectionSettings = _configurationService.GetExchangeConnectionSettings(); var response = await connection.DoRequest( request, exchangeConnectionSettings.ApiKey, exchangeConnectionSettings.SecretKey); var orders = response .ExtractResponseData<Order[]>() .Where(order => order.CurrencyPairId == currencyPair.Id) .Select(entity => entity.ToOuterModel(currencyPair)) .ToList(); return orders; }
public async Task <Order> GetOrderFromHistory(Guid clientOrderId, Infrastructure.Common.Models.Market.CurrencyPair currencyPair) { return(await _stockRestConnector.GetOrderFromHistory(clientOrderId, currencyPair)); }
public async Task <IList <Order> > GetActiveOrders(Infrastructure.Common.Models.Market.CurrencyPair currencyPair) { return(await _stockRestConnector.GetActiveOrders(currencyPair)); }