public OrderModel ToOrder(CurrencyMapping mapping) { var instrument = CexIoInstrument.FromPair(Symbol1, Symbol2); TradeType type; switch (Type?.ToLowerInvariant()) { case "buy": type = TradeType.Buy; break; case "sell": type = TradeType.Sell; break; default: throw new InvalidOperationException($"Type {Type} is unknown"); } return(new OrderModel { Id = Id, AssetPair = CexIoInstrument.ToLykkeInstrument(instrument, mapping), Price = Price, OriginalVolume = Amount, TradeType = type, Timestamp = Time, RemainingAmount = Pending, ExecutedVolume = Amount - Pending }); }
public async Task <IReadOnlyCollection <string> > GetInstruments() { var limits = await Api.GetCurrencyLimits(); return(limits .Select(x => CexIoInstrument.FromPair(x.Symbol1, x.Symbol2)) .Select(x => CexIoInstrument.ToLykkeInstrument(x, _currencyMapping)) .ToArray()); }
private IObservable <OrderBook> CombineWithSnapshot( IObservable <IOrderBookMessage> changes, string instrument) { return(changes.Scan( OrderBookAggregator.CreateDefault( _logFactory, Name, CexIoInstrument.ToLykkeInstrument(instrument, _orderBookSettings.CurrencyMapping)), (context, ev) => context.ApplyChange(ev)) .Select(x => x.OrderBook)); }
public OrderModel ToOrder(CurrencyMapping mapping, string orderType) { var instrument = CexIoInstrument.FromPair(Symbol1, Symbol2); return(new OrderModel { Id = Id, TradeType = Enum.Parse <TradeType>(Type, true), Price = Price, Timestamp = Time, RemainingAmount = Remains, AssetPair = CexIoInstrument.ToLykkeInstrument(instrument, mapping), OriginalVolume = Amount, ExecutedVolume = Amount - Remains, ExecutionStatus = Status.ToOrderStatus() }); }
public void cex_io_instruments_to_lykke(string cexIo, string lykke) { Assert.Equal(lykke, CexIoInstrument.ToLykkeInstrument(cexIo, _mapping)); Assert.Equal(cexIo, CexIoInstrument.FromLykkeInstrument(lykke, _mapping)); }