Skip to content

Commit bf1faa4

Browse files
committed
docs: _
1 parent ba5ad50 commit bf1faa4

File tree

7 files changed

+40
-22
lines changed

7 files changed

+40
-22
lines changed

Cargo.lock

Lines changed: 31 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ARCHITECTURE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ Implementation of each exchange's interactions, consists of blocks for
2929
#### models
3030
any models shared across different markets (futures, spot, margin, etc), are defined in well a shared `models/` directory at the root of associated exchange's directory. Say if `KlinesResponse` matches for
3131
`/binance/futures/market.rs` and `/binance/spot/market.rs`, the model is defined and exported from `/binance/models/market.rs`
32+
33+
34+
#### data endpoints
35+
Some exchanges provide specialized `data` endpoints. Those can't be part of `Exchange` trait, but then I just trivially expose them natively on the associated structs of each exchange, without any traits whatsoever.

examples/binance/market_futures.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::env;
22

33
use v_exchanges::{binance::Binance, core::Exchange};
4-
use v_exchanges_adapters::binance::{BinanceHttpUrl, BinanceOption};
54

65
#[tokio::main]
76
async fn main() {
@@ -10,8 +9,6 @@ async fn main() {
109

1110
let mut bn = Binance::default();
1211

13-
bn.update_default_option(BinanceOption::HttpUrl(BinanceHttpUrl::FuturesUsdM));
14-
1512
let klines = bn.futures_klines(("BTC", "USDT").into(), "1m".into(), 2.into()).await.unwrap();
1613
let price = bn.futures_price(("BTC", "USDT").into()).await.unwrap();
1714
dbg!(&klines, price);

examples/binance/market_spot.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
use v_exchanges::{binance::Binance, core::Exchange};
2-
use v_exchanges_adapters::binance::{BinanceHttpUrl, BinanceOption};
32

43
#[tokio::main]
54
async fn main() {
65
color_eyre::install().unwrap();
76
v_utils::utils::init_subscriber(v_utils::utils::LogDestination::xdg("v_exchanges"));
8-
9-
let mut bn = Binance::default();
10-
bn.update_default_option(BinanceOption::HttpUrl(BinanceHttpUrl::Spot));
7+
let bn = Binance::default();
118

129
let spot_klines = bn.spot_klines(("BTC", "USDT").into(), "1m".into(), 2.into()).await.unwrap();
1310
dbg!(&spot_klines);

v_exchanges/src/binance/spot/market.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde_with::{DisplayFromStr, serde_as};
88
use tracing::instrument;
99
use v_utils::trades::Pair;
1010

11-
#[instrument]
11+
#[instrument(skip_all, fields(?pairs))]
1212
pub async fn prices(client: &v_exchanges_adapters::Client, pairs: Option<Vec<Pair>>) -> Result<Vec<(Pair, f64)>> {
1313
let r: PricesResponse = match pairs {
1414
//TODO!!!: fix this branch

v_exchanges_adapters/src/exchanges/binance.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ where
171171
config
172172
}
173173

174+
//XXX: could print creds
175+
#[tracing::instrument(skip_all, fields(?builder))]
174176
fn build_request(&self, mut builder: RequestBuilder, request_body: &Option<B>, _: u8) -> Result<Request, Self::BuildError> {
175177
if let Some(body) = request_body {
176178
let encoded = serde_urlencoded::to_string(body).or(Err("could not serialize body as application/x-www-form-urlencoded"))?;

v_exchanges_api_generics/src/http.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Client {
3434
///
3535
/// The request is passed to `handler` before being sent, and the response is passed to `handler` before being returned.
3636
/// Note, that as stated in the docs for [RequestBuilder::query()], parameter `query` only accepts a **sequence of** key-value pairs.
37-
#[instrument(skip_all, fields(?url, request_builder = Empty))] //TODO: get all generics to impl std::fmt::Debug
37+
#[instrument(skip_all, fields(?url, ?query, request_builder = Empty))] //TODO: get all generics to impl std::fmt::Debug
3838
pub async fn request<Q, B, H>(&self, method: Method, url: &str, query: Option<&Q>, body: Option<B>, handler: &H) -> Result<H::Successful, RequestError<H::BuildError, H::Unsuccessful>>
3939
where
4040
Q: Serialize + ?Sized + std::fmt::Debug,
@@ -43,18 +43,15 @@ impl Client {
4343
config.verify();
4444

4545
let url = config.url_prefix + url;
46-
dbg!(&url);
4746

4847
for i in 1..=config.max_try {
4948
//HACK: hate to create a new request every time, but I haven't yet figured out how to provide by reference
5049
let mut request_builder = self.client.request(method.clone(), url.clone()).timeout(config.timeout);
51-
dbg!(&query);
5250
if let Some(query) = query {
5351
request_builder = request_builder.query(query);
5452
}
5553
Span::current().record("request_builder", format!("{:?}", request_builder));
5654

57-
dbg!(&request_builder);
5855
let request = handler.build_request(request_builder, &body, i).map_err(RequestError::BuildRequestError)?;
5956
match self.client.execute(request).await {
6057
Ok(mut response) => {

0 commit comments

Comments
 (0)