pub struct FuturesRestClient { /* private fields */ }Expand description
The Kraken Futures REST API client.
This client provides access to all Kraken Futures trading REST endpoints. It handles authentication, rate limiting, and automatic retries.
§Example
use kraken_api_client::futures::rest::FuturesRestClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client for public endpoints only
let client = FuturesRestClient::new();
// Get all tickers
let tickers = client.get_tickers().await?;
for ticker in &tickers {
println!("{}: {}", ticker.symbol, ticker.last);
}
Ok(())
}For private endpoints, provide credentials:
use kraken_api_client::futures::rest::FuturesRestClient;
use kraken_api_client::auth::StaticCredentials;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let credentials = Arc::new(StaticCredentials::new("api_key", "api_secret"));
let client = FuturesRestClient::builder()
.credentials(credentials)
.build();
let accounts = client.get_accounts().await?;
println!("Accounts: {:?}", accounts);
Ok(())
}Implementations§
Source§impl FuturesRestClient
impl FuturesRestClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new client with default settings.
This client can only access public endpoints.
Use FuturesRestClient::builder() to configure credentials for private endpoints.
Sourcepub fn builder() -> FuturesRestClientBuilder
pub fn builder() -> FuturesRestClientBuilder
Create a new client builder.
Sourcepub async fn get_tickers(&self) -> Result<Vec<FuturesTicker>, KrakenError>
pub async fn get_tickers(&self) -> Result<Vec<FuturesTicker>, KrakenError>
Get all tickers.
Returns ticker data for all available futures contracts.
Sourcepub async fn get_ticker(
&self,
symbol: &str,
) -> Result<Option<FuturesTicker>, KrakenError>
pub async fn get_ticker( &self, symbol: &str, ) -> Result<Option<FuturesTicker>, KrakenError>
Get ticker for a specific symbol.
Returns ticker data for the specified symbol, or None if not found.
Sourcepub async fn get_orderbook(
&self,
symbol: &str,
) -> Result<FuturesOrderBook, KrakenError>
pub async fn get_orderbook( &self, symbol: &str, ) -> Result<FuturesOrderBook, KrakenError>
Sourcepub async fn get_trade_history(
&self,
symbol: &str,
last_time: Option<&str>,
) -> Result<Vec<FuturesTrade>, KrakenError>
pub async fn get_trade_history( &self, symbol: &str, last_time: Option<&str>, ) -> Result<Vec<FuturesTrade>, KrakenError>
Get recent trade history for a symbol.
§Arguments
symbol- The futures symbol (e.g., “PI_XBTUSD”)last_time- Optional timestamp to get trades before
Sourcepub async fn get_instruments(
&self,
) -> Result<Vec<FuturesInstrument>, KrakenError>
pub async fn get_instruments( &self, ) -> Result<Vec<FuturesInstrument>, KrakenError>
Get available instruments.
Returns information about all tradeable futures contracts.
Sourcepub async fn get_accounts(&self) -> Result<AccountsResponse, KrakenError>
pub async fn get_accounts(&self) -> Result<AccountsResponse, KrakenError>
Get account information.
Returns balances, margin info, and PnL for all accounts.
Sourcepub async fn get_open_positions(
&self,
) -> Result<Vec<FuturesPosition>, KrakenError>
pub async fn get_open_positions( &self, ) -> Result<Vec<FuturesPosition>, KrakenError>
Get open positions.
Returns all open futures positions.
Sourcepub async fn get_open_orders(&self) -> Result<Vec<FuturesOrder>, KrakenError>
pub async fn get_open_orders(&self) -> Result<Vec<FuturesOrder>, KrakenError>
Get open orders.
Returns all open (unfilled) orders.
Sourcepub async fn get_fills(
&self,
request: Option<&FillsRequest>,
) -> Result<Vec<FuturesFill>, KrakenError>
pub async fn get_fills( &self, request: Option<&FillsRequest>, ) -> Result<Vec<FuturesFill>, KrakenError>
Get fills (trade history).
Returns fills for all futures contracts or a specific symbol.
§Arguments
request- Optional request parameters
Sourcepub async fn send_order(
&self,
request: &SendOrderRequest,
) -> Result<SendOrderResponse, KrakenError>
pub async fn send_order( &self, request: &SendOrderRequest, ) -> Result<SendOrderResponse, KrakenError>
Sourcepub async fn edit_order(
&self,
request: &EditOrderRequest,
) -> Result<EditOrderResponse, KrakenError>
pub async fn edit_order( &self, request: &EditOrderRequest, ) -> Result<EditOrderResponse, KrakenError>
Sourcepub async fn cancel_order(
&self,
order_id: &str,
) -> Result<CancelOrderResponse, KrakenError>
pub async fn cancel_order( &self, order_id: &str, ) -> Result<CancelOrderResponse, KrakenError>
Sourcepub async fn cancel_order_by_cli_ord_id(
&self,
cli_ord_id: &str,
) -> Result<CancelOrderResponse, KrakenError>
pub async fn cancel_order_by_cli_ord_id( &self, cli_ord_id: &str, ) -> Result<CancelOrderResponse, KrakenError>
Sourcepub async fn cancel_all_orders(
&self,
) -> Result<CancelAllOrdersResponse, KrakenError>
pub async fn cancel_all_orders( &self, ) -> Result<CancelAllOrdersResponse, KrakenError>
Cancel all orders.
Cancels all open orders for the account.
Sourcepub async fn cancel_all_orders_for_symbol(
&self,
symbol: &str,
) -> Result<CancelAllOrdersResponse, KrakenError>
pub async fn cancel_all_orders_for_symbol( &self, symbol: &str, ) -> Result<CancelAllOrdersResponse, KrakenError>
Cancel all orders for a specific symbol.
§Arguments
symbol- The futures symbol to cancel orders for
Sourcepub async fn cancel_all_orders_after(
&self,
timeout_seconds: u32,
) -> Result<CancelAllOrdersAfterResponse, KrakenError>
pub async fn cancel_all_orders_after( &self, timeout_seconds: u32, ) -> Result<CancelAllOrdersAfterResponse, KrakenError>
Set dead man’s switch (cancel all orders after timeout).
§Arguments
timeout_seconds- Timeout in seconds (0 to disable)
Sourcepub async fn batch_order(
&self,
request: &BatchOrderRequest,
) -> Result<BatchOrderResponse, KrakenError>
pub async fn batch_order( &self, request: &BatchOrderRequest, ) -> Result<BatchOrderResponse, KrakenError>
Send batch orders.
Allows placing, editing, and cancelling multiple orders in a single request.
§Arguments
request- Batch order request
Trait Implementations§
Source§impl Clone for FuturesRestClient
impl Clone for FuturesRestClient
Source§fn clone(&self) -> FuturesRestClient
fn clone(&self) -> FuturesRestClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more