wisespace-io / binance-rs

Rust Library for the Binance API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KlineSummary Serialization

partisan-bobryk opened this issue · comments

Hi I don't know if this was asked before, but i noticed that KlineSummary struct doesn't implement Serialize/Deserialize macro. Was that intentional by design?

The use case for me would be getting historical data and saving it locally to test against.

Would this be something that I can make a PR for?

@VeprUA Yes, you can create a PR for it. We just missed it.

can someone help me please, i have tried to do the implementation to it but i cant.

impl<'de> Deserialize<'de> for KlineSummaries {

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where D: Deserializer<'de>
{
   
    return KlineSummaries::deserialize(deserializer)
    
}

}

@VeprUA I added the macros in the release 0.13.3, let me know if it is working in your side.

@VeprUA See how you get the Kline values below

// last 10 5min klines (candlesticks) for a symbol:
match market.get_klines("BNBETH", "5m", 10, None, None) {
    Ok(klines) => {   
        match klines {
            binance::model::KlineSummaries::AllKlineSummaries(klines) => {
                let kline: KlineSummary = klines[0].clone(); // You need to iterate over the klines
                println!(
                    "Open: {}, High: {}, Low: {}",
                    kline.open, kline.high, kline.low
                )
            }
        }
    },
    Err(e) => println!("Error: {}", e),
}

Sorry, I got sidetracked, thank you for taking care of this. 🙌🎉