pub trait Market: Send + Sync {
// Required methods
fn buy<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn sell<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Decimal> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn result<'life0, 'async_trait>(
&'life0 self,
trade_id: Uuid,
) -> Pin<Box<dyn Future<Output = PocketResult<Deal>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
The Market trait abstracts trading operations. This allows strategies to run against live accounts, demo accounts, or local simulations (backtesting).
Required Methods§
Sourcefn buy<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn buy<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes a BUY (CALL) order.
Sourcefn sell<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sell<'life0, 'life1, 'async_trait>(
&'life0 self,
asset: &'life1 str,
amount: Decimal,
time: u32,
) -> Pin<Box<dyn Future<Output = PocketResult<(Uuid, Deal)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes a SELL (PUT) order.
Sourcefn balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Decimal> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Decimal> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the current balance. This method should be really lightweight, the balance should be stored by the client and simply retrieved No server call should be performed here, otherwise it will cause performance issues and may lead to rate limits.