/// <summary> /// Sets global data (timestamp, sequence) if it is enabled by configuration. /// </summary> internal static void SetGlobalData(ResponseBase response, ConfigurationState config, JToken data, int lastPosition = 1, bool isPrivateChannel = false) { try { var position = lastPosition + 1; if (config.IsSequencingEnabled) { var sequence = data[position].Value <long?>(); response.ServerSequence = sequence; position++; if (isPrivateChannel) { // private channels send different sequence numbers var privateSequence = data[position].Value <long?>(); response.ServerPrivateSequence = privateSequence; position++; } } if (config.IsTimestampEnabled) { var mts = data[position].Value <long?>(); response.ServerTimestamp = BitfinexTime.ConvertToTime(mts); // position++; } } catch (Exception e) { Log.Warn($"[BFX response] Failed to parse global data (timestamp, sequence). Error: {e.Message}"); } }
private Order JArrayToTradingTicker(JArray array) { return(new Order { Id = (long)array[0], Gid = (long?)array[1], Cid = (long)array[2], Symbol = (string)array[3], MtsCreate = BitfinexTime.ConvertToTime((long?)array[4]), MtsUpdate = BitfinexTime.ConvertToTime((long?)array[5]), Amount = (double?)array[6], AmountOrig = (double?)array[7], Type = ParseType((string)array[8]), TypePrev = ParseType((string)array[9]), MtsTiff = BitfinexTime.ConvertToTime((long?)array[10]), // 11 Flags = (int?)array[12], OrderStatus = ParseStatus((string)array[13]), OrderStatusText = (string)array[13], // 14 // 15 Price = (double?)array[16], PriceAvg = (double?)array[17], PriceTrailing = (double?)array[18], PriceAuxLimit = (double?)array[19], // 20 // 21 // 22 Notify = (int?)array[23], Hidden = (int?)array[24], PlacedId = (long?)array[25], }); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.Value == null) { return(null); } return(BitfinexTime.ConvertToTime((long)reader.Value)); }
private Trade JArrayToTradingTicker(JArray array) { return(new Trade { Id = (long)array[0], Mts = BitfinexTime.ConvertToTime((long)array[1]), Amount = (double)array[2], Price = (double)array[3] }); }
private Funding JArrayToTradingTicker(JArray array) { return(new Funding { Id = (long)array[0], Mts = BitfinexTime.ConvertToTime((long)array[1]), Amount = (double)array[2], Rate = (double)array[3], Period = (int)array[4] }); }
private Candle JArrayToCandle(JToken jToken) { return(new Candle { Mts = BitfinexTime.ConvertToTime((long)jToken[0]), Open = (double)jToken[1], Close = (double)jToken[2], High = (double)jToken[3], Low = (double)jToken[4], Volume = (double)jToken[5] }); }
private DerivativePairStatus JArrayToDerivativePairStatus(JToken jToken) { return(new DerivativePairStatus { TimestampMs = BitfinexTime.ConvertToTime((long)jToken[0]), DerivPrice = (double)jToken[2], SpotPrice = (double)jToken[3], InsuranceFundBalance = (double)jToken[5], FundingAccrued = (double)jToken[8], FundingStep = (long)jToken[9], }); }
private Notification JArrayToNotification(JArray array) { return(new Notification { Mts = BitfinexTime.ConvertToTime((long)array[0]), Type = ParseNotificationType((string)array[1]), MessageId = (long?)array[2], NotifyInfo = array[4].ToString(), Code = (long?)array[5], Status = (string)array[6], Text = array[7].ToString(), }); }
private LiquidationFeedStatus JArrayToDerivativePairStatus(JToken jToken) { return(new LiquidationFeedStatus { Type = (string)jToken[0], PosId = (long)jToken[1], TimestampMs = BitfinexTime.ConvertToTime((long)jToken[2]), Symbol = (string)jToken[4], Amount = (double)jToken[5], BasePrice = (double)jToken[6], IsMatch = (int)jToken[8], IsMarketSold = (int)jToken[9], }); }
private PrivateTrade JArrayToTradingTicker(JArray array) { return(new PrivateTrade { Id = (long)array[0], Symbol = (string)array[1], MtsCreate = BitfinexTime.ConvertToTime((long)array[2]), OrderId = (long)array[3], ExecAmount = (double)array[4], ExecPrice = (double)array[5], OrderType = OrderConverter.ParseType((string)array[6]), OrderPrice = (double)array[7], IsMaker = (int)array[8] > 0, Fee = (double?)array[9], FeeCurrency = (string)array[10] }); }