pub struct RestApi { /* private fields */ }Expand description
An asynchronouse client to make REST API requests to FTX.
Example Initialise the REST client and retrieve the list of available markets.
#[tokio::main]
async fn main() {
let api_key = ""; // A valid api key for a FTX account
let api_secret = ""; // The secret corresponding to the provided API key
let client = ftx_async::rest::RestApi::new(api_key, api_secret);
let markets = client.get_markets().await.unwrap();
}Implementations§
Source§impl RestApi
impl RestApi
Sourcepub async fn get_account_info(&self) -> Result<AccountInfo, ()>
pub async fn get_account_info(&self) -> Result<AccountInfo, ()>
Returns all positions in futures contracts in the account wallet.
Sourcepub async fn get_wallet(&self) -> Result<WalletBalances, ()>
pub async fn get_wallet(&self) -> Result<WalletBalances, ()>
Returns all balances in the account wallet.
Sourcepub async fn get_markets(&self) -> Result<Vec<Market>, ()>
pub async fn get_markets(&self) -> Result<Vec<Market>, ()>
Returns a list of all markets on the exchange.
Sourcepub async fn get_orders(&self) -> Result<RestResponseOrderList, ()>
pub async fn get_orders(&self) -> Result<RestResponseOrderList, ()>
Returns the list of active orders on the exchange for the current account.
Sourcepub async fn place_order(
&self,
market: &str,
side: SideOfBook,
price: FtxPrice,
order_type: OrderType,
size: FtxSize,
reduce_only: bool,
ioc: bool,
post_only: bool,
client_id: Option<&str>,
) -> Result<FtxId, String>
pub async fn place_order( &self, market: &str, side: SideOfBook, price: FtxPrice, order_type: OrderType, size: FtxSize, reduce_only: bool, ioc: bool, post_only: bool, client_id: Option<&str>, ) -> Result<FtxId, String>
Submit an order to the ‘Place Order’ endpoint.
- ‘market’ - Market to trade. e.g. BTC-PERP
- ‘side’ - SideOfBook::BUY or SideOfBook::SELL
- ‘price’ - Order price; Ignored for market orders
- ‘order_type’ - OrderType::MARKET or OrderType::LIMIT
- ‘size’ - Order size
- ‘reduce_only’ - Only place order if it will reduce current position size
- ‘ioc’ - Immediate-or-cancel
- ‘post_only’ - Only place order if it will enter the orderbook (maker only)
- ‘client_id’ - (Optional) Client-assigned order iD; Max length 64 characters; must be unique on a per subaccount basis
Sourcepub async fn cancel_order(&self, order_id: FtxId) -> Result<(), ()>
pub async fn cancel_order(&self, order_id: FtxId) -> Result<(), ()>
Submit an order to the ‘Cancel Order’ endpoint.
Auto Trait Implementations§
impl Freeze for RestApi
impl !RefUnwindSafe for RestApi
impl Send for RestApi
impl Sync for RestApi
impl Unpin for RestApi
impl UnsafeUnpin for RestApi
impl !UnwindSafe for RestApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more