#[allow(unused)]
use crate::clients::core_kraken_client::CoreKrakenClient;
use crate::clients::errors::ClientError;
use crate::clients::http_response_types::ResultErrorResponse;
#[allow(unused)]
use crate::clients::rate_limited_kraken_client::RateLimitedKrakenClient;
use crate::crypto::nonce_provider::NonceProvider;
use crate::request_types::*;
use crate::response_types::*;
use crate::secrets::secrets_provider::SecretsProvider;
use std::collections::HashMap;
use std::future::Future;
use std::sync::Arc;
use tokio::sync::Mutex;
pub mod endpoints {
pub const KRAKEN_BASE_URL: &str = "https://api.kraken.com";
pub const TIME_ENDPOINT: &str = "/0/public/Time";
pub const STATUS_ENDPOINT: &str = "/0/public/SystemStatus";
pub const ASSET_INFO_ENDPOINT: &str = "/0/public/Assets";
pub const TRADABLE_ASSET_PAIRS_ENDPOINT: &str = "/0/public/AssetPairs";
pub const TICKER_INFO_ENDPOINT: &str = "/0/public/Ticker";
pub const OHLC_ENDPOINT: &str = "/0/public/OHLC";
pub const ORDER_BOOK_ENDPOINT: &str = "/0/public/Depth";
pub const RECENT_TRADES_ENDPOINT: &str = "/0/public/Trades";
pub const RECENT_SPREADS_ENDPOINT: &str = "/0/public/Spread";
pub const ACCOUNT_BALANCE_ENDPOINT: &str = "/0/private/Balance";
pub const ACCOUNT_BALANCE_EXTENDED_ENDPOINT: &str = "/0/private/BalanceEx";
pub const TRADE_BALANCE_ENDPOINT: &str = "/0/private/TradeBalance";
pub const OPEN_ORDERS_ENDPOINT: &str = "/0/private/OpenOrders";
pub const CLOSED_ORDERS_ENDPOINT: &str = "/0/private/ClosedOrders";
pub const QUERY_ORDERS_ENDPOINT: &str = "/0/private/QueryOrders";
pub const ORDER_AMENDS_ENDPOINT: &str = "/0/private/OrderAmends";
pub const TRADES_HISTORY_ENDPOINT: &str = "/0/private/TradesHistory";
pub const QUERY_TRADES_ENDPOINT: &str = "/0/private/QueryTrades";
pub const OPEN_POSITIONS_ENDPOINT: &str = "/0/private/OpenPositions";
pub const LEDGERS_ENDPOINT: &str = "/0/private/Ledgers";
pub const QUERY_LEDGERS_ENDPOINT: &str = "/0/private/QueryLedgers";
pub const TRADE_VOLUME_ENDPOINT: &str = "/0/private/TradeVolume";
pub const ADD_EXPORT_ENDPOINT: &str = "/0/private/AddExport";
pub const EXPORT_STATUS_ENDPOINT: &str = "/0/private/ExportStatus";
pub const RETRIEVE_EXPORT_ENDPOINT: &str = "/0/private/RetrieveExport";
pub const REMOVE_EXPORT_ENDPOINT: &str = "/0/private/RemoveExport";
pub const ADD_ORDER_ENDPOINT: &str = "/0/private/AddOrder";
pub const ADD_ORDER_BATCH_ENDPOINT: &str = "/0/private/AddOrderBatch";
pub const AMEND_ORDER_ENDPOINT: &str = "/0/private/AmendOrder";
pub const EDIT_ORDER_ENDPOINT: &str = "/0/private/EditOrder";
pub const CANCEL_ORDER_ENDPOINT: &str = "/0/private/CancelOrder";
pub const CANCEL_ALL_ORDERS_ENDPOINT: &str = "/0/private/CancelAll";
pub const CANCEL_ALL_ORDERS_AFTER_ENDPOINT: &str = "/0/private/CancelAllOrdersAfter";
pub const CANCEL_ORDER_BATCH_ENDPOINT: &str = "/0/private/CancelOrderBatch";
pub const DEPOSIT_METHODS_ENDPOINT: &str = "/0/private/DepositMethods";
pub const DEPOSIT_ADDRESSES_ENDPOINT: &str = "/0/private/DepositAddresses";
pub const DEPOSIT_STATUS_ENDPOINT: &str = "/0/private/DepositStatus";
pub const WITHDRAW_METHODS_ENDPOINT: &str = "/0/private/WithdrawMethods";
pub const WITHDRAW_ADDRESSES_ENDPOINT: &str = "/0/private/WithdrawAddresses";
pub const WITHDRAW_INFO_ENDPOINT: &str = "/0/private/WithdrawInfo";
pub const WITHDRAW_ENDPOINT: &str = "/0/private/Withdraw";
pub const WITHDRAW_STATUS_ENDPOINT: &str = "/0/private/WithdrawStatus";
pub const WITHDRAW_CANCEL_ENDPOINT: &str = "/0/private/WithdrawCancel";
pub const WALLET_TRANSFER_ENDPOINT: &str = "/0/private/WalletTransfer";
pub const CREATE_SUB_ACCOUNT_ENDPOINT: &str = "/0/private/CreateSubaccount";
pub const ACCOUNT_TRANSFER_ENDPOINT: &str = "/0/private/AccountTransfer";
pub const EARN_ALLOCATE_ENDPOINT: &str = "/0/private/Earn/Allocate";
pub const EARN_DEALLOCATE_ENDPOINT: &str = "/0/private/Earn/Deallocate";
pub const EARN_ALLOCATE_STATUS_ENDPOINT: &str = "/0/private/Earn/AllocateStatus";
pub const EARN_DEALLOCATE_STATUS_ENDPOINT: &str = "/0/private/Earn/DeallocateStatus";
pub const EARN_STRATEGIES_ENDPOINT: &str = "/0/private/Earn/Strategies";
pub const EARN_ALLOCATIONS_ENDPOINT: &str = "/0/private/Earn/Allocations";
pub const GET_WS_TOKEN_ENDPOINT: &str = "/0/private/GetWebSocketsToken";
}
pub trait KrakenClient: Send + Sync {
fn new(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
) -> Self;
fn new_with_url(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
url: String,
) -> Self;
fn new_with_tracing(
secrets_provider: Box<Arc<Mutex<dyn SecretsProvider>>>,
nonce_provider: Box<Arc<Mutex<dyn NonceProvider>>>,
trace_inbound: bool,
) -> Self;
fn set_user_agent(&mut self, user_agent: String) -> impl Future<Output = ()>;
fn get_server_time(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<SystemTime>, ClientError>> + Send;
fn get_system_status(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<SystemStatusInfo>, ClientError>>;
fn get_asset_info(
&mut self,
request: &AssetInfoRequest,
) -> impl Future<Output = Result<ResultErrorResponse<HashMap<String, AssetInfo>>, ClientError>>;
fn get_tradable_asset_pairs(
&mut self,
request: &TradableAssetPairsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<HashMap<String, TradableAssetPair>>, ClientError>>;
fn get_ticker_information(
&mut self,
request: &TickerRequest,
) -> impl Future<Output = Result<ResultErrorResponse<HashMap<String, RestTickerInfo>>, ClientError>>;
fn get_ohlc(
&mut self,
request: &OHLCRequest,
) -> impl Future<Output = Result<ResultErrorResponse<OhlcResponse>, ClientError>>;
fn get_orderbook(
&mut self,
request: &OrderbookRequest,
) -> impl Future<Output = Result<ResultErrorResponse<HashMap<String, Orderbook>>, ClientError>>;
fn get_recent_trades(
&mut self,
request: &RecentTradesRequest,
) -> impl Future<Output = Result<ResultErrorResponse<RecentTrades>, ClientError>>;
fn get_recent_spreads(
&mut self,
request: &RecentSpreadsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<RecentSpreads>, ClientError>>;
fn get_account_balance(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<AccountBalances>, ClientError>>;
fn get_extended_balances(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<ExtendedBalances>, ClientError>>;
fn get_trade_balances(
&mut self,
request: &TradeBalanceRequest,
) -> impl Future<Output = Result<ResultErrorResponse<TradeBalances>, ClientError>>;
fn get_open_orders(
&mut self,
request: &OpenOrdersRequest,
) -> impl Future<Output = Result<ResultErrorResponse<OpenOrders>, ClientError>>;
fn get_closed_orders(
&mut self,
request: &ClosedOrdersRequest,
) -> impl Future<Output = Result<ResultErrorResponse<ClosedOrders>, ClientError>>;
fn query_orders_info(
&mut self,
request: &OrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<HashMap<String, Order>>, ClientError>>;
fn get_order_amends(
&mut self,
request: &OrderAmendsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<OrderAmends>, ClientError>>;
fn get_trades_history(
&mut self,
request: &TradesHistoryRequest,
) -> impl Future<Output = Result<ResultErrorResponse<TradesHistory>, ClientError>>;
fn query_trades_info(
&mut self,
request: &TradeInfoRequest,
) -> impl Future<Output = Result<ResultErrorResponse<TradesInfo>, ClientError>>;
fn get_open_positions(
&mut self,
request: &OpenPositionsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<OpenPositions>, ClientError>>;
fn get_ledgers_info(
&mut self,
request: &LedgersInfoRequest,
) -> impl Future<Output = Result<ResultErrorResponse<LedgerInfo>, ClientError>>;
fn query_ledgers(
&mut self,
request: &QueryLedgerRequest,
) -> impl Future<Output = Result<ResultErrorResponse<QueryLedgerInfo>, ClientError>>;
fn get_trade_volume(
&mut self,
request: &TradeVolumeRequest,
) -> impl Future<Output = Result<ResultErrorResponse<TradeVolume>, ClientError>>;
fn request_export_report(
&mut self,
request: &ExportReportRequest,
) -> impl Future<Output = Result<ResultErrorResponse<ExportReport>, ClientError>>;
fn get_export_report_status(
&mut self,
request: &ExportReportStatusRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<ExportReportStatus>>, ClientError>>;
fn retrieve_export_report(
&mut self,
request: &RetrieveExportReportRequest,
) -> impl Future<Output = Result<Vec<u8>, ClientError>>;
fn delete_export_report(
&mut self,
request: &DeleteExportRequest,
) -> impl Future<Output = Result<ResultErrorResponse<DeleteExportReport>, ClientError>>;
fn add_order(
&mut self,
request: &AddOrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AddOrder>, ClientError>>;
fn add_order_batch(
&mut self,
request: &AddBatchedOrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AddOrderBatch>, ClientError>>;
fn amend_order(
&mut self,
request: &AmendOrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AmendOrder>, ClientError>>;
fn edit_order(
&mut self,
request: &EditOrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<OrderEdit>, ClientError>>;
fn cancel_order(
&mut self,
request: &CancelOrderRequest,
) -> impl Future<Output = Result<ResultErrorResponse<CancelOrder>, ClientError>>;
fn cancel_all_orders(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<CancelOrder>, ClientError>>;
fn cancel_all_orders_after(
&mut self,
request: &CancelAllOrdersAfterRequest,
) -> impl Future<Output = Result<ResultErrorResponse<CancelAllOrdersAfter>, ClientError>>;
fn cancel_order_batch(
&mut self,
request: &CancelBatchOrdersRequest,
) -> impl Future<Output = Result<ResultErrorResponse<CancelOrder>, ClientError>>;
fn get_deposit_methods(
&mut self,
request: &DepositMethodsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<DepositMethod>>, ClientError>>;
fn get_deposit_addresses(
&mut self,
request: &DepositAddressesRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<DepositAddress>>, ClientError>>;
fn get_status_of_recent_deposits(
&mut self,
request: &StatusOfDepositWithdrawRequest,
) -> impl Future<Output = Result<ResultErrorResponse<DepositWithdrawResponse>, ClientError>>;
fn get_withdrawal_methods(
&mut self,
request: &WithdrawalMethodsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<WithdrawMethod>>, ClientError>>;
fn get_withdrawal_addresses(
&mut self,
request: &WithdrawalAddressesRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<WithdrawalAddress>>, ClientError>>;
fn get_withdrawal_info(
&mut self,
request: &WithdrawalInfoRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Withdrawal>, ClientError>>;
fn withdraw_funds(
&mut self,
request: &WithdrawFundsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<ConfirmationRefId>, ClientError>>;
fn get_status_of_recent_withdrawals(
&mut self,
request: &StatusOfDepositWithdrawRequest,
) -> impl Future<Output = Result<ResultErrorResponse<Vec<DepositWithdrawal>>, ClientError>>;
fn request_withdrawal_cancellation(
&mut self,
request: &WithdrawCancelRequest,
) -> impl Future<Output = Result<ResultErrorResponse<bool>, ClientError>>;
fn request_wallet_transfer(
&mut self,
request: &WalletTransferRequest,
) -> impl Future<Output = Result<ResultErrorResponse<ConfirmationRefId>, ClientError>>;
fn create_sub_account(
&mut self,
request: &CreateSubAccountRequest,
) -> impl Future<Output = Result<ResultErrorResponse<bool>, ClientError>>;
fn account_transfer(
&mut self,
request: &AccountTransferRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AccountTransfer>, ClientError>>;
fn allocate_earn_funds(
&mut self,
request: &AllocateEarnFundsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<bool>, ClientError>>;
fn deallocate_earn_funds(
&mut self,
request: &AllocateEarnFundsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<bool>, ClientError>>;
fn get_earn_allocation_status(
&mut self,
request: &EarnAllocationStatusRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AllocationStatus>, ClientError>>;
fn get_earn_deallocation_status(
&mut self,
request: &EarnAllocationStatusRequest,
) -> impl Future<Output = Result<ResultErrorResponse<AllocationStatus>, ClientError>>;
fn list_earn_strategies(
&mut self,
request: &ListEarnStrategiesRequest,
) -> impl Future<Output = Result<ResultErrorResponse<EarnStrategies>, ClientError>>;
fn list_earn_allocations(
&mut self,
request: &ListEarnAllocationsRequest,
) -> impl Future<Output = Result<ResultErrorResponse<EarnAllocations>, ClientError>>;
fn get_websockets_token(
&mut self,
) -> impl Future<Output = Result<ResultErrorResponse<WebsocketToken>, ClientError>>;
}