-
Notifications
You must be signed in to change notification settings - Fork 6
Add a few missing endpoints and bug fixes #20
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
Merged
Vardominator
merged 9 commits into
maestro-org:main
from
book-io:add-some-missing-endpoints
Mar 19, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5d33f8f
adds `stake_pool_delegator_history` endpoint.
b00kdev 9cfc383
fixes return type.
b00kdev b0dd2a4
_really_ fixes return types.
b00kdev 516d586
le sigh.
b00kdev 3f8e2b5
margin seems to be a float.
b00kdev 07be805
updates types to match api spec.
b00kdev 93cce39
adds markets dex pair ohlc endpoint.
b00kdev 9af2009
updates req/res for ohlc.
b00kdev 25581cd
fixes bad epoch endpoint.
b00kdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::models::markets::{DexPairOHLC, DexPairOHLCParameters}; | ||
|
||
use super::maestro::Maestro; | ||
use std::{error::Error, fmt::Display}; | ||
|
||
impl Maestro { | ||
/// Returns market activity in candlestick OHLC format for a specific DEX and token pair | ||
pub async fn markets_dex_pair_ohlc( | ||
&self, | ||
dex: impl Display, | ||
pair: impl Display, | ||
parameters: Option<DexPairOHLCParameters>, | ||
) -> Result<Vec<DexPairOHLC>, Box<dyn Error>> { | ||
let ps = parameters | ||
.and_then(|p| serde_qs::to_string(&p).ok()) | ||
.map(|x| format!("?{x}")) | ||
.unwrap_or_default(); | ||
let url = format!("/markets/dexs/ohlc/{dex}/{pair}{ps}"); | ||
let resp = self.get(&url).await?; | ||
|
||
serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box<dyn Error>) | ||
} | ||
Vardominator marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use chrono::{DateTime, Utc}; | ||
use rust_decimal::Decimal; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct DexPairOHLC { | ||
pub coin_a_change_pct: Decimal, | ||
pub coin_a_close: Decimal, | ||
pub coin_a_high: Decimal, | ||
pub coin_a_low: Decimal, | ||
pub coin_a_open: Decimal, | ||
pub coin_a_volume: Decimal, | ||
pub coin_b_change_pct: Decimal, | ||
pub coin_b_close: Decimal, | ||
pub coin_b_high: Decimal, | ||
pub coin_b_low: Decimal, | ||
pub coin_b_open: Decimal, | ||
pub coin_b_volume: Decimal, | ||
pub count: i64, | ||
pub timestamp: DateTime<Utc>, | ||
} | ||
Vardominator marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#[derive(Clone, Copy, Debug, Serialize)] | ||
pub enum Resolution { | ||
#[serde(rename = "1m")] | ||
OneMinute, | ||
#[serde(rename = "5m")] | ||
FiveMinutes, | ||
#[serde(rename = "15m")] | ||
FifteenMinutes, | ||
#[serde(rename = "30m")] | ||
ThirtyMinutes, | ||
#[serde(rename = "1h")] | ||
OneHour, | ||
#[serde(rename = "4h")] | ||
FourHours, | ||
#[serde(rename = "1d")] | ||
OneDay, | ||
#[serde(rename = "1w")] | ||
OneWeek, | ||
#[serde(rename = "1mo")] | ||
OneMonth, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Serialize)] | ||
pub enum Sort { | ||
#[serde(rename = "asc")] | ||
Asc, | ||
#[serde(rename = "desc")] | ||
Desc, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Serialize)] | ||
pub struct DexPairOHLCParameters { | ||
pub resolution: Option<Resolution>, | ||
pub from: Option<String>, | ||
pub to: Option<String>, | ||
pub limit: Option<i64>, | ||
pub sort: Option<Sort>, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.