pub struct CoreKrakenClient {
pub api_url: String,
/* private fields */
}
Expand description
The base implementation of KrakenClient. It has no rate limiting, and uses whatever SecretsProvider and NonceProvider it is given.
This is most useful for one-off calls, or building more complex behavior on top of.
§Example: Making a Public API Call
Creating a CoreKrakenClient is as simple as providing a SecretsProvider and NonceProvider. For public calls, a StaticSecretsProvider with empty strings will work, since there is no auth required for public endpoints.
Requests follow a builder pattern, with required parameters in the ::builder()
call, if there
are any. Here, only the pair (optional) is provided.
#[tokio::main]
async fn main() {
// credentials aren't needed for public endpoints
use kraken_async_rs::secrets::secrets_provider::SecretsProvider;
let secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>> = Box::new(Arc::new(Mutex::new(StaticSecretsProvider::new("", ""))));
let nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>> =
Box::new(Arc::new(Mutex::new(IncreasingNonceProvider::new())));
let mut client = CoreKrakenClient::new(secrets_provider, nonce_provider);
let request = TradableAssetPairsRequest::builder()
.pair(StringCSV::new(vec!["BTCUSD".to_string()]))
.build();
let open_orders_response = client.get_tradable_asset_pairs(&request).await;
// Note that Kraken will return assets in their own naming scheme, e.g. a request for
// "BTCUSD" will return as "XXBTZUSD"
// For a reasonable understanding of their mappings, see: https://gist.github.com/brendano257/975a395d73a6d7bb53e53d292534d6af
if let Ok(ResultErrorResponse {
result: Some(tradable_assets),
..
}) = open_orders_response
{
for (asset, details) in tradable_assets {
println!("{asset}: {details:?}")
}
}
}
Fields§
§api_url: String
Trait Implementations§
Source§impl Clone for CoreKrakenClient
impl Clone for CoreKrakenClient
Source§fn clone(&self) -> CoreKrakenClient
fn clone(&self) -> CoreKrakenClient
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CoreKrakenClient
impl Debug for CoreKrakenClient
Source§impl KrakenClient for CoreKrakenClient
impl KrakenClient for CoreKrakenClient
Source§fn new(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
) -> Self
fn new( secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>, nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>, ) -> Self
Creates a new instance with the given SecretsProvider and NonceProvider.
Source§fn new_with_url(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
url: impl ToString,
) -> Self
fn new_with_url( secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>, nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>, url: impl ToString, ) -> Self
Creates a new instance, allowing a specific URL to be set. Read more
Source§fn new_with_tracing(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
trace_inbound: bool,
) -> Self
fn new_with_tracing( secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>, nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>, trace_inbound: bool, ) -> Self
Creates a new instance with the given SecretsProvider and NonceProvider, optionally
enabling tracing for inbound messages.
Source§async fn set_user_agent(&mut self, user_agent: impl ToString)
async fn set_user_agent(&mut self, user_agent: impl ToString)
Set the user-agent that will be sent in HTTP headers to Kraken. This is not required to be
set.
Source§async fn get_server_time(
&mut self,
) -> Result<ResultErrorResponse<SystemTime>, ClientError>
async fn get_server_time( &mut self, ) -> Result<ResultErrorResponse<SystemTime>, ClientError>
Get the server time in two useful formats.
Source§async fn get_system_status(
&mut self,
) -> Result<ResultErrorResponse<SystemStatusInfo>, ClientError>
async fn get_system_status( &mut self, ) -> Result<ResultErrorResponse<SystemStatusInfo>, ClientError>
Get the status of the system, including the current server time.
Source§async fn get_asset_info(
&mut self,
request: &AssetInfoRequest,
) -> Result<ResultErrorResponse<HashMap<String, AssetInfo>>, ClientError>
async fn get_asset_info( &mut self, request: &AssetInfoRequest, ) -> Result<ResultErrorResponse<HashMap<String, AssetInfo>>, ClientError>
Get info about a particular asset, e.g. “XBT” or “ETH”.
Source§async fn get_tradable_asset_pairs(
&mut self,
request: &TradableAssetPairsRequest,
) -> Result<ResultErrorResponse<HashMap<String, TradableAssetPair>>, ClientError>
async fn get_tradable_asset_pairs( &mut self, request: &TradableAssetPairsRequest, ) -> Result<ResultErrorResponse<HashMap<String, TradableAssetPair>>, ClientError>
Get info about tradable asset pairs, such as USDCUSD, BTCUSD, or XETHZUSD. Read more
Source§async fn get_ticker_information(
&mut self,
request: &TickerRequest,
) -> Result<ResultErrorResponse<HashMap<String, RestTickerInfo>>, ClientError>
async fn get_ticker_information( &mut self, request: &TickerRequest, ) -> Result<ResultErrorResponse<HashMap<String, RestTickerInfo>>, ClientError>
Return some or all ticker data, including the most recent bid, ask, price, and last-24h
stats for each requested pair.
Source§async fn get_ohlc(
&mut self,
request: &OHLCRequest,
) -> Result<ResultErrorResponse<OhlcResponse>, ClientError>
async fn get_ohlc( &mut self, request: &OHLCRequest, ) -> Result<ResultErrorResponse<OhlcResponse>, ClientError>
Retrieve up to the last 720 OHLC candlesticks for a given pair and interval. Read more
Source§async fn get_orderbook(
&mut self,
request: &OrderbookRequest,
) -> Result<ResultErrorResponse<HashMap<String, Orderbook>>, ClientError>
async fn get_orderbook( &mut self, request: &OrderbookRequest, ) -> Result<ResultErrorResponse<HashMap<String, Orderbook>>, ClientError>
Get a snapshot of the orderbook for the requested pair and depth-of-book.
Source§async fn get_recent_trades(
&mut self,
request: &RecentTradesRequest,
) -> Result<ResultErrorResponse<RecentTrades>, ClientError>
async fn get_recent_trades( &mut self, request: &RecentTradesRequest, ) -> Result<ResultErrorResponse<RecentTrades>, ClientError>
Retrieve up to 1000 trades at a time from the FULL history of Kraken’s exchange for the
requested pair. Read more
Source§async fn get_recent_spreads(
&mut self,
request: &RecentSpreadsRequest,
) -> Result<ResultErrorResponse<RecentSpreads>, ClientError>
async fn get_recent_spreads( &mut self, request: &RecentSpreadsRequest, ) -> Result<ResultErrorResponse<RecentSpreads>, ClientError>
Get the last ~200 spread values for the requested pair. Read more
Source§async fn get_account_balance(
&mut self,
) -> Result<ResultErrorResponse<AccountBalances>, ClientError>
async fn get_account_balance( &mut self, ) -> Result<ResultErrorResponse<AccountBalances>, ClientError>
Get the raw balances for your account, minus any pending withdrawals.
Source§async fn get_extended_balances(
&mut self,
) -> Result<ResultErrorResponse<ExtendedBalances>, ClientError>
async fn get_extended_balances( &mut self, ) -> Result<ResultErrorResponse<ExtendedBalances>, ClientError>
Get the extended balances for your account, which denotes the balance, any balance on hold,
and lines of credit (if available on your account).
Source§async fn get_trade_balances(
&mut self,
request: &TradeBalanceRequest,
) -> Result<ResultErrorResponse<TradeBalances>, ClientError>
async fn get_trade_balances( &mut self, request: &TradeBalanceRequest, ) -> Result<ResultErrorResponse<TradeBalances>, ClientError>
Get balances relevant for futures and margin trading, including equity and margin levels.
Source§async fn get_open_orders(
&mut self,
request: &OpenOrdersRequest,
) -> Result<ResultErrorResponse<OpenOrders>, ClientError>
async fn get_open_orders( &mut self, request: &OpenOrdersRequest, ) -> Result<ResultErrorResponse<OpenOrders>, ClientError>
Get all open orders for your account.
Source§async fn get_closed_orders(
&mut self,
request: &ClosedOrdersRequest,
) -> Result<ResultErrorResponse<ClosedOrders>, ClientError>
async fn get_closed_orders( &mut self, request: &ClosedOrdersRequest, ) -> Result<ResultErrorResponse<ClosedOrders>, ClientError>
Get closed orders from the full history of your account, up to 50 at a time. Read more
Source§async fn query_orders_info(
&mut self,
request: &OrderRequest,
) -> Result<ResultErrorResponse<HashMap<String, Order>>, ClientError>
async fn query_orders_info( &mut self, request: &OrderRequest, ) -> Result<ResultErrorResponse<HashMap<String, Order>>, ClientError>
Get the information for up to 50 orders at a time.
async fn get_order_amends( &mut self, request: &OrderAmendsRequest, ) -> Result<ResultErrorResponse<OrderAmends>, ClientError>
Source§async fn get_trades_history(
&mut self,
request: &TradesHistoryRequest,
) -> Result<ResultErrorResponse<TradesHistory>, ClientError>
async fn get_trades_history( &mut self, request: &TradesHistoryRequest, ) -> Result<ResultErrorResponse<TradesHistory>, ClientError>
Get trades from the full history your account, up to 50 at a time. Read more
Source§async fn query_trades_info(
&mut self,
request: &TradeInfoRequest,
) -> Result<ResultErrorResponse<TradesInfo>, ClientError>
async fn query_trades_info( &mut self, request: &TradeInfoRequest, ) -> Result<ResultErrorResponse<TradesInfo>, ClientError>
Get trade details for up to 20 specific trades by id at a time.
Source§async fn get_open_positions(
&mut self,
request: &OpenPositionsRequest,
) -> Result<ResultErrorResponse<OpenPositions>, ClientError>
async fn get_open_positions( &mut self, request: &OpenPositionsRequest, ) -> Result<ResultErrorResponse<OpenPositions>, ClientError>
Get information about open margin positions.
Source§async fn get_ledgers_info(
&mut self,
request: &LedgersInfoRequest,
) -> Result<ResultErrorResponse<LedgerInfo>, ClientError>
async fn get_ledgers_info( &mut self, request: &LedgersInfoRequest, ) -> Result<ResultErrorResponse<LedgerInfo>, ClientError>
Get ledger entries for the full history of your account, up to 50 at a time. Read more
Source§async fn query_ledgers(
&mut self,
request: &QueryLedgerRequest,
) -> Result<ResultErrorResponse<QueryLedgerInfo>, ClientError>
async fn query_ledgers( &mut self, request: &QueryLedgerRequest, ) -> Result<ResultErrorResponse<QueryLedgerInfo>, ClientError>
Get ledger information for up to 20 ids at a time.
Source§async fn get_trade_volume(
&mut self,
request: &TradeVolumeRequest,
) -> Result<ResultErrorResponse<TradeVolume>, ClientError>
async fn get_trade_volume( &mut self, request: &TradeVolumeRequest, ) -> Result<ResultErrorResponse<TradeVolume>, ClientError>
Get the 30-day trading volume for your account, and fee information for any pairs (if requested).
Source§async fn request_export_report(
&mut self,
request: &ExportReportRequest,
) -> Result<ResultErrorResponse<ExportReport>, ClientError>
async fn request_export_report( &mut self, request: &ExportReportRequest, ) -> Result<ResultErrorResponse<ExportReport>, ClientError>
Request a report for ledgers or trades to be generated asynchronously.
Source§async fn get_export_report_status(
&mut self,
request: &ExportReportStatusRequest,
) -> Result<ResultErrorResponse<Vec<ExportReportStatus>>, ClientError>
async fn get_export_report_status( &mut self, request: &ExportReportStatusRequest, ) -> Result<ResultErrorResponse<Vec<ExportReportStatus>>, ClientError>
Get the status of a report that was requested.
Source§async fn retrieve_export_report(
&mut self,
request: &RetrieveExportReportRequest,
) -> Result<Vec<u8>, ClientError>
async fn retrieve_export_report( &mut self, request: &RetrieveExportReportRequest, ) -> Result<Vec<u8>, ClientError>
Retrieve an export report once generated.
Source§async fn delete_export_report(
&mut self,
request: &DeleteExportRequest,
) -> Result<ResultErrorResponse<DeleteExportReport>, ClientError>
async fn delete_export_report( &mut self, request: &DeleteExportRequest, ) -> Result<ResultErrorResponse<DeleteExportReport>, ClientError>
Request for an export report to be deleted.
Source§async fn add_order(
&mut self,
request: &AddOrderRequest,
) -> Result<ResultErrorResponse<AddOrder>, ClientError>
async fn add_order( &mut self, request: &AddOrderRequest, ) -> Result<ResultErrorResponse<AddOrder>, ClientError>
Add an order of any type (market, limit, trailing stop, etc).
Source§async fn add_order_batch(
&mut self,
request: &AddBatchedOrderRequest,
) -> Result<ResultErrorResponse<AddOrderBatch>, ClientError>
async fn add_order_batch( &mut self, request: &AddBatchedOrderRequest, ) -> Result<ResultErrorResponse<AddOrderBatch>, ClientError>
Add up to 15 orders for a single pair at once. Orders that fail to place are dropped from
processing and will be returned with errors in the response’s
Vec
.async fn amend_order( &mut self, request: &AmendOrderRequest, ) -> Result<ResultErrorResponse<AmendOrder>, ClientError>
Source§async fn edit_order(
&mut self,
request: &EditOrderRequest,
) -> Result<ResultErrorResponse<OrderEdit>, ClientError>
async fn edit_order( &mut self, request: &EditOrderRequest, ) -> Result<ResultErrorResponse<OrderEdit>, ClientError>
Edit the volume or price of an existing order, excluding contingent orders like stop/profit orders.
Source§async fn cancel_order(
&mut self,
request: &CancelOrderRequest,
) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
async fn cancel_order( &mut self, request: &CancelOrderRequest, ) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
Cancel an existing order by ref-id or user-ref.
Source§async fn cancel_all_orders(
&mut self,
) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
async fn cancel_all_orders( &mut self, ) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
Cancel all active orders.
Source§async fn cancel_all_orders_after(
&mut self,
request: &CancelAllOrdersAfterRequest,
) -> Result<ResultErrorResponse<CancelAllOrdersAfter>, ClientError>
async fn cancel_all_orders_after( &mut self, request: &CancelAllOrdersAfterRequest, ) -> Result<ResultErrorResponse<CancelAllOrdersAfter>, ClientError>
Submit a “Dead Man’s Switch” that will cancel all orders if not repeatedly updated over time.
Source§async fn cancel_order_batch(
&mut self,
request: &CancelBatchOrdersRequest,
) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
async fn cancel_order_batch( &mut self, request: &CancelBatchOrdersRequest, ) -> Result<ResultErrorResponse<CancelOrder>, ClientError>
Cancel up to 50 orders in a batch by id or user-ref.
Source§async fn get_deposit_methods(
&mut self,
request: &DepositMethodsRequest,
) -> Result<ResultErrorResponse<Vec<DepositMethod>>, ClientError>
async fn get_deposit_methods( &mut self, request: &DepositMethodsRequest, ) -> Result<ResultErrorResponse<Vec<DepositMethod>>, ClientError>
Get all methods of depositing a specific asset.
Source§async fn get_deposit_addresses(
&mut self,
request: &DepositAddressesRequest,
) -> Result<ResultErrorResponse<Vec<DepositAddress>>, ClientError>
async fn get_deposit_addresses( &mut self, request: &DepositAddressesRequest, ) -> Result<ResultErrorResponse<Vec<DepositAddress>>, ClientError>
Get all available addresses for a given asset and method.
Source§async fn get_status_of_recent_deposits(
&mut self,
request: &StatusOfDepositWithdrawRequest,
) -> Result<ResultErrorResponse<DepositWithdrawResponse>, ClientError>
async fn get_status_of_recent_deposits( &mut self, request: &StatusOfDepositWithdrawRequest, ) -> Result<ResultErrorResponse<DepositWithdrawResponse>, ClientError>
Get the status of recent deposits. Read more
Source§async fn get_withdrawal_methods(
&mut self,
request: &WithdrawalMethodsRequest,
) -> Result<ResultErrorResponse<Vec<WithdrawMethod>>, ClientError>
async fn get_withdrawal_methods( &mut self, request: &WithdrawalMethodsRequest, ) -> Result<ResultErrorResponse<Vec<WithdrawMethod>>, ClientError>
Get all withdrawal methods, optionally for a given asset.
Source§async fn get_withdrawal_addresses(
&mut self,
request: &WithdrawalAddressesRequest,
) -> Result<ResultErrorResponse<Vec<WithdrawalAddress>>, ClientError>
async fn get_withdrawal_addresses( &mut self, request: &WithdrawalAddressesRequest, ) -> Result<ResultErrorResponse<Vec<WithdrawalAddress>>, ClientError>
Get all withdrawal addresses, optionally for a specific asset or method.
Source§async fn get_withdrawal_info(
&mut self,
request: &WithdrawalInfoRequest,
) -> Result<ResultErrorResponse<Withdrawal>, ClientError>
async fn get_withdrawal_info( &mut self, request: &WithdrawalInfoRequest, ) -> Result<ResultErrorResponse<Withdrawal>, ClientError>
Get details about a particular withdrawal.
Source§async fn withdraw_funds(
&mut self,
request: &WithdrawFundsRequest,
) -> Result<ResultErrorResponse<ConfirmationRefId>, ClientError>
async fn withdraw_funds( &mut self, request: &WithdrawFundsRequest, ) -> Result<ResultErrorResponse<ConfirmationRefId>, ClientError>
Request a withdrawal for the provided asset and key.
Source§async fn get_status_of_recent_withdrawals(
&mut self,
request: &StatusOfDepositWithdrawRequest,
) -> Result<ResultErrorResponse<Vec<DepositWithdrawal>>, ClientError>
async fn get_status_of_recent_withdrawals( &mut self, request: &StatusOfDepositWithdrawRequest, ) -> Result<ResultErrorResponse<Vec<DepositWithdrawal>>, ClientError>
Get the status of recent withdrawals. Read more
Source§async fn request_withdrawal_cancellation(
&mut self,
request: &WithdrawCancelRequest,
) -> Result<ResultErrorResponse<bool>, ClientError>
async fn request_withdrawal_cancellation( &mut self, request: &WithdrawCancelRequest, ) -> Result<ResultErrorResponse<bool>, ClientError>
Request to cancel a particular withdrawal if it has not been fully processed.
Source§async fn request_wallet_transfer(
&mut self,
request: &WalletTransferRequest,
) -> Result<ResultErrorResponse<ConfirmationRefId>, ClientError>
async fn request_wallet_transfer( &mut self, request: &WalletTransferRequest, ) -> Result<ResultErrorResponse<ConfirmationRefId>, ClientError>
Request to transfer from the default Spot wallet to a Futures wallet if available.
Source§async fn create_sub_account(
&mut self,
request: &CreateSubAccountRequest,
) -> Result<ResultErrorResponse<bool>, ClientError>
async fn create_sub_account( &mut self, request: &CreateSubAccountRequest, ) -> Result<ResultErrorResponse<bool>, ClientError>
Create a linked sub-account for the given username and email (Institutional Clients only).
Source§async fn account_transfer(
&mut self,
request: &AccountTransferRequest,
) -> Result<ResultErrorResponse<AccountTransfer>, ClientError>
async fn account_transfer( &mut self, request: &AccountTransferRequest, ) -> Result<ResultErrorResponse<AccountTransfer>, ClientError>
Request to transfer a given asset between sub-accounts (Institutional Clients only).
Source§async fn allocate_earn_funds(
&mut self,
request: &AllocateEarnFundsRequest,
) -> Result<ResultErrorResponse<bool>, ClientError>
async fn allocate_earn_funds( &mut self, request: &AllocateEarnFundsRequest, ) -> Result<ResultErrorResponse<bool>, ClientError>
Allocate available funds to a given earn strategy.
Source§async fn deallocate_earn_funds(
&mut self,
request: &AllocateEarnFundsRequest,
) -> Result<ResultErrorResponse<bool>, ClientError>
async fn deallocate_earn_funds( &mut self, request: &AllocateEarnFundsRequest, ) -> Result<ResultErrorResponse<bool>, ClientError>
De-allocate funds from a given earn strategy.
Source§async fn get_earn_allocation_status(
&mut self,
request: &EarnAllocationStatusRequest,
) -> Result<ResultErrorResponse<AllocationStatus>, ClientError>
async fn get_earn_allocation_status( &mut self, request: &EarnAllocationStatusRequest, ) -> Result<ResultErrorResponse<AllocationStatus>, ClientError>
Get the status for the only pending earn allocation request if there is one.
Source§async fn get_earn_deallocation_status(
&mut self,
request: &EarnAllocationStatusRequest,
) -> Result<ResultErrorResponse<AllocationStatus>, ClientError>
async fn get_earn_deallocation_status( &mut self, request: &EarnAllocationStatusRequest, ) -> Result<ResultErrorResponse<AllocationStatus>, ClientError>
Get the status for the only pending earn de-allocation if there is one.
Source§async fn list_earn_strategies(
&mut self,
request: &ListEarnStrategiesRequest,
) -> Result<ResultErrorResponse<EarnStrategies>, ClientError>
async fn list_earn_strategies( &mut self, request: &ListEarnStrategiesRequest, ) -> Result<ResultErrorResponse<EarnStrategies>, ClientError>
List all earn strategies. Read more
Source§async fn list_earn_allocations(
&mut self,
request: &ListEarnAllocationsRequest,
) -> Result<ResultErrorResponse<EarnAllocations>, ClientError>
async fn list_earn_allocations( &mut self, request: &ListEarnAllocationsRequest, ) -> Result<ResultErrorResponse<EarnAllocations>, ClientError>
List all current earn allocations.
Source§async fn get_websockets_token(
&mut self,
) -> Result<ResultErrorResponse<WebsocketToken>, ClientError>
async fn get_websockets_token( &mut self, ) -> Result<ResultErrorResponse<WebsocketToken>, ClientError>
Get a token for connecting to private websockets. Read more
Auto Trait Implementations§
impl Freeze for CoreKrakenClient
impl !RefUnwindSafe for CoreKrakenClient
impl Send for CoreKrakenClient
impl Sync for CoreKrakenClient
impl Unpin for CoreKrakenClient
impl !UnwindSafe for CoreKrakenClient
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