public TickerItem(IWampSerializedEvent e) { CurrencyPair = e.Arguments[0].Deserialize <string>(); Last = e.Arguments[1].Deserialize <decimal>(); LowestAsk = e.Arguments[2].Deserialize <decimal>(); HighestBid = e.Arguments[3].Deserialize <decimal>(); PercentChange = e.Arguments[4].Deserialize <decimal>(); BaseVolume = e.Arguments[5].Deserialize <decimal>(); QuoteVolume = e.Arguments[6].Deserialize <decimal>(); IsFrozen = e.Arguments[7].Deserialize <bool>(); High24H = e.Arguments[8].Deserialize <decimal>(); Low24H = e.Arguments[9].Deserialize <decimal>(); }
PoloniexTicker IWampEventValueTupleConverter <PoloniexTicker> .ToTuple(IWampSerializedEvent @event) { PoloniexTicker res = new PoloniexTicker(); res.CurrencyPair = @event.Arguments[0].Deserialize <string>(); res.Last = @event.Arguments[1].Deserialize <double>(); res.LowestAsk = @event.Arguments[2].Deserialize <double>(); res.HighestBid = @event.Arguments[3].Deserialize <double>(); res.Change = @event.Arguments[4].Deserialize <double>(); res.BaseVolume = @event.Arguments[5].Deserialize <double>(); res.Volume = @event.Arguments[6].Deserialize <double>(); res.IsFrozen = @event.Arguments[7].Deserialize <int>() > 0; res.Hr24High = @event.Arguments[8].Deserialize <double>(); res.Hr24Low = @event.Arguments[9].Deserialize <double>(); res.Time = DateTime.Now; return(res); }
PoloniexTicker IWampEventValueTupleConverter <PoloniexTicker> .ToTuple(IWampSerializedEvent @event) { string currencyPair = @event.Arguments[0].Deserialize <string>(); PoloniexTicker res = (PoloniexTicker)Exchange.Tickers.FirstOrDefault(t => t.CurrencyPair == currencyPair); res.Last = FastDoubleConverter.Convert(@event.Arguments[1].ToString()); res.LowestAsk = FastDoubleConverter.Convert(@event.Arguments[2].ToString()); res.HighestBid = FastDoubleConverter.Convert(@event.Arguments[3].ToString()); res.Change = FastDoubleConverter.Convert(@event.Arguments[4].ToString()); res.BaseVolume = FastDoubleConverter.Convert(@event.Arguments[5].ToString()); res.Volume = FastDoubleConverter.Convert(@event.Arguments[6].ToString()); res.IsFrozen = @event.Arguments[7].Deserialize <int>() > 0; res.Hr24High = FastDoubleConverter.Convert(@event.Arguments[8].ToString()); res.Hr24Low = FastDoubleConverter.Convert(@event.Arguments[9].ToString()); res.Time = DateTime.Now; return(res); }
OrderBookUpdateInfo IWampEventValueTupleConverter <OrderBookUpdateInfo> .ToTuple(IWampSerializedEvent @event) { JObject item = @event.Arguments[0].Deserialize <JObject>(); JProperty typeProp = (JProperty)item.First; if (typeProp.Name != "type") { return(null); } JProperty objProp = (JProperty)typeProp.Next; JObject obj = objProp.Value.ToObject <JObject>(); OrderBookUpdateInfo info = new OrderBookUpdateInfo(); info.Action = ((JValue)typeProp.Value).ToObject <string>() == "orderBookRemove" ? OrderBookUpdateType.Remove : OrderBookUpdateType.Modify; info.Entry = new OrderBookEntry(); foreach (JProperty prop in obj.Children()) { if (prop.Name == "type") { info.Type = prop.Value.ToObject <string>() == "bid" ? OrderBookEntryType.Bid : OrderBookEntryType.Ask; } else if (prop.Name == "rate") { info.Entry.Value = prop.Value.ToObject <double>(); } else if (prop.Name == "amount") { info.Entry.Amount = prop.Value.ToObject <double>(); } } info.SeqNo = @event.ArgumentsKeywords["seq"].Deserialize <int>(); //Debug.WriteLine("seq = " + info.SeqNo + " update = " + info.Update + " type = " + info.Type + " rate = " + info.Entry.Rate + " amount = " + info.Entry.Amount); return(info); }
public virtual TTuple ToTuple(IWampSerializedEvent @event) { return(ToTuple(SerializedValueFormatter.Value, @event.Arguments, @event.ArgumentsKeywords)); }
BitFinexTicker IWampEventValueTupleConverter <BitFinexTicker> .ToTuple(IWampSerializedEvent @event) { throw new NotImplementedException(); }