binance-rs icon indicating copy to clipboard operation
binance-rs copied to clipboard

Error with exchange_info()

Open rabolon opened this issue 1 month ago • 0 comments

My error:

src/binance_mod.rs:217 2025-11-21T02:29:44 [INFO] - Error kind: ReqError(reqwest::Error { kind: Decode, source: Error("unknown variant MAX_NUM_ORDER_LISTS, expected one of PRICE_FILTER, PERCENT_PRICE, PERCENT_PRICE_BY_SIDE, LOT_SIZE, MIN_NOTIONAL, NOTIONAL, ICEBERG_PARTS, MAX_NUM_ORDERS, MAX_NUM_ALGO_ORDERS, MAX_NUM_ICEBERG_ORDERS, MAX_POSITION, MARKET_LOT_SIZE, TRAILING_DELTA", line: 1, column: 1867) })

My code:

pub fn exchange_info(api_url: &str) -> Option<ExchangeInformation> { let config = Config::default().set_rest_api_endpoint(api_url); let general: General = Binance::new_with_config(None, None, &config);

match general.exchange_info() {
    Ok(answer) => {
        log::info!("{:?}", answer);
        Some(answer)
    },
    Err(e) => {
        log::info!("Error kind: {:?}", e.kind());
        None
    }
}

}

called from here:

pub fn min_notional(api_url: &str, symbol: &str) -> Option { let config = Config::default().set_rest_api_endpoint(api_url); let general: General = Binance::new_with_config(None, None, &config);

match general.exchange_info() {
    Ok(exchange_info) => {
        let data: Filters = exchange_info.symbols
            .into_iter()
            .filter(|item| item.symbol == symbol)
            .next()
            .and_then(|item| item.filters.into_iter().find(|filter| matches!(filter, Filters::Notional { .. })))?;

        match data {
            Filters::Notional {notional: _, min_notional, apply_to_market: _, avg_price_mins: _,} => {
                let min_notional= min_notional.unwrap_or_default().parse::<f64>();
                match min_notional {
                    Ok(min_notional) => return Some(min_notional),
                    Err(e) => {
                        log::info!("{:?}", e);
                        return None;
                    },
                }
            },
            _ => {
                log::info!("No matching filter found");
                None
            }                
        }
    },
    Err(e) => {
        log::info!("Error kind: {:?}", e.kind());        <-------- 217
        None
    },
}

}

rabolon avatar Nov 21 '25 02:11 rabolon