public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject obj = JObject.Load(reader); SymbolFilterType type = new SymbolFilterTypeConverter(false).ReadString(obj["filterType"].ToString()); BinanceSymbolFilter result = null; switch (type) { case SymbolFilterType.LotSize: result = new BinanceSymbolLotSizeFilter() { MaxQuantity = JsonConvert.DeserializeObject <decimal>(obj["maxQty"].ToString()), MinQuantity = JsonConvert.DeserializeObject <decimal>(obj["minQty"].ToString()), StepSize = JsonConvert.DeserializeObject <decimal>(obj["stepSize"].ToString()) }; break; case SymbolFilterType.MinNotional: result = new BinanceSymbolMinNotionalFilter() { MinNotional = JsonConvert.DeserializeObject <decimal>(obj["minNotional"].ToString()) }; break; case SymbolFilterType.PriceFilter: result = new BinanceSymbolPriceFilter() { MaxPrice = JsonConvert.DeserializeObject <decimal>(obj["maxPrice"].ToString()), MinPrice = JsonConvert.DeserializeObject <decimal>(obj["minPrice"].ToString()), TickSize = JsonConvert.DeserializeObject <decimal>(obj["tickSize"].ToString()), }; break; case SymbolFilterType.MaxNumberAlogitmicalOrders: result = new BinanceSymbolMaxAlgoritmicalOrdersFilter() { MaxNumberAlgoritmicalOrders = JsonConvert.DeserializeObject <int>(obj["maxNumAlgoOrders"].ToString()) }; break; case SymbolFilterType.IcebergParts: result = new BinanceSymbolIcebergPartsFilter() { Limit = JsonConvert.DeserializeObject <int>(obj["limit"].ToString()) }; break; } result.FilterType = type; return(result); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); var type = new SymbolFilterTypeConverter(false).ReadString(obj["filterType"].ToString()); BinanceSymbolFilter result; switch (type) { case SymbolFilterType.LotSize: result = new BinanceSymbolLotSizeFilter { MaxQuantity = (decimal)obj["maxQty"], MinQuantity = (decimal)obj["minQty"], StepSize = (decimal)obj["stepSize"] }; break; case SymbolFilterType.MarketLotSize: result = new BinanceSymbolMarketLotSizeFilter { MaxQuantity = (decimal)obj["maxQty"], MinQuantity = (decimal)obj["minQty"], StepSize = (decimal)obj["stepSize"] }; break; case SymbolFilterType.MinNotional: result = new BinanceSymbolMinNotionalFilter { MinNotional = (decimal)obj["minNotional"], ApplyToMarketOrders = (bool)obj["applyToMarket"], AveragePriceMinutes = (int)obj["avgPriceMins"] }; break; case SymbolFilterType.Price: result = new BinanceSymbolPriceFilter { MaxPrice = (decimal)obj["maxPrice"], MinPrice = (decimal)obj["minPrice"], TickSize = (decimal)obj["tickSize"] }; break; case SymbolFilterType.MaxNumberAlgorithmicOrders: result = new BinanceSymbolMaxAlgorithmicOrdersFilter { MaxNumberAlgorithmicOrders = (int)obj["maxNumAlgoOrders"] }; break; case SymbolFilterType.MaxNumberOrders: result = new BinanceSymbolMaxOrdersFilter { MaxNumberOrders = (int)obj["maxNumOrders"] }; break; case SymbolFilterType.IcebergParts: result = new BinanceSymbolIcebergPartsFilter { Limit = (int)obj["limit"] }; break; case SymbolFilterType.PricePercent: result = new BinanceSymbolPercentPriceFilter { MultiplierUp = (decimal)obj["multiplierUp"], MultiplierDown = (decimal)obj["multiplierDown"], AveragePriceMinutes = (int)obj["avgPriceMins"] }; break; default: Debug.WriteLine("Can't parse symbol filter of type: " + obj["filterType"]); result = new BinanceSymbolFilter(); break; } result.FilterType = type; return(result); }