Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add public/get_last_trades_by_currency method, allow for pagination results #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OskarGottlieb
Copy link
Contributor

Ok, so I was playing around with your library some more, tried to add the get_last_trades_by_currency method, but that didn't work on its own, as the "result" part of the json response actually has two parts - "trades" which has the collection of trades and has_more which is a bool.
Couldn't parse it w/ the existing helper enum, so had to write an object that wraps around Either..which uhm I don't like? I mean it works, I was able to make it run, but I'd say I'm still new-ish to Rust and it just isn't a solution I like right out of the gate, hence the WIP.

If I'm reading it correctly, Either is really the same object collections crate uses that you're using here so you can parse either the response or an error and propagate it back to the user?
Also I couldn't figure out what's the purpose of Any enums, looks like it's dead code? Thanks for writing this library, I think I'm getting the gist of the internals and I definitely learned a lot by reading the code and playing around w/ it!


impl Request for GetLastTradesByCurrencyRequest {
const METHOD: &'static str = "public/get_last_trades_by_currency";
type Response = Vec<GetLastTradesByCurrencyResponse>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here you can make GetLastTradesByCurrencyResponse into

struct GetLastTradesByCurrencyResponse {
    trades: Vec<LastTrade>,
    has_more: bool
}

and in impl Request it can have

type Response =GetLastTradesByCurrencyResponse;

then

struct LastTrade {
  pub amount: Option<f64>,
    pub block_trade_id: Option<String>,
    pub direction: Direction,
    pub index_price: f64,
    pub instrument_name: String,
    pub iv: Option<f64>,
    pub mark_price: f64,
    pub price: f64,
    pub trade_id: String,
    pub timestamp: u64,
    pub trade_seq: u64,
    pub tick_direction: i64,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants