public BitfinexExecutionHarvester(IBitfinexWebSocketSubscriber socketSubscriber, BitfinexModelConverter bitfinexModelConverter, IHandler <ExecutionReport> handler, ILog log) { _socketSubscriber = socketSubscriber; _bitfinexModelConverter = bitfinexModelConverter; _handler = handler; _log = log; }
private ExecutionReport OrderToTrade(Order order) { var id = order.Id; var execTime = order.Timestamp; var execPrice = order.Price; var execVolume = order.ExecutedAmount; var tradeType = BitfinexModelConverter.ConvertTradeType(order.Side); var status = ConvertExecutionStatus(order); var instr = _modelConverter.ExchangeSymbolToLykkeInstrument(order.Symbol); return(new ExecutionReport(instr, execTime, execPrice, execVolume, tradeType, id, status) { ExecType = ExecType.Trade, Success = true, FailureType = OrderStatusUpdateFailureType.None }); }
private async Task HandleResponse(OrderBookUpdateResponse response) { var orderBookItem = BitfinexModelConverter.ToOrderBookItem(response); var pair = _channels[response.ChannelId].Pair; response.Pair = pair; if (response.Price == 0) { await HandleOrdersEventsAsync(response.Pair, OrderBookEventType.Delete, new[] { orderBookItem }); } else { await HandleOrdersEventsAsync(response.Pair, OrderBookEventType.Add, new[] { orderBookItem }); } }
public BitfinexExchange(BitfinexExchangeConfiguration configuration, TranslatedSignalsRepository translatedSignalsRepository, BitfinexOrderBooksHarvester orderBooksHarvester, BitfinexExecutionHarvester executionHarvester, ILog log) : base(Name, configuration, translatedSignalsRepository, log) { _modelConverter = new BitfinexModelConverter(configuration); _orderBooksHarvester = orderBooksHarvester; _executionHarvester = executionHarvester; var credenitals = new BitfinexServiceClientCredentials(configuration.ApiKey, configuration.ApiSecret); _exchangeApi = new BitfinexApi(credenitals) { BaseUri = new Uri(configuration.EndpointUrl) }; orderBooksHarvester.MaxOrderBookRate = configuration.MaxOrderBookRate; }