|
1 | 1 | pub mod futures; |
2 | 2 | use color_eyre::eyre::Result; |
3 | | -pub use v_exchanges_adapters::Client; // re-export |
4 | | -use v_exchanges_adapters::binance; |
| 3 | +use v_exchanges_adapters::{Client, binance}; |
5 | 4 | use v_utils::trades::{Asset, Pair, Timeframe}; |
6 | 5 |
|
7 | 6 | use crate::core::{AssetBalance, Exchange, Klines}; |
8 | 7 |
|
| 8 | +#[derive(Clone, Debug, Default)] |
| 9 | +pub struct Binance(pub Client); |
| 10 | +impl Binance { |
| 11 | + pub fn new() -> Self { |
| 12 | + Self(Client::new()) |
| 13 | + } |
| 14 | +} |
| 15 | +impl std::ops::Deref for Binance { |
| 16 | + type Target = Client; |
| 17 | + |
| 18 | + fn deref(&self) -> &Self::Target { |
| 19 | + &self.0 |
| 20 | + } |
| 21 | +} |
| 22 | +impl std::ops::DerefMut for Binance { |
| 23 | + fn deref_mut(&mut self) -> &mut Self::Target { |
| 24 | + &mut self.0 |
| 25 | + } |
| 26 | +} |
| 27 | + |
9 | 28 | //? currently client ends up importing this from crate::binance, but could it be possible to lift the [Client] reexport up, and still have the ability to call all exchange methods right on it? |
10 | | -impl Exchange<binance::BinanceOptions> for Client { |
| 29 | +impl Exchange for Binance { |
11 | 30 | async fn futures_klines(&self, symbol: Pair, tf: Timeframe, limit: u32, start_time: Option<u64>, end_time: Option<u64>) -> Result<Klines> { |
12 | | - futures::market::klines(&self, symbol, tf, limit, start_time, end_time).await |
| 31 | + futures::market::klines(&self.0, symbol, tf, limit, start_time, end_time).await |
13 | 32 | } |
14 | 33 |
|
15 | 34 | async fn futures_price(&self, symbol: Pair) -> Result<f64> { |
16 | | - futures::market::price(&self, symbol).await |
| 35 | + futures::market::price(&self.0, symbol).await |
17 | 36 | } |
18 | 37 |
|
19 | 38 | async fn futures_asset_balance(&self, asset: Asset) -> Result<AssetBalance> { |
20 | | - futures::account::asset_balance(&self, asset).await |
| 39 | + futures::account::asset_balance(&self.0, asset).await |
21 | 40 | } |
22 | 41 |
|
23 | 42 | async fn futures_balances(&self) -> Result<Vec<AssetBalance>> { |
24 | | - futures::account::balances(&self).await |
| 43 | + futures::account::balances(&self.0).await |
25 | 44 | } |
26 | 45 |
|
27 | 46 | //DO: async fn balance(&self, |
|
0 commit comments