whitebit-python-sdk 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- whitebit/__init__.py +793 -0
- whitebit/client.py +580 -0
- whitebit/codes/__init__.py +7 -0
- whitebit/codes/client.py +510 -0
- whitebit/codes/raw_client.py +809 -0
- whitebit/codes/types/__init__.py +10 -0
- whitebit/codes/types/apply_code_response.py +22 -0
- whitebit/codes/types/create_code_response.py +32 -0
- whitebit/codes/types/get_codes_history_response.py +27 -0
- whitebit/codes/types/get_my_codes_response.py +27 -0
- whitebit/collateral_trading/__init__.py +183 -0
- whitebit/collateral_trading/client.py +2452 -0
- whitebit/collateral_trading/raw_client.py +4337 -0
- whitebit/collateral_trading/types/__init__.py +213 -0
- whitebit/collateral_trading/types/cancel_oco_order_response.py +34 -0
- whitebit/collateral_trading/types/cancel_oco_order_response_stop_loss.py +146 -0
- whitebit/collateral_trading/types/cancel_oco_order_response_stop_loss_activation_condition.py +5 -0
- whitebit/collateral_trading/types/cancel_oco_order_response_stop_loss_side.py +5 -0
- whitebit/collateral_trading/types/cancel_oco_order_response_take_profit.py +114 -0
- whitebit/collateral_trading/types/cancel_oco_order_response_take_profit_side.py +5 -0
- whitebit/collateral_trading/types/change_collateral_account_leverage_response.py +22 -0
- whitebit/collateral_trading/types/close_position_request_position_side.py +5 -0
- whitebit/collateral_trading/types/collateral_account_balance_summary_response_item.py +48 -0
- whitebit/collateral_trading/types/collateral_account_summary_response.py +60 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_request_orders_item.py +98 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_request_orders_item_position_side.py +7 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_request_orders_item_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item.py +29 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item_error.py +36 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item_result.py +132 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item_result_position_side.py +7 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item_result_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_bulk_order_response_item_result_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_request_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_request_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_response.py +132 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_response_oto.py +44 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_response_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_response_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_limit_order_response_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_market_order_request_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_market_order_request_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_market_order_response.py +110 -0
- whitebit/collateral_trading/types/create_collateral_market_order_response_oto.py +44 -0
- whitebit/collateral_trading/types/create_collateral_market_order_response_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_market_order_response_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_market_order_response_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_request_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response.py +34 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_stop_loss.py +159 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_stop_loss_activation_condition.py +5 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_stop_loss_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_stop_loss_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_stop_loss_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_take_profit.py +139 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_take_profit_position_side.py +7 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_take_profit_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_oco_order_response_take_profit_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_request_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_request_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_response.py +122 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_response_oto.py +44 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_response_position_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_response_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_stop_limit_order_response_status.py +7 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_request_position_side.py +7 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_request_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_response.py +117 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_response_oto.py +44 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_response_position_side.py +7 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_response_side.py +5 -0
- whitebit/collateral_trading/types/create_collateral_trigger_market_order_response_status.py +7 -0
- whitebit/collateral_trading/types/get_collateral_hedge_mode_response.py +26 -0
- whitebit/collateral_trading/types/get_conditional_orders_response.py +38 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item.py +60 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oco.py +31 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oco_stop_loss.py +28 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oco_stop_loss_position_side.py +7 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oco_take_profit.py +28 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oco_take_profit_position_side.py +7 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oto.py +34 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oto_conditional_order.py +30 -0
- whitebit/collateral_trading/types/get_conditional_orders_response_records_item_oto_conditional_order_position_side.py +7 -0
- whitebit/collateral_trading/types/get_funding_history_response.py +33 -0
- whitebit/collateral_trading/types/get_funding_history_response_records_item.py +66 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item.py +34 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item_stop_loss.py +49 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item_stop_loss_activation_condition.py +5 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item_stop_loss_side.py +5 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item_take_profit.py +43 -0
- whitebit/collateral_trading/types/get_oco_orders_response_item_take_profit_side.py +5 -0
- whitebit/collateral_trading/types/get_open_positions_response_item.py +136 -0
- whitebit/collateral_trading/types/get_open_positions_response_item_liquidation_state.py +5 -0
- whitebit/collateral_trading/types/get_open_positions_response_item_position_side.py +5 -0
- whitebit/collateral_trading/types/get_open_positions_response_item_tpsl.py +51 -0
- whitebit/collateral_trading/types/get_positions_history_response_item.py +95 -0
- whitebit/collateral_trading/types/get_positions_history_response_item_liquidation_state.py +5 -0
- whitebit/collateral_trading/types/get_positions_history_response_item_order_detail.py +61 -0
- whitebit/collateral_trading/types/get_positions_history_response_item_position_side.py +5 -0
- whitebit/core/__init__.py +52 -0
- whitebit/core/api_error.py +23 -0
- whitebit/core/client_wrapper.py +57 -0
- whitebit/core/datetime_utils.py +28 -0
- whitebit/core/file.py +67 -0
- whitebit/core/http_client.py +497 -0
- whitebit/core/http_response.py +55 -0
- whitebit/core/jsonable_encoder.py +100 -0
- whitebit/core/pydantic_utilities.py +255 -0
- whitebit/core/query_encoder.py +58 -0
- whitebit/core/remove_none_from_dict.py +11 -0
- whitebit/core/request_options.py +35 -0
- whitebit/core/serialization.py +276 -0
- whitebit/credit_line/__init__.py +4 -0
- whitebit/credit_line/client.py +128 -0
- whitebit/credit_line/raw_client.py +191 -0
- whitebit/crypto_lending_fixed/__init__.py +7 -0
- whitebit/crypto_lending_fixed/client.py +651 -0
- whitebit/crypto_lending_fixed/raw_client.py +931 -0
- whitebit/crypto_lending_fixed/types/__init__.py +9 -0
- whitebit/crypto_lending_fixed/types/create_fixed_investment_response.py +22 -0
- whitebit/crypto_lending_fixed/types/get_fixed_investments_history_response.py +22 -0
- whitebit/crypto_lending_fixed/types/get_interest_payment_history_response.py +22 -0
- whitebit/crypto_lending_flex/__init__.py +29 -0
- whitebit/crypto_lending_flex/client.py +1140 -0
- whitebit/crypto_lending_flex/raw_client.py +1651 -0
- whitebit/crypto_lending_flex/types/__init__.py +27 -0
- whitebit/crypto_lending_flex/types/close_flex_investment_response.py +20 -0
- whitebit/crypto_lending_flex/types/close_flex_investment_response_data.py +26 -0
- whitebit/crypto_lending_flex/types/create_flex_investment_response.py +20 -0
- whitebit/crypto_lending_flex/types/create_flex_investment_response_data.py +26 -0
- whitebit/crypto_lending_flex/types/get_flex_investment_history_response.py +22 -0
- whitebit/crypto_lending_flex/types/get_flex_payment_history_response.py +22 -0
- whitebit/crypto_lending_flex/types/get_user_flex_investments_response.py +22 -0
- whitebit/crypto_lending_flex/types/update_flex_auto_reinvestment_response.py +19 -0
- whitebit/crypto_lending_flex/types/withdraw_from_flex_investment_response.py +20 -0
- whitebit/crypto_lending_flex/types/withdraw_from_flex_investment_response_data.py +26 -0
- whitebit/deposit/__init__.py +35 -0
- whitebit/deposit/client.py +997 -0
- whitebit/deposit/raw_client.py +1342 -0
- whitebit/deposit/types/__init__.py +33 -0
- whitebit/deposit/types/create_new_address_request_type.py +5 -0
- whitebit/deposit/types/create_new_address_response.py +22 -0
- whitebit/deposit/types/create_new_address_response_account.py +27 -0
- whitebit/deposit/types/create_new_address_response_required.py +48 -0
- whitebit/deposit/types/create_new_address_response_required_flex_fee.py +42 -0
- whitebit/deposit/types/get_deposit_address_response.py +22 -0
- whitebit/deposit/types/get_deposit_address_response_account.py +27 -0
- whitebit/deposit/types/get_deposit_address_response_required.py +48 -0
- whitebit/deposit/types/get_deposit_address_response_required_flex_fee.py +42 -0
- whitebit/deposit/types/get_fiat_deposit_url_request_customer.py +61 -0
- whitebit/deposit/types/get_fiat_deposit_url_request_customer_address.py +56 -0
- whitebit/deposit/types/get_fiat_deposit_url_response.py +22 -0
- whitebit/deposit/types/refund_deposit_response.py +22 -0
- whitebit/environment.py +17 -0
- whitebit/errors/__init__.py +19 -0
- whitebit/errors/bad_request_error.py +10 -0
- whitebit/errors/internal_server_error.py +10 -0
- whitebit/errors/not_found_error.py +11 -0
- whitebit/errors/service_unavailable_error.py +10 -0
- whitebit/errors/unauthorized_error.py +10 -0
- whitebit/errors/unprocessable_entity_error.py +10 -0
- whitebit/fees/__init__.py +4 -0
- whitebit/fees/client.py +126 -0
- whitebit/fees/raw_client.py +144 -0
- whitebit/jwt/__init__.py +7 -0
- whitebit/jwt/client.py +224 -0
- whitebit/jwt/raw_client.py +389 -0
- whitebit/jwt/types/__init__.py +9 -0
- whitebit/jwt/types/get_web_socket_token_response.py +22 -0
- whitebit/jwt/types/issue_jwt_token_response.py +20 -0
- whitebit/jwt/types/issue_jwt_token_response_data.py +27 -0
- whitebit/main_account/__init__.py +7 -0
- whitebit/main_account/client.py +380 -0
- whitebit/main_account/raw_client.py +493 -0
- whitebit/main_account/types/__init__.py +8 -0
- whitebit/main_account/types/get_deposit_withdraw_history_response.py +26 -0
- whitebit/main_account/types/get_main_balance_response_value.py +22 -0
- whitebit/market_fee/__init__.py +7 -0
- whitebit/market_fee/client.py +193 -0
- whitebit/market_fee/raw_client.py +267 -0
- whitebit/market_fee/types/__init__.py +8 -0
- whitebit/market_fee/types/get_all_market_fees_response.py +43 -0
- whitebit/market_fee/types/get_market_fee_response.py +38 -0
- whitebit/mining_pool/__init__.py +67 -0
- whitebit/mining_pool/client.py +1083 -0
- whitebit/mining_pool/raw_client.py +1695 -0
- whitebit/mining_pool/types/__init__.py +69 -0
- whitebit/mining_pool/types/create_mining_account_response.py +20 -0
- whitebit/mining_pool/types/create_mining_account_response_data.py +31 -0
- whitebit/mining_pool/types/create_mining_watcher_link_request_live_until.py +5 -0
- whitebit/mining_pool/types/create_mining_watcher_link_request_permissions_item.py +7 -0
- whitebit/mining_pool/types/create_mining_watcher_link_response.py +20 -0
- whitebit/mining_pool/types/create_mining_watcher_link_response_data.py +24 -0
- whitebit/mining_pool/types/get_mining_accounts_response.py +20 -0
- whitebit/mining_pool/types/get_mining_accounts_response_data_item.py +31 -0
- whitebit/mining_pool/types/get_mining_hashrate_request_interval.py +5 -0
- whitebit/mining_pool/types/get_mining_hashrate_response.py +20 -0
- whitebit/mining_pool/types/get_mining_hashrate_response_data.py +21 -0
- whitebit/mining_pool/types/get_mining_hashrate_response_data_hashrate_item.py +20 -0
- whitebit/mining_pool/types/get_mining_miner_info_response.py +20 -0
- whitebit/mining_pool/types/get_mining_miner_info_response_data.py +25 -0
- whitebit/mining_pool/types/get_mining_miner_info_response_data_stratum_item.py +22 -0
- whitebit/mining_pool/types/get_mining_payout_destination_response.py +36 -0
- whitebit/mining_pool/types/get_mining_payout_destination_response_payout_destination.py +7 -0
- whitebit/mining_pool/types/get_mining_rewards_response.py +22 -0
- whitebit/mining_pool/types/get_mining_worker_hashrate_request_interval.py +5 -0
- whitebit/mining_pool/types/get_mining_worker_hashrate_response.py +20 -0
- whitebit/mining_pool/types/get_mining_worker_hashrate_response_data.py +20 -0
- whitebit/mining_pool/types/get_mining_worker_hashrate_response_data_hashrates_item.py +23 -0
- whitebit/mining_pool/types/get_mining_worker_names_response.py +22 -0
- whitebit/mining_pool/types/get_mining_worker_names_response_data.py +19 -0
- whitebit/mining_pool/types/list_mining_watcher_links_response.py +20 -0
- whitebit/mining_pool/types/list_mining_watcher_links_response_data_item.py +27 -0
- whitebit/mining_pool/types/set_mining_payout_destination_request_destination.py +7 -0
- whitebit/mining_pool/types/set_mining_payout_destination_response.py +27 -0
- whitebit/mining_pool/types/set_mining_payout_destination_response_payout_destination.py +7 -0
- whitebit/public_api_v4/__init__.py +37 -0
- whitebit/public_api_v4/client.py +1096 -0
- whitebit/public_api_v4/raw_client.py +1398 -0
- whitebit/public_api_v4/types/__init__.py +37 -0
- whitebit/public_api_v4/types/get_api_v4public_funding_history_market_response_item.py +52 -0
- whitebit/public_api_v4/types/get_api_v4public_futures_response.py +22 -0
- whitebit/public_api_v4/types/get_api_v4public_markets_response_item.py +110 -0
- whitebit/public_api_v4/types/get_api_v4public_markets_response_item_type.py +5 -0
- whitebit/public_api_v4/types/get_api_v4public_mining_pool_response.py +20 -0
- whitebit/public_api_v4/types/get_api_v4public_mining_pool_response_data.py +39 -0
- whitebit/public_api_v4/types/get_api_v4public_mining_pool_response_data_blocks_item.py +22 -0
- whitebit/public_api_v4/types/get_api_v4public_mining_pool_response_data_last7days_hash_rate_item.py +20 -0
- whitebit/public_api_v4/types/get_api_v4public_platform_status_response.py +22 -0
- whitebit/public_api_v4/types/get_api_v4public_ticker_response_value.py +56 -0
- whitebit/public_api_v4/types/get_api_v4public_time_response.py +22 -0
- whitebit/public_api_v4/types/get_api_v4public_trades_market_request_type.py +5 -0
- whitebit/public_api_v4/types/get_api_v4public_trades_market_response_item.py +57 -0
- whitebit/public_api_v4/types/get_api_v4public_trades_market_response_item_type.py +5 -0
- whitebit/raw_client.py +637 -0
- whitebit/spot_trading/__init__.py +47 -0
- whitebit/spot_trading/client.py +4143 -0
- whitebit/spot_trading/raw_client.py +5628 -0
- whitebit/spot_trading/types/__init__.py +45 -0
- whitebit/spot_trading/types/cancel_all_orders_request_type_item.py +5 -0
- whitebit/spot_trading/types/get_executed_order_history_response_value_item.py +62 -0
- whitebit/spot_trading/types/get_executed_order_history_response_value_item_side.py +5 -0
- whitebit/spot_trading/types/get_kill_switch_status_response_item.py +44 -0
- whitebit/spot_trading/types/get_kill_switch_status_response_item_types_item.py +5 -0
- whitebit/spot_trading/types/get_order_deals_response.py +33 -0
- whitebit/spot_trading/types/get_order_deals_response_records_item.py +80 -0
- whitebit/spot_trading/types/get_order_history_response_value_item.py +131 -0
- whitebit/spot_trading/types/get_order_history_response_value_item_side.py +5 -0
- whitebit/spot_trading/types/limit_order_request_side.py +5 -0
- whitebit/spot_trading/types/limit_order_request_stp.py +5 -0
- whitebit/spot_trading/types/set_kill_switch_request_types_item.py +5 -0
- whitebit/spot_trading/types/set_kill_switch_response.py +44 -0
- whitebit/spot_trading/types/set_kill_switch_response_types_item.py +5 -0
- whitebit/spot_trading/types/stop_limit_order_request_side.py +5 -0
- whitebit/spot_trading/types/stop_limit_order_request_stp.py +5 -0
- whitebit/spot_trading/types/stop_market_order_request_side.py +5 -0
- whitebit/spot_trading/types/stop_market_order_request_stp.py +5 -0
- whitebit/spot_trading/types/trade_account_balance_response_value.py +27 -0
- whitebit/sub_account/__init__.py +25 -0
- whitebit/sub_account/client.py +892 -0
- whitebit/sub_account/raw_client.py +1399 -0
- whitebit/sub_account/types/__init__.py +23 -0
- whitebit/sub_account/types/create_sub_account_request_permissions.py +29 -0
- whitebit/sub_account/types/edit_sub_account_request_permissions.py +29 -0
- whitebit/sub_account/types/get_sub_account_balances_response_value_item.py +21 -0
- whitebit/sub_account/types/get_sub_account_transfer_history_request_direction.py +5 -0
- whitebit/sub_account/types/get_sub_account_transfer_history_response.py +22 -0
- whitebit/sub_account/types/list_sub_accounts_response.py +22 -0
- whitebit/sub_account/types/sub_account_transfer_request_direction.py +5 -0
- whitebit/sub_account/types/sub_account_transfer_response.py +26 -0
- whitebit/sub_account_api_keys/__init__.py +19 -0
- whitebit/sub_account_api_keys/client.py +754 -0
- whitebit/sub_account_api_keys/raw_client.py +1183 -0
- whitebit/sub_account_api_keys/types/__init__.py +17 -0
- whitebit/sub_account_api_keys/types/create_sub_account_api_key_ip_address_response.py +19 -0
- whitebit/sub_account_api_keys/types/delete_sub_account_api_key_ip_address_response.py +19 -0
- whitebit/sub_account_api_keys/types/edit_sub_account_api_key_request_urls_item.py +20 -0
- whitebit/sub_account_api_keys/types/list_sub_account_api_key_ip_addresses_response.py +19 -0
- whitebit/sub_account_api_keys/types/list_sub_account_api_keys_response.py +22 -0
- whitebit/transfer/__init__.py +15 -0
- whitebit/transfer/client.py +220 -0
- whitebit/transfer/raw_client.py +276 -0
- whitebit/transfer/types/__init__.py +13 -0
- whitebit/transfer/types/transfer_between_balances_request_from.py +5 -0
- whitebit/transfer/types/transfer_between_balances_request_method.py +7 -0
- whitebit/transfer/types/transfer_between_balances_request_to.py +5 -0
- whitebit/types/__init__.py +311 -0
- whitebit/types/asset.py +106 -0
- whitebit/types/asset_limits.py +33 -0
- whitebit/types/asset_limits_deposit_value.py +20 -0
- whitebit/types/asset_limits_withdraw_value.py +20 -0
- whitebit/types/asset_memo.py +24 -0
- whitebit/types/asset_networks.py +36 -0
- whitebit/types/asset_providers.py +24 -0
- whitebit/types/authorize_request.py +32 -0
- whitebit/types/authorize_response.py +29 -0
- whitebit/types/authorize_response_result.py +22 -0
- whitebit/types/bad_request_error_body.py +20 -0
- whitebit/types/balance_margin_request.py +32 -0
- whitebit/types/balance_margin_response.py +33 -0
- whitebit/types/balance_margin_response_result_value.py +37 -0
- whitebit/types/balance_margin_subscribe.py +32 -0
- whitebit/types/balance_margin_update.py +33 -0
- whitebit/types/balance_margin_update_params_item.py +48 -0
- whitebit/types/balance_spot_request.py +32 -0
- whitebit/types/balance_spot_response.py +33 -0
- whitebit/types/balance_spot_response_result_value.py +27 -0
- whitebit/types/balance_spot_subscribe.py +32 -0
- whitebit/types/balance_spot_update.py +33 -0
- whitebit/types/balance_spot_update_params_item_value.py +27 -0
- whitebit/types/base_request.py +22 -0
- whitebit/types/base_response.py +24 -0
- whitebit/types/book_ticker_subscribe.py +29 -0
- whitebit/types/book_ticker_update.py +26 -0
- whitebit/types/book_ticker_update_data.py +5 -0
- whitebit/types/borrows_events_subscribe.py +32 -0
- whitebit/types/borrows_events_update.py +34 -0
- whitebit/types/borrows_subscribe.py +32 -0
- whitebit/types/borrows_update.py +30 -0
- whitebit/types/borrows_update_params.py +25 -0
- whitebit/types/borrows_update_params_records_item.py +47 -0
- whitebit/types/bulk_limit_order_response.py +7 -0
- whitebit/types/bulk_limit_order_response_item.py +22 -0
- whitebit/types/bulk_order_item.py +42 -0
- whitebit/types/bulk_order_item_side.py +5 -0
- whitebit/types/candle.py +5 -0
- whitebit/types/candles_request.py +36 -0
- whitebit/types/candles_response.py +26 -0
- whitebit/types/candles_subscribe.py +34 -0
- whitebit/types/candles_update.py +26 -0
- whitebit/types/code_history.py +47 -0
- whitebit/types/code_info.py +47 -0
- whitebit/types/convert_confirm_response.py +33 -0
- whitebit/types/convert_estimate_request_direction.py +5 -0
- whitebit/types/convert_estimate_response.py +56 -0
- whitebit/types/convert_history_response.py +34 -0
- whitebit/types/convert_history_response_records_item.py +45 -0
- whitebit/types/convert_history_response_records_item_path_item.py +23 -0
- whitebit/types/credit_line.py +28 -0
- whitebit/types/deals_request.py +35 -0
- whitebit/types/deals_response.py +29 -0
- whitebit/types/deals_response_result.py +30 -0
- whitebit/types/deals_response_result_records_item.py +82 -0
- whitebit/types/deals_subscribe.py +32 -0
- whitebit/types/deals_update.py +43 -0
- whitebit/types/depth_level.py +5 -0
- whitebit/types/depth_request.py +35 -0
- whitebit/types/depth_response.py +22 -0
- whitebit/types/depth_subscribe.py +32 -0
- whitebit/types/depth_update.py +31 -0
- whitebit/types/depth_update_data.py +40 -0
- whitebit/types/error.py +21 -0
- whitebit/types/error_inner.py +21 -0
- whitebit/types/error_response.py +32 -0
- whitebit/types/error_v4.py +25 -0
- whitebit/types/executed_order_object.py +133 -0
- whitebit/types/executed_order_object_position_side.py +5 -0
- whitebit/types/executed_order_object_stp.py +5 -0
- whitebit/types/fee_details.py +23 -0
- whitebit/types/fee_details_flex.py +21 -0
- whitebit/types/fee_info.py +49 -0
- whitebit/types/fee_info_deposit.py +63 -0
- whitebit/types/fee_info_withdraw.py +63 -0
- whitebit/types/fixed_plan.py +79 -0
- whitebit/types/flex_investment.py +67 -0
- whitebit/types/flex_investment_history.py +64 -0
- whitebit/types/flex_plan.py +50 -0
- whitebit/types/futures_market.py +117 -0
- whitebit/types/interest_payment.py +48 -0
- whitebit/types/investment.py +64 -0
- whitebit/types/lastprice_request.py +29 -0
- whitebit/types/lastprice_response.py +25 -0
- whitebit/types/lastprice_subscribe.py +29 -0
- whitebit/types/lastprice_update.py +30 -0
- whitebit/types/margin_positions_events_subscribe.py +34 -0
- whitebit/types/margin_positions_events_update.py +34 -0
- whitebit/types/market_order_request.py +51 -0
- whitebit/types/market_order_request_side.py +5 -0
- whitebit/types/market_order_request_stp.py +5 -0
- whitebit/types/market_request.py +34 -0
- whitebit/types/market_response.py +22 -0
- whitebit/types/market_statistics.py +57 -0
- whitebit/types/market_subscribe.py +25 -0
- whitebit/types/market_today_request.py +29 -0
- whitebit/types/market_today_response.py +22 -0
- whitebit/types/market_today_statistics.py +47 -0
- whitebit/types/market_today_subscribe.py +25 -0
- whitebit/types/market_today_update.py +30 -0
- whitebit/types/market_update.py +30 -0
- whitebit/types/mining_reward.py +62 -0
- whitebit/types/not_found_error_body.py +20 -0
- whitebit/types/order_book.py +33 -0
- whitebit/types/order_object.py +118 -0
- whitebit/types/order_object_position_side.py +5 -0
- whitebit/types/order_object_stp.py +5 -0
- whitebit/types/order_response.py +123 -0
- whitebit/types/orderbook_response.py +37 -0
- whitebit/types/orders_executed_request.py +35 -0
- whitebit/types/orders_executed_response.py +29 -0
- whitebit/types/orders_executed_response_result.py +30 -0
- whitebit/types/orders_executed_subscribe.py +34 -0
- whitebit/types/orders_executed_update.py +33 -0
- whitebit/types/orders_pending_request.py +32 -0
- whitebit/types/orders_pending_response.py +29 -0
- whitebit/types/orders_pending_response_result.py +35 -0
- whitebit/types/orders_pending_subscribe.py +32 -0
- whitebit/types/orders_pending_update.py +32 -0
- whitebit/types/ping_request.py +25 -0
- whitebit/types/ping_response.py +21 -0
- whitebit/types/ping_response_result.py +5 -0
- whitebit/types/positions_subscribe.py +32 -0
- whitebit/types/positions_update.py +30 -0
- whitebit/types/positions_update_params.py +25 -0
- whitebit/types/positions_update_params_records_item.py +99 -0
- whitebit/types/positions_update_params_records_item_liq_stage.py +5 -0
- whitebit/types/positions_update_params_records_item_position_side.py +5 -0
- whitebit/types/provider_fee_details.py +28 -0
- whitebit/types/sub_account.py +63 -0
- whitebit/types/sub_account_api_key.py +84 -0
- whitebit/types/sub_account_api_key_access_endpoints_item.py +27 -0
- whitebit/types/sub_account_api_key_list.py +39 -0
- whitebit/types/sub_account_api_key_list_access_endpoints_item.py +20 -0
- whitebit/types/sub_account_kyc.py +37 -0
- whitebit/types/sub_account_permissions.py +37 -0
- whitebit/types/sub_account_transfer.py +53 -0
- whitebit/types/subscription_response.py +29 -0
- whitebit/types/subscription_response_result.py +22 -0
- whitebit/types/time_request.py +25 -0
- whitebit/types/time_response.py +23 -0
- whitebit/types/trade.py +48 -0
- whitebit/types/trade_type.py +5 -0
- whitebit/types/trades_request.py +35 -0
- whitebit/types/trades_response.py +22 -0
- whitebit/types/trades_subscribe.py +28 -0
- whitebit/types/trades_update.py +30 -0
- whitebit/types/transaction_history.py +108 -0
- whitebit/types/transaction_history_confirmations.py +31 -0
- whitebit/types/unprocessable_entity_error_body.py +20 -0
- whitebit/types/unsubscribe_request.py +32 -0
- whitebit/withdraw/__init__.py +11 -0
- whitebit/withdraw/client.py +496 -0
- whitebit/withdraw/raw_client.py +634 -0
- whitebit/withdraw/types/__init__.py +9 -0
- whitebit/withdraw/types/create_withdraw_request_beneficiary.py +74 -0
- whitebit/withdraw/types/create_withdraw_request_travel_rule.py +52 -0
- whitebit/withdraw/types/create_withdraw_request_travel_rule_type.py +5 -0
- whitebit_python_sdk-1.1.0.dist-info/METADATA +155 -0
- whitebit_python_sdk-1.1.0.dist-info/RECORD +451 -0
- whitebit_python_sdk-1.1.0.dist-info/WHEEL +5 -0
- whitebit_python_sdk-1.1.0.dist-info/licenses/LICENSE +20 -0
- whitebit_python_sdk-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,4337 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
12
|
+
from ..errors.bad_request_error import BadRequestError
|
|
13
|
+
from ..errors.internal_server_error import InternalServerError
|
|
14
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
15
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
16
|
+
from .types.cancel_oco_order_response import CancelOcoOrderResponse
|
|
17
|
+
from .types.change_collateral_account_leverage_response import ChangeCollateralAccountLeverageResponse
|
|
18
|
+
from .types.close_position_request_position_side import ClosePositionRequestPositionSide
|
|
19
|
+
from .types.collateral_account_balance_summary_response_item import CollateralAccountBalanceSummaryResponseItem
|
|
20
|
+
from .types.collateral_account_summary_response import CollateralAccountSummaryResponse
|
|
21
|
+
from .types.create_collateral_bulk_order_request_orders_item import CreateCollateralBulkOrderRequestOrdersItem
|
|
22
|
+
from .types.create_collateral_bulk_order_response_item import CreateCollateralBulkOrderResponseItem
|
|
23
|
+
from .types.create_collateral_limit_order_request_position_side import CreateCollateralLimitOrderRequestPositionSide
|
|
24
|
+
from .types.create_collateral_limit_order_request_side import CreateCollateralLimitOrderRequestSide
|
|
25
|
+
from .types.create_collateral_limit_order_response import CreateCollateralLimitOrderResponse
|
|
26
|
+
from .types.create_collateral_market_order_request_position_side import CreateCollateralMarketOrderRequestPositionSide
|
|
27
|
+
from .types.create_collateral_market_order_request_side import CreateCollateralMarketOrderRequestSide
|
|
28
|
+
from .types.create_collateral_market_order_response import CreateCollateralMarketOrderResponse
|
|
29
|
+
from .types.create_collateral_oco_order_request_side import CreateCollateralOcoOrderRequestSide
|
|
30
|
+
from .types.create_collateral_oco_order_response import CreateCollateralOcoOrderResponse
|
|
31
|
+
from .types.create_collateral_stop_limit_order_request_position_side import (
|
|
32
|
+
CreateCollateralStopLimitOrderRequestPositionSide,
|
|
33
|
+
)
|
|
34
|
+
from .types.create_collateral_stop_limit_order_request_side import CreateCollateralStopLimitOrderRequestSide
|
|
35
|
+
from .types.create_collateral_stop_limit_order_response import CreateCollateralStopLimitOrderResponse
|
|
36
|
+
from .types.create_collateral_trigger_market_order_request_position_side import (
|
|
37
|
+
CreateCollateralTriggerMarketOrderRequestPositionSide,
|
|
38
|
+
)
|
|
39
|
+
from .types.create_collateral_trigger_market_order_request_side import CreateCollateralTriggerMarketOrderRequestSide
|
|
40
|
+
from .types.create_collateral_trigger_market_order_response import CreateCollateralTriggerMarketOrderResponse
|
|
41
|
+
from .types.get_collateral_hedge_mode_response import GetCollateralHedgeModeResponse
|
|
42
|
+
from .types.get_conditional_orders_response import GetConditionalOrdersResponse
|
|
43
|
+
from .types.get_funding_history_response import GetFundingHistoryResponse
|
|
44
|
+
from .types.get_oco_orders_response_item import GetOcoOrdersResponseItem
|
|
45
|
+
from .types.get_open_positions_response_item import GetOpenPositionsResponseItem
|
|
46
|
+
from .types.get_positions_history_response_item import GetPositionsHistoryResponseItem
|
|
47
|
+
|
|
48
|
+
# this is used as the default value for optional parameters
|
|
49
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class RawCollateralTradingClient:
|
|
53
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
54
|
+
self._client_wrapper = client_wrapper
|
|
55
|
+
|
|
56
|
+
def collateral_account_balance(
|
|
57
|
+
self,
|
|
58
|
+
*,
|
|
59
|
+
ticker: typing.Optional[str] = OMIT,
|
|
60
|
+
request: typing.Optional[str] = OMIT,
|
|
61
|
+
nonce: typing.Optional[str] = OMIT,
|
|
62
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
63
|
+
) -> HttpResponse[typing.Dict[str, float]]:
|
|
64
|
+
"""
|
|
65
|
+
The endpoint returns a current [collateral balance](/glossary#balance-collateral).
|
|
66
|
+
|
|
67
|
+
<Note>
|
|
68
|
+
The API does not cache the response.
|
|
69
|
+
</Note>
|
|
70
|
+
|
|
71
|
+
<Warning>
|
|
72
|
+
Rate limit: 12000 requests/10 sec.
|
|
73
|
+
</Warning>
|
|
74
|
+
|
|
75
|
+
<Accordion title="Errors">
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"code": 30,
|
|
79
|
+
"message": "Validation failed",
|
|
80
|
+
"errors": {
|
|
81
|
+
"ticker": ["ticker is invalid."]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
</Accordion>
|
|
86
|
+
|
|
87
|
+
Parameters
|
|
88
|
+
----------
|
|
89
|
+
ticker : typing.Optional[str]
|
|
90
|
+
[Asset](/glossary#assets) to be filtered. For example: BTC
|
|
91
|
+
|
|
92
|
+
If not specified, returns balances for all assets.
|
|
93
|
+
|
|
94
|
+
request : typing.Optional[str]
|
|
95
|
+
Request signature
|
|
96
|
+
|
|
97
|
+
nonce : typing.Optional[str]
|
|
98
|
+
Unique request identifier
|
|
99
|
+
|
|
100
|
+
request_options : typing.Optional[RequestOptions]
|
|
101
|
+
Request-specific configuration.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
HttpResponse[typing.Dict[str, float]]
|
|
106
|
+
Successful response - returns collateral balances by asset
|
|
107
|
+
"""
|
|
108
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
109
|
+
"api/v4/collateral-account/balance",
|
|
110
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
111
|
+
method="POST",
|
|
112
|
+
json={
|
|
113
|
+
"ticker": ticker,
|
|
114
|
+
"request": request,
|
|
115
|
+
"nonce": nonce,
|
|
116
|
+
},
|
|
117
|
+
headers={
|
|
118
|
+
"content-type": "application/json",
|
|
119
|
+
},
|
|
120
|
+
request_options=request_options,
|
|
121
|
+
omit=OMIT,
|
|
122
|
+
)
|
|
123
|
+
try:
|
|
124
|
+
if 200 <= _response.status_code < 300:
|
|
125
|
+
_data = typing.cast(
|
|
126
|
+
typing.Dict[str, float],
|
|
127
|
+
parse_obj_as(
|
|
128
|
+
type_=typing.Dict[str, float], # type: ignore
|
|
129
|
+
object_=_response.json(),
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
return HttpResponse(response=_response, data=_data)
|
|
133
|
+
if _response.status_code == 422:
|
|
134
|
+
raise UnprocessableEntityError(
|
|
135
|
+
headers=dict(_response.headers),
|
|
136
|
+
body=typing.cast(
|
|
137
|
+
typing.Optional[typing.Any],
|
|
138
|
+
parse_obj_as(
|
|
139
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
140
|
+
object_=_response.json(),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
if _response.status_code == 503:
|
|
145
|
+
raise ServiceUnavailableError(
|
|
146
|
+
headers=dict(_response.headers),
|
|
147
|
+
body=typing.cast(
|
|
148
|
+
typing.Optional[typing.Any],
|
|
149
|
+
parse_obj_as(
|
|
150
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
151
|
+
object_=_response.json(),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
_response_json = _response.json()
|
|
156
|
+
except JSONDecodeError:
|
|
157
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
158
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
159
|
+
|
|
160
|
+
def collateral_account_balance_summary(
|
|
161
|
+
self,
|
|
162
|
+
*,
|
|
163
|
+
ticker: typing.Optional[str] = OMIT,
|
|
164
|
+
request: typing.Optional[str] = OMIT,
|
|
165
|
+
nonce: typing.Optional[str] = OMIT,
|
|
166
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
167
|
+
) -> HttpResponse[typing.List[CollateralAccountBalanceSummaryResponseItem]]:
|
|
168
|
+
"""
|
|
169
|
+
The endpoint retrieves collateral account balance summary with detailed breakdown per asset.
|
|
170
|
+
|
|
171
|
+
<Note>
|
|
172
|
+
The API does not cache the response.
|
|
173
|
+
</Note>
|
|
174
|
+
|
|
175
|
+
<Warning>
|
|
176
|
+
Rate limit: 12000 requests/10 sec.
|
|
177
|
+
</Warning>
|
|
178
|
+
|
|
179
|
+
<Accordion title="Errors">
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"code": 30,
|
|
183
|
+
"message": "Validation failed",
|
|
184
|
+
"errors": {
|
|
185
|
+
"ticker": ["ticker is invalid."]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
</Accordion>
|
|
190
|
+
|
|
191
|
+
Parameters
|
|
192
|
+
----------
|
|
193
|
+
ticker : typing.Optional[str]
|
|
194
|
+
Filter by requested asset. For example: BTC
|
|
195
|
+
|
|
196
|
+
If not specified, returns summary for all assets.
|
|
197
|
+
|
|
198
|
+
request : typing.Optional[str]
|
|
199
|
+
Request signature
|
|
200
|
+
|
|
201
|
+
nonce : typing.Optional[str]
|
|
202
|
+
Unique request identifier
|
|
203
|
+
|
|
204
|
+
request_options : typing.Optional[RequestOptions]
|
|
205
|
+
Request-specific configuration.
|
|
206
|
+
|
|
207
|
+
Returns
|
|
208
|
+
-------
|
|
209
|
+
HttpResponse[typing.List[CollateralAccountBalanceSummaryResponseItem]]
|
|
210
|
+
Successful response - returns detailed balance information per asset
|
|
211
|
+
"""
|
|
212
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
213
|
+
"api/v4/collateral-account/balance-summary",
|
|
214
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
215
|
+
method="POST",
|
|
216
|
+
json={
|
|
217
|
+
"ticker": ticker,
|
|
218
|
+
"request": request,
|
|
219
|
+
"nonce": nonce,
|
|
220
|
+
},
|
|
221
|
+
headers={
|
|
222
|
+
"content-type": "application/json",
|
|
223
|
+
},
|
|
224
|
+
request_options=request_options,
|
|
225
|
+
omit=OMIT,
|
|
226
|
+
)
|
|
227
|
+
try:
|
|
228
|
+
if 200 <= _response.status_code < 300:
|
|
229
|
+
_data = typing.cast(
|
|
230
|
+
typing.List[CollateralAccountBalanceSummaryResponseItem],
|
|
231
|
+
parse_obj_as(
|
|
232
|
+
type_=typing.List[CollateralAccountBalanceSummaryResponseItem], # type: ignore
|
|
233
|
+
object_=_response.json(),
|
|
234
|
+
),
|
|
235
|
+
)
|
|
236
|
+
return HttpResponse(response=_response, data=_data)
|
|
237
|
+
if _response.status_code == 422:
|
|
238
|
+
raise UnprocessableEntityError(
|
|
239
|
+
headers=dict(_response.headers),
|
|
240
|
+
body=typing.cast(
|
|
241
|
+
typing.Optional[typing.Any],
|
|
242
|
+
parse_obj_as(
|
|
243
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
244
|
+
object_=_response.json(),
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
if _response.status_code == 503:
|
|
249
|
+
raise ServiceUnavailableError(
|
|
250
|
+
headers=dict(_response.headers),
|
|
251
|
+
body=typing.cast(
|
|
252
|
+
typing.Optional[typing.Any],
|
|
253
|
+
parse_obj_as(
|
|
254
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
255
|
+
object_=_response.json(),
|
|
256
|
+
),
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
_response_json = _response.json()
|
|
260
|
+
except JSONDecodeError:
|
|
261
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
262
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
263
|
+
|
|
264
|
+
def create_collateral_limit_order(
|
|
265
|
+
self,
|
|
266
|
+
*,
|
|
267
|
+
market: str,
|
|
268
|
+
side: CreateCollateralLimitOrderRequestSide,
|
|
269
|
+
amount: str,
|
|
270
|
+
price: str,
|
|
271
|
+
request: str,
|
|
272
|
+
nonce: str,
|
|
273
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
274
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
275
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
276
|
+
post_only: typing.Optional[bool] = OMIT,
|
|
277
|
+
ioc: typing.Optional[bool] = OMIT,
|
|
278
|
+
rpi: typing.Optional[bool] = OMIT,
|
|
279
|
+
position_side: typing.Optional[CreateCollateralLimitOrderRequestPositionSide] = OMIT,
|
|
280
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
281
|
+
) -> HttpResponse[CreateCollateralLimitOrderResponse]:
|
|
282
|
+
"""
|
|
283
|
+
The endpoint creates [limit order](/glossary#limit-order) using [collateral balance](/glossary#balance-collateral).
|
|
284
|
+
|
|
285
|
+
<Warning>
|
|
286
|
+
Rate limit: 10000 requests/10 sec.
|
|
287
|
+
</Warning>
|
|
288
|
+
|
|
289
|
+
<Note>
|
|
290
|
+
For open long position use **buy**, for short **sell**. To close current position, place opposite order with current position amount.
|
|
291
|
+
</Note>
|
|
292
|
+
|
|
293
|
+
<Note>
|
|
294
|
+
- RPI orders are post-only by design and cannot be used with the IOC flag. The API returns error code `37` when both `rpi=true` and `ioc=true` are used.
|
|
295
|
+
</Note>
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
<Accordion title="Error Codes">
|
|
299
|
+
- `30` - default validation error code
|
|
300
|
+
- `31` - market validation failed
|
|
301
|
+
- `32` - amount validation failed
|
|
302
|
+
- `33` - price validation failed
|
|
303
|
+
- `36` - clientOrderId validation failed
|
|
304
|
+
- `37` - `ioc=true` cannot be used with `postOnly=true` or `rpi=true`
|
|
305
|
+
</Accordion>
|
|
306
|
+
|
|
307
|
+
Parameters
|
|
308
|
+
----------
|
|
309
|
+
market : str
|
|
310
|
+
Available margin [market](/glossary#market). Example: BTC_USDT
|
|
311
|
+
|
|
312
|
+
side : CreateCollateralLimitOrderRequestSide
|
|
313
|
+
Order type. Variables: 'buy' / 'sell'. For open long position use **buy**, for short **sell**.
|
|
314
|
+
|
|
315
|
+
amount : str
|
|
316
|
+
Amount of [stock](/glossary#stock) currency to buy or sell.
|
|
317
|
+
|
|
318
|
+
price : str
|
|
319
|
+
Price in [money](/glossary#money) currency. Example: '9800'
|
|
320
|
+
|
|
321
|
+
request : str
|
|
322
|
+
|
|
323
|
+
nonce : str
|
|
324
|
+
|
|
325
|
+
client_order_id : typing.Optional[str]
|
|
326
|
+
Identifier should be unique and contain letters, dashes, numbers, dots or underscores.
|
|
327
|
+
|
|
328
|
+
stop_loss : typing.Optional[str]
|
|
329
|
+
Stop loss price.
|
|
330
|
+
|
|
331
|
+
When provided, the system creates an [OTO](/glossary#one-triggers-the-other-oto) order with a stop loss condition.
|
|
332
|
+
|
|
333
|
+
take_profit : typing.Optional[str]
|
|
334
|
+
Take profit price.
|
|
335
|
+
|
|
336
|
+
When provided, the system creates an [OTO](/glossary#one-triggers-the-other-oto) order with a take profit condition.
|
|
337
|
+
|
|
338
|
+
post_only : typing.Optional[bool]
|
|
339
|
+
Orders are guaranteed to be the [maker](/glossary#maker) order when [executed](/glossary#finished-orders).
|
|
340
|
+
|
|
341
|
+
ioc : typing.Optional[bool]
|
|
342
|
+
An immediate or cancel order (IOC) is an order that attempts to execute all or part immediately and then cancels any unfilled portion.
|
|
343
|
+
|
|
344
|
+
rpi : typing.Optional[bool]
|
|
345
|
+
Enables Retail Price Improvement (RPI) mode.
|
|
346
|
+
|
|
347
|
+
RPI orders are post-only by design and cannot be used with `ioc=true`. The API returns error code `37` when both `rpi=true` and `ioc=true` are used.
|
|
348
|
+
|
|
349
|
+
position_side : typing.Optional[CreateCollateralLimitOrderRequestPositionSide]
|
|
350
|
+
Defines the position direction when hedge mode is enabled. See [positionSide](/glossary#position-side)
|
|
351
|
+
|
|
352
|
+
request_options : typing.Optional[RequestOptions]
|
|
353
|
+
Request-specific configuration.
|
|
354
|
+
|
|
355
|
+
Returns
|
|
356
|
+
-------
|
|
357
|
+
HttpResponse[CreateCollateralLimitOrderResponse]
|
|
358
|
+
Successful response - order created
|
|
359
|
+
"""
|
|
360
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
361
|
+
"api/v4/order/collateral/limit",
|
|
362
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
363
|
+
method="POST",
|
|
364
|
+
json={
|
|
365
|
+
"market": market,
|
|
366
|
+
"side": side,
|
|
367
|
+
"amount": amount,
|
|
368
|
+
"price": price,
|
|
369
|
+
"clientOrderId": client_order_id,
|
|
370
|
+
"stopLoss": stop_loss,
|
|
371
|
+
"takeProfit": take_profit,
|
|
372
|
+
"postOnly": post_only,
|
|
373
|
+
"ioc": ioc,
|
|
374
|
+
"rpi": rpi,
|
|
375
|
+
"positionSide": position_side,
|
|
376
|
+
"request": request,
|
|
377
|
+
"nonce": nonce,
|
|
378
|
+
},
|
|
379
|
+
headers={
|
|
380
|
+
"content-type": "application/json",
|
|
381
|
+
},
|
|
382
|
+
request_options=request_options,
|
|
383
|
+
omit=OMIT,
|
|
384
|
+
)
|
|
385
|
+
try:
|
|
386
|
+
if 200 <= _response.status_code < 300:
|
|
387
|
+
_data = typing.cast(
|
|
388
|
+
CreateCollateralLimitOrderResponse,
|
|
389
|
+
parse_obj_as(
|
|
390
|
+
type_=CreateCollateralLimitOrderResponse, # type: ignore
|
|
391
|
+
object_=_response.json(),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
return HttpResponse(response=_response, data=_data)
|
|
395
|
+
if _response.status_code == 422:
|
|
396
|
+
raise UnprocessableEntityError(
|
|
397
|
+
headers=dict(_response.headers),
|
|
398
|
+
body=typing.cast(
|
|
399
|
+
typing.Optional[typing.Any],
|
|
400
|
+
parse_obj_as(
|
|
401
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
402
|
+
object_=_response.json(),
|
|
403
|
+
),
|
|
404
|
+
),
|
|
405
|
+
)
|
|
406
|
+
if _response.status_code == 503:
|
|
407
|
+
raise ServiceUnavailableError(
|
|
408
|
+
headers=dict(_response.headers),
|
|
409
|
+
body=typing.cast(
|
|
410
|
+
typing.Optional[typing.Any],
|
|
411
|
+
parse_obj_as(
|
|
412
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
413
|
+
object_=_response.json(),
|
|
414
|
+
),
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
_response_json = _response.json()
|
|
418
|
+
except JSONDecodeError:
|
|
419
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
420
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
421
|
+
|
|
422
|
+
def create_collateral_bulk_order(
|
|
423
|
+
self,
|
|
424
|
+
*,
|
|
425
|
+
orders: typing.Optional[typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem]] = OMIT,
|
|
426
|
+
stop_on_fail: typing.Optional[bool] = OMIT,
|
|
427
|
+
request: typing.Optional[str] = OMIT,
|
|
428
|
+
nonce: typing.Optional[str] = OMIT,
|
|
429
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
430
|
+
) -> HttpResponse[typing.List[CreateCollateralBulkOrderResponseItem]]:
|
|
431
|
+
"""
|
|
432
|
+
The endpoint creates multiple collateral limit orders.
|
|
433
|
+
|
|
434
|
+
<Warning>
|
|
435
|
+
Rate limit: 10000 requests/10 sec.
|
|
436
|
+
</Warning>
|
|
437
|
+
|
|
438
|
+
Parameters
|
|
439
|
+
----------
|
|
440
|
+
orders : typing.Optional[typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem]]
|
|
441
|
+
|
|
442
|
+
stop_on_fail : typing.Optional[bool]
|
|
443
|
+
Controls how the bulk order processor handles failures.
|
|
444
|
+
|
|
445
|
+
When true: Processing stops at the first order that fails validation or execution. Only orders up to (but not including) the failed order are processed.
|
|
446
|
+
|
|
447
|
+
When false (default): All orders in the bulk request are processed regardless of individual failures. Each order result is returned in the response array.
|
|
448
|
+
|
|
449
|
+
request : typing.Optional[str]
|
|
450
|
+
|
|
451
|
+
nonce : typing.Optional[str]
|
|
452
|
+
|
|
453
|
+
request_options : typing.Optional[RequestOptions]
|
|
454
|
+
Request-specific configuration.
|
|
455
|
+
|
|
456
|
+
Returns
|
|
457
|
+
-------
|
|
458
|
+
HttpResponse[typing.List[CreateCollateralBulkOrderResponseItem]]
|
|
459
|
+
Successful response - returns array of order results
|
|
460
|
+
"""
|
|
461
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
462
|
+
"api/v4/order/collateral/bulk",
|
|
463
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
464
|
+
method="POST",
|
|
465
|
+
json={
|
|
466
|
+
"orders": convert_and_respect_annotation_metadata(
|
|
467
|
+
object_=orders,
|
|
468
|
+
annotation=typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem],
|
|
469
|
+
direction="write",
|
|
470
|
+
),
|
|
471
|
+
"stopOnFail": stop_on_fail,
|
|
472
|
+
"request": request,
|
|
473
|
+
"nonce": nonce,
|
|
474
|
+
},
|
|
475
|
+
headers={
|
|
476
|
+
"content-type": "application/json",
|
|
477
|
+
},
|
|
478
|
+
request_options=request_options,
|
|
479
|
+
omit=OMIT,
|
|
480
|
+
)
|
|
481
|
+
try:
|
|
482
|
+
if 200 <= _response.status_code < 300:
|
|
483
|
+
_data = typing.cast(
|
|
484
|
+
typing.List[CreateCollateralBulkOrderResponseItem],
|
|
485
|
+
parse_obj_as(
|
|
486
|
+
type_=typing.List[CreateCollateralBulkOrderResponseItem], # type: ignore
|
|
487
|
+
object_=_response.json(),
|
|
488
|
+
),
|
|
489
|
+
)
|
|
490
|
+
return HttpResponse(response=_response, data=_data)
|
|
491
|
+
if _response.status_code == 400:
|
|
492
|
+
raise BadRequestError(
|
|
493
|
+
headers=dict(_response.headers),
|
|
494
|
+
body=typing.cast(
|
|
495
|
+
typing.Optional[typing.Any],
|
|
496
|
+
parse_obj_as(
|
|
497
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
498
|
+
object_=_response.json(),
|
|
499
|
+
),
|
|
500
|
+
),
|
|
501
|
+
)
|
|
502
|
+
if _response.status_code == 422:
|
|
503
|
+
raise UnprocessableEntityError(
|
|
504
|
+
headers=dict(_response.headers),
|
|
505
|
+
body=typing.cast(
|
|
506
|
+
typing.Optional[typing.Any],
|
|
507
|
+
parse_obj_as(
|
|
508
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
509
|
+
object_=_response.json(),
|
|
510
|
+
),
|
|
511
|
+
),
|
|
512
|
+
)
|
|
513
|
+
if _response.status_code == 503:
|
|
514
|
+
raise ServiceUnavailableError(
|
|
515
|
+
headers=dict(_response.headers),
|
|
516
|
+
body=typing.cast(
|
|
517
|
+
typing.Optional[typing.Any],
|
|
518
|
+
parse_obj_as(
|
|
519
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
520
|
+
object_=_response.json(),
|
|
521
|
+
),
|
|
522
|
+
),
|
|
523
|
+
)
|
|
524
|
+
_response_json = _response.json()
|
|
525
|
+
except JSONDecodeError:
|
|
526
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
527
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
528
|
+
|
|
529
|
+
def create_collateral_market_order(
|
|
530
|
+
self,
|
|
531
|
+
*,
|
|
532
|
+
market: str,
|
|
533
|
+
side: CreateCollateralMarketOrderRequestSide,
|
|
534
|
+
amount: str,
|
|
535
|
+
request: str,
|
|
536
|
+
nonce: str,
|
|
537
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
538
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
539
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
540
|
+
position_side: typing.Optional[CreateCollateralMarketOrderRequestPositionSide] = OMIT,
|
|
541
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
542
|
+
) -> HttpResponse[CreateCollateralMarketOrderResponse]:
|
|
543
|
+
"""
|
|
544
|
+
The endpoint creates a collateral market order.
|
|
545
|
+
|
|
546
|
+
<Warning>
|
|
547
|
+
Rate limit: 10000 requests/10 sec.
|
|
548
|
+
</Warning>
|
|
549
|
+
|
|
550
|
+
Parameters
|
|
551
|
+
----------
|
|
552
|
+
market : str
|
|
553
|
+
|
|
554
|
+
side : CreateCollateralMarketOrderRequestSide
|
|
555
|
+
|
|
556
|
+
amount : str
|
|
557
|
+
|
|
558
|
+
request : str
|
|
559
|
+
|
|
560
|
+
nonce : str
|
|
561
|
+
|
|
562
|
+
client_order_id : typing.Optional[str]
|
|
563
|
+
|
|
564
|
+
stop_loss : typing.Optional[str]
|
|
565
|
+
|
|
566
|
+
take_profit : typing.Optional[str]
|
|
567
|
+
|
|
568
|
+
position_side : typing.Optional[CreateCollateralMarketOrderRequestPositionSide]
|
|
569
|
+
|
|
570
|
+
request_options : typing.Optional[RequestOptions]
|
|
571
|
+
Request-specific configuration.
|
|
572
|
+
|
|
573
|
+
Returns
|
|
574
|
+
-------
|
|
575
|
+
HttpResponse[CreateCollateralMarketOrderResponse]
|
|
576
|
+
Successful response - market order created
|
|
577
|
+
"""
|
|
578
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
579
|
+
"api/v4/order/collateral/market",
|
|
580
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
581
|
+
method="POST",
|
|
582
|
+
json={
|
|
583
|
+
"market": market,
|
|
584
|
+
"side": side,
|
|
585
|
+
"amount": amount,
|
|
586
|
+
"clientOrderId": client_order_id,
|
|
587
|
+
"stopLoss": stop_loss,
|
|
588
|
+
"takeProfit": take_profit,
|
|
589
|
+
"positionSide": position_side,
|
|
590
|
+
"request": request,
|
|
591
|
+
"nonce": nonce,
|
|
592
|
+
},
|
|
593
|
+
headers={
|
|
594
|
+
"content-type": "application/json",
|
|
595
|
+
},
|
|
596
|
+
request_options=request_options,
|
|
597
|
+
omit=OMIT,
|
|
598
|
+
)
|
|
599
|
+
try:
|
|
600
|
+
if 200 <= _response.status_code < 300:
|
|
601
|
+
_data = typing.cast(
|
|
602
|
+
CreateCollateralMarketOrderResponse,
|
|
603
|
+
parse_obj_as(
|
|
604
|
+
type_=CreateCollateralMarketOrderResponse, # type: ignore
|
|
605
|
+
object_=_response.json(),
|
|
606
|
+
),
|
|
607
|
+
)
|
|
608
|
+
return HttpResponse(response=_response, data=_data)
|
|
609
|
+
if _response.status_code == 422:
|
|
610
|
+
raise UnprocessableEntityError(
|
|
611
|
+
headers=dict(_response.headers),
|
|
612
|
+
body=typing.cast(
|
|
613
|
+
typing.Optional[typing.Any],
|
|
614
|
+
parse_obj_as(
|
|
615
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
616
|
+
object_=_response.json(),
|
|
617
|
+
),
|
|
618
|
+
),
|
|
619
|
+
)
|
|
620
|
+
if _response.status_code == 503:
|
|
621
|
+
raise ServiceUnavailableError(
|
|
622
|
+
headers=dict(_response.headers),
|
|
623
|
+
body=typing.cast(
|
|
624
|
+
typing.Optional[typing.Any],
|
|
625
|
+
parse_obj_as(
|
|
626
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
627
|
+
object_=_response.json(),
|
|
628
|
+
),
|
|
629
|
+
),
|
|
630
|
+
)
|
|
631
|
+
_response_json = _response.json()
|
|
632
|
+
except JSONDecodeError:
|
|
633
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
634
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
635
|
+
|
|
636
|
+
def create_collateral_stop_limit_order(
|
|
637
|
+
self,
|
|
638
|
+
*,
|
|
639
|
+
market: str,
|
|
640
|
+
side: CreateCollateralStopLimitOrderRequestSide,
|
|
641
|
+
amount: str,
|
|
642
|
+
price: str,
|
|
643
|
+
activation_price: str,
|
|
644
|
+
request: str,
|
|
645
|
+
nonce: str,
|
|
646
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
647
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
648
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
649
|
+
position_side: typing.Optional[CreateCollateralStopLimitOrderRequestPositionSide] = OMIT,
|
|
650
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
651
|
+
) -> HttpResponse[CreateCollateralStopLimitOrderResponse]:
|
|
652
|
+
"""
|
|
653
|
+
The endpoint creates a collateral stop-limit order.
|
|
654
|
+
|
|
655
|
+
<Warning>
|
|
656
|
+
Rate limit: 10000 requests/10 sec.
|
|
657
|
+
</Warning>
|
|
658
|
+
|
|
659
|
+
Parameters
|
|
660
|
+
----------
|
|
661
|
+
market : str
|
|
662
|
+
|
|
663
|
+
side : CreateCollateralStopLimitOrderRequestSide
|
|
664
|
+
|
|
665
|
+
amount : str
|
|
666
|
+
|
|
667
|
+
price : str
|
|
668
|
+
|
|
669
|
+
activation_price : str
|
|
670
|
+
|
|
671
|
+
request : str
|
|
672
|
+
|
|
673
|
+
nonce : str
|
|
674
|
+
|
|
675
|
+
stop_loss : typing.Optional[str]
|
|
676
|
+
|
|
677
|
+
take_profit : typing.Optional[str]
|
|
678
|
+
|
|
679
|
+
client_order_id : typing.Optional[str]
|
|
680
|
+
|
|
681
|
+
position_side : typing.Optional[CreateCollateralStopLimitOrderRequestPositionSide]
|
|
682
|
+
|
|
683
|
+
request_options : typing.Optional[RequestOptions]
|
|
684
|
+
Request-specific configuration.
|
|
685
|
+
|
|
686
|
+
Returns
|
|
687
|
+
-------
|
|
688
|
+
HttpResponse[CreateCollateralStopLimitOrderResponse]
|
|
689
|
+
Successful response - stop-limit order created
|
|
690
|
+
"""
|
|
691
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
692
|
+
"api/v4/order/collateral/stop-limit",
|
|
693
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
694
|
+
method="POST",
|
|
695
|
+
json={
|
|
696
|
+
"market": market,
|
|
697
|
+
"side": side,
|
|
698
|
+
"amount": amount,
|
|
699
|
+
"price": price,
|
|
700
|
+
"activation_price": activation_price,
|
|
701
|
+
"stopLoss": stop_loss,
|
|
702
|
+
"takeProfit": take_profit,
|
|
703
|
+
"clientOrderId": client_order_id,
|
|
704
|
+
"positionSide": position_side,
|
|
705
|
+
"request": request,
|
|
706
|
+
"nonce": nonce,
|
|
707
|
+
},
|
|
708
|
+
headers={
|
|
709
|
+
"content-type": "application/json",
|
|
710
|
+
},
|
|
711
|
+
request_options=request_options,
|
|
712
|
+
omit=OMIT,
|
|
713
|
+
)
|
|
714
|
+
try:
|
|
715
|
+
if 200 <= _response.status_code < 300:
|
|
716
|
+
_data = typing.cast(
|
|
717
|
+
CreateCollateralStopLimitOrderResponse,
|
|
718
|
+
parse_obj_as(
|
|
719
|
+
type_=CreateCollateralStopLimitOrderResponse, # type: ignore
|
|
720
|
+
object_=_response.json(),
|
|
721
|
+
),
|
|
722
|
+
)
|
|
723
|
+
return HttpResponse(response=_response, data=_data)
|
|
724
|
+
if _response.status_code == 400:
|
|
725
|
+
raise BadRequestError(
|
|
726
|
+
headers=dict(_response.headers),
|
|
727
|
+
body=typing.cast(
|
|
728
|
+
typing.Optional[typing.Any],
|
|
729
|
+
parse_obj_as(
|
|
730
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
731
|
+
object_=_response.json(),
|
|
732
|
+
),
|
|
733
|
+
),
|
|
734
|
+
)
|
|
735
|
+
if _response.status_code == 422:
|
|
736
|
+
raise UnprocessableEntityError(
|
|
737
|
+
headers=dict(_response.headers),
|
|
738
|
+
body=typing.cast(
|
|
739
|
+
typing.Optional[typing.Any],
|
|
740
|
+
parse_obj_as(
|
|
741
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
742
|
+
object_=_response.json(),
|
|
743
|
+
),
|
|
744
|
+
),
|
|
745
|
+
)
|
|
746
|
+
if _response.status_code == 503:
|
|
747
|
+
raise ServiceUnavailableError(
|
|
748
|
+
headers=dict(_response.headers),
|
|
749
|
+
body=typing.cast(
|
|
750
|
+
typing.Optional[typing.Any],
|
|
751
|
+
parse_obj_as(
|
|
752
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
753
|
+
object_=_response.json(),
|
|
754
|
+
),
|
|
755
|
+
),
|
|
756
|
+
)
|
|
757
|
+
_response_json = _response.json()
|
|
758
|
+
except JSONDecodeError:
|
|
759
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
760
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
761
|
+
|
|
762
|
+
def create_collateral_trigger_market_order(
|
|
763
|
+
self,
|
|
764
|
+
*,
|
|
765
|
+
market: str,
|
|
766
|
+
side: CreateCollateralTriggerMarketOrderRequestSide,
|
|
767
|
+
amount: str,
|
|
768
|
+
activation_price: str,
|
|
769
|
+
request: str,
|
|
770
|
+
nonce: str,
|
|
771
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
772
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
773
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
774
|
+
position_side: typing.Optional[CreateCollateralTriggerMarketOrderRequestPositionSide] = OMIT,
|
|
775
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
776
|
+
) -> HttpResponse[CreateCollateralTriggerMarketOrderResponse]:
|
|
777
|
+
"""
|
|
778
|
+
The endpoint creates a collateral trigger market order.
|
|
779
|
+
|
|
780
|
+
<Warning>
|
|
781
|
+
Rate limit: 10000 requests/10 sec.
|
|
782
|
+
</Warning>
|
|
783
|
+
|
|
784
|
+
Parameters
|
|
785
|
+
----------
|
|
786
|
+
market : str
|
|
787
|
+
|
|
788
|
+
side : CreateCollateralTriggerMarketOrderRequestSide
|
|
789
|
+
|
|
790
|
+
amount : str
|
|
791
|
+
|
|
792
|
+
activation_price : str
|
|
793
|
+
|
|
794
|
+
request : str
|
|
795
|
+
|
|
796
|
+
nonce : str
|
|
797
|
+
|
|
798
|
+
client_order_id : typing.Optional[str]
|
|
799
|
+
|
|
800
|
+
stop_loss : typing.Optional[str]
|
|
801
|
+
|
|
802
|
+
take_profit : typing.Optional[str]
|
|
803
|
+
|
|
804
|
+
position_side : typing.Optional[CreateCollateralTriggerMarketOrderRequestPositionSide]
|
|
805
|
+
|
|
806
|
+
request_options : typing.Optional[RequestOptions]
|
|
807
|
+
Request-specific configuration.
|
|
808
|
+
|
|
809
|
+
Returns
|
|
810
|
+
-------
|
|
811
|
+
HttpResponse[CreateCollateralTriggerMarketOrderResponse]
|
|
812
|
+
Successful response - trigger market order created
|
|
813
|
+
"""
|
|
814
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
815
|
+
"api/v4/order/collateral/trigger-market",
|
|
816
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
817
|
+
method="POST",
|
|
818
|
+
json={
|
|
819
|
+
"market": market,
|
|
820
|
+
"side": side,
|
|
821
|
+
"amount": amount,
|
|
822
|
+
"activation_price": activation_price,
|
|
823
|
+
"clientOrderId": client_order_id,
|
|
824
|
+
"stopLoss": stop_loss,
|
|
825
|
+
"takeProfit": take_profit,
|
|
826
|
+
"positionSide": position_side,
|
|
827
|
+
"request": request,
|
|
828
|
+
"nonce": nonce,
|
|
829
|
+
},
|
|
830
|
+
headers={
|
|
831
|
+
"content-type": "application/json",
|
|
832
|
+
},
|
|
833
|
+
request_options=request_options,
|
|
834
|
+
omit=OMIT,
|
|
835
|
+
)
|
|
836
|
+
try:
|
|
837
|
+
if 200 <= _response.status_code < 300:
|
|
838
|
+
_data = typing.cast(
|
|
839
|
+
CreateCollateralTriggerMarketOrderResponse,
|
|
840
|
+
parse_obj_as(
|
|
841
|
+
type_=CreateCollateralTriggerMarketOrderResponse, # type: ignore
|
|
842
|
+
object_=_response.json(),
|
|
843
|
+
),
|
|
844
|
+
)
|
|
845
|
+
return HttpResponse(response=_response, data=_data)
|
|
846
|
+
if _response.status_code == 422:
|
|
847
|
+
raise UnprocessableEntityError(
|
|
848
|
+
headers=dict(_response.headers),
|
|
849
|
+
body=typing.cast(
|
|
850
|
+
typing.Optional[typing.Any],
|
|
851
|
+
parse_obj_as(
|
|
852
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
853
|
+
object_=_response.json(),
|
|
854
|
+
),
|
|
855
|
+
),
|
|
856
|
+
)
|
|
857
|
+
if _response.status_code == 503:
|
|
858
|
+
raise ServiceUnavailableError(
|
|
859
|
+
headers=dict(_response.headers),
|
|
860
|
+
body=typing.cast(
|
|
861
|
+
typing.Optional[typing.Any],
|
|
862
|
+
parse_obj_as(
|
|
863
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
864
|
+
object_=_response.json(),
|
|
865
|
+
),
|
|
866
|
+
),
|
|
867
|
+
)
|
|
868
|
+
_response_json = _response.json()
|
|
869
|
+
except JSONDecodeError:
|
|
870
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
871
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
872
|
+
|
|
873
|
+
def collateral_account_summary(
|
|
874
|
+
self,
|
|
875
|
+
*,
|
|
876
|
+
request: typing.Optional[str] = OMIT,
|
|
877
|
+
nonce: typing.Optional[str] = OMIT,
|
|
878
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
879
|
+
) -> HttpResponse[CollateralAccountSummaryResponse]:
|
|
880
|
+
"""
|
|
881
|
+
The endpoint retrieves collateral account summary.
|
|
882
|
+
|
|
883
|
+
<Warning>
|
|
884
|
+
Rate limit: 12000 requests/10 sec.
|
|
885
|
+
</Warning>
|
|
886
|
+
|
|
887
|
+
Parameters
|
|
888
|
+
----------
|
|
889
|
+
request : typing.Optional[str]
|
|
890
|
+
|
|
891
|
+
nonce : typing.Optional[str]
|
|
892
|
+
|
|
893
|
+
request_options : typing.Optional[RequestOptions]
|
|
894
|
+
Request-specific configuration.
|
|
895
|
+
|
|
896
|
+
Returns
|
|
897
|
+
-------
|
|
898
|
+
HttpResponse[CollateralAccountSummaryResponse]
|
|
899
|
+
Successful response - returns collateral account summary
|
|
900
|
+
"""
|
|
901
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
902
|
+
"api/v4/collateral-account/summary",
|
|
903
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
904
|
+
method="POST",
|
|
905
|
+
json={
|
|
906
|
+
"request": request,
|
|
907
|
+
"nonce": nonce,
|
|
908
|
+
},
|
|
909
|
+
headers={
|
|
910
|
+
"content-type": "application/json",
|
|
911
|
+
},
|
|
912
|
+
request_options=request_options,
|
|
913
|
+
omit=OMIT,
|
|
914
|
+
)
|
|
915
|
+
try:
|
|
916
|
+
if 200 <= _response.status_code < 300:
|
|
917
|
+
_data = typing.cast(
|
|
918
|
+
CollateralAccountSummaryResponse,
|
|
919
|
+
parse_obj_as(
|
|
920
|
+
type_=CollateralAccountSummaryResponse, # type: ignore
|
|
921
|
+
object_=_response.json(),
|
|
922
|
+
),
|
|
923
|
+
)
|
|
924
|
+
return HttpResponse(response=_response, data=_data)
|
|
925
|
+
if _response.status_code == 422:
|
|
926
|
+
raise UnprocessableEntityError(
|
|
927
|
+
headers=dict(_response.headers),
|
|
928
|
+
body=typing.cast(
|
|
929
|
+
typing.Optional[typing.Any],
|
|
930
|
+
parse_obj_as(
|
|
931
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
932
|
+
object_=_response.json(),
|
|
933
|
+
),
|
|
934
|
+
),
|
|
935
|
+
)
|
|
936
|
+
if _response.status_code == 503:
|
|
937
|
+
raise ServiceUnavailableError(
|
|
938
|
+
headers=dict(_response.headers),
|
|
939
|
+
body=typing.cast(
|
|
940
|
+
typing.Optional[typing.Any],
|
|
941
|
+
parse_obj_as(
|
|
942
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
943
|
+
object_=_response.json(),
|
|
944
|
+
),
|
|
945
|
+
),
|
|
946
|
+
)
|
|
947
|
+
_response_json = _response.json()
|
|
948
|
+
except JSONDecodeError:
|
|
949
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
950
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
951
|
+
|
|
952
|
+
def get_open_positions(
|
|
953
|
+
self,
|
|
954
|
+
*,
|
|
955
|
+
market: typing.Optional[str] = OMIT,
|
|
956
|
+
request: typing.Optional[str] = OMIT,
|
|
957
|
+
nonce: typing.Optional[str] = OMIT,
|
|
958
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
959
|
+
) -> HttpResponse[typing.List[GetOpenPositionsResponseItem]]:
|
|
960
|
+
"""
|
|
961
|
+
The endpoint retrieves open positions.
|
|
962
|
+
|
|
963
|
+
<Warning>
|
|
964
|
+
Rate limit: 12000 requests/10 sec.
|
|
965
|
+
</Warning>
|
|
966
|
+
|
|
967
|
+
Parameters
|
|
968
|
+
----------
|
|
969
|
+
market : typing.Optional[str]
|
|
970
|
+
Filter by specific market. For example: BTC_USDT
|
|
971
|
+
|
|
972
|
+
If not specified, returns all open positions.
|
|
973
|
+
|
|
974
|
+
request : typing.Optional[str]
|
|
975
|
+
Request signature
|
|
976
|
+
|
|
977
|
+
nonce : typing.Optional[str]
|
|
978
|
+
Unique request identifier
|
|
979
|
+
|
|
980
|
+
request_options : typing.Optional[RequestOptions]
|
|
981
|
+
Request-specific configuration.
|
|
982
|
+
|
|
983
|
+
Returns
|
|
984
|
+
-------
|
|
985
|
+
HttpResponse[typing.List[GetOpenPositionsResponseItem]]
|
|
986
|
+
Successful response - returns array of open positions
|
|
987
|
+
"""
|
|
988
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
989
|
+
"api/v4/collateral-account/positions",
|
|
990
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
991
|
+
method="POST",
|
|
992
|
+
json={
|
|
993
|
+
"market": market,
|
|
994
|
+
"request": request,
|
|
995
|
+
"nonce": nonce,
|
|
996
|
+
},
|
|
997
|
+
headers={
|
|
998
|
+
"content-type": "application/json",
|
|
999
|
+
},
|
|
1000
|
+
request_options=request_options,
|
|
1001
|
+
omit=OMIT,
|
|
1002
|
+
)
|
|
1003
|
+
try:
|
|
1004
|
+
if 200 <= _response.status_code < 300:
|
|
1005
|
+
_data = typing.cast(
|
|
1006
|
+
typing.List[GetOpenPositionsResponseItem],
|
|
1007
|
+
parse_obj_as(
|
|
1008
|
+
type_=typing.List[GetOpenPositionsResponseItem], # type: ignore
|
|
1009
|
+
object_=_response.json(),
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
1012
|
+
return HttpResponse(response=_response, data=_data)
|
|
1013
|
+
if _response.status_code == 422:
|
|
1014
|
+
raise UnprocessableEntityError(
|
|
1015
|
+
headers=dict(_response.headers),
|
|
1016
|
+
body=typing.cast(
|
|
1017
|
+
typing.Optional[typing.Any],
|
|
1018
|
+
parse_obj_as(
|
|
1019
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1020
|
+
object_=_response.json(),
|
|
1021
|
+
),
|
|
1022
|
+
),
|
|
1023
|
+
)
|
|
1024
|
+
if _response.status_code == 503:
|
|
1025
|
+
raise ServiceUnavailableError(
|
|
1026
|
+
headers=dict(_response.headers),
|
|
1027
|
+
body=typing.cast(
|
|
1028
|
+
typing.Optional[typing.Any],
|
|
1029
|
+
parse_obj_as(
|
|
1030
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1031
|
+
object_=_response.json(),
|
|
1032
|
+
),
|
|
1033
|
+
),
|
|
1034
|
+
)
|
|
1035
|
+
_response_json = _response.json()
|
|
1036
|
+
except JSONDecodeError:
|
|
1037
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1038
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1039
|
+
|
|
1040
|
+
def close_position(
|
|
1041
|
+
self,
|
|
1042
|
+
*,
|
|
1043
|
+
position_id: int,
|
|
1044
|
+
market: str,
|
|
1045
|
+
request: str,
|
|
1046
|
+
nonce: str,
|
|
1047
|
+
position_side: typing.Optional[ClosePositionRequestPositionSide] = OMIT,
|
|
1048
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1049
|
+
) -> HttpResponse[None]:
|
|
1050
|
+
"""
|
|
1051
|
+
The endpoint closes a position.
|
|
1052
|
+
|
|
1053
|
+
<Warning>
|
|
1054
|
+
Rate limit: 10000 requests/10 sec.
|
|
1055
|
+
</Warning>
|
|
1056
|
+
|
|
1057
|
+
Parameters
|
|
1058
|
+
----------
|
|
1059
|
+
position_id : int
|
|
1060
|
+
|
|
1061
|
+
market : str
|
|
1062
|
+
|
|
1063
|
+
request : str
|
|
1064
|
+
|
|
1065
|
+
nonce : str
|
|
1066
|
+
|
|
1067
|
+
position_side : typing.Optional[ClosePositionRequestPositionSide]
|
|
1068
|
+
|
|
1069
|
+
request_options : typing.Optional[RequestOptions]
|
|
1070
|
+
Request-specific configuration.
|
|
1071
|
+
|
|
1072
|
+
Returns
|
|
1073
|
+
-------
|
|
1074
|
+
HttpResponse[None]
|
|
1075
|
+
"""
|
|
1076
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1077
|
+
"api/v4/collateral-account/position/close",
|
|
1078
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1079
|
+
method="POST",
|
|
1080
|
+
json={
|
|
1081
|
+
"positionId": position_id,
|
|
1082
|
+
"positionSide": position_side,
|
|
1083
|
+
"market": market,
|
|
1084
|
+
"request": request,
|
|
1085
|
+
"nonce": nonce,
|
|
1086
|
+
},
|
|
1087
|
+
headers={
|
|
1088
|
+
"content-type": "application/json",
|
|
1089
|
+
},
|
|
1090
|
+
request_options=request_options,
|
|
1091
|
+
omit=OMIT,
|
|
1092
|
+
)
|
|
1093
|
+
try:
|
|
1094
|
+
if 200 <= _response.status_code < 300:
|
|
1095
|
+
return HttpResponse(response=_response, data=None)
|
|
1096
|
+
if _response.status_code == 400:
|
|
1097
|
+
raise BadRequestError(
|
|
1098
|
+
headers=dict(_response.headers),
|
|
1099
|
+
body=typing.cast(
|
|
1100
|
+
typing.Optional[typing.Any],
|
|
1101
|
+
parse_obj_as(
|
|
1102
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1103
|
+
object_=_response.json(),
|
|
1104
|
+
),
|
|
1105
|
+
),
|
|
1106
|
+
)
|
|
1107
|
+
if _response.status_code == 422:
|
|
1108
|
+
raise UnprocessableEntityError(
|
|
1109
|
+
headers=dict(_response.headers),
|
|
1110
|
+
body=typing.cast(
|
|
1111
|
+
typing.Optional[typing.Any],
|
|
1112
|
+
parse_obj_as(
|
|
1113
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1114
|
+
object_=_response.json(),
|
|
1115
|
+
),
|
|
1116
|
+
),
|
|
1117
|
+
)
|
|
1118
|
+
if _response.status_code == 500:
|
|
1119
|
+
raise InternalServerError(
|
|
1120
|
+
headers=dict(_response.headers),
|
|
1121
|
+
body=typing.cast(
|
|
1122
|
+
typing.Optional[typing.Any],
|
|
1123
|
+
parse_obj_as(
|
|
1124
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1125
|
+
object_=_response.json(),
|
|
1126
|
+
),
|
|
1127
|
+
),
|
|
1128
|
+
)
|
|
1129
|
+
if _response.status_code == 503:
|
|
1130
|
+
raise ServiceUnavailableError(
|
|
1131
|
+
headers=dict(_response.headers),
|
|
1132
|
+
body=typing.cast(
|
|
1133
|
+
typing.Optional[typing.Any],
|
|
1134
|
+
parse_obj_as(
|
|
1135
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1136
|
+
object_=_response.json(),
|
|
1137
|
+
),
|
|
1138
|
+
),
|
|
1139
|
+
)
|
|
1140
|
+
_response_json = _response.json()
|
|
1141
|
+
except JSONDecodeError:
|
|
1142
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1143
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1144
|
+
|
|
1145
|
+
def get_positions_history(
|
|
1146
|
+
self,
|
|
1147
|
+
*,
|
|
1148
|
+
market: typing.Optional[str] = OMIT,
|
|
1149
|
+
position_id: typing.Optional[int] = OMIT,
|
|
1150
|
+
request: typing.Optional[str] = OMIT,
|
|
1151
|
+
nonce: typing.Optional[str] = OMIT,
|
|
1152
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1153
|
+
) -> HttpResponse[typing.List[GetPositionsHistoryResponseItem]]:
|
|
1154
|
+
"""
|
|
1155
|
+
The endpoint retrieves positions history.
|
|
1156
|
+
|
|
1157
|
+
<Warning>
|
|
1158
|
+
Rate limit: 12000 requests/10 sec.
|
|
1159
|
+
</Warning>
|
|
1160
|
+
|
|
1161
|
+
Parameters
|
|
1162
|
+
----------
|
|
1163
|
+
market : typing.Optional[str]
|
|
1164
|
+
|
|
1165
|
+
position_id : typing.Optional[int]
|
|
1166
|
+
|
|
1167
|
+
request : typing.Optional[str]
|
|
1168
|
+
|
|
1169
|
+
nonce : typing.Optional[str]
|
|
1170
|
+
|
|
1171
|
+
request_options : typing.Optional[RequestOptions]
|
|
1172
|
+
Request-specific configuration.
|
|
1173
|
+
|
|
1174
|
+
Returns
|
|
1175
|
+
-------
|
|
1176
|
+
HttpResponse[typing.List[GetPositionsHistoryResponseItem]]
|
|
1177
|
+
Successful response - returns array of position history
|
|
1178
|
+
"""
|
|
1179
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1180
|
+
"api/v4/collateral-account/positions/history",
|
|
1181
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1182
|
+
method="POST",
|
|
1183
|
+
json={
|
|
1184
|
+
"market": market,
|
|
1185
|
+
"positionId": position_id,
|
|
1186
|
+
"request": request,
|
|
1187
|
+
"nonce": nonce,
|
|
1188
|
+
},
|
|
1189
|
+
headers={
|
|
1190
|
+
"content-type": "application/json",
|
|
1191
|
+
},
|
|
1192
|
+
request_options=request_options,
|
|
1193
|
+
omit=OMIT,
|
|
1194
|
+
)
|
|
1195
|
+
try:
|
|
1196
|
+
if 200 <= _response.status_code < 300:
|
|
1197
|
+
_data = typing.cast(
|
|
1198
|
+
typing.List[GetPositionsHistoryResponseItem],
|
|
1199
|
+
parse_obj_as(
|
|
1200
|
+
type_=typing.List[GetPositionsHistoryResponseItem], # type: ignore
|
|
1201
|
+
object_=_response.json(),
|
|
1202
|
+
),
|
|
1203
|
+
)
|
|
1204
|
+
return HttpResponse(response=_response, data=_data)
|
|
1205
|
+
if _response.status_code == 400:
|
|
1206
|
+
raise BadRequestError(
|
|
1207
|
+
headers=dict(_response.headers),
|
|
1208
|
+
body=typing.cast(
|
|
1209
|
+
typing.Optional[typing.Any],
|
|
1210
|
+
parse_obj_as(
|
|
1211
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1212
|
+
object_=_response.json(),
|
|
1213
|
+
),
|
|
1214
|
+
),
|
|
1215
|
+
)
|
|
1216
|
+
if _response.status_code == 422:
|
|
1217
|
+
raise UnprocessableEntityError(
|
|
1218
|
+
headers=dict(_response.headers),
|
|
1219
|
+
body=typing.cast(
|
|
1220
|
+
typing.Optional[typing.Any],
|
|
1221
|
+
parse_obj_as(
|
|
1222
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1223
|
+
object_=_response.json(),
|
|
1224
|
+
),
|
|
1225
|
+
),
|
|
1226
|
+
)
|
|
1227
|
+
if _response.status_code == 500:
|
|
1228
|
+
raise InternalServerError(
|
|
1229
|
+
headers=dict(_response.headers),
|
|
1230
|
+
body=typing.cast(
|
|
1231
|
+
typing.Optional[typing.Any],
|
|
1232
|
+
parse_obj_as(
|
|
1233
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1234
|
+
object_=_response.json(),
|
|
1235
|
+
),
|
|
1236
|
+
),
|
|
1237
|
+
)
|
|
1238
|
+
if _response.status_code == 503:
|
|
1239
|
+
raise ServiceUnavailableError(
|
|
1240
|
+
headers=dict(_response.headers),
|
|
1241
|
+
body=typing.cast(
|
|
1242
|
+
typing.Optional[typing.Any],
|
|
1243
|
+
parse_obj_as(
|
|
1244
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1245
|
+
object_=_response.json(),
|
|
1246
|
+
),
|
|
1247
|
+
),
|
|
1248
|
+
)
|
|
1249
|
+
_response_json = _response.json()
|
|
1250
|
+
except JSONDecodeError:
|
|
1251
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1252
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1253
|
+
|
|
1254
|
+
def get_funding_history(
|
|
1255
|
+
self,
|
|
1256
|
+
*,
|
|
1257
|
+
market: typing.Optional[str] = OMIT,
|
|
1258
|
+
limit: typing.Optional[int] = OMIT,
|
|
1259
|
+
offset: typing.Optional[int] = OMIT,
|
|
1260
|
+
request: typing.Optional[str] = OMIT,
|
|
1261
|
+
nonce: typing.Optional[str] = OMIT,
|
|
1262
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1263
|
+
) -> HttpResponse[GetFundingHistoryResponse]:
|
|
1264
|
+
"""
|
|
1265
|
+
The endpoint retrieves funding history.
|
|
1266
|
+
|
|
1267
|
+
<Warning>
|
|
1268
|
+
Rate limit: 12000 requests/10 sec.
|
|
1269
|
+
</Warning>
|
|
1270
|
+
|
|
1271
|
+
Parameters
|
|
1272
|
+
----------
|
|
1273
|
+
market : typing.Optional[str]
|
|
1274
|
+
Filter by specific market. For example: BTC_PERP
|
|
1275
|
+
|
|
1276
|
+
If not specified, returns funding history for all markets.
|
|
1277
|
+
|
|
1278
|
+
limit : typing.Optional[int]
|
|
1279
|
+
Number of records to return
|
|
1280
|
+
|
|
1281
|
+
offset : typing.Optional[int]
|
|
1282
|
+
Number of records to skip
|
|
1283
|
+
|
|
1284
|
+
request : typing.Optional[str]
|
|
1285
|
+
Request signature
|
|
1286
|
+
|
|
1287
|
+
nonce : typing.Optional[str]
|
|
1288
|
+
Unique request identifier
|
|
1289
|
+
|
|
1290
|
+
request_options : typing.Optional[RequestOptions]
|
|
1291
|
+
Request-specific configuration.
|
|
1292
|
+
|
|
1293
|
+
Returns
|
|
1294
|
+
-------
|
|
1295
|
+
HttpResponse[GetFundingHistoryResponse]
|
|
1296
|
+
Successful response - returns paginated funding history
|
|
1297
|
+
"""
|
|
1298
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1299
|
+
"api/v4/collateral-account/funding-history",
|
|
1300
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1301
|
+
method="POST",
|
|
1302
|
+
json={
|
|
1303
|
+
"market": market,
|
|
1304
|
+
"limit": limit,
|
|
1305
|
+
"offset": offset,
|
|
1306
|
+
"request": request,
|
|
1307
|
+
"nonce": nonce,
|
|
1308
|
+
},
|
|
1309
|
+
headers={
|
|
1310
|
+
"content-type": "application/json",
|
|
1311
|
+
},
|
|
1312
|
+
request_options=request_options,
|
|
1313
|
+
omit=OMIT,
|
|
1314
|
+
)
|
|
1315
|
+
try:
|
|
1316
|
+
if 200 <= _response.status_code < 300:
|
|
1317
|
+
_data = typing.cast(
|
|
1318
|
+
GetFundingHistoryResponse,
|
|
1319
|
+
parse_obj_as(
|
|
1320
|
+
type_=GetFundingHistoryResponse, # type: ignore
|
|
1321
|
+
object_=_response.json(),
|
|
1322
|
+
),
|
|
1323
|
+
)
|
|
1324
|
+
return HttpResponse(response=_response, data=_data)
|
|
1325
|
+
if _response.status_code == 422:
|
|
1326
|
+
raise UnprocessableEntityError(
|
|
1327
|
+
headers=dict(_response.headers),
|
|
1328
|
+
body=typing.cast(
|
|
1329
|
+
typing.Optional[typing.Any],
|
|
1330
|
+
parse_obj_as(
|
|
1331
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1332
|
+
object_=_response.json(),
|
|
1333
|
+
),
|
|
1334
|
+
),
|
|
1335
|
+
)
|
|
1336
|
+
if _response.status_code == 503:
|
|
1337
|
+
raise ServiceUnavailableError(
|
|
1338
|
+
headers=dict(_response.headers),
|
|
1339
|
+
body=typing.cast(
|
|
1340
|
+
typing.Optional[typing.Any],
|
|
1341
|
+
parse_obj_as(
|
|
1342
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1343
|
+
object_=_response.json(),
|
|
1344
|
+
),
|
|
1345
|
+
),
|
|
1346
|
+
)
|
|
1347
|
+
_response_json = _response.json()
|
|
1348
|
+
except JSONDecodeError:
|
|
1349
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1350
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1351
|
+
|
|
1352
|
+
def change_collateral_account_leverage(
|
|
1353
|
+
self, *, leverage: int, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
1354
|
+
) -> HttpResponse[ChangeCollateralAccountLeverageResponse]:
|
|
1355
|
+
"""
|
|
1356
|
+
The endpoint changes account leverage.
|
|
1357
|
+
|
|
1358
|
+
<Warning>
|
|
1359
|
+
Rate limit: 1000 requests/10 sec.
|
|
1360
|
+
</Warning>
|
|
1361
|
+
|
|
1362
|
+
Parameters
|
|
1363
|
+
----------
|
|
1364
|
+
leverage : int
|
|
1365
|
+
|
|
1366
|
+
request : str
|
|
1367
|
+
|
|
1368
|
+
nonce : str
|
|
1369
|
+
|
|
1370
|
+
request_options : typing.Optional[RequestOptions]
|
|
1371
|
+
Request-specific configuration.
|
|
1372
|
+
|
|
1373
|
+
Returns
|
|
1374
|
+
-------
|
|
1375
|
+
HttpResponse[ChangeCollateralAccountLeverageResponse]
|
|
1376
|
+
Successful response - leverage changed
|
|
1377
|
+
"""
|
|
1378
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1379
|
+
"api/v4/collateral-account/leverage",
|
|
1380
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1381
|
+
method="POST",
|
|
1382
|
+
json={
|
|
1383
|
+
"leverage": leverage,
|
|
1384
|
+
"request": request,
|
|
1385
|
+
"nonce": nonce,
|
|
1386
|
+
},
|
|
1387
|
+
headers={
|
|
1388
|
+
"content-type": "application/json",
|
|
1389
|
+
},
|
|
1390
|
+
request_options=request_options,
|
|
1391
|
+
omit=OMIT,
|
|
1392
|
+
)
|
|
1393
|
+
try:
|
|
1394
|
+
if 200 <= _response.status_code < 300:
|
|
1395
|
+
_data = typing.cast(
|
|
1396
|
+
ChangeCollateralAccountLeverageResponse,
|
|
1397
|
+
parse_obj_as(
|
|
1398
|
+
type_=ChangeCollateralAccountLeverageResponse, # type: ignore
|
|
1399
|
+
object_=_response.json(),
|
|
1400
|
+
),
|
|
1401
|
+
)
|
|
1402
|
+
return HttpResponse(response=_response, data=_data)
|
|
1403
|
+
if _response.status_code == 422:
|
|
1404
|
+
raise UnprocessableEntityError(
|
|
1405
|
+
headers=dict(_response.headers),
|
|
1406
|
+
body=typing.cast(
|
|
1407
|
+
typing.Optional[typing.Any],
|
|
1408
|
+
parse_obj_as(
|
|
1409
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1410
|
+
object_=_response.json(),
|
|
1411
|
+
),
|
|
1412
|
+
),
|
|
1413
|
+
)
|
|
1414
|
+
if _response.status_code == 503:
|
|
1415
|
+
raise ServiceUnavailableError(
|
|
1416
|
+
headers=dict(_response.headers),
|
|
1417
|
+
body=typing.cast(
|
|
1418
|
+
typing.Optional[typing.Any],
|
|
1419
|
+
parse_obj_as(
|
|
1420
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1421
|
+
object_=_response.json(),
|
|
1422
|
+
),
|
|
1423
|
+
),
|
|
1424
|
+
)
|
|
1425
|
+
_response_json = _response.json()
|
|
1426
|
+
except JSONDecodeError:
|
|
1427
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1428
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1429
|
+
|
|
1430
|
+
def get_collateral_hedge_mode(
|
|
1431
|
+
self,
|
|
1432
|
+
*,
|
|
1433
|
+
request: typing.Optional[str] = OMIT,
|
|
1434
|
+
nonce: typing.Optional[str] = OMIT,
|
|
1435
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1436
|
+
) -> HttpResponse[GetCollateralHedgeModeResponse]:
|
|
1437
|
+
"""
|
|
1438
|
+
The endpoint retrieves hedge mode status.
|
|
1439
|
+
|
|
1440
|
+
<Warning>
|
|
1441
|
+
Rate limit: 12000 requests/10 sec.
|
|
1442
|
+
</Warning>
|
|
1443
|
+
|
|
1444
|
+
Parameters
|
|
1445
|
+
----------
|
|
1446
|
+
request : typing.Optional[str]
|
|
1447
|
+
|
|
1448
|
+
nonce : typing.Optional[str]
|
|
1449
|
+
|
|
1450
|
+
request_options : typing.Optional[RequestOptions]
|
|
1451
|
+
Request-specific configuration.
|
|
1452
|
+
|
|
1453
|
+
Returns
|
|
1454
|
+
-------
|
|
1455
|
+
HttpResponse[GetCollateralHedgeModeResponse]
|
|
1456
|
+
Successful response - returns hedge mode status
|
|
1457
|
+
"""
|
|
1458
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1459
|
+
"api/v4/collateral-account/hedge-mode",
|
|
1460
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1461
|
+
method="POST",
|
|
1462
|
+
json={
|
|
1463
|
+
"request": request,
|
|
1464
|
+
"nonce": nonce,
|
|
1465
|
+
},
|
|
1466
|
+
headers={
|
|
1467
|
+
"content-type": "application/json",
|
|
1468
|
+
},
|
|
1469
|
+
request_options=request_options,
|
|
1470
|
+
omit=OMIT,
|
|
1471
|
+
)
|
|
1472
|
+
try:
|
|
1473
|
+
if 200 <= _response.status_code < 300:
|
|
1474
|
+
_data = typing.cast(
|
|
1475
|
+
GetCollateralHedgeModeResponse,
|
|
1476
|
+
parse_obj_as(
|
|
1477
|
+
type_=GetCollateralHedgeModeResponse, # type: ignore
|
|
1478
|
+
object_=_response.json(),
|
|
1479
|
+
),
|
|
1480
|
+
)
|
|
1481
|
+
return HttpResponse(response=_response, data=_data)
|
|
1482
|
+
if _response.status_code == 422:
|
|
1483
|
+
raise UnprocessableEntityError(
|
|
1484
|
+
headers=dict(_response.headers),
|
|
1485
|
+
body=typing.cast(
|
|
1486
|
+
typing.Optional[typing.Any],
|
|
1487
|
+
parse_obj_as(
|
|
1488
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1489
|
+
object_=_response.json(),
|
|
1490
|
+
),
|
|
1491
|
+
),
|
|
1492
|
+
)
|
|
1493
|
+
if _response.status_code == 500:
|
|
1494
|
+
raise InternalServerError(
|
|
1495
|
+
headers=dict(_response.headers),
|
|
1496
|
+
body=typing.cast(
|
|
1497
|
+
typing.Optional[typing.Any],
|
|
1498
|
+
parse_obj_as(
|
|
1499
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1500
|
+
object_=_response.json(),
|
|
1501
|
+
),
|
|
1502
|
+
),
|
|
1503
|
+
)
|
|
1504
|
+
if _response.status_code == 503:
|
|
1505
|
+
raise ServiceUnavailableError(
|
|
1506
|
+
headers=dict(_response.headers),
|
|
1507
|
+
body=typing.cast(
|
|
1508
|
+
typing.Optional[typing.Any],
|
|
1509
|
+
parse_obj_as(
|
|
1510
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1511
|
+
object_=_response.json(),
|
|
1512
|
+
),
|
|
1513
|
+
),
|
|
1514
|
+
)
|
|
1515
|
+
_response_json = _response.json()
|
|
1516
|
+
except JSONDecodeError:
|
|
1517
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1518
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1519
|
+
|
|
1520
|
+
def update_hedge_mode(
|
|
1521
|
+
self, *, hedge_mode: bool, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
1522
|
+
) -> HttpResponse[None]:
|
|
1523
|
+
"""
|
|
1524
|
+
The endpoint updates hedge mode.
|
|
1525
|
+
|
|
1526
|
+
<Warning>
|
|
1527
|
+
Rate limit: 1000 requests/10 sec.
|
|
1528
|
+
</Warning>
|
|
1529
|
+
|
|
1530
|
+
Parameters
|
|
1531
|
+
----------
|
|
1532
|
+
hedge_mode : bool
|
|
1533
|
+
|
|
1534
|
+
request : str
|
|
1535
|
+
|
|
1536
|
+
nonce : str
|
|
1537
|
+
|
|
1538
|
+
request_options : typing.Optional[RequestOptions]
|
|
1539
|
+
Request-specific configuration.
|
|
1540
|
+
|
|
1541
|
+
Returns
|
|
1542
|
+
-------
|
|
1543
|
+
HttpResponse[None]
|
|
1544
|
+
"""
|
|
1545
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1546
|
+
"api/v4/collateral-account/hedge-mode/update",
|
|
1547
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1548
|
+
method="POST",
|
|
1549
|
+
json={
|
|
1550
|
+
"hedgeMode": hedge_mode,
|
|
1551
|
+
"request": request,
|
|
1552
|
+
"nonce": nonce,
|
|
1553
|
+
},
|
|
1554
|
+
headers={
|
|
1555
|
+
"content-type": "application/json",
|
|
1556
|
+
},
|
|
1557
|
+
request_options=request_options,
|
|
1558
|
+
omit=OMIT,
|
|
1559
|
+
)
|
|
1560
|
+
try:
|
|
1561
|
+
if 200 <= _response.status_code < 300:
|
|
1562
|
+
return HttpResponse(response=_response, data=None)
|
|
1563
|
+
if _response.status_code == 422:
|
|
1564
|
+
raise UnprocessableEntityError(
|
|
1565
|
+
headers=dict(_response.headers),
|
|
1566
|
+
body=typing.cast(
|
|
1567
|
+
typing.Optional[typing.Any],
|
|
1568
|
+
parse_obj_as(
|
|
1569
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1570
|
+
object_=_response.json(),
|
|
1571
|
+
),
|
|
1572
|
+
),
|
|
1573
|
+
)
|
|
1574
|
+
if _response.status_code == 500:
|
|
1575
|
+
raise InternalServerError(
|
|
1576
|
+
headers=dict(_response.headers),
|
|
1577
|
+
body=typing.cast(
|
|
1578
|
+
typing.Optional[typing.Any],
|
|
1579
|
+
parse_obj_as(
|
|
1580
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1581
|
+
object_=_response.json(),
|
|
1582
|
+
),
|
|
1583
|
+
),
|
|
1584
|
+
)
|
|
1585
|
+
if _response.status_code == 503:
|
|
1586
|
+
raise ServiceUnavailableError(
|
|
1587
|
+
headers=dict(_response.headers),
|
|
1588
|
+
body=typing.cast(
|
|
1589
|
+
typing.Optional[typing.Any],
|
|
1590
|
+
parse_obj_as(
|
|
1591
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1592
|
+
object_=_response.json(),
|
|
1593
|
+
),
|
|
1594
|
+
),
|
|
1595
|
+
)
|
|
1596
|
+
_response_json = _response.json()
|
|
1597
|
+
except JSONDecodeError:
|
|
1598
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1599
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1600
|
+
|
|
1601
|
+
def get_conditional_orders(
|
|
1602
|
+
self,
|
|
1603
|
+
*,
|
|
1604
|
+
market: typing.Optional[str] = OMIT,
|
|
1605
|
+
offset: typing.Optional[int] = OMIT,
|
|
1606
|
+
limit: typing.Optional[int] = OMIT,
|
|
1607
|
+
request: typing.Optional[str] = OMIT,
|
|
1608
|
+
nonce: typing.Optional[str] = OMIT,
|
|
1609
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1610
|
+
) -> HttpResponse[GetConditionalOrdersResponse]:
|
|
1611
|
+
"""
|
|
1612
|
+
The endpoint retrieves active conditional orders.
|
|
1613
|
+
|
|
1614
|
+
<Warning>
|
|
1615
|
+
Rate limit: 12000 requests/10 sec.
|
|
1616
|
+
</Warning>
|
|
1617
|
+
|
|
1618
|
+
Parameters
|
|
1619
|
+
----------
|
|
1620
|
+
market : typing.Optional[str]
|
|
1621
|
+
|
|
1622
|
+
offset : typing.Optional[int]
|
|
1623
|
+
|
|
1624
|
+
limit : typing.Optional[int]
|
|
1625
|
+
|
|
1626
|
+
request : typing.Optional[str]
|
|
1627
|
+
|
|
1628
|
+
nonce : typing.Optional[str]
|
|
1629
|
+
|
|
1630
|
+
request_options : typing.Optional[RequestOptions]
|
|
1631
|
+
Request-specific configuration.
|
|
1632
|
+
|
|
1633
|
+
Returns
|
|
1634
|
+
-------
|
|
1635
|
+
HttpResponse[GetConditionalOrdersResponse]
|
|
1636
|
+
Successful response - returns paginated conditional orders (OCO and OTO types)
|
|
1637
|
+
"""
|
|
1638
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1639
|
+
"api/v4/orders/conditional",
|
|
1640
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1641
|
+
method="POST",
|
|
1642
|
+
json={
|
|
1643
|
+
"market": market,
|
|
1644
|
+
"offset": offset,
|
|
1645
|
+
"limit": limit,
|
|
1646
|
+
"request": request,
|
|
1647
|
+
"nonce": nonce,
|
|
1648
|
+
},
|
|
1649
|
+
headers={
|
|
1650
|
+
"content-type": "application/json",
|
|
1651
|
+
},
|
|
1652
|
+
request_options=request_options,
|
|
1653
|
+
omit=OMIT,
|
|
1654
|
+
)
|
|
1655
|
+
try:
|
|
1656
|
+
if 200 <= _response.status_code < 300:
|
|
1657
|
+
_data = typing.cast(
|
|
1658
|
+
GetConditionalOrdersResponse,
|
|
1659
|
+
parse_obj_as(
|
|
1660
|
+
type_=GetConditionalOrdersResponse, # type: ignore
|
|
1661
|
+
object_=_response.json(),
|
|
1662
|
+
),
|
|
1663
|
+
)
|
|
1664
|
+
return HttpResponse(response=_response, data=_data)
|
|
1665
|
+
if _response.status_code == 400:
|
|
1666
|
+
raise BadRequestError(
|
|
1667
|
+
headers=dict(_response.headers),
|
|
1668
|
+
body=typing.cast(
|
|
1669
|
+
typing.Optional[typing.Any],
|
|
1670
|
+
parse_obj_as(
|
|
1671
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1672
|
+
object_=_response.json(),
|
|
1673
|
+
),
|
|
1674
|
+
),
|
|
1675
|
+
)
|
|
1676
|
+
if _response.status_code == 422:
|
|
1677
|
+
raise UnprocessableEntityError(
|
|
1678
|
+
headers=dict(_response.headers),
|
|
1679
|
+
body=typing.cast(
|
|
1680
|
+
typing.Optional[typing.Any],
|
|
1681
|
+
parse_obj_as(
|
|
1682
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1683
|
+
object_=_response.json(),
|
|
1684
|
+
),
|
|
1685
|
+
),
|
|
1686
|
+
)
|
|
1687
|
+
if _response.status_code == 503:
|
|
1688
|
+
raise ServiceUnavailableError(
|
|
1689
|
+
headers=dict(_response.headers),
|
|
1690
|
+
body=typing.cast(
|
|
1691
|
+
typing.Optional[typing.Any],
|
|
1692
|
+
parse_obj_as(
|
|
1693
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1694
|
+
object_=_response.json(),
|
|
1695
|
+
),
|
|
1696
|
+
),
|
|
1697
|
+
)
|
|
1698
|
+
_response_json = _response.json()
|
|
1699
|
+
except JSONDecodeError:
|
|
1700
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1701
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1702
|
+
|
|
1703
|
+
def get_oco_orders(
|
|
1704
|
+
self,
|
|
1705
|
+
*,
|
|
1706
|
+
market: typing.Optional[str] = OMIT,
|
|
1707
|
+
offset: typing.Optional[int] = OMIT,
|
|
1708
|
+
limit: typing.Optional[int] = OMIT,
|
|
1709
|
+
request: typing.Optional[str] = OMIT,
|
|
1710
|
+
nonce: typing.Optional[str] = OMIT,
|
|
1711
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1712
|
+
) -> HttpResponse[typing.List[GetOcoOrdersResponseItem]]:
|
|
1713
|
+
"""
|
|
1714
|
+
The endpoint retrieves active OCO orders.
|
|
1715
|
+
|
|
1716
|
+
<Warning>
|
|
1717
|
+
Rate limit: 12000 requests/10 sec.
|
|
1718
|
+
</Warning>
|
|
1719
|
+
|
|
1720
|
+
Parameters
|
|
1721
|
+
----------
|
|
1722
|
+
market : typing.Optional[str]
|
|
1723
|
+
|
|
1724
|
+
offset : typing.Optional[int]
|
|
1725
|
+
|
|
1726
|
+
limit : typing.Optional[int]
|
|
1727
|
+
|
|
1728
|
+
request : typing.Optional[str]
|
|
1729
|
+
|
|
1730
|
+
nonce : typing.Optional[str]
|
|
1731
|
+
|
|
1732
|
+
request_options : typing.Optional[RequestOptions]
|
|
1733
|
+
Request-specific configuration.
|
|
1734
|
+
|
|
1735
|
+
Returns
|
|
1736
|
+
-------
|
|
1737
|
+
HttpResponse[typing.List[GetOcoOrdersResponseItem]]
|
|
1738
|
+
Successful response - returns array of active OCO orders
|
|
1739
|
+
"""
|
|
1740
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1741
|
+
"api/v4/orders/oco",
|
|
1742
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1743
|
+
method="POST",
|
|
1744
|
+
json={
|
|
1745
|
+
"market": market,
|
|
1746
|
+
"offset": offset,
|
|
1747
|
+
"limit": limit,
|
|
1748
|
+
"request": request,
|
|
1749
|
+
"nonce": nonce,
|
|
1750
|
+
},
|
|
1751
|
+
headers={
|
|
1752
|
+
"content-type": "application/json",
|
|
1753
|
+
},
|
|
1754
|
+
request_options=request_options,
|
|
1755
|
+
omit=OMIT,
|
|
1756
|
+
)
|
|
1757
|
+
try:
|
|
1758
|
+
if 200 <= _response.status_code < 300:
|
|
1759
|
+
_data = typing.cast(
|
|
1760
|
+
typing.List[GetOcoOrdersResponseItem],
|
|
1761
|
+
parse_obj_as(
|
|
1762
|
+
type_=typing.List[GetOcoOrdersResponseItem], # type: ignore
|
|
1763
|
+
object_=_response.json(),
|
|
1764
|
+
),
|
|
1765
|
+
)
|
|
1766
|
+
return HttpResponse(response=_response, data=_data)
|
|
1767
|
+
if _response.status_code == 400:
|
|
1768
|
+
raise BadRequestError(
|
|
1769
|
+
headers=dict(_response.headers),
|
|
1770
|
+
body=typing.cast(
|
|
1771
|
+
typing.Optional[typing.Any],
|
|
1772
|
+
parse_obj_as(
|
|
1773
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1774
|
+
object_=_response.json(),
|
|
1775
|
+
),
|
|
1776
|
+
),
|
|
1777
|
+
)
|
|
1778
|
+
if _response.status_code == 422:
|
|
1779
|
+
raise UnprocessableEntityError(
|
|
1780
|
+
headers=dict(_response.headers),
|
|
1781
|
+
body=typing.cast(
|
|
1782
|
+
typing.Optional[typing.Any],
|
|
1783
|
+
parse_obj_as(
|
|
1784
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1785
|
+
object_=_response.json(),
|
|
1786
|
+
),
|
|
1787
|
+
),
|
|
1788
|
+
)
|
|
1789
|
+
if _response.status_code == 503:
|
|
1790
|
+
raise ServiceUnavailableError(
|
|
1791
|
+
headers=dict(_response.headers),
|
|
1792
|
+
body=typing.cast(
|
|
1793
|
+
typing.Optional[typing.Any],
|
|
1794
|
+
parse_obj_as(
|
|
1795
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1796
|
+
object_=_response.json(),
|
|
1797
|
+
),
|
|
1798
|
+
),
|
|
1799
|
+
)
|
|
1800
|
+
_response_json = _response.json()
|
|
1801
|
+
except JSONDecodeError:
|
|
1802
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1803
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1804
|
+
|
|
1805
|
+
def create_collateral_oco_order(
|
|
1806
|
+
self,
|
|
1807
|
+
*,
|
|
1808
|
+
market: str,
|
|
1809
|
+
side: CreateCollateralOcoOrderRequestSide,
|
|
1810
|
+
amount: str,
|
|
1811
|
+
price: str,
|
|
1812
|
+
activation_price: str,
|
|
1813
|
+
stop_limit_price: str,
|
|
1814
|
+
request: str,
|
|
1815
|
+
nonce: str,
|
|
1816
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
1817
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1818
|
+
) -> HttpResponse[CreateCollateralOcoOrderResponse]:
|
|
1819
|
+
"""
|
|
1820
|
+
The endpoint creates a collateral OCO order.
|
|
1821
|
+
|
|
1822
|
+
<Warning>
|
|
1823
|
+
Rate limit: 10000 requests/10 sec.
|
|
1824
|
+
</Warning>
|
|
1825
|
+
|
|
1826
|
+
Parameters
|
|
1827
|
+
----------
|
|
1828
|
+
market : str
|
|
1829
|
+
|
|
1830
|
+
side : CreateCollateralOcoOrderRequestSide
|
|
1831
|
+
|
|
1832
|
+
amount : str
|
|
1833
|
+
|
|
1834
|
+
price : str
|
|
1835
|
+
|
|
1836
|
+
activation_price : str
|
|
1837
|
+
|
|
1838
|
+
stop_limit_price : str
|
|
1839
|
+
|
|
1840
|
+
request : str
|
|
1841
|
+
|
|
1842
|
+
nonce : str
|
|
1843
|
+
|
|
1844
|
+
client_order_id : typing.Optional[str]
|
|
1845
|
+
|
|
1846
|
+
request_options : typing.Optional[RequestOptions]
|
|
1847
|
+
Request-specific configuration.
|
|
1848
|
+
|
|
1849
|
+
Returns
|
|
1850
|
+
-------
|
|
1851
|
+
HttpResponse[CreateCollateralOcoOrderResponse]
|
|
1852
|
+
Successful response - OCO order created
|
|
1853
|
+
"""
|
|
1854
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1855
|
+
"api/v4/order/collateral/oco",
|
|
1856
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1857
|
+
method="POST",
|
|
1858
|
+
json={
|
|
1859
|
+
"market": market,
|
|
1860
|
+
"side": side,
|
|
1861
|
+
"amount": amount,
|
|
1862
|
+
"price": price,
|
|
1863
|
+
"activation_price": activation_price,
|
|
1864
|
+
"stop_limit_price": stop_limit_price,
|
|
1865
|
+
"clientOrderId": client_order_id,
|
|
1866
|
+
"request": request,
|
|
1867
|
+
"nonce": nonce,
|
|
1868
|
+
},
|
|
1869
|
+
headers={
|
|
1870
|
+
"content-type": "application/json",
|
|
1871
|
+
},
|
|
1872
|
+
request_options=request_options,
|
|
1873
|
+
omit=OMIT,
|
|
1874
|
+
)
|
|
1875
|
+
try:
|
|
1876
|
+
if 200 <= _response.status_code < 300:
|
|
1877
|
+
_data = typing.cast(
|
|
1878
|
+
CreateCollateralOcoOrderResponse,
|
|
1879
|
+
parse_obj_as(
|
|
1880
|
+
type_=CreateCollateralOcoOrderResponse, # type: ignore
|
|
1881
|
+
object_=_response.json(),
|
|
1882
|
+
),
|
|
1883
|
+
)
|
|
1884
|
+
return HttpResponse(response=_response, data=_data)
|
|
1885
|
+
if _response.status_code == 400:
|
|
1886
|
+
raise BadRequestError(
|
|
1887
|
+
headers=dict(_response.headers),
|
|
1888
|
+
body=typing.cast(
|
|
1889
|
+
typing.Optional[typing.Any],
|
|
1890
|
+
parse_obj_as(
|
|
1891
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1892
|
+
object_=_response.json(),
|
|
1893
|
+
),
|
|
1894
|
+
),
|
|
1895
|
+
)
|
|
1896
|
+
if _response.status_code == 422:
|
|
1897
|
+
raise UnprocessableEntityError(
|
|
1898
|
+
headers=dict(_response.headers),
|
|
1899
|
+
body=typing.cast(
|
|
1900
|
+
typing.Optional[typing.Any],
|
|
1901
|
+
parse_obj_as(
|
|
1902
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1903
|
+
object_=_response.json(),
|
|
1904
|
+
),
|
|
1905
|
+
),
|
|
1906
|
+
)
|
|
1907
|
+
if _response.status_code == 503:
|
|
1908
|
+
raise ServiceUnavailableError(
|
|
1909
|
+
headers=dict(_response.headers),
|
|
1910
|
+
body=typing.cast(
|
|
1911
|
+
typing.Optional[typing.Any],
|
|
1912
|
+
parse_obj_as(
|
|
1913
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1914
|
+
object_=_response.json(),
|
|
1915
|
+
),
|
|
1916
|
+
),
|
|
1917
|
+
)
|
|
1918
|
+
_response_json = _response.json()
|
|
1919
|
+
except JSONDecodeError:
|
|
1920
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1921
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1922
|
+
|
|
1923
|
+
def cancel_conditional_order(
|
|
1924
|
+
self, *, market: str, id: int, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
1925
|
+
) -> HttpResponse[None]:
|
|
1926
|
+
"""
|
|
1927
|
+
The endpoint cancels a conditional order.
|
|
1928
|
+
|
|
1929
|
+
<Warning>
|
|
1930
|
+
Rate limit: 10000 requests/10 sec.
|
|
1931
|
+
</Warning>
|
|
1932
|
+
|
|
1933
|
+
Parameters
|
|
1934
|
+
----------
|
|
1935
|
+
market : str
|
|
1936
|
+
|
|
1937
|
+
id : int
|
|
1938
|
+
|
|
1939
|
+
request : str
|
|
1940
|
+
|
|
1941
|
+
nonce : str
|
|
1942
|
+
|
|
1943
|
+
request_options : typing.Optional[RequestOptions]
|
|
1944
|
+
Request-specific configuration.
|
|
1945
|
+
|
|
1946
|
+
Returns
|
|
1947
|
+
-------
|
|
1948
|
+
HttpResponse[None]
|
|
1949
|
+
"""
|
|
1950
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1951
|
+
"api/v4/order/conditional-cancel",
|
|
1952
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
1953
|
+
method="POST",
|
|
1954
|
+
json={
|
|
1955
|
+
"market": market,
|
|
1956
|
+
"id": id,
|
|
1957
|
+
"request": request,
|
|
1958
|
+
"nonce": nonce,
|
|
1959
|
+
},
|
|
1960
|
+
headers={
|
|
1961
|
+
"content-type": "application/json",
|
|
1962
|
+
},
|
|
1963
|
+
request_options=request_options,
|
|
1964
|
+
omit=OMIT,
|
|
1965
|
+
)
|
|
1966
|
+
try:
|
|
1967
|
+
if 200 <= _response.status_code < 300:
|
|
1968
|
+
return HttpResponse(response=_response, data=None)
|
|
1969
|
+
if _response.status_code == 400:
|
|
1970
|
+
raise BadRequestError(
|
|
1971
|
+
headers=dict(_response.headers),
|
|
1972
|
+
body=typing.cast(
|
|
1973
|
+
typing.Optional[typing.Any],
|
|
1974
|
+
parse_obj_as(
|
|
1975
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1976
|
+
object_=_response.json(),
|
|
1977
|
+
),
|
|
1978
|
+
),
|
|
1979
|
+
)
|
|
1980
|
+
if _response.status_code == 422:
|
|
1981
|
+
raise UnprocessableEntityError(
|
|
1982
|
+
headers=dict(_response.headers),
|
|
1983
|
+
body=typing.cast(
|
|
1984
|
+
typing.Optional[typing.Any],
|
|
1985
|
+
parse_obj_as(
|
|
1986
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1987
|
+
object_=_response.json(),
|
|
1988
|
+
),
|
|
1989
|
+
),
|
|
1990
|
+
)
|
|
1991
|
+
if _response.status_code == 503:
|
|
1992
|
+
raise ServiceUnavailableError(
|
|
1993
|
+
headers=dict(_response.headers),
|
|
1994
|
+
body=typing.cast(
|
|
1995
|
+
typing.Optional[typing.Any],
|
|
1996
|
+
parse_obj_as(
|
|
1997
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1998
|
+
object_=_response.json(),
|
|
1999
|
+
),
|
|
2000
|
+
),
|
|
2001
|
+
)
|
|
2002
|
+
_response_json = _response.json()
|
|
2003
|
+
except JSONDecodeError:
|
|
2004
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2005
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2006
|
+
|
|
2007
|
+
def cancel_oco_order(
|
|
2008
|
+
self,
|
|
2009
|
+
*,
|
|
2010
|
+
market: str,
|
|
2011
|
+
order_id: int,
|
|
2012
|
+
request: str,
|
|
2013
|
+
nonce: str,
|
|
2014
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2015
|
+
) -> HttpResponse[CancelOcoOrderResponse]:
|
|
2016
|
+
"""
|
|
2017
|
+
The endpoint cancels an OCO order.
|
|
2018
|
+
|
|
2019
|
+
<Warning>
|
|
2020
|
+
Rate limit: 10000 requests/10 sec.
|
|
2021
|
+
</Warning>
|
|
2022
|
+
|
|
2023
|
+
Parameters
|
|
2024
|
+
----------
|
|
2025
|
+
market : str
|
|
2026
|
+
|
|
2027
|
+
order_id : int
|
|
2028
|
+
|
|
2029
|
+
request : str
|
|
2030
|
+
|
|
2031
|
+
nonce : str
|
|
2032
|
+
|
|
2033
|
+
request_options : typing.Optional[RequestOptions]
|
|
2034
|
+
Request-specific configuration.
|
|
2035
|
+
|
|
2036
|
+
Returns
|
|
2037
|
+
-------
|
|
2038
|
+
HttpResponse[CancelOcoOrderResponse]
|
|
2039
|
+
Successful response - OCO order cancelled
|
|
2040
|
+
"""
|
|
2041
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
2042
|
+
"api/v4/order/oco-cancel",
|
|
2043
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2044
|
+
method="POST",
|
|
2045
|
+
json={
|
|
2046
|
+
"market": market,
|
|
2047
|
+
"orderId": order_id,
|
|
2048
|
+
"request": request,
|
|
2049
|
+
"nonce": nonce,
|
|
2050
|
+
},
|
|
2051
|
+
headers={
|
|
2052
|
+
"content-type": "application/json",
|
|
2053
|
+
},
|
|
2054
|
+
request_options=request_options,
|
|
2055
|
+
omit=OMIT,
|
|
2056
|
+
)
|
|
2057
|
+
try:
|
|
2058
|
+
if 200 <= _response.status_code < 300:
|
|
2059
|
+
_data = typing.cast(
|
|
2060
|
+
CancelOcoOrderResponse,
|
|
2061
|
+
parse_obj_as(
|
|
2062
|
+
type_=CancelOcoOrderResponse, # type: ignore
|
|
2063
|
+
object_=_response.json(),
|
|
2064
|
+
),
|
|
2065
|
+
)
|
|
2066
|
+
return HttpResponse(response=_response, data=_data)
|
|
2067
|
+
if _response.status_code == 400:
|
|
2068
|
+
raise BadRequestError(
|
|
2069
|
+
headers=dict(_response.headers),
|
|
2070
|
+
body=typing.cast(
|
|
2071
|
+
typing.Optional[typing.Any],
|
|
2072
|
+
parse_obj_as(
|
|
2073
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2074
|
+
object_=_response.json(),
|
|
2075
|
+
),
|
|
2076
|
+
),
|
|
2077
|
+
)
|
|
2078
|
+
if _response.status_code == 422:
|
|
2079
|
+
raise UnprocessableEntityError(
|
|
2080
|
+
headers=dict(_response.headers),
|
|
2081
|
+
body=typing.cast(
|
|
2082
|
+
typing.Optional[typing.Any],
|
|
2083
|
+
parse_obj_as(
|
|
2084
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2085
|
+
object_=_response.json(),
|
|
2086
|
+
),
|
|
2087
|
+
),
|
|
2088
|
+
)
|
|
2089
|
+
if _response.status_code == 503:
|
|
2090
|
+
raise ServiceUnavailableError(
|
|
2091
|
+
headers=dict(_response.headers),
|
|
2092
|
+
body=typing.cast(
|
|
2093
|
+
typing.Optional[typing.Any],
|
|
2094
|
+
parse_obj_as(
|
|
2095
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2096
|
+
object_=_response.json(),
|
|
2097
|
+
),
|
|
2098
|
+
),
|
|
2099
|
+
)
|
|
2100
|
+
_response_json = _response.json()
|
|
2101
|
+
except JSONDecodeError:
|
|
2102
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2103
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2104
|
+
|
|
2105
|
+
def cancel_oto_order(
|
|
2106
|
+
self,
|
|
2107
|
+
*,
|
|
2108
|
+
market: str,
|
|
2109
|
+
oto_id: int,
|
|
2110
|
+
request: str,
|
|
2111
|
+
nonce: str,
|
|
2112
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2113
|
+
) -> HttpResponse[None]:
|
|
2114
|
+
"""
|
|
2115
|
+
The endpoint cancels an OTO order.
|
|
2116
|
+
|
|
2117
|
+
<Warning>
|
|
2118
|
+
Rate limit: 10000 requests/10 sec.
|
|
2119
|
+
</Warning>
|
|
2120
|
+
|
|
2121
|
+
Parameters
|
|
2122
|
+
----------
|
|
2123
|
+
market : str
|
|
2124
|
+
|
|
2125
|
+
oto_id : int
|
|
2126
|
+
|
|
2127
|
+
request : str
|
|
2128
|
+
|
|
2129
|
+
nonce : str
|
|
2130
|
+
|
|
2131
|
+
request_options : typing.Optional[RequestOptions]
|
|
2132
|
+
Request-specific configuration.
|
|
2133
|
+
|
|
2134
|
+
Returns
|
|
2135
|
+
-------
|
|
2136
|
+
HttpResponse[None]
|
|
2137
|
+
"""
|
|
2138
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
2139
|
+
"api/v4/order/oto-cancel",
|
|
2140
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2141
|
+
method="POST",
|
|
2142
|
+
json={
|
|
2143
|
+
"market": market,
|
|
2144
|
+
"otoId": oto_id,
|
|
2145
|
+
"request": request,
|
|
2146
|
+
"nonce": nonce,
|
|
2147
|
+
},
|
|
2148
|
+
headers={
|
|
2149
|
+
"content-type": "application/json",
|
|
2150
|
+
},
|
|
2151
|
+
request_options=request_options,
|
|
2152
|
+
omit=OMIT,
|
|
2153
|
+
)
|
|
2154
|
+
try:
|
|
2155
|
+
if 200 <= _response.status_code < 300:
|
|
2156
|
+
return HttpResponse(response=_response, data=None)
|
|
2157
|
+
if _response.status_code == 400:
|
|
2158
|
+
raise BadRequestError(
|
|
2159
|
+
headers=dict(_response.headers),
|
|
2160
|
+
body=typing.cast(
|
|
2161
|
+
typing.Optional[typing.Any],
|
|
2162
|
+
parse_obj_as(
|
|
2163
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2164
|
+
object_=_response.json(),
|
|
2165
|
+
),
|
|
2166
|
+
),
|
|
2167
|
+
)
|
|
2168
|
+
if _response.status_code == 422:
|
|
2169
|
+
raise UnprocessableEntityError(
|
|
2170
|
+
headers=dict(_response.headers),
|
|
2171
|
+
body=typing.cast(
|
|
2172
|
+
typing.Optional[typing.Any],
|
|
2173
|
+
parse_obj_as(
|
|
2174
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2175
|
+
object_=_response.json(),
|
|
2176
|
+
),
|
|
2177
|
+
),
|
|
2178
|
+
)
|
|
2179
|
+
if _response.status_code == 503:
|
|
2180
|
+
raise ServiceUnavailableError(
|
|
2181
|
+
headers=dict(_response.headers),
|
|
2182
|
+
body=typing.cast(
|
|
2183
|
+
typing.Optional[typing.Any],
|
|
2184
|
+
parse_obj_as(
|
|
2185
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2186
|
+
object_=_response.json(),
|
|
2187
|
+
),
|
|
2188
|
+
),
|
|
2189
|
+
)
|
|
2190
|
+
_response_json = _response.json()
|
|
2191
|
+
except JSONDecodeError:
|
|
2192
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2193
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
class AsyncRawCollateralTradingClient:
|
|
2197
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
2198
|
+
self._client_wrapper = client_wrapper
|
|
2199
|
+
|
|
2200
|
+
async def collateral_account_balance(
|
|
2201
|
+
self,
|
|
2202
|
+
*,
|
|
2203
|
+
ticker: typing.Optional[str] = OMIT,
|
|
2204
|
+
request: typing.Optional[str] = OMIT,
|
|
2205
|
+
nonce: typing.Optional[str] = OMIT,
|
|
2206
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2207
|
+
) -> AsyncHttpResponse[typing.Dict[str, float]]:
|
|
2208
|
+
"""
|
|
2209
|
+
The endpoint returns a current [collateral balance](/glossary#balance-collateral).
|
|
2210
|
+
|
|
2211
|
+
<Note>
|
|
2212
|
+
The API does not cache the response.
|
|
2213
|
+
</Note>
|
|
2214
|
+
|
|
2215
|
+
<Warning>
|
|
2216
|
+
Rate limit: 12000 requests/10 sec.
|
|
2217
|
+
</Warning>
|
|
2218
|
+
|
|
2219
|
+
<Accordion title="Errors">
|
|
2220
|
+
```json
|
|
2221
|
+
{
|
|
2222
|
+
"code": 30,
|
|
2223
|
+
"message": "Validation failed",
|
|
2224
|
+
"errors": {
|
|
2225
|
+
"ticker": ["ticker is invalid."]
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
```
|
|
2229
|
+
</Accordion>
|
|
2230
|
+
|
|
2231
|
+
Parameters
|
|
2232
|
+
----------
|
|
2233
|
+
ticker : typing.Optional[str]
|
|
2234
|
+
[Asset](/glossary#assets) to be filtered. For example: BTC
|
|
2235
|
+
|
|
2236
|
+
If not specified, returns balances for all assets.
|
|
2237
|
+
|
|
2238
|
+
request : typing.Optional[str]
|
|
2239
|
+
Request signature
|
|
2240
|
+
|
|
2241
|
+
nonce : typing.Optional[str]
|
|
2242
|
+
Unique request identifier
|
|
2243
|
+
|
|
2244
|
+
request_options : typing.Optional[RequestOptions]
|
|
2245
|
+
Request-specific configuration.
|
|
2246
|
+
|
|
2247
|
+
Returns
|
|
2248
|
+
-------
|
|
2249
|
+
AsyncHttpResponse[typing.Dict[str, float]]
|
|
2250
|
+
Successful response - returns collateral balances by asset
|
|
2251
|
+
"""
|
|
2252
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2253
|
+
"api/v4/collateral-account/balance",
|
|
2254
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2255
|
+
method="POST",
|
|
2256
|
+
json={
|
|
2257
|
+
"ticker": ticker,
|
|
2258
|
+
"request": request,
|
|
2259
|
+
"nonce": nonce,
|
|
2260
|
+
},
|
|
2261
|
+
headers={
|
|
2262
|
+
"content-type": "application/json",
|
|
2263
|
+
},
|
|
2264
|
+
request_options=request_options,
|
|
2265
|
+
omit=OMIT,
|
|
2266
|
+
)
|
|
2267
|
+
try:
|
|
2268
|
+
if 200 <= _response.status_code < 300:
|
|
2269
|
+
_data = typing.cast(
|
|
2270
|
+
typing.Dict[str, float],
|
|
2271
|
+
parse_obj_as(
|
|
2272
|
+
type_=typing.Dict[str, float], # type: ignore
|
|
2273
|
+
object_=_response.json(),
|
|
2274
|
+
),
|
|
2275
|
+
)
|
|
2276
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2277
|
+
if _response.status_code == 422:
|
|
2278
|
+
raise UnprocessableEntityError(
|
|
2279
|
+
headers=dict(_response.headers),
|
|
2280
|
+
body=typing.cast(
|
|
2281
|
+
typing.Optional[typing.Any],
|
|
2282
|
+
parse_obj_as(
|
|
2283
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2284
|
+
object_=_response.json(),
|
|
2285
|
+
),
|
|
2286
|
+
),
|
|
2287
|
+
)
|
|
2288
|
+
if _response.status_code == 503:
|
|
2289
|
+
raise ServiceUnavailableError(
|
|
2290
|
+
headers=dict(_response.headers),
|
|
2291
|
+
body=typing.cast(
|
|
2292
|
+
typing.Optional[typing.Any],
|
|
2293
|
+
parse_obj_as(
|
|
2294
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2295
|
+
object_=_response.json(),
|
|
2296
|
+
),
|
|
2297
|
+
),
|
|
2298
|
+
)
|
|
2299
|
+
_response_json = _response.json()
|
|
2300
|
+
except JSONDecodeError:
|
|
2301
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2302
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2303
|
+
|
|
2304
|
+
async def collateral_account_balance_summary(
|
|
2305
|
+
self,
|
|
2306
|
+
*,
|
|
2307
|
+
ticker: typing.Optional[str] = OMIT,
|
|
2308
|
+
request: typing.Optional[str] = OMIT,
|
|
2309
|
+
nonce: typing.Optional[str] = OMIT,
|
|
2310
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2311
|
+
) -> AsyncHttpResponse[typing.List[CollateralAccountBalanceSummaryResponseItem]]:
|
|
2312
|
+
"""
|
|
2313
|
+
The endpoint retrieves collateral account balance summary with detailed breakdown per asset.
|
|
2314
|
+
|
|
2315
|
+
<Note>
|
|
2316
|
+
The API does not cache the response.
|
|
2317
|
+
</Note>
|
|
2318
|
+
|
|
2319
|
+
<Warning>
|
|
2320
|
+
Rate limit: 12000 requests/10 sec.
|
|
2321
|
+
</Warning>
|
|
2322
|
+
|
|
2323
|
+
<Accordion title="Errors">
|
|
2324
|
+
```json
|
|
2325
|
+
{
|
|
2326
|
+
"code": 30,
|
|
2327
|
+
"message": "Validation failed",
|
|
2328
|
+
"errors": {
|
|
2329
|
+
"ticker": ["ticker is invalid."]
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
```
|
|
2333
|
+
</Accordion>
|
|
2334
|
+
|
|
2335
|
+
Parameters
|
|
2336
|
+
----------
|
|
2337
|
+
ticker : typing.Optional[str]
|
|
2338
|
+
Filter by requested asset. For example: BTC
|
|
2339
|
+
|
|
2340
|
+
If not specified, returns summary for all assets.
|
|
2341
|
+
|
|
2342
|
+
request : typing.Optional[str]
|
|
2343
|
+
Request signature
|
|
2344
|
+
|
|
2345
|
+
nonce : typing.Optional[str]
|
|
2346
|
+
Unique request identifier
|
|
2347
|
+
|
|
2348
|
+
request_options : typing.Optional[RequestOptions]
|
|
2349
|
+
Request-specific configuration.
|
|
2350
|
+
|
|
2351
|
+
Returns
|
|
2352
|
+
-------
|
|
2353
|
+
AsyncHttpResponse[typing.List[CollateralAccountBalanceSummaryResponseItem]]
|
|
2354
|
+
Successful response - returns detailed balance information per asset
|
|
2355
|
+
"""
|
|
2356
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2357
|
+
"api/v4/collateral-account/balance-summary",
|
|
2358
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2359
|
+
method="POST",
|
|
2360
|
+
json={
|
|
2361
|
+
"ticker": ticker,
|
|
2362
|
+
"request": request,
|
|
2363
|
+
"nonce": nonce,
|
|
2364
|
+
},
|
|
2365
|
+
headers={
|
|
2366
|
+
"content-type": "application/json",
|
|
2367
|
+
},
|
|
2368
|
+
request_options=request_options,
|
|
2369
|
+
omit=OMIT,
|
|
2370
|
+
)
|
|
2371
|
+
try:
|
|
2372
|
+
if 200 <= _response.status_code < 300:
|
|
2373
|
+
_data = typing.cast(
|
|
2374
|
+
typing.List[CollateralAccountBalanceSummaryResponseItem],
|
|
2375
|
+
parse_obj_as(
|
|
2376
|
+
type_=typing.List[CollateralAccountBalanceSummaryResponseItem], # type: ignore
|
|
2377
|
+
object_=_response.json(),
|
|
2378
|
+
),
|
|
2379
|
+
)
|
|
2380
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2381
|
+
if _response.status_code == 422:
|
|
2382
|
+
raise UnprocessableEntityError(
|
|
2383
|
+
headers=dict(_response.headers),
|
|
2384
|
+
body=typing.cast(
|
|
2385
|
+
typing.Optional[typing.Any],
|
|
2386
|
+
parse_obj_as(
|
|
2387
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2388
|
+
object_=_response.json(),
|
|
2389
|
+
),
|
|
2390
|
+
),
|
|
2391
|
+
)
|
|
2392
|
+
if _response.status_code == 503:
|
|
2393
|
+
raise ServiceUnavailableError(
|
|
2394
|
+
headers=dict(_response.headers),
|
|
2395
|
+
body=typing.cast(
|
|
2396
|
+
typing.Optional[typing.Any],
|
|
2397
|
+
parse_obj_as(
|
|
2398
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2399
|
+
object_=_response.json(),
|
|
2400
|
+
),
|
|
2401
|
+
),
|
|
2402
|
+
)
|
|
2403
|
+
_response_json = _response.json()
|
|
2404
|
+
except JSONDecodeError:
|
|
2405
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2406
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2407
|
+
|
|
2408
|
+
async def create_collateral_limit_order(
|
|
2409
|
+
self,
|
|
2410
|
+
*,
|
|
2411
|
+
market: str,
|
|
2412
|
+
side: CreateCollateralLimitOrderRequestSide,
|
|
2413
|
+
amount: str,
|
|
2414
|
+
price: str,
|
|
2415
|
+
request: str,
|
|
2416
|
+
nonce: str,
|
|
2417
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
2418
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
2419
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
2420
|
+
post_only: typing.Optional[bool] = OMIT,
|
|
2421
|
+
ioc: typing.Optional[bool] = OMIT,
|
|
2422
|
+
rpi: typing.Optional[bool] = OMIT,
|
|
2423
|
+
position_side: typing.Optional[CreateCollateralLimitOrderRequestPositionSide] = OMIT,
|
|
2424
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2425
|
+
) -> AsyncHttpResponse[CreateCollateralLimitOrderResponse]:
|
|
2426
|
+
"""
|
|
2427
|
+
The endpoint creates [limit order](/glossary#limit-order) using [collateral balance](/glossary#balance-collateral).
|
|
2428
|
+
|
|
2429
|
+
<Warning>
|
|
2430
|
+
Rate limit: 10000 requests/10 sec.
|
|
2431
|
+
</Warning>
|
|
2432
|
+
|
|
2433
|
+
<Note>
|
|
2434
|
+
For open long position use **buy**, for short **sell**. To close current position, place opposite order with current position amount.
|
|
2435
|
+
</Note>
|
|
2436
|
+
|
|
2437
|
+
<Note>
|
|
2438
|
+
- RPI orders are post-only by design and cannot be used with the IOC flag. The API returns error code `37` when both `rpi=true` and `ioc=true` are used.
|
|
2439
|
+
</Note>
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
<Accordion title="Error Codes">
|
|
2443
|
+
- `30` - default validation error code
|
|
2444
|
+
- `31` - market validation failed
|
|
2445
|
+
- `32` - amount validation failed
|
|
2446
|
+
- `33` - price validation failed
|
|
2447
|
+
- `36` - clientOrderId validation failed
|
|
2448
|
+
- `37` - `ioc=true` cannot be used with `postOnly=true` or `rpi=true`
|
|
2449
|
+
</Accordion>
|
|
2450
|
+
|
|
2451
|
+
Parameters
|
|
2452
|
+
----------
|
|
2453
|
+
market : str
|
|
2454
|
+
Available margin [market](/glossary#market). Example: BTC_USDT
|
|
2455
|
+
|
|
2456
|
+
side : CreateCollateralLimitOrderRequestSide
|
|
2457
|
+
Order type. Variables: 'buy' / 'sell'. For open long position use **buy**, for short **sell**.
|
|
2458
|
+
|
|
2459
|
+
amount : str
|
|
2460
|
+
Amount of [stock](/glossary#stock) currency to buy or sell.
|
|
2461
|
+
|
|
2462
|
+
price : str
|
|
2463
|
+
Price in [money](/glossary#money) currency. Example: '9800'
|
|
2464
|
+
|
|
2465
|
+
request : str
|
|
2466
|
+
|
|
2467
|
+
nonce : str
|
|
2468
|
+
|
|
2469
|
+
client_order_id : typing.Optional[str]
|
|
2470
|
+
Identifier should be unique and contain letters, dashes, numbers, dots or underscores.
|
|
2471
|
+
|
|
2472
|
+
stop_loss : typing.Optional[str]
|
|
2473
|
+
Stop loss price.
|
|
2474
|
+
|
|
2475
|
+
When provided, the system creates an [OTO](/glossary#one-triggers-the-other-oto) order with a stop loss condition.
|
|
2476
|
+
|
|
2477
|
+
take_profit : typing.Optional[str]
|
|
2478
|
+
Take profit price.
|
|
2479
|
+
|
|
2480
|
+
When provided, the system creates an [OTO](/glossary#one-triggers-the-other-oto) order with a take profit condition.
|
|
2481
|
+
|
|
2482
|
+
post_only : typing.Optional[bool]
|
|
2483
|
+
Orders are guaranteed to be the [maker](/glossary#maker) order when [executed](/glossary#finished-orders).
|
|
2484
|
+
|
|
2485
|
+
ioc : typing.Optional[bool]
|
|
2486
|
+
An immediate or cancel order (IOC) is an order that attempts to execute all or part immediately and then cancels any unfilled portion.
|
|
2487
|
+
|
|
2488
|
+
rpi : typing.Optional[bool]
|
|
2489
|
+
Enables Retail Price Improvement (RPI) mode.
|
|
2490
|
+
|
|
2491
|
+
RPI orders are post-only by design and cannot be used with `ioc=true`. The API returns error code `37` when both `rpi=true` and `ioc=true` are used.
|
|
2492
|
+
|
|
2493
|
+
position_side : typing.Optional[CreateCollateralLimitOrderRequestPositionSide]
|
|
2494
|
+
Defines the position direction when hedge mode is enabled. See [positionSide](/glossary#position-side)
|
|
2495
|
+
|
|
2496
|
+
request_options : typing.Optional[RequestOptions]
|
|
2497
|
+
Request-specific configuration.
|
|
2498
|
+
|
|
2499
|
+
Returns
|
|
2500
|
+
-------
|
|
2501
|
+
AsyncHttpResponse[CreateCollateralLimitOrderResponse]
|
|
2502
|
+
Successful response - order created
|
|
2503
|
+
"""
|
|
2504
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2505
|
+
"api/v4/order/collateral/limit",
|
|
2506
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2507
|
+
method="POST",
|
|
2508
|
+
json={
|
|
2509
|
+
"market": market,
|
|
2510
|
+
"side": side,
|
|
2511
|
+
"amount": amount,
|
|
2512
|
+
"price": price,
|
|
2513
|
+
"clientOrderId": client_order_id,
|
|
2514
|
+
"stopLoss": stop_loss,
|
|
2515
|
+
"takeProfit": take_profit,
|
|
2516
|
+
"postOnly": post_only,
|
|
2517
|
+
"ioc": ioc,
|
|
2518
|
+
"rpi": rpi,
|
|
2519
|
+
"positionSide": position_side,
|
|
2520
|
+
"request": request,
|
|
2521
|
+
"nonce": nonce,
|
|
2522
|
+
},
|
|
2523
|
+
headers={
|
|
2524
|
+
"content-type": "application/json",
|
|
2525
|
+
},
|
|
2526
|
+
request_options=request_options,
|
|
2527
|
+
omit=OMIT,
|
|
2528
|
+
)
|
|
2529
|
+
try:
|
|
2530
|
+
if 200 <= _response.status_code < 300:
|
|
2531
|
+
_data = typing.cast(
|
|
2532
|
+
CreateCollateralLimitOrderResponse,
|
|
2533
|
+
parse_obj_as(
|
|
2534
|
+
type_=CreateCollateralLimitOrderResponse, # type: ignore
|
|
2535
|
+
object_=_response.json(),
|
|
2536
|
+
),
|
|
2537
|
+
)
|
|
2538
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2539
|
+
if _response.status_code == 422:
|
|
2540
|
+
raise UnprocessableEntityError(
|
|
2541
|
+
headers=dict(_response.headers),
|
|
2542
|
+
body=typing.cast(
|
|
2543
|
+
typing.Optional[typing.Any],
|
|
2544
|
+
parse_obj_as(
|
|
2545
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2546
|
+
object_=_response.json(),
|
|
2547
|
+
),
|
|
2548
|
+
),
|
|
2549
|
+
)
|
|
2550
|
+
if _response.status_code == 503:
|
|
2551
|
+
raise ServiceUnavailableError(
|
|
2552
|
+
headers=dict(_response.headers),
|
|
2553
|
+
body=typing.cast(
|
|
2554
|
+
typing.Optional[typing.Any],
|
|
2555
|
+
parse_obj_as(
|
|
2556
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2557
|
+
object_=_response.json(),
|
|
2558
|
+
),
|
|
2559
|
+
),
|
|
2560
|
+
)
|
|
2561
|
+
_response_json = _response.json()
|
|
2562
|
+
except JSONDecodeError:
|
|
2563
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2564
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2565
|
+
|
|
2566
|
+
async def create_collateral_bulk_order(
|
|
2567
|
+
self,
|
|
2568
|
+
*,
|
|
2569
|
+
orders: typing.Optional[typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem]] = OMIT,
|
|
2570
|
+
stop_on_fail: typing.Optional[bool] = OMIT,
|
|
2571
|
+
request: typing.Optional[str] = OMIT,
|
|
2572
|
+
nonce: typing.Optional[str] = OMIT,
|
|
2573
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2574
|
+
) -> AsyncHttpResponse[typing.List[CreateCollateralBulkOrderResponseItem]]:
|
|
2575
|
+
"""
|
|
2576
|
+
The endpoint creates multiple collateral limit orders.
|
|
2577
|
+
|
|
2578
|
+
<Warning>
|
|
2579
|
+
Rate limit: 10000 requests/10 sec.
|
|
2580
|
+
</Warning>
|
|
2581
|
+
|
|
2582
|
+
Parameters
|
|
2583
|
+
----------
|
|
2584
|
+
orders : typing.Optional[typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem]]
|
|
2585
|
+
|
|
2586
|
+
stop_on_fail : typing.Optional[bool]
|
|
2587
|
+
Controls how the bulk order processor handles failures.
|
|
2588
|
+
|
|
2589
|
+
When true: Processing stops at the first order that fails validation or execution. Only orders up to (but not including) the failed order are processed.
|
|
2590
|
+
|
|
2591
|
+
When false (default): All orders in the bulk request are processed regardless of individual failures. Each order result is returned in the response array.
|
|
2592
|
+
|
|
2593
|
+
request : typing.Optional[str]
|
|
2594
|
+
|
|
2595
|
+
nonce : typing.Optional[str]
|
|
2596
|
+
|
|
2597
|
+
request_options : typing.Optional[RequestOptions]
|
|
2598
|
+
Request-specific configuration.
|
|
2599
|
+
|
|
2600
|
+
Returns
|
|
2601
|
+
-------
|
|
2602
|
+
AsyncHttpResponse[typing.List[CreateCollateralBulkOrderResponseItem]]
|
|
2603
|
+
Successful response - returns array of order results
|
|
2604
|
+
"""
|
|
2605
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2606
|
+
"api/v4/order/collateral/bulk",
|
|
2607
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2608
|
+
method="POST",
|
|
2609
|
+
json={
|
|
2610
|
+
"orders": convert_and_respect_annotation_metadata(
|
|
2611
|
+
object_=orders,
|
|
2612
|
+
annotation=typing.Sequence[CreateCollateralBulkOrderRequestOrdersItem],
|
|
2613
|
+
direction="write",
|
|
2614
|
+
),
|
|
2615
|
+
"stopOnFail": stop_on_fail,
|
|
2616
|
+
"request": request,
|
|
2617
|
+
"nonce": nonce,
|
|
2618
|
+
},
|
|
2619
|
+
headers={
|
|
2620
|
+
"content-type": "application/json",
|
|
2621
|
+
},
|
|
2622
|
+
request_options=request_options,
|
|
2623
|
+
omit=OMIT,
|
|
2624
|
+
)
|
|
2625
|
+
try:
|
|
2626
|
+
if 200 <= _response.status_code < 300:
|
|
2627
|
+
_data = typing.cast(
|
|
2628
|
+
typing.List[CreateCollateralBulkOrderResponseItem],
|
|
2629
|
+
parse_obj_as(
|
|
2630
|
+
type_=typing.List[CreateCollateralBulkOrderResponseItem], # type: ignore
|
|
2631
|
+
object_=_response.json(),
|
|
2632
|
+
),
|
|
2633
|
+
)
|
|
2634
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2635
|
+
if _response.status_code == 400:
|
|
2636
|
+
raise BadRequestError(
|
|
2637
|
+
headers=dict(_response.headers),
|
|
2638
|
+
body=typing.cast(
|
|
2639
|
+
typing.Optional[typing.Any],
|
|
2640
|
+
parse_obj_as(
|
|
2641
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2642
|
+
object_=_response.json(),
|
|
2643
|
+
),
|
|
2644
|
+
),
|
|
2645
|
+
)
|
|
2646
|
+
if _response.status_code == 422:
|
|
2647
|
+
raise UnprocessableEntityError(
|
|
2648
|
+
headers=dict(_response.headers),
|
|
2649
|
+
body=typing.cast(
|
|
2650
|
+
typing.Optional[typing.Any],
|
|
2651
|
+
parse_obj_as(
|
|
2652
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2653
|
+
object_=_response.json(),
|
|
2654
|
+
),
|
|
2655
|
+
),
|
|
2656
|
+
)
|
|
2657
|
+
if _response.status_code == 503:
|
|
2658
|
+
raise ServiceUnavailableError(
|
|
2659
|
+
headers=dict(_response.headers),
|
|
2660
|
+
body=typing.cast(
|
|
2661
|
+
typing.Optional[typing.Any],
|
|
2662
|
+
parse_obj_as(
|
|
2663
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2664
|
+
object_=_response.json(),
|
|
2665
|
+
),
|
|
2666
|
+
),
|
|
2667
|
+
)
|
|
2668
|
+
_response_json = _response.json()
|
|
2669
|
+
except JSONDecodeError:
|
|
2670
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2671
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2672
|
+
|
|
2673
|
+
async def create_collateral_market_order(
|
|
2674
|
+
self,
|
|
2675
|
+
*,
|
|
2676
|
+
market: str,
|
|
2677
|
+
side: CreateCollateralMarketOrderRequestSide,
|
|
2678
|
+
amount: str,
|
|
2679
|
+
request: str,
|
|
2680
|
+
nonce: str,
|
|
2681
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
2682
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
2683
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
2684
|
+
position_side: typing.Optional[CreateCollateralMarketOrderRequestPositionSide] = OMIT,
|
|
2685
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2686
|
+
) -> AsyncHttpResponse[CreateCollateralMarketOrderResponse]:
|
|
2687
|
+
"""
|
|
2688
|
+
The endpoint creates a collateral market order.
|
|
2689
|
+
|
|
2690
|
+
<Warning>
|
|
2691
|
+
Rate limit: 10000 requests/10 sec.
|
|
2692
|
+
</Warning>
|
|
2693
|
+
|
|
2694
|
+
Parameters
|
|
2695
|
+
----------
|
|
2696
|
+
market : str
|
|
2697
|
+
|
|
2698
|
+
side : CreateCollateralMarketOrderRequestSide
|
|
2699
|
+
|
|
2700
|
+
amount : str
|
|
2701
|
+
|
|
2702
|
+
request : str
|
|
2703
|
+
|
|
2704
|
+
nonce : str
|
|
2705
|
+
|
|
2706
|
+
client_order_id : typing.Optional[str]
|
|
2707
|
+
|
|
2708
|
+
stop_loss : typing.Optional[str]
|
|
2709
|
+
|
|
2710
|
+
take_profit : typing.Optional[str]
|
|
2711
|
+
|
|
2712
|
+
position_side : typing.Optional[CreateCollateralMarketOrderRequestPositionSide]
|
|
2713
|
+
|
|
2714
|
+
request_options : typing.Optional[RequestOptions]
|
|
2715
|
+
Request-specific configuration.
|
|
2716
|
+
|
|
2717
|
+
Returns
|
|
2718
|
+
-------
|
|
2719
|
+
AsyncHttpResponse[CreateCollateralMarketOrderResponse]
|
|
2720
|
+
Successful response - market order created
|
|
2721
|
+
"""
|
|
2722
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2723
|
+
"api/v4/order/collateral/market",
|
|
2724
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2725
|
+
method="POST",
|
|
2726
|
+
json={
|
|
2727
|
+
"market": market,
|
|
2728
|
+
"side": side,
|
|
2729
|
+
"amount": amount,
|
|
2730
|
+
"clientOrderId": client_order_id,
|
|
2731
|
+
"stopLoss": stop_loss,
|
|
2732
|
+
"takeProfit": take_profit,
|
|
2733
|
+
"positionSide": position_side,
|
|
2734
|
+
"request": request,
|
|
2735
|
+
"nonce": nonce,
|
|
2736
|
+
},
|
|
2737
|
+
headers={
|
|
2738
|
+
"content-type": "application/json",
|
|
2739
|
+
},
|
|
2740
|
+
request_options=request_options,
|
|
2741
|
+
omit=OMIT,
|
|
2742
|
+
)
|
|
2743
|
+
try:
|
|
2744
|
+
if 200 <= _response.status_code < 300:
|
|
2745
|
+
_data = typing.cast(
|
|
2746
|
+
CreateCollateralMarketOrderResponse,
|
|
2747
|
+
parse_obj_as(
|
|
2748
|
+
type_=CreateCollateralMarketOrderResponse, # type: ignore
|
|
2749
|
+
object_=_response.json(),
|
|
2750
|
+
),
|
|
2751
|
+
)
|
|
2752
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2753
|
+
if _response.status_code == 422:
|
|
2754
|
+
raise UnprocessableEntityError(
|
|
2755
|
+
headers=dict(_response.headers),
|
|
2756
|
+
body=typing.cast(
|
|
2757
|
+
typing.Optional[typing.Any],
|
|
2758
|
+
parse_obj_as(
|
|
2759
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2760
|
+
object_=_response.json(),
|
|
2761
|
+
),
|
|
2762
|
+
),
|
|
2763
|
+
)
|
|
2764
|
+
if _response.status_code == 503:
|
|
2765
|
+
raise ServiceUnavailableError(
|
|
2766
|
+
headers=dict(_response.headers),
|
|
2767
|
+
body=typing.cast(
|
|
2768
|
+
typing.Optional[typing.Any],
|
|
2769
|
+
parse_obj_as(
|
|
2770
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2771
|
+
object_=_response.json(),
|
|
2772
|
+
),
|
|
2773
|
+
),
|
|
2774
|
+
)
|
|
2775
|
+
_response_json = _response.json()
|
|
2776
|
+
except JSONDecodeError:
|
|
2777
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2778
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2779
|
+
|
|
2780
|
+
async def create_collateral_stop_limit_order(
|
|
2781
|
+
self,
|
|
2782
|
+
*,
|
|
2783
|
+
market: str,
|
|
2784
|
+
side: CreateCollateralStopLimitOrderRequestSide,
|
|
2785
|
+
amount: str,
|
|
2786
|
+
price: str,
|
|
2787
|
+
activation_price: str,
|
|
2788
|
+
request: str,
|
|
2789
|
+
nonce: str,
|
|
2790
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
2791
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
2792
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
2793
|
+
position_side: typing.Optional[CreateCollateralStopLimitOrderRequestPositionSide] = OMIT,
|
|
2794
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2795
|
+
) -> AsyncHttpResponse[CreateCollateralStopLimitOrderResponse]:
|
|
2796
|
+
"""
|
|
2797
|
+
The endpoint creates a collateral stop-limit order.
|
|
2798
|
+
|
|
2799
|
+
<Warning>
|
|
2800
|
+
Rate limit: 10000 requests/10 sec.
|
|
2801
|
+
</Warning>
|
|
2802
|
+
|
|
2803
|
+
Parameters
|
|
2804
|
+
----------
|
|
2805
|
+
market : str
|
|
2806
|
+
|
|
2807
|
+
side : CreateCollateralStopLimitOrderRequestSide
|
|
2808
|
+
|
|
2809
|
+
amount : str
|
|
2810
|
+
|
|
2811
|
+
price : str
|
|
2812
|
+
|
|
2813
|
+
activation_price : str
|
|
2814
|
+
|
|
2815
|
+
request : str
|
|
2816
|
+
|
|
2817
|
+
nonce : str
|
|
2818
|
+
|
|
2819
|
+
stop_loss : typing.Optional[str]
|
|
2820
|
+
|
|
2821
|
+
take_profit : typing.Optional[str]
|
|
2822
|
+
|
|
2823
|
+
client_order_id : typing.Optional[str]
|
|
2824
|
+
|
|
2825
|
+
position_side : typing.Optional[CreateCollateralStopLimitOrderRequestPositionSide]
|
|
2826
|
+
|
|
2827
|
+
request_options : typing.Optional[RequestOptions]
|
|
2828
|
+
Request-specific configuration.
|
|
2829
|
+
|
|
2830
|
+
Returns
|
|
2831
|
+
-------
|
|
2832
|
+
AsyncHttpResponse[CreateCollateralStopLimitOrderResponse]
|
|
2833
|
+
Successful response - stop-limit order created
|
|
2834
|
+
"""
|
|
2835
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2836
|
+
"api/v4/order/collateral/stop-limit",
|
|
2837
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2838
|
+
method="POST",
|
|
2839
|
+
json={
|
|
2840
|
+
"market": market,
|
|
2841
|
+
"side": side,
|
|
2842
|
+
"amount": amount,
|
|
2843
|
+
"price": price,
|
|
2844
|
+
"activation_price": activation_price,
|
|
2845
|
+
"stopLoss": stop_loss,
|
|
2846
|
+
"takeProfit": take_profit,
|
|
2847
|
+
"clientOrderId": client_order_id,
|
|
2848
|
+
"positionSide": position_side,
|
|
2849
|
+
"request": request,
|
|
2850
|
+
"nonce": nonce,
|
|
2851
|
+
},
|
|
2852
|
+
headers={
|
|
2853
|
+
"content-type": "application/json",
|
|
2854
|
+
},
|
|
2855
|
+
request_options=request_options,
|
|
2856
|
+
omit=OMIT,
|
|
2857
|
+
)
|
|
2858
|
+
try:
|
|
2859
|
+
if 200 <= _response.status_code < 300:
|
|
2860
|
+
_data = typing.cast(
|
|
2861
|
+
CreateCollateralStopLimitOrderResponse,
|
|
2862
|
+
parse_obj_as(
|
|
2863
|
+
type_=CreateCollateralStopLimitOrderResponse, # type: ignore
|
|
2864
|
+
object_=_response.json(),
|
|
2865
|
+
),
|
|
2866
|
+
)
|
|
2867
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2868
|
+
if _response.status_code == 400:
|
|
2869
|
+
raise BadRequestError(
|
|
2870
|
+
headers=dict(_response.headers),
|
|
2871
|
+
body=typing.cast(
|
|
2872
|
+
typing.Optional[typing.Any],
|
|
2873
|
+
parse_obj_as(
|
|
2874
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2875
|
+
object_=_response.json(),
|
|
2876
|
+
),
|
|
2877
|
+
),
|
|
2878
|
+
)
|
|
2879
|
+
if _response.status_code == 422:
|
|
2880
|
+
raise UnprocessableEntityError(
|
|
2881
|
+
headers=dict(_response.headers),
|
|
2882
|
+
body=typing.cast(
|
|
2883
|
+
typing.Optional[typing.Any],
|
|
2884
|
+
parse_obj_as(
|
|
2885
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2886
|
+
object_=_response.json(),
|
|
2887
|
+
),
|
|
2888
|
+
),
|
|
2889
|
+
)
|
|
2890
|
+
if _response.status_code == 503:
|
|
2891
|
+
raise ServiceUnavailableError(
|
|
2892
|
+
headers=dict(_response.headers),
|
|
2893
|
+
body=typing.cast(
|
|
2894
|
+
typing.Optional[typing.Any],
|
|
2895
|
+
parse_obj_as(
|
|
2896
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2897
|
+
object_=_response.json(),
|
|
2898
|
+
),
|
|
2899
|
+
),
|
|
2900
|
+
)
|
|
2901
|
+
_response_json = _response.json()
|
|
2902
|
+
except JSONDecodeError:
|
|
2903
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2904
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2905
|
+
|
|
2906
|
+
async def create_collateral_trigger_market_order(
|
|
2907
|
+
self,
|
|
2908
|
+
*,
|
|
2909
|
+
market: str,
|
|
2910
|
+
side: CreateCollateralTriggerMarketOrderRequestSide,
|
|
2911
|
+
amount: str,
|
|
2912
|
+
activation_price: str,
|
|
2913
|
+
request: str,
|
|
2914
|
+
nonce: str,
|
|
2915
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
2916
|
+
stop_loss: typing.Optional[str] = OMIT,
|
|
2917
|
+
take_profit: typing.Optional[str] = OMIT,
|
|
2918
|
+
position_side: typing.Optional[CreateCollateralTriggerMarketOrderRequestPositionSide] = OMIT,
|
|
2919
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2920
|
+
) -> AsyncHttpResponse[CreateCollateralTriggerMarketOrderResponse]:
|
|
2921
|
+
"""
|
|
2922
|
+
The endpoint creates a collateral trigger market order.
|
|
2923
|
+
|
|
2924
|
+
<Warning>
|
|
2925
|
+
Rate limit: 10000 requests/10 sec.
|
|
2926
|
+
</Warning>
|
|
2927
|
+
|
|
2928
|
+
Parameters
|
|
2929
|
+
----------
|
|
2930
|
+
market : str
|
|
2931
|
+
|
|
2932
|
+
side : CreateCollateralTriggerMarketOrderRequestSide
|
|
2933
|
+
|
|
2934
|
+
amount : str
|
|
2935
|
+
|
|
2936
|
+
activation_price : str
|
|
2937
|
+
|
|
2938
|
+
request : str
|
|
2939
|
+
|
|
2940
|
+
nonce : str
|
|
2941
|
+
|
|
2942
|
+
client_order_id : typing.Optional[str]
|
|
2943
|
+
|
|
2944
|
+
stop_loss : typing.Optional[str]
|
|
2945
|
+
|
|
2946
|
+
take_profit : typing.Optional[str]
|
|
2947
|
+
|
|
2948
|
+
position_side : typing.Optional[CreateCollateralTriggerMarketOrderRequestPositionSide]
|
|
2949
|
+
|
|
2950
|
+
request_options : typing.Optional[RequestOptions]
|
|
2951
|
+
Request-specific configuration.
|
|
2952
|
+
|
|
2953
|
+
Returns
|
|
2954
|
+
-------
|
|
2955
|
+
AsyncHttpResponse[CreateCollateralTriggerMarketOrderResponse]
|
|
2956
|
+
Successful response - trigger market order created
|
|
2957
|
+
"""
|
|
2958
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2959
|
+
"api/v4/order/collateral/trigger-market",
|
|
2960
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
2961
|
+
method="POST",
|
|
2962
|
+
json={
|
|
2963
|
+
"market": market,
|
|
2964
|
+
"side": side,
|
|
2965
|
+
"amount": amount,
|
|
2966
|
+
"activation_price": activation_price,
|
|
2967
|
+
"clientOrderId": client_order_id,
|
|
2968
|
+
"stopLoss": stop_loss,
|
|
2969
|
+
"takeProfit": take_profit,
|
|
2970
|
+
"positionSide": position_side,
|
|
2971
|
+
"request": request,
|
|
2972
|
+
"nonce": nonce,
|
|
2973
|
+
},
|
|
2974
|
+
headers={
|
|
2975
|
+
"content-type": "application/json",
|
|
2976
|
+
},
|
|
2977
|
+
request_options=request_options,
|
|
2978
|
+
omit=OMIT,
|
|
2979
|
+
)
|
|
2980
|
+
try:
|
|
2981
|
+
if 200 <= _response.status_code < 300:
|
|
2982
|
+
_data = typing.cast(
|
|
2983
|
+
CreateCollateralTriggerMarketOrderResponse,
|
|
2984
|
+
parse_obj_as(
|
|
2985
|
+
type_=CreateCollateralTriggerMarketOrderResponse, # type: ignore
|
|
2986
|
+
object_=_response.json(),
|
|
2987
|
+
),
|
|
2988
|
+
)
|
|
2989
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2990
|
+
if _response.status_code == 422:
|
|
2991
|
+
raise UnprocessableEntityError(
|
|
2992
|
+
headers=dict(_response.headers),
|
|
2993
|
+
body=typing.cast(
|
|
2994
|
+
typing.Optional[typing.Any],
|
|
2995
|
+
parse_obj_as(
|
|
2996
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
2997
|
+
object_=_response.json(),
|
|
2998
|
+
),
|
|
2999
|
+
),
|
|
3000
|
+
)
|
|
3001
|
+
if _response.status_code == 503:
|
|
3002
|
+
raise ServiceUnavailableError(
|
|
3003
|
+
headers=dict(_response.headers),
|
|
3004
|
+
body=typing.cast(
|
|
3005
|
+
typing.Optional[typing.Any],
|
|
3006
|
+
parse_obj_as(
|
|
3007
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3008
|
+
object_=_response.json(),
|
|
3009
|
+
),
|
|
3010
|
+
),
|
|
3011
|
+
)
|
|
3012
|
+
_response_json = _response.json()
|
|
3013
|
+
except JSONDecodeError:
|
|
3014
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3015
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3016
|
+
|
|
3017
|
+
async def collateral_account_summary(
|
|
3018
|
+
self,
|
|
3019
|
+
*,
|
|
3020
|
+
request: typing.Optional[str] = OMIT,
|
|
3021
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3022
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3023
|
+
) -> AsyncHttpResponse[CollateralAccountSummaryResponse]:
|
|
3024
|
+
"""
|
|
3025
|
+
The endpoint retrieves collateral account summary.
|
|
3026
|
+
|
|
3027
|
+
<Warning>
|
|
3028
|
+
Rate limit: 12000 requests/10 sec.
|
|
3029
|
+
</Warning>
|
|
3030
|
+
|
|
3031
|
+
Parameters
|
|
3032
|
+
----------
|
|
3033
|
+
request : typing.Optional[str]
|
|
3034
|
+
|
|
3035
|
+
nonce : typing.Optional[str]
|
|
3036
|
+
|
|
3037
|
+
request_options : typing.Optional[RequestOptions]
|
|
3038
|
+
Request-specific configuration.
|
|
3039
|
+
|
|
3040
|
+
Returns
|
|
3041
|
+
-------
|
|
3042
|
+
AsyncHttpResponse[CollateralAccountSummaryResponse]
|
|
3043
|
+
Successful response - returns collateral account summary
|
|
3044
|
+
"""
|
|
3045
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3046
|
+
"api/v4/collateral-account/summary",
|
|
3047
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3048
|
+
method="POST",
|
|
3049
|
+
json={
|
|
3050
|
+
"request": request,
|
|
3051
|
+
"nonce": nonce,
|
|
3052
|
+
},
|
|
3053
|
+
headers={
|
|
3054
|
+
"content-type": "application/json",
|
|
3055
|
+
},
|
|
3056
|
+
request_options=request_options,
|
|
3057
|
+
omit=OMIT,
|
|
3058
|
+
)
|
|
3059
|
+
try:
|
|
3060
|
+
if 200 <= _response.status_code < 300:
|
|
3061
|
+
_data = typing.cast(
|
|
3062
|
+
CollateralAccountSummaryResponse,
|
|
3063
|
+
parse_obj_as(
|
|
3064
|
+
type_=CollateralAccountSummaryResponse, # type: ignore
|
|
3065
|
+
object_=_response.json(),
|
|
3066
|
+
),
|
|
3067
|
+
)
|
|
3068
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3069
|
+
if _response.status_code == 422:
|
|
3070
|
+
raise UnprocessableEntityError(
|
|
3071
|
+
headers=dict(_response.headers),
|
|
3072
|
+
body=typing.cast(
|
|
3073
|
+
typing.Optional[typing.Any],
|
|
3074
|
+
parse_obj_as(
|
|
3075
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3076
|
+
object_=_response.json(),
|
|
3077
|
+
),
|
|
3078
|
+
),
|
|
3079
|
+
)
|
|
3080
|
+
if _response.status_code == 503:
|
|
3081
|
+
raise ServiceUnavailableError(
|
|
3082
|
+
headers=dict(_response.headers),
|
|
3083
|
+
body=typing.cast(
|
|
3084
|
+
typing.Optional[typing.Any],
|
|
3085
|
+
parse_obj_as(
|
|
3086
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3087
|
+
object_=_response.json(),
|
|
3088
|
+
),
|
|
3089
|
+
),
|
|
3090
|
+
)
|
|
3091
|
+
_response_json = _response.json()
|
|
3092
|
+
except JSONDecodeError:
|
|
3093
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3094
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3095
|
+
|
|
3096
|
+
async def get_open_positions(
|
|
3097
|
+
self,
|
|
3098
|
+
*,
|
|
3099
|
+
market: typing.Optional[str] = OMIT,
|
|
3100
|
+
request: typing.Optional[str] = OMIT,
|
|
3101
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3102
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3103
|
+
) -> AsyncHttpResponse[typing.List[GetOpenPositionsResponseItem]]:
|
|
3104
|
+
"""
|
|
3105
|
+
The endpoint retrieves open positions.
|
|
3106
|
+
|
|
3107
|
+
<Warning>
|
|
3108
|
+
Rate limit: 12000 requests/10 sec.
|
|
3109
|
+
</Warning>
|
|
3110
|
+
|
|
3111
|
+
Parameters
|
|
3112
|
+
----------
|
|
3113
|
+
market : typing.Optional[str]
|
|
3114
|
+
Filter by specific market. For example: BTC_USDT
|
|
3115
|
+
|
|
3116
|
+
If not specified, returns all open positions.
|
|
3117
|
+
|
|
3118
|
+
request : typing.Optional[str]
|
|
3119
|
+
Request signature
|
|
3120
|
+
|
|
3121
|
+
nonce : typing.Optional[str]
|
|
3122
|
+
Unique request identifier
|
|
3123
|
+
|
|
3124
|
+
request_options : typing.Optional[RequestOptions]
|
|
3125
|
+
Request-specific configuration.
|
|
3126
|
+
|
|
3127
|
+
Returns
|
|
3128
|
+
-------
|
|
3129
|
+
AsyncHttpResponse[typing.List[GetOpenPositionsResponseItem]]
|
|
3130
|
+
Successful response - returns array of open positions
|
|
3131
|
+
"""
|
|
3132
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3133
|
+
"api/v4/collateral-account/positions",
|
|
3134
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3135
|
+
method="POST",
|
|
3136
|
+
json={
|
|
3137
|
+
"market": market,
|
|
3138
|
+
"request": request,
|
|
3139
|
+
"nonce": nonce,
|
|
3140
|
+
},
|
|
3141
|
+
headers={
|
|
3142
|
+
"content-type": "application/json",
|
|
3143
|
+
},
|
|
3144
|
+
request_options=request_options,
|
|
3145
|
+
omit=OMIT,
|
|
3146
|
+
)
|
|
3147
|
+
try:
|
|
3148
|
+
if 200 <= _response.status_code < 300:
|
|
3149
|
+
_data = typing.cast(
|
|
3150
|
+
typing.List[GetOpenPositionsResponseItem],
|
|
3151
|
+
parse_obj_as(
|
|
3152
|
+
type_=typing.List[GetOpenPositionsResponseItem], # type: ignore
|
|
3153
|
+
object_=_response.json(),
|
|
3154
|
+
),
|
|
3155
|
+
)
|
|
3156
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3157
|
+
if _response.status_code == 422:
|
|
3158
|
+
raise UnprocessableEntityError(
|
|
3159
|
+
headers=dict(_response.headers),
|
|
3160
|
+
body=typing.cast(
|
|
3161
|
+
typing.Optional[typing.Any],
|
|
3162
|
+
parse_obj_as(
|
|
3163
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3164
|
+
object_=_response.json(),
|
|
3165
|
+
),
|
|
3166
|
+
),
|
|
3167
|
+
)
|
|
3168
|
+
if _response.status_code == 503:
|
|
3169
|
+
raise ServiceUnavailableError(
|
|
3170
|
+
headers=dict(_response.headers),
|
|
3171
|
+
body=typing.cast(
|
|
3172
|
+
typing.Optional[typing.Any],
|
|
3173
|
+
parse_obj_as(
|
|
3174
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3175
|
+
object_=_response.json(),
|
|
3176
|
+
),
|
|
3177
|
+
),
|
|
3178
|
+
)
|
|
3179
|
+
_response_json = _response.json()
|
|
3180
|
+
except JSONDecodeError:
|
|
3181
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3182
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3183
|
+
|
|
3184
|
+
async def close_position(
|
|
3185
|
+
self,
|
|
3186
|
+
*,
|
|
3187
|
+
position_id: int,
|
|
3188
|
+
market: str,
|
|
3189
|
+
request: str,
|
|
3190
|
+
nonce: str,
|
|
3191
|
+
position_side: typing.Optional[ClosePositionRequestPositionSide] = OMIT,
|
|
3192
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3193
|
+
) -> AsyncHttpResponse[None]:
|
|
3194
|
+
"""
|
|
3195
|
+
The endpoint closes a position.
|
|
3196
|
+
|
|
3197
|
+
<Warning>
|
|
3198
|
+
Rate limit: 10000 requests/10 sec.
|
|
3199
|
+
</Warning>
|
|
3200
|
+
|
|
3201
|
+
Parameters
|
|
3202
|
+
----------
|
|
3203
|
+
position_id : int
|
|
3204
|
+
|
|
3205
|
+
market : str
|
|
3206
|
+
|
|
3207
|
+
request : str
|
|
3208
|
+
|
|
3209
|
+
nonce : str
|
|
3210
|
+
|
|
3211
|
+
position_side : typing.Optional[ClosePositionRequestPositionSide]
|
|
3212
|
+
|
|
3213
|
+
request_options : typing.Optional[RequestOptions]
|
|
3214
|
+
Request-specific configuration.
|
|
3215
|
+
|
|
3216
|
+
Returns
|
|
3217
|
+
-------
|
|
3218
|
+
AsyncHttpResponse[None]
|
|
3219
|
+
"""
|
|
3220
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3221
|
+
"api/v4/collateral-account/position/close",
|
|
3222
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3223
|
+
method="POST",
|
|
3224
|
+
json={
|
|
3225
|
+
"positionId": position_id,
|
|
3226
|
+
"positionSide": position_side,
|
|
3227
|
+
"market": market,
|
|
3228
|
+
"request": request,
|
|
3229
|
+
"nonce": nonce,
|
|
3230
|
+
},
|
|
3231
|
+
headers={
|
|
3232
|
+
"content-type": "application/json",
|
|
3233
|
+
},
|
|
3234
|
+
request_options=request_options,
|
|
3235
|
+
omit=OMIT,
|
|
3236
|
+
)
|
|
3237
|
+
try:
|
|
3238
|
+
if 200 <= _response.status_code < 300:
|
|
3239
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
3240
|
+
if _response.status_code == 400:
|
|
3241
|
+
raise BadRequestError(
|
|
3242
|
+
headers=dict(_response.headers),
|
|
3243
|
+
body=typing.cast(
|
|
3244
|
+
typing.Optional[typing.Any],
|
|
3245
|
+
parse_obj_as(
|
|
3246
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3247
|
+
object_=_response.json(),
|
|
3248
|
+
),
|
|
3249
|
+
),
|
|
3250
|
+
)
|
|
3251
|
+
if _response.status_code == 422:
|
|
3252
|
+
raise UnprocessableEntityError(
|
|
3253
|
+
headers=dict(_response.headers),
|
|
3254
|
+
body=typing.cast(
|
|
3255
|
+
typing.Optional[typing.Any],
|
|
3256
|
+
parse_obj_as(
|
|
3257
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3258
|
+
object_=_response.json(),
|
|
3259
|
+
),
|
|
3260
|
+
),
|
|
3261
|
+
)
|
|
3262
|
+
if _response.status_code == 500:
|
|
3263
|
+
raise InternalServerError(
|
|
3264
|
+
headers=dict(_response.headers),
|
|
3265
|
+
body=typing.cast(
|
|
3266
|
+
typing.Optional[typing.Any],
|
|
3267
|
+
parse_obj_as(
|
|
3268
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3269
|
+
object_=_response.json(),
|
|
3270
|
+
),
|
|
3271
|
+
),
|
|
3272
|
+
)
|
|
3273
|
+
if _response.status_code == 503:
|
|
3274
|
+
raise ServiceUnavailableError(
|
|
3275
|
+
headers=dict(_response.headers),
|
|
3276
|
+
body=typing.cast(
|
|
3277
|
+
typing.Optional[typing.Any],
|
|
3278
|
+
parse_obj_as(
|
|
3279
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3280
|
+
object_=_response.json(),
|
|
3281
|
+
),
|
|
3282
|
+
),
|
|
3283
|
+
)
|
|
3284
|
+
_response_json = _response.json()
|
|
3285
|
+
except JSONDecodeError:
|
|
3286
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3287
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3288
|
+
|
|
3289
|
+
async def get_positions_history(
|
|
3290
|
+
self,
|
|
3291
|
+
*,
|
|
3292
|
+
market: typing.Optional[str] = OMIT,
|
|
3293
|
+
position_id: typing.Optional[int] = OMIT,
|
|
3294
|
+
request: typing.Optional[str] = OMIT,
|
|
3295
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3296
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3297
|
+
) -> AsyncHttpResponse[typing.List[GetPositionsHistoryResponseItem]]:
|
|
3298
|
+
"""
|
|
3299
|
+
The endpoint retrieves positions history.
|
|
3300
|
+
|
|
3301
|
+
<Warning>
|
|
3302
|
+
Rate limit: 12000 requests/10 sec.
|
|
3303
|
+
</Warning>
|
|
3304
|
+
|
|
3305
|
+
Parameters
|
|
3306
|
+
----------
|
|
3307
|
+
market : typing.Optional[str]
|
|
3308
|
+
|
|
3309
|
+
position_id : typing.Optional[int]
|
|
3310
|
+
|
|
3311
|
+
request : typing.Optional[str]
|
|
3312
|
+
|
|
3313
|
+
nonce : typing.Optional[str]
|
|
3314
|
+
|
|
3315
|
+
request_options : typing.Optional[RequestOptions]
|
|
3316
|
+
Request-specific configuration.
|
|
3317
|
+
|
|
3318
|
+
Returns
|
|
3319
|
+
-------
|
|
3320
|
+
AsyncHttpResponse[typing.List[GetPositionsHistoryResponseItem]]
|
|
3321
|
+
Successful response - returns array of position history
|
|
3322
|
+
"""
|
|
3323
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3324
|
+
"api/v4/collateral-account/positions/history",
|
|
3325
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3326
|
+
method="POST",
|
|
3327
|
+
json={
|
|
3328
|
+
"market": market,
|
|
3329
|
+
"positionId": position_id,
|
|
3330
|
+
"request": request,
|
|
3331
|
+
"nonce": nonce,
|
|
3332
|
+
},
|
|
3333
|
+
headers={
|
|
3334
|
+
"content-type": "application/json",
|
|
3335
|
+
},
|
|
3336
|
+
request_options=request_options,
|
|
3337
|
+
omit=OMIT,
|
|
3338
|
+
)
|
|
3339
|
+
try:
|
|
3340
|
+
if 200 <= _response.status_code < 300:
|
|
3341
|
+
_data = typing.cast(
|
|
3342
|
+
typing.List[GetPositionsHistoryResponseItem],
|
|
3343
|
+
parse_obj_as(
|
|
3344
|
+
type_=typing.List[GetPositionsHistoryResponseItem], # type: ignore
|
|
3345
|
+
object_=_response.json(),
|
|
3346
|
+
),
|
|
3347
|
+
)
|
|
3348
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3349
|
+
if _response.status_code == 400:
|
|
3350
|
+
raise BadRequestError(
|
|
3351
|
+
headers=dict(_response.headers),
|
|
3352
|
+
body=typing.cast(
|
|
3353
|
+
typing.Optional[typing.Any],
|
|
3354
|
+
parse_obj_as(
|
|
3355
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3356
|
+
object_=_response.json(),
|
|
3357
|
+
),
|
|
3358
|
+
),
|
|
3359
|
+
)
|
|
3360
|
+
if _response.status_code == 422:
|
|
3361
|
+
raise UnprocessableEntityError(
|
|
3362
|
+
headers=dict(_response.headers),
|
|
3363
|
+
body=typing.cast(
|
|
3364
|
+
typing.Optional[typing.Any],
|
|
3365
|
+
parse_obj_as(
|
|
3366
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3367
|
+
object_=_response.json(),
|
|
3368
|
+
),
|
|
3369
|
+
),
|
|
3370
|
+
)
|
|
3371
|
+
if _response.status_code == 500:
|
|
3372
|
+
raise InternalServerError(
|
|
3373
|
+
headers=dict(_response.headers),
|
|
3374
|
+
body=typing.cast(
|
|
3375
|
+
typing.Optional[typing.Any],
|
|
3376
|
+
parse_obj_as(
|
|
3377
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3378
|
+
object_=_response.json(),
|
|
3379
|
+
),
|
|
3380
|
+
),
|
|
3381
|
+
)
|
|
3382
|
+
if _response.status_code == 503:
|
|
3383
|
+
raise ServiceUnavailableError(
|
|
3384
|
+
headers=dict(_response.headers),
|
|
3385
|
+
body=typing.cast(
|
|
3386
|
+
typing.Optional[typing.Any],
|
|
3387
|
+
parse_obj_as(
|
|
3388
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3389
|
+
object_=_response.json(),
|
|
3390
|
+
),
|
|
3391
|
+
),
|
|
3392
|
+
)
|
|
3393
|
+
_response_json = _response.json()
|
|
3394
|
+
except JSONDecodeError:
|
|
3395
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3396
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3397
|
+
|
|
3398
|
+
async def get_funding_history(
|
|
3399
|
+
self,
|
|
3400
|
+
*,
|
|
3401
|
+
market: typing.Optional[str] = OMIT,
|
|
3402
|
+
limit: typing.Optional[int] = OMIT,
|
|
3403
|
+
offset: typing.Optional[int] = OMIT,
|
|
3404
|
+
request: typing.Optional[str] = OMIT,
|
|
3405
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3406
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3407
|
+
) -> AsyncHttpResponse[GetFundingHistoryResponse]:
|
|
3408
|
+
"""
|
|
3409
|
+
The endpoint retrieves funding history.
|
|
3410
|
+
|
|
3411
|
+
<Warning>
|
|
3412
|
+
Rate limit: 12000 requests/10 sec.
|
|
3413
|
+
</Warning>
|
|
3414
|
+
|
|
3415
|
+
Parameters
|
|
3416
|
+
----------
|
|
3417
|
+
market : typing.Optional[str]
|
|
3418
|
+
Filter by specific market. For example: BTC_PERP
|
|
3419
|
+
|
|
3420
|
+
If not specified, returns funding history for all markets.
|
|
3421
|
+
|
|
3422
|
+
limit : typing.Optional[int]
|
|
3423
|
+
Number of records to return
|
|
3424
|
+
|
|
3425
|
+
offset : typing.Optional[int]
|
|
3426
|
+
Number of records to skip
|
|
3427
|
+
|
|
3428
|
+
request : typing.Optional[str]
|
|
3429
|
+
Request signature
|
|
3430
|
+
|
|
3431
|
+
nonce : typing.Optional[str]
|
|
3432
|
+
Unique request identifier
|
|
3433
|
+
|
|
3434
|
+
request_options : typing.Optional[RequestOptions]
|
|
3435
|
+
Request-specific configuration.
|
|
3436
|
+
|
|
3437
|
+
Returns
|
|
3438
|
+
-------
|
|
3439
|
+
AsyncHttpResponse[GetFundingHistoryResponse]
|
|
3440
|
+
Successful response - returns paginated funding history
|
|
3441
|
+
"""
|
|
3442
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3443
|
+
"api/v4/collateral-account/funding-history",
|
|
3444
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3445
|
+
method="POST",
|
|
3446
|
+
json={
|
|
3447
|
+
"market": market,
|
|
3448
|
+
"limit": limit,
|
|
3449
|
+
"offset": offset,
|
|
3450
|
+
"request": request,
|
|
3451
|
+
"nonce": nonce,
|
|
3452
|
+
},
|
|
3453
|
+
headers={
|
|
3454
|
+
"content-type": "application/json",
|
|
3455
|
+
},
|
|
3456
|
+
request_options=request_options,
|
|
3457
|
+
omit=OMIT,
|
|
3458
|
+
)
|
|
3459
|
+
try:
|
|
3460
|
+
if 200 <= _response.status_code < 300:
|
|
3461
|
+
_data = typing.cast(
|
|
3462
|
+
GetFundingHistoryResponse,
|
|
3463
|
+
parse_obj_as(
|
|
3464
|
+
type_=GetFundingHistoryResponse, # type: ignore
|
|
3465
|
+
object_=_response.json(),
|
|
3466
|
+
),
|
|
3467
|
+
)
|
|
3468
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3469
|
+
if _response.status_code == 422:
|
|
3470
|
+
raise UnprocessableEntityError(
|
|
3471
|
+
headers=dict(_response.headers),
|
|
3472
|
+
body=typing.cast(
|
|
3473
|
+
typing.Optional[typing.Any],
|
|
3474
|
+
parse_obj_as(
|
|
3475
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3476
|
+
object_=_response.json(),
|
|
3477
|
+
),
|
|
3478
|
+
),
|
|
3479
|
+
)
|
|
3480
|
+
if _response.status_code == 503:
|
|
3481
|
+
raise ServiceUnavailableError(
|
|
3482
|
+
headers=dict(_response.headers),
|
|
3483
|
+
body=typing.cast(
|
|
3484
|
+
typing.Optional[typing.Any],
|
|
3485
|
+
parse_obj_as(
|
|
3486
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3487
|
+
object_=_response.json(),
|
|
3488
|
+
),
|
|
3489
|
+
),
|
|
3490
|
+
)
|
|
3491
|
+
_response_json = _response.json()
|
|
3492
|
+
except JSONDecodeError:
|
|
3493
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3494
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3495
|
+
|
|
3496
|
+
async def change_collateral_account_leverage(
|
|
3497
|
+
self, *, leverage: int, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
3498
|
+
) -> AsyncHttpResponse[ChangeCollateralAccountLeverageResponse]:
|
|
3499
|
+
"""
|
|
3500
|
+
The endpoint changes account leverage.
|
|
3501
|
+
|
|
3502
|
+
<Warning>
|
|
3503
|
+
Rate limit: 1000 requests/10 sec.
|
|
3504
|
+
</Warning>
|
|
3505
|
+
|
|
3506
|
+
Parameters
|
|
3507
|
+
----------
|
|
3508
|
+
leverage : int
|
|
3509
|
+
|
|
3510
|
+
request : str
|
|
3511
|
+
|
|
3512
|
+
nonce : str
|
|
3513
|
+
|
|
3514
|
+
request_options : typing.Optional[RequestOptions]
|
|
3515
|
+
Request-specific configuration.
|
|
3516
|
+
|
|
3517
|
+
Returns
|
|
3518
|
+
-------
|
|
3519
|
+
AsyncHttpResponse[ChangeCollateralAccountLeverageResponse]
|
|
3520
|
+
Successful response - leverage changed
|
|
3521
|
+
"""
|
|
3522
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3523
|
+
"api/v4/collateral-account/leverage",
|
|
3524
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3525
|
+
method="POST",
|
|
3526
|
+
json={
|
|
3527
|
+
"leverage": leverage,
|
|
3528
|
+
"request": request,
|
|
3529
|
+
"nonce": nonce,
|
|
3530
|
+
},
|
|
3531
|
+
headers={
|
|
3532
|
+
"content-type": "application/json",
|
|
3533
|
+
},
|
|
3534
|
+
request_options=request_options,
|
|
3535
|
+
omit=OMIT,
|
|
3536
|
+
)
|
|
3537
|
+
try:
|
|
3538
|
+
if 200 <= _response.status_code < 300:
|
|
3539
|
+
_data = typing.cast(
|
|
3540
|
+
ChangeCollateralAccountLeverageResponse,
|
|
3541
|
+
parse_obj_as(
|
|
3542
|
+
type_=ChangeCollateralAccountLeverageResponse, # type: ignore
|
|
3543
|
+
object_=_response.json(),
|
|
3544
|
+
),
|
|
3545
|
+
)
|
|
3546
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3547
|
+
if _response.status_code == 422:
|
|
3548
|
+
raise UnprocessableEntityError(
|
|
3549
|
+
headers=dict(_response.headers),
|
|
3550
|
+
body=typing.cast(
|
|
3551
|
+
typing.Optional[typing.Any],
|
|
3552
|
+
parse_obj_as(
|
|
3553
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3554
|
+
object_=_response.json(),
|
|
3555
|
+
),
|
|
3556
|
+
),
|
|
3557
|
+
)
|
|
3558
|
+
if _response.status_code == 503:
|
|
3559
|
+
raise ServiceUnavailableError(
|
|
3560
|
+
headers=dict(_response.headers),
|
|
3561
|
+
body=typing.cast(
|
|
3562
|
+
typing.Optional[typing.Any],
|
|
3563
|
+
parse_obj_as(
|
|
3564
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3565
|
+
object_=_response.json(),
|
|
3566
|
+
),
|
|
3567
|
+
),
|
|
3568
|
+
)
|
|
3569
|
+
_response_json = _response.json()
|
|
3570
|
+
except JSONDecodeError:
|
|
3571
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3572
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3573
|
+
|
|
3574
|
+
async def get_collateral_hedge_mode(
|
|
3575
|
+
self,
|
|
3576
|
+
*,
|
|
3577
|
+
request: typing.Optional[str] = OMIT,
|
|
3578
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3579
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3580
|
+
) -> AsyncHttpResponse[GetCollateralHedgeModeResponse]:
|
|
3581
|
+
"""
|
|
3582
|
+
The endpoint retrieves hedge mode status.
|
|
3583
|
+
|
|
3584
|
+
<Warning>
|
|
3585
|
+
Rate limit: 12000 requests/10 sec.
|
|
3586
|
+
</Warning>
|
|
3587
|
+
|
|
3588
|
+
Parameters
|
|
3589
|
+
----------
|
|
3590
|
+
request : typing.Optional[str]
|
|
3591
|
+
|
|
3592
|
+
nonce : typing.Optional[str]
|
|
3593
|
+
|
|
3594
|
+
request_options : typing.Optional[RequestOptions]
|
|
3595
|
+
Request-specific configuration.
|
|
3596
|
+
|
|
3597
|
+
Returns
|
|
3598
|
+
-------
|
|
3599
|
+
AsyncHttpResponse[GetCollateralHedgeModeResponse]
|
|
3600
|
+
Successful response - returns hedge mode status
|
|
3601
|
+
"""
|
|
3602
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3603
|
+
"api/v4/collateral-account/hedge-mode",
|
|
3604
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3605
|
+
method="POST",
|
|
3606
|
+
json={
|
|
3607
|
+
"request": request,
|
|
3608
|
+
"nonce": nonce,
|
|
3609
|
+
},
|
|
3610
|
+
headers={
|
|
3611
|
+
"content-type": "application/json",
|
|
3612
|
+
},
|
|
3613
|
+
request_options=request_options,
|
|
3614
|
+
omit=OMIT,
|
|
3615
|
+
)
|
|
3616
|
+
try:
|
|
3617
|
+
if 200 <= _response.status_code < 300:
|
|
3618
|
+
_data = typing.cast(
|
|
3619
|
+
GetCollateralHedgeModeResponse,
|
|
3620
|
+
parse_obj_as(
|
|
3621
|
+
type_=GetCollateralHedgeModeResponse, # type: ignore
|
|
3622
|
+
object_=_response.json(),
|
|
3623
|
+
),
|
|
3624
|
+
)
|
|
3625
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3626
|
+
if _response.status_code == 422:
|
|
3627
|
+
raise UnprocessableEntityError(
|
|
3628
|
+
headers=dict(_response.headers),
|
|
3629
|
+
body=typing.cast(
|
|
3630
|
+
typing.Optional[typing.Any],
|
|
3631
|
+
parse_obj_as(
|
|
3632
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3633
|
+
object_=_response.json(),
|
|
3634
|
+
),
|
|
3635
|
+
),
|
|
3636
|
+
)
|
|
3637
|
+
if _response.status_code == 500:
|
|
3638
|
+
raise InternalServerError(
|
|
3639
|
+
headers=dict(_response.headers),
|
|
3640
|
+
body=typing.cast(
|
|
3641
|
+
typing.Optional[typing.Any],
|
|
3642
|
+
parse_obj_as(
|
|
3643
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3644
|
+
object_=_response.json(),
|
|
3645
|
+
),
|
|
3646
|
+
),
|
|
3647
|
+
)
|
|
3648
|
+
if _response.status_code == 503:
|
|
3649
|
+
raise ServiceUnavailableError(
|
|
3650
|
+
headers=dict(_response.headers),
|
|
3651
|
+
body=typing.cast(
|
|
3652
|
+
typing.Optional[typing.Any],
|
|
3653
|
+
parse_obj_as(
|
|
3654
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3655
|
+
object_=_response.json(),
|
|
3656
|
+
),
|
|
3657
|
+
),
|
|
3658
|
+
)
|
|
3659
|
+
_response_json = _response.json()
|
|
3660
|
+
except JSONDecodeError:
|
|
3661
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3662
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3663
|
+
|
|
3664
|
+
async def update_hedge_mode(
|
|
3665
|
+
self, *, hedge_mode: bool, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
3666
|
+
) -> AsyncHttpResponse[None]:
|
|
3667
|
+
"""
|
|
3668
|
+
The endpoint updates hedge mode.
|
|
3669
|
+
|
|
3670
|
+
<Warning>
|
|
3671
|
+
Rate limit: 1000 requests/10 sec.
|
|
3672
|
+
</Warning>
|
|
3673
|
+
|
|
3674
|
+
Parameters
|
|
3675
|
+
----------
|
|
3676
|
+
hedge_mode : bool
|
|
3677
|
+
|
|
3678
|
+
request : str
|
|
3679
|
+
|
|
3680
|
+
nonce : str
|
|
3681
|
+
|
|
3682
|
+
request_options : typing.Optional[RequestOptions]
|
|
3683
|
+
Request-specific configuration.
|
|
3684
|
+
|
|
3685
|
+
Returns
|
|
3686
|
+
-------
|
|
3687
|
+
AsyncHttpResponse[None]
|
|
3688
|
+
"""
|
|
3689
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3690
|
+
"api/v4/collateral-account/hedge-mode/update",
|
|
3691
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3692
|
+
method="POST",
|
|
3693
|
+
json={
|
|
3694
|
+
"hedgeMode": hedge_mode,
|
|
3695
|
+
"request": request,
|
|
3696
|
+
"nonce": nonce,
|
|
3697
|
+
},
|
|
3698
|
+
headers={
|
|
3699
|
+
"content-type": "application/json",
|
|
3700
|
+
},
|
|
3701
|
+
request_options=request_options,
|
|
3702
|
+
omit=OMIT,
|
|
3703
|
+
)
|
|
3704
|
+
try:
|
|
3705
|
+
if 200 <= _response.status_code < 300:
|
|
3706
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
3707
|
+
if _response.status_code == 422:
|
|
3708
|
+
raise UnprocessableEntityError(
|
|
3709
|
+
headers=dict(_response.headers),
|
|
3710
|
+
body=typing.cast(
|
|
3711
|
+
typing.Optional[typing.Any],
|
|
3712
|
+
parse_obj_as(
|
|
3713
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3714
|
+
object_=_response.json(),
|
|
3715
|
+
),
|
|
3716
|
+
),
|
|
3717
|
+
)
|
|
3718
|
+
if _response.status_code == 500:
|
|
3719
|
+
raise InternalServerError(
|
|
3720
|
+
headers=dict(_response.headers),
|
|
3721
|
+
body=typing.cast(
|
|
3722
|
+
typing.Optional[typing.Any],
|
|
3723
|
+
parse_obj_as(
|
|
3724
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3725
|
+
object_=_response.json(),
|
|
3726
|
+
),
|
|
3727
|
+
),
|
|
3728
|
+
)
|
|
3729
|
+
if _response.status_code == 503:
|
|
3730
|
+
raise ServiceUnavailableError(
|
|
3731
|
+
headers=dict(_response.headers),
|
|
3732
|
+
body=typing.cast(
|
|
3733
|
+
typing.Optional[typing.Any],
|
|
3734
|
+
parse_obj_as(
|
|
3735
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3736
|
+
object_=_response.json(),
|
|
3737
|
+
),
|
|
3738
|
+
),
|
|
3739
|
+
)
|
|
3740
|
+
_response_json = _response.json()
|
|
3741
|
+
except JSONDecodeError:
|
|
3742
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3743
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3744
|
+
|
|
3745
|
+
async def get_conditional_orders(
|
|
3746
|
+
self,
|
|
3747
|
+
*,
|
|
3748
|
+
market: typing.Optional[str] = OMIT,
|
|
3749
|
+
offset: typing.Optional[int] = OMIT,
|
|
3750
|
+
limit: typing.Optional[int] = OMIT,
|
|
3751
|
+
request: typing.Optional[str] = OMIT,
|
|
3752
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3753
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3754
|
+
) -> AsyncHttpResponse[GetConditionalOrdersResponse]:
|
|
3755
|
+
"""
|
|
3756
|
+
The endpoint retrieves active conditional orders.
|
|
3757
|
+
|
|
3758
|
+
<Warning>
|
|
3759
|
+
Rate limit: 12000 requests/10 sec.
|
|
3760
|
+
</Warning>
|
|
3761
|
+
|
|
3762
|
+
Parameters
|
|
3763
|
+
----------
|
|
3764
|
+
market : typing.Optional[str]
|
|
3765
|
+
|
|
3766
|
+
offset : typing.Optional[int]
|
|
3767
|
+
|
|
3768
|
+
limit : typing.Optional[int]
|
|
3769
|
+
|
|
3770
|
+
request : typing.Optional[str]
|
|
3771
|
+
|
|
3772
|
+
nonce : typing.Optional[str]
|
|
3773
|
+
|
|
3774
|
+
request_options : typing.Optional[RequestOptions]
|
|
3775
|
+
Request-specific configuration.
|
|
3776
|
+
|
|
3777
|
+
Returns
|
|
3778
|
+
-------
|
|
3779
|
+
AsyncHttpResponse[GetConditionalOrdersResponse]
|
|
3780
|
+
Successful response - returns paginated conditional orders (OCO and OTO types)
|
|
3781
|
+
"""
|
|
3782
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3783
|
+
"api/v4/orders/conditional",
|
|
3784
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3785
|
+
method="POST",
|
|
3786
|
+
json={
|
|
3787
|
+
"market": market,
|
|
3788
|
+
"offset": offset,
|
|
3789
|
+
"limit": limit,
|
|
3790
|
+
"request": request,
|
|
3791
|
+
"nonce": nonce,
|
|
3792
|
+
},
|
|
3793
|
+
headers={
|
|
3794
|
+
"content-type": "application/json",
|
|
3795
|
+
},
|
|
3796
|
+
request_options=request_options,
|
|
3797
|
+
omit=OMIT,
|
|
3798
|
+
)
|
|
3799
|
+
try:
|
|
3800
|
+
if 200 <= _response.status_code < 300:
|
|
3801
|
+
_data = typing.cast(
|
|
3802
|
+
GetConditionalOrdersResponse,
|
|
3803
|
+
parse_obj_as(
|
|
3804
|
+
type_=GetConditionalOrdersResponse, # type: ignore
|
|
3805
|
+
object_=_response.json(),
|
|
3806
|
+
),
|
|
3807
|
+
)
|
|
3808
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3809
|
+
if _response.status_code == 400:
|
|
3810
|
+
raise BadRequestError(
|
|
3811
|
+
headers=dict(_response.headers),
|
|
3812
|
+
body=typing.cast(
|
|
3813
|
+
typing.Optional[typing.Any],
|
|
3814
|
+
parse_obj_as(
|
|
3815
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3816
|
+
object_=_response.json(),
|
|
3817
|
+
),
|
|
3818
|
+
),
|
|
3819
|
+
)
|
|
3820
|
+
if _response.status_code == 422:
|
|
3821
|
+
raise UnprocessableEntityError(
|
|
3822
|
+
headers=dict(_response.headers),
|
|
3823
|
+
body=typing.cast(
|
|
3824
|
+
typing.Optional[typing.Any],
|
|
3825
|
+
parse_obj_as(
|
|
3826
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3827
|
+
object_=_response.json(),
|
|
3828
|
+
),
|
|
3829
|
+
),
|
|
3830
|
+
)
|
|
3831
|
+
if _response.status_code == 503:
|
|
3832
|
+
raise ServiceUnavailableError(
|
|
3833
|
+
headers=dict(_response.headers),
|
|
3834
|
+
body=typing.cast(
|
|
3835
|
+
typing.Optional[typing.Any],
|
|
3836
|
+
parse_obj_as(
|
|
3837
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3838
|
+
object_=_response.json(),
|
|
3839
|
+
),
|
|
3840
|
+
),
|
|
3841
|
+
)
|
|
3842
|
+
_response_json = _response.json()
|
|
3843
|
+
except JSONDecodeError:
|
|
3844
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3845
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3846
|
+
|
|
3847
|
+
async def get_oco_orders(
|
|
3848
|
+
self,
|
|
3849
|
+
*,
|
|
3850
|
+
market: typing.Optional[str] = OMIT,
|
|
3851
|
+
offset: typing.Optional[int] = OMIT,
|
|
3852
|
+
limit: typing.Optional[int] = OMIT,
|
|
3853
|
+
request: typing.Optional[str] = OMIT,
|
|
3854
|
+
nonce: typing.Optional[str] = OMIT,
|
|
3855
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3856
|
+
) -> AsyncHttpResponse[typing.List[GetOcoOrdersResponseItem]]:
|
|
3857
|
+
"""
|
|
3858
|
+
The endpoint retrieves active OCO orders.
|
|
3859
|
+
|
|
3860
|
+
<Warning>
|
|
3861
|
+
Rate limit: 12000 requests/10 sec.
|
|
3862
|
+
</Warning>
|
|
3863
|
+
|
|
3864
|
+
Parameters
|
|
3865
|
+
----------
|
|
3866
|
+
market : typing.Optional[str]
|
|
3867
|
+
|
|
3868
|
+
offset : typing.Optional[int]
|
|
3869
|
+
|
|
3870
|
+
limit : typing.Optional[int]
|
|
3871
|
+
|
|
3872
|
+
request : typing.Optional[str]
|
|
3873
|
+
|
|
3874
|
+
nonce : typing.Optional[str]
|
|
3875
|
+
|
|
3876
|
+
request_options : typing.Optional[RequestOptions]
|
|
3877
|
+
Request-specific configuration.
|
|
3878
|
+
|
|
3879
|
+
Returns
|
|
3880
|
+
-------
|
|
3881
|
+
AsyncHttpResponse[typing.List[GetOcoOrdersResponseItem]]
|
|
3882
|
+
Successful response - returns array of active OCO orders
|
|
3883
|
+
"""
|
|
3884
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3885
|
+
"api/v4/orders/oco",
|
|
3886
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
3887
|
+
method="POST",
|
|
3888
|
+
json={
|
|
3889
|
+
"market": market,
|
|
3890
|
+
"offset": offset,
|
|
3891
|
+
"limit": limit,
|
|
3892
|
+
"request": request,
|
|
3893
|
+
"nonce": nonce,
|
|
3894
|
+
},
|
|
3895
|
+
headers={
|
|
3896
|
+
"content-type": "application/json",
|
|
3897
|
+
},
|
|
3898
|
+
request_options=request_options,
|
|
3899
|
+
omit=OMIT,
|
|
3900
|
+
)
|
|
3901
|
+
try:
|
|
3902
|
+
if 200 <= _response.status_code < 300:
|
|
3903
|
+
_data = typing.cast(
|
|
3904
|
+
typing.List[GetOcoOrdersResponseItem],
|
|
3905
|
+
parse_obj_as(
|
|
3906
|
+
type_=typing.List[GetOcoOrdersResponseItem], # type: ignore
|
|
3907
|
+
object_=_response.json(),
|
|
3908
|
+
),
|
|
3909
|
+
)
|
|
3910
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
3911
|
+
if _response.status_code == 400:
|
|
3912
|
+
raise BadRequestError(
|
|
3913
|
+
headers=dict(_response.headers),
|
|
3914
|
+
body=typing.cast(
|
|
3915
|
+
typing.Optional[typing.Any],
|
|
3916
|
+
parse_obj_as(
|
|
3917
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3918
|
+
object_=_response.json(),
|
|
3919
|
+
),
|
|
3920
|
+
),
|
|
3921
|
+
)
|
|
3922
|
+
if _response.status_code == 422:
|
|
3923
|
+
raise UnprocessableEntityError(
|
|
3924
|
+
headers=dict(_response.headers),
|
|
3925
|
+
body=typing.cast(
|
|
3926
|
+
typing.Optional[typing.Any],
|
|
3927
|
+
parse_obj_as(
|
|
3928
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3929
|
+
object_=_response.json(),
|
|
3930
|
+
),
|
|
3931
|
+
),
|
|
3932
|
+
)
|
|
3933
|
+
if _response.status_code == 503:
|
|
3934
|
+
raise ServiceUnavailableError(
|
|
3935
|
+
headers=dict(_response.headers),
|
|
3936
|
+
body=typing.cast(
|
|
3937
|
+
typing.Optional[typing.Any],
|
|
3938
|
+
parse_obj_as(
|
|
3939
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
3940
|
+
object_=_response.json(),
|
|
3941
|
+
),
|
|
3942
|
+
),
|
|
3943
|
+
)
|
|
3944
|
+
_response_json = _response.json()
|
|
3945
|
+
except JSONDecodeError:
|
|
3946
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
3947
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
3948
|
+
|
|
3949
|
+
async def create_collateral_oco_order(
|
|
3950
|
+
self,
|
|
3951
|
+
*,
|
|
3952
|
+
market: str,
|
|
3953
|
+
side: CreateCollateralOcoOrderRequestSide,
|
|
3954
|
+
amount: str,
|
|
3955
|
+
price: str,
|
|
3956
|
+
activation_price: str,
|
|
3957
|
+
stop_limit_price: str,
|
|
3958
|
+
request: str,
|
|
3959
|
+
nonce: str,
|
|
3960
|
+
client_order_id: typing.Optional[str] = OMIT,
|
|
3961
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
3962
|
+
) -> AsyncHttpResponse[CreateCollateralOcoOrderResponse]:
|
|
3963
|
+
"""
|
|
3964
|
+
The endpoint creates a collateral OCO order.
|
|
3965
|
+
|
|
3966
|
+
<Warning>
|
|
3967
|
+
Rate limit: 10000 requests/10 sec.
|
|
3968
|
+
</Warning>
|
|
3969
|
+
|
|
3970
|
+
Parameters
|
|
3971
|
+
----------
|
|
3972
|
+
market : str
|
|
3973
|
+
|
|
3974
|
+
side : CreateCollateralOcoOrderRequestSide
|
|
3975
|
+
|
|
3976
|
+
amount : str
|
|
3977
|
+
|
|
3978
|
+
price : str
|
|
3979
|
+
|
|
3980
|
+
activation_price : str
|
|
3981
|
+
|
|
3982
|
+
stop_limit_price : str
|
|
3983
|
+
|
|
3984
|
+
request : str
|
|
3985
|
+
|
|
3986
|
+
nonce : str
|
|
3987
|
+
|
|
3988
|
+
client_order_id : typing.Optional[str]
|
|
3989
|
+
|
|
3990
|
+
request_options : typing.Optional[RequestOptions]
|
|
3991
|
+
Request-specific configuration.
|
|
3992
|
+
|
|
3993
|
+
Returns
|
|
3994
|
+
-------
|
|
3995
|
+
AsyncHttpResponse[CreateCollateralOcoOrderResponse]
|
|
3996
|
+
Successful response - OCO order created
|
|
3997
|
+
"""
|
|
3998
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
3999
|
+
"api/v4/order/collateral/oco",
|
|
4000
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
4001
|
+
method="POST",
|
|
4002
|
+
json={
|
|
4003
|
+
"market": market,
|
|
4004
|
+
"side": side,
|
|
4005
|
+
"amount": amount,
|
|
4006
|
+
"price": price,
|
|
4007
|
+
"activation_price": activation_price,
|
|
4008
|
+
"stop_limit_price": stop_limit_price,
|
|
4009
|
+
"clientOrderId": client_order_id,
|
|
4010
|
+
"request": request,
|
|
4011
|
+
"nonce": nonce,
|
|
4012
|
+
},
|
|
4013
|
+
headers={
|
|
4014
|
+
"content-type": "application/json",
|
|
4015
|
+
},
|
|
4016
|
+
request_options=request_options,
|
|
4017
|
+
omit=OMIT,
|
|
4018
|
+
)
|
|
4019
|
+
try:
|
|
4020
|
+
if 200 <= _response.status_code < 300:
|
|
4021
|
+
_data = typing.cast(
|
|
4022
|
+
CreateCollateralOcoOrderResponse,
|
|
4023
|
+
parse_obj_as(
|
|
4024
|
+
type_=CreateCollateralOcoOrderResponse, # type: ignore
|
|
4025
|
+
object_=_response.json(),
|
|
4026
|
+
),
|
|
4027
|
+
)
|
|
4028
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
4029
|
+
if _response.status_code == 400:
|
|
4030
|
+
raise BadRequestError(
|
|
4031
|
+
headers=dict(_response.headers),
|
|
4032
|
+
body=typing.cast(
|
|
4033
|
+
typing.Optional[typing.Any],
|
|
4034
|
+
parse_obj_as(
|
|
4035
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4036
|
+
object_=_response.json(),
|
|
4037
|
+
),
|
|
4038
|
+
),
|
|
4039
|
+
)
|
|
4040
|
+
if _response.status_code == 422:
|
|
4041
|
+
raise UnprocessableEntityError(
|
|
4042
|
+
headers=dict(_response.headers),
|
|
4043
|
+
body=typing.cast(
|
|
4044
|
+
typing.Optional[typing.Any],
|
|
4045
|
+
parse_obj_as(
|
|
4046
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4047
|
+
object_=_response.json(),
|
|
4048
|
+
),
|
|
4049
|
+
),
|
|
4050
|
+
)
|
|
4051
|
+
if _response.status_code == 503:
|
|
4052
|
+
raise ServiceUnavailableError(
|
|
4053
|
+
headers=dict(_response.headers),
|
|
4054
|
+
body=typing.cast(
|
|
4055
|
+
typing.Optional[typing.Any],
|
|
4056
|
+
parse_obj_as(
|
|
4057
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4058
|
+
object_=_response.json(),
|
|
4059
|
+
),
|
|
4060
|
+
),
|
|
4061
|
+
)
|
|
4062
|
+
_response_json = _response.json()
|
|
4063
|
+
except JSONDecodeError:
|
|
4064
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
4065
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
4066
|
+
|
|
4067
|
+
async def cancel_conditional_order(
|
|
4068
|
+
self, *, market: str, id: int, request: str, nonce: str, request_options: typing.Optional[RequestOptions] = None
|
|
4069
|
+
) -> AsyncHttpResponse[None]:
|
|
4070
|
+
"""
|
|
4071
|
+
The endpoint cancels a conditional order.
|
|
4072
|
+
|
|
4073
|
+
<Warning>
|
|
4074
|
+
Rate limit: 10000 requests/10 sec.
|
|
4075
|
+
</Warning>
|
|
4076
|
+
|
|
4077
|
+
Parameters
|
|
4078
|
+
----------
|
|
4079
|
+
market : str
|
|
4080
|
+
|
|
4081
|
+
id : int
|
|
4082
|
+
|
|
4083
|
+
request : str
|
|
4084
|
+
|
|
4085
|
+
nonce : str
|
|
4086
|
+
|
|
4087
|
+
request_options : typing.Optional[RequestOptions]
|
|
4088
|
+
Request-specific configuration.
|
|
4089
|
+
|
|
4090
|
+
Returns
|
|
4091
|
+
-------
|
|
4092
|
+
AsyncHttpResponse[None]
|
|
4093
|
+
"""
|
|
4094
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
4095
|
+
"api/v4/order/conditional-cancel",
|
|
4096
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
4097
|
+
method="POST",
|
|
4098
|
+
json={
|
|
4099
|
+
"market": market,
|
|
4100
|
+
"id": id,
|
|
4101
|
+
"request": request,
|
|
4102
|
+
"nonce": nonce,
|
|
4103
|
+
},
|
|
4104
|
+
headers={
|
|
4105
|
+
"content-type": "application/json",
|
|
4106
|
+
},
|
|
4107
|
+
request_options=request_options,
|
|
4108
|
+
omit=OMIT,
|
|
4109
|
+
)
|
|
4110
|
+
try:
|
|
4111
|
+
if 200 <= _response.status_code < 300:
|
|
4112
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
4113
|
+
if _response.status_code == 400:
|
|
4114
|
+
raise BadRequestError(
|
|
4115
|
+
headers=dict(_response.headers),
|
|
4116
|
+
body=typing.cast(
|
|
4117
|
+
typing.Optional[typing.Any],
|
|
4118
|
+
parse_obj_as(
|
|
4119
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4120
|
+
object_=_response.json(),
|
|
4121
|
+
),
|
|
4122
|
+
),
|
|
4123
|
+
)
|
|
4124
|
+
if _response.status_code == 422:
|
|
4125
|
+
raise UnprocessableEntityError(
|
|
4126
|
+
headers=dict(_response.headers),
|
|
4127
|
+
body=typing.cast(
|
|
4128
|
+
typing.Optional[typing.Any],
|
|
4129
|
+
parse_obj_as(
|
|
4130
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4131
|
+
object_=_response.json(),
|
|
4132
|
+
),
|
|
4133
|
+
),
|
|
4134
|
+
)
|
|
4135
|
+
if _response.status_code == 503:
|
|
4136
|
+
raise ServiceUnavailableError(
|
|
4137
|
+
headers=dict(_response.headers),
|
|
4138
|
+
body=typing.cast(
|
|
4139
|
+
typing.Optional[typing.Any],
|
|
4140
|
+
parse_obj_as(
|
|
4141
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4142
|
+
object_=_response.json(),
|
|
4143
|
+
),
|
|
4144
|
+
),
|
|
4145
|
+
)
|
|
4146
|
+
_response_json = _response.json()
|
|
4147
|
+
except JSONDecodeError:
|
|
4148
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
4149
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
4150
|
+
|
|
4151
|
+
async def cancel_oco_order(
|
|
4152
|
+
self,
|
|
4153
|
+
*,
|
|
4154
|
+
market: str,
|
|
4155
|
+
order_id: int,
|
|
4156
|
+
request: str,
|
|
4157
|
+
nonce: str,
|
|
4158
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
4159
|
+
) -> AsyncHttpResponse[CancelOcoOrderResponse]:
|
|
4160
|
+
"""
|
|
4161
|
+
The endpoint cancels an OCO order.
|
|
4162
|
+
|
|
4163
|
+
<Warning>
|
|
4164
|
+
Rate limit: 10000 requests/10 sec.
|
|
4165
|
+
</Warning>
|
|
4166
|
+
|
|
4167
|
+
Parameters
|
|
4168
|
+
----------
|
|
4169
|
+
market : str
|
|
4170
|
+
|
|
4171
|
+
order_id : int
|
|
4172
|
+
|
|
4173
|
+
request : str
|
|
4174
|
+
|
|
4175
|
+
nonce : str
|
|
4176
|
+
|
|
4177
|
+
request_options : typing.Optional[RequestOptions]
|
|
4178
|
+
Request-specific configuration.
|
|
4179
|
+
|
|
4180
|
+
Returns
|
|
4181
|
+
-------
|
|
4182
|
+
AsyncHttpResponse[CancelOcoOrderResponse]
|
|
4183
|
+
Successful response - OCO order cancelled
|
|
4184
|
+
"""
|
|
4185
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
4186
|
+
"api/v4/order/oco-cancel",
|
|
4187
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
4188
|
+
method="POST",
|
|
4189
|
+
json={
|
|
4190
|
+
"market": market,
|
|
4191
|
+
"orderId": order_id,
|
|
4192
|
+
"request": request,
|
|
4193
|
+
"nonce": nonce,
|
|
4194
|
+
},
|
|
4195
|
+
headers={
|
|
4196
|
+
"content-type": "application/json",
|
|
4197
|
+
},
|
|
4198
|
+
request_options=request_options,
|
|
4199
|
+
omit=OMIT,
|
|
4200
|
+
)
|
|
4201
|
+
try:
|
|
4202
|
+
if 200 <= _response.status_code < 300:
|
|
4203
|
+
_data = typing.cast(
|
|
4204
|
+
CancelOcoOrderResponse,
|
|
4205
|
+
parse_obj_as(
|
|
4206
|
+
type_=CancelOcoOrderResponse, # type: ignore
|
|
4207
|
+
object_=_response.json(),
|
|
4208
|
+
),
|
|
4209
|
+
)
|
|
4210
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
4211
|
+
if _response.status_code == 400:
|
|
4212
|
+
raise BadRequestError(
|
|
4213
|
+
headers=dict(_response.headers),
|
|
4214
|
+
body=typing.cast(
|
|
4215
|
+
typing.Optional[typing.Any],
|
|
4216
|
+
parse_obj_as(
|
|
4217
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4218
|
+
object_=_response.json(),
|
|
4219
|
+
),
|
|
4220
|
+
),
|
|
4221
|
+
)
|
|
4222
|
+
if _response.status_code == 422:
|
|
4223
|
+
raise UnprocessableEntityError(
|
|
4224
|
+
headers=dict(_response.headers),
|
|
4225
|
+
body=typing.cast(
|
|
4226
|
+
typing.Optional[typing.Any],
|
|
4227
|
+
parse_obj_as(
|
|
4228
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4229
|
+
object_=_response.json(),
|
|
4230
|
+
),
|
|
4231
|
+
),
|
|
4232
|
+
)
|
|
4233
|
+
if _response.status_code == 503:
|
|
4234
|
+
raise ServiceUnavailableError(
|
|
4235
|
+
headers=dict(_response.headers),
|
|
4236
|
+
body=typing.cast(
|
|
4237
|
+
typing.Optional[typing.Any],
|
|
4238
|
+
parse_obj_as(
|
|
4239
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4240
|
+
object_=_response.json(),
|
|
4241
|
+
),
|
|
4242
|
+
),
|
|
4243
|
+
)
|
|
4244
|
+
_response_json = _response.json()
|
|
4245
|
+
except JSONDecodeError:
|
|
4246
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
4247
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
4248
|
+
|
|
4249
|
+
async def cancel_oto_order(
|
|
4250
|
+
self,
|
|
4251
|
+
*,
|
|
4252
|
+
market: str,
|
|
4253
|
+
oto_id: int,
|
|
4254
|
+
request: str,
|
|
4255
|
+
nonce: str,
|
|
4256
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
4257
|
+
) -> AsyncHttpResponse[None]:
|
|
4258
|
+
"""
|
|
4259
|
+
The endpoint cancels an OTO order.
|
|
4260
|
+
|
|
4261
|
+
<Warning>
|
|
4262
|
+
Rate limit: 10000 requests/10 sec.
|
|
4263
|
+
</Warning>
|
|
4264
|
+
|
|
4265
|
+
Parameters
|
|
4266
|
+
----------
|
|
4267
|
+
market : str
|
|
4268
|
+
|
|
4269
|
+
oto_id : int
|
|
4270
|
+
|
|
4271
|
+
request : str
|
|
4272
|
+
|
|
4273
|
+
nonce : str
|
|
4274
|
+
|
|
4275
|
+
request_options : typing.Optional[RequestOptions]
|
|
4276
|
+
Request-specific configuration.
|
|
4277
|
+
|
|
4278
|
+
Returns
|
|
4279
|
+
-------
|
|
4280
|
+
AsyncHttpResponse[None]
|
|
4281
|
+
"""
|
|
4282
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
4283
|
+
"api/v4/order/oto-cancel",
|
|
4284
|
+
base_url=self._client_wrapper.get_environment().base,
|
|
4285
|
+
method="POST",
|
|
4286
|
+
json={
|
|
4287
|
+
"market": market,
|
|
4288
|
+
"otoId": oto_id,
|
|
4289
|
+
"request": request,
|
|
4290
|
+
"nonce": nonce,
|
|
4291
|
+
},
|
|
4292
|
+
headers={
|
|
4293
|
+
"content-type": "application/json",
|
|
4294
|
+
},
|
|
4295
|
+
request_options=request_options,
|
|
4296
|
+
omit=OMIT,
|
|
4297
|
+
)
|
|
4298
|
+
try:
|
|
4299
|
+
if 200 <= _response.status_code < 300:
|
|
4300
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
4301
|
+
if _response.status_code == 400:
|
|
4302
|
+
raise BadRequestError(
|
|
4303
|
+
headers=dict(_response.headers),
|
|
4304
|
+
body=typing.cast(
|
|
4305
|
+
typing.Optional[typing.Any],
|
|
4306
|
+
parse_obj_as(
|
|
4307
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4308
|
+
object_=_response.json(),
|
|
4309
|
+
),
|
|
4310
|
+
),
|
|
4311
|
+
)
|
|
4312
|
+
if _response.status_code == 422:
|
|
4313
|
+
raise UnprocessableEntityError(
|
|
4314
|
+
headers=dict(_response.headers),
|
|
4315
|
+
body=typing.cast(
|
|
4316
|
+
typing.Optional[typing.Any],
|
|
4317
|
+
parse_obj_as(
|
|
4318
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4319
|
+
object_=_response.json(),
|
|
4320
|
+
),
|
|
4321
|
+
),
|
|
4322
|
+
)
|
|
4323
|
+
if _response.status_code == 503:
|
|
4324
|
+
raise ServiceUnavailableError(
|
|
4325
|
+
headers=dict(_response.headers),
|
|
4326
|
+
body=typing.cast(
|
|
4327
|
+
typing.Optional[typing.Any],
|
|
4328
|
+
parse_obj_as(
|
|
4329
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
4330
|
+
object_=_response.json(),
|
|
4331
|
+
),
|
|
4332
|
+
),
|
|
4333
|
+
)
|
|
4334
|
+
_response_json = _response.json()
|
|
4335
|
+
except JSONDecodeError:
|
|
4336
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
4337
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|