├── .github ├── ISSUE_TEMPLATE.md └── workflows │ ├── pythonpackage.yml │ └── release.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── MANIFEST.in ├── README.md ├── binance ├── __init__.py ├── __version__.py ├── api.py ├── error.py ├── lib │ ├── __init__.py │ ├── authentication.py │ ├── enums.py │ └── utils.py ├── spot │ ├── __init__.py │ ├── _auto_invest.py │ ├── _c2c.py │ ├── _convert.py │ ├── _crypto_loan.py │ ├── _data_stream.py │ ├── _fiat.py │ ├── _gift_card.py │ ├── _margin.py │ ├── _market.py │ ├── _mining.py │ ├── _nft.py │ ├── _pay.py │ ├── _portfolio_margin.py │ ├── _rebate.py │ ├── _simple_earn.py │ ├── _staking.py │ ├── _sub_account.py │ ├── _trade.py │ └── _wallet.py └── websocket │ ├── __init__.py │ ├── binance_socket_manager.py │ ├── spot │ ├── __init__.py │ ├── websocket_api │ │ ├── __init__.py │ │ ├── _account.py │ │ ├── _market.py │ │ ├── _trade.py │ │ └── _user_data.py │ └── websocket_stream.py │ └── websocket_client.py ├── docs ├── Makefile ├── make.bat └── source │ ├── CHANGELOG.rst │ ├── binance.spot.auto_invest.rst │ ├── binance.spot.c2c.rst │ ├── binance.spot.convert.rst │ ├── binance.spot.crypto_loan.rst │ ├── binance.spot.data_stream.rst │ ├── binance.spot.fiat.rst │ ├── binance.spot.gift_card.rst │ ├── binance.spot.margin.rst │ ├── binance.spot.market.rst │ ├── binance.spot.mining.rst │ ├── binance.spot.nft.rst │ ├── binance.spot.pay.rst │ ├── binance.spot.portfolio_margin.rst │ ├── binance.spot.rebate.rst │ ├── binance.spot.rst │ ├── binance.spot.simple_earn.rst │ ├── binance.spot.staking.rst │ ├── binance.spot.sub_account.rst │ ├── binance.spot.trade.rst │ ├── binance.spot.wallet.rst │ ├── binance.websocket_api.rst │ ├── binance.websocket_stream.spot.rst │ ├── conf.py │ ├── getting_started.rst │ ├── index.rst │ └── intro.rst ├── examples ├── __init__.py ├── config.ini.example ├── spot │ ├── auto_invest │ │ ├── change_plan_status.py │ │ ├── get_index_linked_plan_redemption_history.py │ │ ├── get_list_of_plans.py │ │ ├── get_target_asset_list.py │ │ ├── get_target_asset_roi_data.py │ │ ├── index_linked_plan_rebalance_details.py │ │ ├── index_linked_plan_redemption.py │ │ ├── one_time_transaction.py │ │ ├── query_all_source_asset_and_target_asset.py │ │ ├── query_holding_details_of_the_plan.py │ │ ├── query_index_details.py │ │ ├── query_index_linked_plan_position_details.py │ │ ├── query_one_time_transaction_status.py │ │ ├── query_source_asset_list.py │ │ └── query_subscription_transaction_history.py │ ├── c2c │ │ └── c2c_trade_history.py │ ├── convert │ │ ├── accept_quote.py │ │ ├── cancel_limit_order.py │ │ ├── get_convert_trade_history.py │ │ ├── list_all_convert_pairs.py │ │ ├── order_status.py │ │ ├── place_limit_order.py │ │ ├── query_limit_open_order.py │ │ ├── query_order_quantity_precision_per_asset.py │ │ └── send_quote_request.py │ ├── fiat │ │ ├── fiat_order_history.py │ │ └── fiat_payment_history.py │ ├── gift_card │ │ ├── gift_card_buy_code.py │ │ ├── gift_card_create_code.py │ │ ├── gift_card_redeem_code.py │ │ ├── gift_card_rsa_public_key.py │ │ ├── gift_card_token_limit.py │ │ └── gift_card_verify_code.py │ ├── loan │ │ ├── loan_adjust_ltv_history.py │ │ ├── loan_borrow_history.py │ │ ├── loan_history.py │ │ ├── loan_loanable_data.py │ │ ├── loan_repay_history.py │ │ ├── loan_vip_collateral_account.py │ │ ├── loan_vip_ongoing_orders.py │ │ ├── loan_vip_repay.py │ │ └── loan_vip_repay_history.py │ ├── margin │ │ ├── adjust_cross_margin_max_leverage.py │ │ ├── bnbBurn_status.py │ │ ├── borrow_repay.py │ │ ├── borrow_repay_record.py │ │ ├── cancel_isolated_margin_account.py │ │ ├── cancel_margin_oco_order.py │ │ ├── cancel_margin_order.py │ │ ├── cross_margin_collateral_ratio.py │ │ ├── enable_isolated_margin_account.py │ │ ├── get_a_future_hourly_interest_rate.py │ │ ├── get_margin_oco_order.py │ │ ├── get_margin_oco_orders.py │ │ ├── get_margin_open_oco_orders.py │ │ ├── get_small_liability_exchange_coin_list.py │ │ ├── get_small_liability_exchange_history.py │ │ ├── isolated_margin_account.py │ │ ├── isolated_margin_account_limit.py │ │ ├── isolated_margin_all_pairs.py │ │ ├── isolated_margin_fee.py │ │ ├── isolated_margin_tier.py │ │ ├── liability_coin_leverage_bracket.py │ │ ├── margin_account.py │ │ ├── margin_all_assets.py │ │ ├── margin_all_orders.py │ │ ├── margin_all_pairs.py │ │ ├── margin_available_inventory.py │ │ ├── margin_fee.py │ │ ├── margin_force_liquidation_record.py │ │ ├── margin_interest_history.py │ │ ├── margin_interest_rate_history.py │ │ ├── margin_manual_liquidation.py │ │ ├── margin_max_borrowable.py │ │ ├── margin_max_transferable.py │ │ ├── margin_my_trades.py │ │ ├── margin_new_oto_order.py │ │ ├── margin_new_otoco_order.py │ │ ├── margin_open_orders.py │ │ ├── margin_open_orders_cancellation.py │ │ ├── margin_order.py │ │ ├── margin_order_usage.py │ │ ├── margin_pair_index.py │ │ ├── margin_transfer_history.py │ │ ├── new_margin_oco_order.py │ │ ├── new_margin_order.py │ │ ├── summary_of_margin_account.py │ │ └── toggle_bnbBurn.py │ ├── market │ │ ├── agg_trades.py │ │ ├── avg_price.py │ │ ├── book_ticker.py │ │ ├── depth.py │ │ ├── exchange_info.py │ │ ├── historical_trades.py │ │ ├── klines.py │ │ ├── ping.py │ │ ├── rolling_window_ticker.py │ │ ├── ticker_24hr.py │ │ ├── ticker_price.py │ │ ├── time.py │ │ ├── trades.py │ │ ├── trading_day_ticker.py │ │ └── ui_klines.py │ ├── mining │ │ ├── mining_account_earning.py │ │ ├── mining_account_list.py │ │ ├── mining_algo_list.py │ │ ├── mining_bonus_list.py │ │ ├── mining_coin_list.py │ │ ├── mining_earnings_list.py │ │ ├── mining_hashrate_resale_cancellation.py │ │ ├── mining_hashrate_resale_details.py │ │ ├── mining_hashrate_resale_list.py │ │ ├── mining_hashrate_resale_request.py │ │ ├── mining_statistics_list.py │ │ ├── mining_worker.py │ │ └── mining_worker_list.py │ ├── nft │ │ ├── nft_asset.py │ │ ├── nft_deposit_history.py │ │ ├── nft_transaction_history.py │ │ └── nft_withdraw_history.py │ ├── pay │ │ └── pay_history.py │ ├── portfolio_margin │ │ ├── bnb_transfer.py │ │ ├── change_auto_repay_futures_status.py │ │ ├── fund_auto_collection.py │ │ ├── fund_collection_by_asset.py │ │ ├── get_auto_repay_futures_status.py │ │ ├── get_portfolio_margin_account_balance.py │ │ ├── get_portfolio_margin_span_account_info.py │ │ ├── portfolio_margin_account.py │ │ ├── portfolio_margin_bankruptcy_loan_amount.py │ │ ├── portfolio_margin_bankruptcy_loan_repay.py │ │ ├── portfolio_margin_collateral_rate.py │ │ ├── portfolio_margin_tiered_collateral_rate.py │ │ ├── query_classic_portfolio_margin_negative_balance_interest_history.py │ │ ├── query_portfolio_margin_asset_index_price.py │ │ └── repay_futures_negative_balance.py │ ├── rebate │ │ └── rebate_spot_history.py │ ├── simple_earn │ │ ├── get_collateral_record.py │ │ ├── get_flexible_personal_left_quota.py │ │ ├── get_flexible_product_position.py │ │ ├── get_flexible_redemption_record.py │ │ ├── get_flexible_rewards_history.py │ │ ├── get_flexible_subscription_preview.py │ │ ├── get_flexible_subscription_record.py │ │ ├── get_locked_personal_left_quota.py │ │ ├── get_locked_product_position.py │ │ ├── get_locked_redemption_record.py │ │ ├── get_locked_rewards_history.py │ │ ├── get_locked_subscription_preview.py │ │ ├── get_locked_subscription_record.py │ │ ├── get_rate_history.py │ │ ├── get_simple_earn_flexible_product_list.py │ │ ├── get_simple_earn_locked_product_list.py │ │ ├── redeem_flexible_product.py │ │ ├── redeem_locked_product.py │ │ ├── set_flexible_auto_subscribe.py │ │ ├── set_locked_auto_subscribe.py │ │ ├── set_locked_product_redeem_option.py │ │ ├── simple_account.py │ │ ├── subscribe_flexible_product.py │ │ └── subscribe_locked_product.py │ ├── staking │ │ ├── eth_staking_account.py │ │ ├── get_beth_rewards_distribution_history.py │ │ ├── get_eth_redemption_history.py │ │ ├── get_eth_staking_history.py │ │ ├── get_eth_staking_quota.py │ │ ├── get_wbeth_rate_history.py │ │ ├── get_wbeth_rewards_history.py │ │ ├── get_wbeth_unwrap_history.py │ │ ├── get_wbeth_wrap_history.py │ │ ├── redeem_eth.py │ │ ├── subscribe_eth_staking.py │ │ └── wrap_beth.py │ ├── stream │ │ ├── isolated_margin │ │ │ ├── close_isolated_margin_listen_key.py │ │ │ ├── new_isolated_margin_listen_key.py │ │ │ └── renew_isolated_margin_listen_key.py │ │ ├── margin │ │ │ ├── close_margin_listen_key.py │ │ │ ├── new_margin_listen_key.py │ │ │ └── renew_margin_listen_key.py │ │ └── spot │ │ │ ├── close_listen_key.py │ │ │ ├── new_listen_key.py │ │ │ └── renew_listen_key.py │ ├── sub_account │ │ ├── detail_on_sub_account_s_futures_account.py │ │ ├── enable_options_for_sub_account.py │ │ ├── futures_position_risk_of_sub_account.py │ │ ├── managed_sub_account_assets.py │ │ ├── managed_sub_account_deposit.py │ │ ├── managed_sub_account_deposit_address.py │ │ ├── managed_sub_account_get_snapshot.py │ │ ├── managed_sub_account_investor_trans_log.py │ │ ├── managed_sub_account_trading_trans_log.py │ │ ├── managed_sub_account_withdraw.py │ │ ├── query_managed_sub_account_futures_asset_details.py │ │ ├── query_managed_sub_account_list.py │ │ ├── query_managed_sub_account_margin_asset_details.py │ │ ├── query_managed_sub_account_transfer_log.py │ │ ├── query_sub_account_assets.py │ │ ├── query_sub_account_transaction_statistics.py │ │ ├── sub_account_api_delete_ip.py │ │ ├── sub_account_api_get_ip_restriction.py │ │ ├── sub_account_assets.py │ │ ├── sub_account_create.py │ │ ├── sub_account_deposit_address.py │ │ ├── sub_account_deposit_history.py │ │ ├── sub_account_enable_futures.py │ │ ├── sub_account_enable_leverage_token.py │ │ ├── sub_account_enable_margin.py │ │ ├── sub_account_futures_account.py │ │ ├── sub_account_futures_account_summary.py │ │ ├── sub_account_futures_asset_transfer.py │ │ ├── sub_account_futures_asset_transfer_history.py │ │ ├── sub_account_futures_position_risk.py │ │ ├── sub_account_futures_transfer.py │ │ ├── sub_account_list.py │ │ ├── sub_account_margin_account.py │ │ ├── sub_account_margin_account_summary.py │ │ ├── sub_account_margin_transfer.py │ │ ├── sub_account_spot_summary.py │ │ ├── sub_account_spot_transfer_history.py │ │ ├── sub_account_status.py │ │ ├── sub_account_transfer_sub_account_history.py │ │ ├── sub_account_transfer_to_master.py │ │ ├── sub_account_transfer_to_sub.py │ │ ├── sub_account_universal_transfer.py │ │ ├── sub_account_universal_transfer_history.py │ │ ├── sub_account_update_ip_restriction.py │ │ └── summary_of_sub_account_s_futures_account.py │ ├── trade │ │ ├── cancel_and_replace.py │ │ ├── cancel_oco_order.py │ │ ├── cancel_open_orders.py │ │ ├── cancel_order.py │ │ ├── get_account.py │ │ ├── get_my_trades.py │ │ ├── get_oco_open_orders.py │ │ ├── get_oco_order.py │ │ ├── get_oco_orders.py │ │ ├── get_open_orders.py │ │ ├── get_order.py │ │ ├── get_order_rate_limit.py │ │ ├── get_orders.py │ │ ├── new_oco_order.py │ │ ├── new_order.py │ │ ├── new_order_testing.py │ │ ├── new_oto_order.py │ │ ├── new_otoco_order.py │ │ ├── query_allocations.py │ │ ├── query_commission_rates.py │ │ └── query_prevented_matches.py │ └── wallet │ │ ├── account_snapshot.py │ │ ├── account_status.py │ │ ├── api_key_permissions.py │ │ ├── api_trading_status.py │ │ ├── asset_detail.py │ │ ├── asset_dividend_record.py │ │ ├── balance.py │ │ ├── bnb_convertible_assets.py │ │ ├── cloud_mining_trans_history.py │ │ ├── coin_info.py │ │ ├── delist_schedule_symbols.py │ │ ├── deposit_address.py │ │ ├── deposit_history.py │ │ ├── disable_fast_withdraw.py │ │ ├── dust_log.py │ │ ├── enable_fast_withdraw.py │ │ ├── funding_wallet.py │ │ ├── list_deposit_address.py │ │ ├── local_entity_deposit_history.py │ │ ├── local_entity_submit_deposit_questionnaire.py │ │ ├── local_entity_withdraw.py │ │ ├── local_entity_withdraw_history.py │ │ ├── one_click_arrival_deposit_apply.py │ │ ├── system_status.py │ │ ├── trade_fee.py │ │ ├── transfer_dust.py │ │ ├── user_asset.py │ │ ├── user_universal_transfer.py │ │ ├── user_universal_transfer_history.py │ │ ├── withdraw.py │ │ └── withdraw_history.py ├── utils │ ├── __init__.py │ └── prepare_env.py └── websocket │ └── spot │ ├── websocket_api │ ├── account │ │ ├── account.py │ │ ├── my_trades.py │ │ ├── oco_history.py │ │ ├── order_history.py │ │ ├── order_rate_limit.py │ │ └── prevented_matches.py │ ├── app_demo.py │ ├── market │ │ ├── aggregate_trades.py │ │ ├── all.py │ │ ├── avg_price.py │ │ ├── exchange_info.py │ │ ├── historical_trades.py │ │ ├── klines.py │ │ ├── order_book.py │ │ ├── ping_connectivity.py │ │ ├── recent_trades.py │ │ ├── server_time.py │ │ ├── ticker.py │ │ ├── ticker_24hr.py │ │ ├── ticker_book.py │ │ ├── ticker_price.py │ │ └── ui_klines.py │ ├── trade │ │ ├── cancel_oco_order.py │ │ ├── cancel_open_orders.py │ │ ├── cancel_order.py │ │ ├── cancel_replace_order.py │ │ ├── get_oco_order.py │ │ ├── get_open_oco_orders.py │ │ ├── get_open_orders.py │ │ ├── get_order.py │ │ ├── new_oco_order.py │ │ ├── new_order.py │ │ ├── new_order_test.py │ │ ├── new_oto_order.py │ │ └── new_otoco_order.py │ └── user_data │ │ ├── user_data_ping.py │ │ ├── user_data_start.py │ │ └── user_data_stop.py │ └── websocket_stream │ ├── agg_trade.py │ ├── all_symbols_mini_ticker.py │ ├── all_symbols_ticker.py │ ├── book_ticker.py │ ├── combined_streams.py │ ├── diff_book_depth.py │ ├── partial_book_depth.py │ ├── rolling_window_ticker.py │ ├── rolling_window_ticker_all_symbols.py │ ├── symbol_kline.py │ ├── symbol_kline_timezone_offset.py │ ├── symbol_mini_ticker.py │ ├── symbol_ticker.py │ ├── test.py │ ├── trade.py │ └── user_data.py ├── requirements ├── common.txt ├── requirements-dev.txt ├── requirements-test.txt └── requirements.txt ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── lib │ ├── test_authentication.py │ └── test_utils.py ├── spot │ ├── auto_invest │ │ ├── test_change_plan_status.py │ │ ├── test_get_index_linked_plan_redemption_history.py │ │ ├── test_get_list_of_plans.py │ │ ├── test_get_target_asset_list.py │ │ ├── test_get_target_asset_roi_data.py │ │ ├── test_index_linked_plan_rebalance_details.py │ │ ├── test_index_linked_plan_redemption.py │ │ ├── test_one_time_transaction.py │ │ ├── test_query_all_source_asset_and_target_asset.py │ │ ├── test_query_holding_details_of_the_plan.py │ │ ├── test_query_index_details.py │ │ ├── test_query_index_linked_plan_position_details.py │ │ ├── test_query_one_time_transaction_status.py │ │ ├── test_query_source_asset_list.py │ │ └── test_query_subscription_transaction_history.py │ ├── c2c │ │ └── test_c2c_trade_history.py │ ├── convert │ │ ├── test_accept_quote.py │ │ ├── test_cancel_limit_order.py │ │ ├── test_get_convert_trade_history.py │ │ ├── test_list_all_convert_pairs.py │ │ ├── test_order_status.py │ │ ├── test_place_limit_order.py │ │ ├── test_query_limit_open_order.py │ │ ├── test_query_order_quantity_precision_per_asset.py │ │ └── test_send_quote_request.py │ ├── data_stream │ │ ├── isolated_margin │ │ │ ├── test_close_isolated_margin_listen_key.py │ │ │ ├── test_new_isolated_margin_listen_key.py │ │ │ └── test_renew_isolated_margin_listen_key.py │ │ ├── margin │ │ │ ├── test_close_margin_listen_key.py │ │ │ ├── test_new_margin_listen_key.py │ │ │ └── test_renew_margin_listen_key.py │ │ └── spot │ │ │ ├── test_close_listen_key.py │ │ │ ├── test_new_listen_key.py │ │ │ └── test_renew_listen_key.py │ ├── fiat │ │ ├── test_fiat_order_history.py │ │ └── test_fiat_payment_history.py │ ├── gift_card │ │ ├── test_gift_card_buy_code.py │ │ ├── test_gift_card_create_code.py │ │ ├── test_gift_card_redeem_code.py │ │ ├── test_gift_card_rsa_public_key.py │ │ ├── test_gift_card_token_limit.py │ │ └── test_gift_card_verify_code.py │ ├── loan │ │ ├── test_loan_adjust_ltv_history.py │ │ ├── test_loan_borrow_history.py │ │ ├── test_loan_history.py │ │ ├── test_loan_loanable_data.py │ │ ├── test_loan_repay_history.py │ │ ├── test_loan_vip_collateral_account.py │ │ ├── test_loan_vip_ongoing_orders.py │ │ ├── test_loan_vip_repay.py │ │ └── test_loan_vip_repay_history.py │ ├── margin │ │ ├── test_adjust_cross_margin_max_leverage.py │ │ ├── test_bnbBurn_status.py │ │ ├── test_borrow_repay.py │ │ ├── test_borrow_repay_record.py │ │ ├── test_cancel_isolated_margin_account.py │ │ ├── test_cancel_margin_oco_order.py │ │ ├── test_cancel_margin_order.py │ │ ├── test_cross_margin_collateral_ratio.py │ │ ├── test_enable_isolated_margin_account.py │ │ ├── test_get_a_future_hourly_interest_rate.py │ │ ├── test_get_margin_oco_order.py │ │ ├── test_get_margin_oco_orders.py │ │ ├── test_get_margin_open_oco_orders.py │ │ ├── test_get_small_liability_exchange_coin_list.py │ │ ├── test_get_small_liability_exchange_history.py │ │ ├── test_isolated_margin_account.py │ │ ├── test_isolated_margin_account_limit.py │ │ ├── test_isolated_margin_all_pairs.py │ │ ├── test_isolated_margin_fee.py │ │ ├── test_isolated_margin_tier.py │ │ ├── test_liability_coin_leverage_bracket.py │ │ ├── test_margin_account.py │ │ ├── test_margin_all_assets.py │ │ ├── test_margin_all_orders.py │ │ ├── test_margin_all_pairs.py │ │ ├── test_margin_available_inventory.py │ │ ├── test_margin_fee.py │ │ ├── test_margin_force_liquidation_record.py │ │ ├── test_margin_interest_history.py │ │ ├── test_margin_interest_rate_history.py │ │ ├── test_margin_manual_liquidation.py │ │ ├── test_margin_max_borrowable.py │ │ ├── test_margin_max_transferable.py │ │ ├── test_margin_my_trades.py │ │ ├── test_margin_new_order.py │ │ ├── test_margin_new_oto_order.py │ │ ├── test_margin_new_otoco_order.py │ │ ├── test_margin_open_orders.py │ │ ├── test_margin_open_orders_cancellation.py │ │ ├── test_margin_order.py │ │ ├── test_margin_order_usage.py │ │ ├── test_margin_pair_index.py │ │ ├── test_margin_transfer_history.py │ │ ├── test_new_margin_oco_order.py │ │ ├── test_summary_of_margin_account.py │ │ └── test_toggle_bnbBurn.py │ ├── market │ │ ├── test_agg_trades.py │ │ ├── test_avg_price.py │ │ ├── test_book_ticker.py │ │ ├── test_depth.py │ │ ├── test_exchange_info.py │ │ ├── test_historical_trades.py │ │ ├── test_kline.py │ │ ├── test_ping.py │ │ ├── test_rolling_window_ticker.py │ │ ├── test_ticker_24hr.py │ │ ├── test_ticker_price.py │ │ ├── test_time.py │ │ ├── test_trades.py │ │ ├── test_trading_day_ticker.py │ │ └── test_ui_klines.py │ ├── mining │ │ ├── test_mining_account_earning.py │ │ ├── test_mining_account_list.py │ │ ├── test_mining_algo_list.py │ │ ├── test_mining_bonus_list.py │ │ ├── test_mining_coin_list.py │ │ ├── test_mining_earnings_list.py │ │ ├── test_mining_hashrate_resale_cancellation.py │ │ ├── test_mining_hashrate_resale_details.py │ │ ├── test_mining_hashrate_resale_list.py │ │ ├── test_mining_hashrate_resale_request.py │ │ ├── test_mining_statistics_list.py │ │ ├── test_mining_worker.py │ │ └── test_mining_worker_list.py │ ├── nft │ │ ├── test_nft_deposit_history.py │ │ ├── test_nft_get_asset.py │ │ ├── test_nft_transaction_history.py │ │ └── test_nft_withdraw_history.py │ ├── pay │ │ └── test_pay_history.py │ ├── portfolio_margin │ │ ├── test_bnb_transfer.py │ │ ├── test_change_auto_repay_futures_status.py │ │ ├── test_fund_auto_collection.py │ │ ├── test_fund_collection_by_asset.py │ │ ├── test_get_auto_repay_futures_status.py │ │ ├── test_get_portfolio_margin_account_balance.py │ │ ├── test_get_portfolio_margin_span_account_info.py │ │ ├── test_portfolio_margin_account.py │ │ ├── test_portfolio_margin_bankruptcy_loan_amount.py │ │ ├── test_portfolio_margin_bankruptcy_loan_repay.py │ │ ├── test_portfolio_margin_collateral_rate.py │ │ ├── test_portfolio_margin_tiered_collateral_rate.py │ │ ├── test_query_classic_portfolio_margin_negative_balance_interest_history.py │ │ ├── test_query_portfolio_margin_asset_index_price.py │ │ └── test_repay_futures_negative_balance.py │ ├── rebate │ │ └── test_rebate_spot_history.py │ ├── simple_earn │ │ ├── test_get_collateral_record.py │ │ ├── test_get_flexible_personal_left_quota.py │ │ ├── test_get_flexible_product_position.py │ │ ├── test_get_flexible_redemption_record.py │ │ ├── test_get_flexible_rewards_history.py │ │ ├── test_get_flexible_subscription_preview.py │ │ ├── test_get_flexible_subscription_record.py │ │ ├── test_get_locked_personal_left_quota.py │ │ ├── test_get_locked_product_position.py │ │ ├── test_get_locked_redemption_record.py │ │ ├── test_get_locked_rewards_history.py │ │ ├── test_get_locked_subscription_preview.py │ │ ├── test_get_locked_subscription_record.py │ │ ├── test_get_rate_history.py │ │ ├── test_get_simple_earn_flexible_product_list.py │ │ ├── test_get_simple_earn_locked_product_list.py │ │ ├── test_redeem_flexible_product.py │ │ ├── test_redeem_locked_product.py │ │ ├── test_set_flexible_auto_subscribe.py │ │ ├── test_set_locked_auto_subscribe.py │ │ ├── test_set_locked_product_redeem_option.py │ │ ├── test_simple_account.py │ │ ├── test_subscribe_flexible_product.py │ │ └── test_subscribe_locked_product.py │ ├── staking │ │ ├── test_eth_staking_account.py │ │ ├── test_get_beth_rewards_distribution_history.py │ │ ├── test_get_eth_redemption_history.py │ │ ├── test_get_eth_staking_history.py │ │ ├── test_get_eth_staking_quota.py │ │ ├── test_get_wbeth_rate_history.py │ │ ├── test_get_wbeth_rewards_history.py │ │ ├── test_get_wbeth_unwrap_history.py │ │ ├── test_get_wbeth_wrap_history.py │ │ ├── test_redeem_eth.py │ │ ├── test_subscribe_eth_staking.py │ │ └── test_wrap_beth.py │ ├── sub_account │ │ ├── test_detail_on_sub_account_s_futures_account.py │ │ ├── test_enable_options_for_sub_account.py │ │ ├── test_futures_position_risk_of_sub_account.py │ │ ├── test_managed_sub_account_assets.py │ │ ├── test_managed_sub_account_deposit.py │ │ ├── test_managed_sub_account_deposit_address.py │ │ ├── test_managed_sub_account_get_snapshot.py │ │ ├── test_managed_sub_account_investor_trans_log.py │ │ ├── test_managed_sub_account_trading_trans_log.py │ │ ├── test_managed_sub_account_withdraw.py │ │ ├── test_query_managed_sub_account_futures_asset_details.py │ │ ├── test_query_managed_sub_account_list.py │ │ ├── test_query_managed_sub_account_margin_asset_details.py │ │ ├── test_query_managed_sub_account_transfer_log.py │ │ ├── test_query_sub_account_assets.py │ │ ├── test_query_sub_account_transaction_statistics.py │ │ ├── test_sub_account_api_delete_ip.py │ │ ├── test_sub_account_api_get_ip_restriction.py │ │ ├── test_sub_account_asset.py │ │ ├── test_sub_account_assets.py │ │ ├── test_sub_account_create.py │ │ ├── test_sub_account_deposit_address.py │ │ ├── test_sub_account_deposit_history.py │ │ ├── test_sub_account_enable_futures.py │ │ ├── test_sub_account_enable_leverage_token.py │ │ ├── test_sub_account_enable_margin.py │ │ ├── test_sub_account_futures_account.py │ │ ├── test_sub_account_futures_account_summary.py │ │ ├── test_sub_account_futures_asset_transfer.py │ │ ├── test_sub_account_futures_asset_transfer_history.py │ │ ├── test_sub_account_futures_position_risk.py │ │ ├── test_sub_account_futures_transfer.py │ │ ├── test_sub_account_list.py │ │ ├── test_sub_account_margin_account.py │ │ ├── test_sub_account_margin_account_summary.py │ │ ├── test_sub_account_margin_transfer.py │ │ ├── test_sub_account_spot_summary.py │ │ ├── test_sub_account_spot_transfer_history.py │ │ ├── test_sub_account_status.py │ │ ├── test_sub_account_transfer_sub_account_history.py │ │ ├── test_sub_account_transfer_to_master.py │ │ ├── test_sub_account_transfer_to_sub.py │ │ ├── test_sub_account_universal_transfer.py │ │ ├── test_sub_account_universal_transfer_history.py │ │ ├── test_sub_account_update_ip_restriction.py │ │ └── test_summary_of_sub_account_s_futures_account.py │ ├── trade │ │ ├── test_account.py │ │ ├── test_cancel_and_replace.py │ │ ├── test_cancel_oco_order.py │ │ ├── test_cancel_open_orders.py │ │ ├── test_cancel_order.py │ │ ├── test_get_oco_open_orders.py │ │ ├── test_get_oco_order.py │ │ ├── test_get_oco_orders.py │ │ ├── test_get_open_orders.py │ │ ├── test_get_order.py │ │ ├── test_get_order_rate_limit.py │ │ ├── test_get_orders.py │ │ ├── test_my_trades.py │ │ ├── test_new_oco_order.py │ │ ├── test_new_order.py │ │ ├── test_new_order_test.py │ │ ├── test_new_oto_order.py │ │ ├── test_new_otoco_order.py │ │ ├── test_query_allocations.py │ │ ├── test_query_commission_rates.py │ │ └── test_query_prevented_matches.py │ └── wallet │ │ ├── test_account_snapshot.py │ │ ├── test_account_status.py │ │ ├── test_api_key_permissions.py │ │ ├── test_api_trading_status.py │ │ ├── test_asset_detail.py │ │ ├── test_asset_dividend_record.py │ │ ├── test_balance.py │ │ ├── test_bnb_convertible_assets.py │ │ ├── test_cloud_mining_trans_history.py │ │ ├── test_coin_info.py │ │ ├── test_delist_schedule_symbols.py │ │ ├── test_deposit_address.py │ │ ├── test_deposit_history.py │ │ ├── test_disable_fast_withdraw.py │ │ ├── test_dust_log.py │ │ ├── test_enable_fast_withdraw.py │ │ ├── test_funding_wallet.py │ │ ├── test_list_deposit_address.py │ │ ├── test_local_entity_deposit_history.py │ │ ├── test_local_entity_submit_deposit_questionnaire.py │ │ ├── test_local_entity_withdraw.py │ │ ├── test_local_entity_withdraw_history.py │ │ ├── test_one_click_arrival_deposit_apply.py │ │ ├── test_system_status.py │ │ ├── test_trade_fee.py │ │ ├── test_transfer_dust.py │ │ ├── test_user_asset.py │ │ ├── test_user_universal_transfer.py │ │ ├── test_user_universal_transfer_history.py │ │ ├── test_withdraw.py │ │ └── test_withdraw_history.py ├── test_api.py └── util.py └── tox.ini /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Before submitting a new issue, please check if a similar issue has already been filed. 2 | 3 | ### Issue subject 4 | Briefly describe the issue here. 5 | 6 | 7 | ### Expected behaviour 8 | Describe what should happen. 9 | 10 | 11 | ### Actual behaviour 12 | Describe what happens instead. Please include the complete failure message. 13 | 14 | 15 | ### Steps to reproduce 16 | Provide steps to let us know how we can reproduce this issue. 17 | 18 | 19 | ### Environment 20 | Provide any relevant information about your setup, such as: 21 | * Version of binance-connector-python 22 | * Python version 23 | * Operating system 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Distributables 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | build-n-upload: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-python@v2 14 | with: 15 | python-version: "3.10" 16 | - run: pip install wheel 17 | - name: Build new distributables 18 | run: python setup.py sdist bdist_wheel 19 | - name: Upload distributables to PyPI 20 | uses: pypa/gh-action-pypi-publish@release/v1 21 | with: 22 | user: __token__ 23 | password: ${{ secrets.PYPI_API_TOKEN }} 24 | - name: Post release cleaning 25 | run: | 26 | python setup.py clean --all 27 | rm dist/* 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | binance_connector.egg-info/ 4 | __pycache__ 5 | *.pyc 6 | .tox 7 | .python-version 8 | .DS_Store 9 | 10 | # Environments 11 | .env 12 | .venv 13 | venv/ 14 | 15 | # IDE 16 | .idea/ 17 | .vscode/ 18 | 19 | # document build 20 | docs/build/ 21 | 22 | examples/*.ini 23 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_stages: [commit] 2 | fail_fast: true 3 | repos: 4 | - repo: https://github.com/ambv/black 5 | rev: 21.7b0 6 | hooks: 7 | - id: black 8 | - repo: https://gitlab.com/pycqa/flake8 9 | rev: 3.9.2 10 | hooks: 11 | - id: flake8 12 | - repo: local 13 | hooks: 14 | - id: pytest-check 15 | name: pytest-check 16 | entry: pytest 17 | language: system 18 | pass_filenames: false 19 | always_run: true -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements/common.txt -------------------------------------------------------------------------------- /binance/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binance/binance-connector-python/b943389d1a6030da9c300e4c2af6889cd5be4142/binance/__init__.py -------------------------------------------------------------------------------- /binance/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = "3.12.0" 2 | -------------------------------------------------------------------------------- /binance/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binance/binance-connector-python/b943389d1a6030da9c300e4c2af6889cd5be4142/binance/lib/__init__.py -------------------------------------------------------------------------------- /binance/spot/_pay.py: -------------------------------------------------------------------------------- 1 | def pay_history(self, **kwargs): 2 | """Get Pay Trade History (USER_DATA) 3 | 4 | GET /sapi/v1/pay/transactions 5 | 6 | https://binance-docs.github.io/apidocs/spot/en/#get-pay-trade-history-user_data 7 | 8 | Keyword Args: 9 | startTime (int, optional) 10 | endTime (int, optional) 11 | limit (int, optional): default 100, max 100 12 | recvWindow (int, optional): The value cannot be greater than 60000 13 | """ 14 | 15 | return self.sign_request("GET", "/sapi/v1/pay/transactions", kwargs) 16 | -------------------------------------------------------------------------------- /binance/spot/_rebate.py: -------------------------------------------------------------------------------- 1 | def rebate_spot_history(self, **kwargs): 2 | """Get Spot Rebate History Records (USER_DATA) 3 | 4 | GET /sapi/v1/rebate/taxQuery 5 | 6 | https://developers.binance.com/docs/rebate/rest-api/Get-Spot-Rebate-History-Records 7 | 8 | Keyword Args: 9 | startTime (int, optional) 10 | endTime (int, optional) 11 | page (int, optional): default 1 12 | recvWindow (int, optional): The value cannot be greater than 60000 13 | """ 14 | 15 | return self.sign_request("GET", "/sapi/v1/rebate/taxQuery", kwargs) 16 | -------------------------------------------------------------------------------- /binance/websocket/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binance/binance-connector-python/b943389d1a6030da9c300e4c2af6889cd5be4142/binance/websocket/__init__.py -------------------------------------------------------------------------------- /binance/websocket/spot/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binance/binance-connector-python/b943389d1a6030da9c300e4c2af6889cd5be4142/binance/websocket/spot/__init__.py -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/source/binance.spot.c2c.rst: -------------------------------------------------------------------------------- 1 | C2C Endpoints 2 | ============= 3 | 4 | Get C2C Trade History (USER_DATA) 5 | --------------------------------- 6 | .. autofunction:: binance.spot.Spot.c2c_trade_history 7 | -------------------------------------------------------------------------------- /docs/source/binance.spot.fiat.rst: -------------------------------------------------------------------------------- 1 | Fiat Endpoints 2 | ============== 3 | 4 | Get Fiat Order History (USER_DATA) 5 | --------------------------------------------- 6 | .. autofunction:: binance.spot.Spot.fiat_order_history 7 | 8 | Get Fiat Payments History (USER_DATA) 9 | --------------------------------------------- 10 | .. autofunction:: binance.spot.Spot.fiat_payment_history 11 | -------------------------------------------------------------------------------- /docs/source/binance.spot.nft.rst: -------------------------------------------------------------------------------- 1 | NFT Endpoints 2 | ============= 3 | 4 | Get NFT Transaction History (USER_DATA) 5 | --------------------------------------- 6 | .. autofunction:: binance.spot.Spot.nft_transaction_history 7 | 8 | Get NFT Deposit History(USER_DATA) 9 | ---------------------------------- 10 | .. autofunction:: binance.spot.Spot.nft_deposit_history 11 | 12 | Get NFT Withdraw History (USER_DATA) 13 | ------------------------------------ 14 | .. autofunction:: binance.spot.Spot.nft_withdraw_history 15 | 16 | Get NFT Asset (USER_DATA) 17 | ------------------------- 18 | .. autofunction:: binance.spot.Spot.nft_asset 19 | -------------------------------------------------------------------------------- /docs/source/binance.spot.pay.rst: -------------------------------------------------------------------------------- 1 | Pay Endpoints 2 | ============= 3 | 4 | Get Pay Trade History (USER_DATA) 5 | --------------------------------- 6 | .. autofunction:: binance.spot.Spot.pay_history 7 | -------------------------------------------------------------------------------- /docs/source/binance.spot.rebate.rst: -------------------------------------------------------------------------------- 1 | Rebate Endpoints 2 | ================ 3 | 4 | Get Spot Rebate History Records (USER_DATA) 5 | ------------------------------------------- 6 | .. autofunction:: binance.spot.Spot.rebate_spot_history 7 | -------------------------------------------------------------------------------- /docs/source/binance.spot.rst: -------------------------------------------------------------------------------- 1 | Spot APIs 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | binance.spot.auto_invest 8 | binance.spot.c2c 9 | binance.spot.convert 10 | binance.spot.data_stream 11 | binance.spot.fiat 12 | binance.spot.gift_card 13 | binance.spot.crypto_loan 14 | binance.spot.margin 15 | binance.spot.market 16 | binance.spot.mining 17 | binance.spot.nft 18 | binance.spot.pay 19 | binance.spot.portfolio_margin 20 | binance.spot.rebate 21 | binance.spot.staking 22 | binance.spot.sub_account 23 | binance.spot.trade 24 | binance.spot.wallet 25 | binance.spot.simple_earn 26 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. binance-connector documentation master file, created by 2 | sphinx-quickstart on Thu Jun 3 10:37:38 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | .. include:: intro.rst 7 | 8 | Contents 9 | ========= 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | CHANGELOG 14 | getting_started 15 | binance.spot 16 | binance.websocket_stream.spot 17 | binance.websocket_api 18 | 19 | Indices and tables 20 | ================== 21 | 22 | * :ref:`genindex` 23 | * :ref:`modindex` 24 | * :ref:`search` 25 | -------------------------------------------------------------------------------- /examples/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binance/binance-connector-python/b943389d1a6030da9c300e4c2af6889cd5be4142/examples/__init__.py -------------------------------------------------------------------------------- /examples/config.ini.example: -------------------------------------------------------------------------------- 1 | 2 | # Make a copy of this file, and save to `config.ini` 3 | # Enter your API and Secret Key for use in the example files; No need to add double quote or single quote. For example: 4 | # api_key=vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A 5 | # api_secret=NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j 6 | # It's a demo key, doesn't work on production :) 7 | 8 | [keys] 9 | api_key= 10 | api_secret= 11 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/change_plan_status.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.change_plan_status(1234, "ONGOING", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/get_list_of_plans.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.get_list_of_plans("SINGLE", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/get_target_asset_roi_data.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.get_target_asset_roi_data("BTC", "FIVE_YEAR", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/index_linked_plan_redemption.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.index_linked_plan_redemption(12345, 10, recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/one_time_transaction.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.one_time_transaction("MAIN_SITE", 10.1, "USDT", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/query_holding_details_of_the_plan.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.query_holding_details_of_the_plan(recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/query_index_details.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.query_index_details(1234, recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/auto_invest/query_source_asset_list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.query_source_asset_list("RECURRING", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/c2c/c2c_trade_history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | from examples.utils.prepare_env import get_api_key 8 | 9 | config_logging(logging, logging.DEBUG) 10 | 11 | api_key, api_secret = get_api_key() 12 | 13 | client = Client(api_key, api_secret) 14 | 15 | try: 16 | response = client.c2c_trade_history("BUY") 17 | logging.info(response) 18 | except ClientError as error: 19 | logging.error( 20 | "Found error. status: {}, error code: {}, error message: {}".format( 21 | error.status_code, error.error_code, error.error_message 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /examples/spot/convert/accept_quote.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.accept_quote("1000", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/convert/cancel_limit_order.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.cancel_limit_order(orderId=1) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/convert/list_all_convert_pairs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | 9 | config_logging(logging, logging.DEBUG) 10 | logger = logging.getLogger(__name__) 11 | 12 | 13 | client = Client() 14 | 15 | try: 16 | response = client.list_all_convert_pairs(fromAsset="BTC", toAsset="USDT") 17 | logger.info(response) 18 | except ClientError as error: 19 | logger.error( 20 | "Found error. status: {}, error code: {}, error message: {}".format( 21 | error.status_code, error.error_code, error.error_message 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /examples/spot/convert/order_status.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.order_status(orderId="1000", quoteId="1000", recvWindow=5000) 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/convert/query_limit_open_order.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | 8 | from examples.utils.prepare_env import get_api_key 9 | 10 | config_logging(logging, logging.DEBUG) 11 | logger = logging.getLogger(__name__) 12 | 13 | api_key, api_secret = get_api_key() 14 | 15 | client = Client(api_key, api_secret) 16 | 17 | try: 18 | response = client.query_limit_open_order() 19 | logger.info(response) 20 | except ClientError as error: 21 | logger.error( 22 | "Found error. status: {}, error code: {}, error message: {}".format( 23 | error.status_code, error.error_code, error.error_message 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /examples/spot/fiat/fiat_order_history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | from examples.utils.prepare_env import get_api_key 8 | 9 | config_logging(logging, logging.DEBUG) 10 | 11 | api_key, api_secret = get_api_key() 12 | 13 | client = Client(api_key, api_secret) 14 | 15 | try: 16 | response = client.fiat_order_history(0) 17 | logging.info(response) 18 | except ClientError as error: 19 | logging.error( 20 | "Found error. status: {}, error code: {}, error message: {}".format( 21 | error.status_code, error.error_code, error.error_message 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /examples/spot/fiat/fiat_payment_history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | from examples.utils.prepare_env import get_api_key 8 | 9 | config_logging(logging, logging.DEBUG) 10 | 11 | api_key, api_secret = get_api_key() 12 | 13 | client = Client(api_key, api_secret) 14 | 15 | try: 16 | response = client.fiat_payment_history(0) 17 | logging.info(response) 18 | except ClientError as error: 19 | logging.error( 20 | "Found error. status: {}, error code: {}, error message: {}".format( 21 | error.status_code, error.error_code, error.error_message 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_buy_code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from examples.utils.prepare_env import get_api_key 7 | 8 | config_logging(logging, logging.DEBUG) 9 | 10 | api_key, api_secret = get_api_key() 11 | 12 | client = Client(api_key, api_secret) 13 | 14 | response = client.gift_card_buy_code( 15 | baseToken="BUSD", faceToken="BNB", baseTokenAmount=100 16 | ) 17 | logging.info(response) 18 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_create_code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from examples.utils.prepare_env import get_api_key 7 | 8 | config_logging(logging, logging.DEBUG) 9 | 10 | api_key, api_secret = get_api_key() 11 | 12 | client = Client(api_key, api_secret) 13 | 14 | logger = logging.getLogger(__name__) 15 | 16 | response = client.gift_card_create_code("BNB", 0.2) 17 | logger.info(response) 18 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_redeem_code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from examples.utils.prepare_env import get_api_key 7 | 8 | config_logging(logging, logging.DEBUG) 9 | 10 | api_key, api_secret = get_api_key() 11 | 12 | client = Client(api_key, api_secret) 13 | 14 | logger = logging.getLogger(__name__) 15 | 16 | response = client.gift_card_redeem_code("") 17 | logger.info(response) 18 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_rsa_public_key.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from binance.error import ClientError 7 | from examples.utils.prepare_env import get_api_key 8 | 9 | config_logging(logging, logging.DEBUG) 10 | 11 | api_key, api_secret = get_api_key() 12 | 13 | client = Client(api_key, api_secret) 14 | 15 | try: 16 | response = client.gift_card_rsa_public_key() 17 | logging.info(response) 18 | except ClientError as error: 19 | logging.error( 20 | "Found error. status: {}, error code: {}, error message: {}".format( 21 | error.status_code, error.error_code, error.error_message 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_token_limit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from examples.utils.prepare_env import get_api_key 7 | 8 | config_logging(logging, logging.DEBUG) 9 | 10 | api_key, api_secret = get_api_key() 11 | 12 | client = Client(api_key, api_secret) 13 | 14 | response = client.gift_card_token_limit(baseToken="BUSD") 15 | logging.info(response) 16 | -------------------------------------------------------------------------------- /examples/spot/gift_card/gift_card_verify_code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import logging 4 | from binance.spot import Spot as Client 5 | from binance.lib.utils import config_logging 6 | from examples.utils.prepare_env import get_api_key 7 | 8 | config_logging(logging, logging.DEBUG) 9 | 10 | api_key, api_secret = get_api_key() 11 | 12 | client = Client(api_key, api_secret) 13 | 14 | logger = logging.getLogger(__name__) 15 | 16 | response = client.gift_card_verify_code("=2.31.0 2 | websocket-client>=1.6.3 3 | pycryptodome>=3.15.0 4 | -------------------------------------------------------------------------------- /requirements/requirements-dev.txt: -------------------------------------------------------------------------------- 1 | -r requirements-test.txt 2 | pre-commit 3 | sphinx 4 | sphinx_rtd_theme 5 | configparser>=5.3.0 -------------------------------------------------------------------------------- /requirements/requirements-test.txt: -------------------------------------------------------------------------------- 1 | -r common.txt 2 | pytest-cov>=2.8.1 3 | pytest>=6.2.5 4 | sure>=2.0.0 5 | responses>=0.10.12 6 | pytest-pep8>=1.0.6 7 | black 8 | flake8 9 | sphinx 10 | sphinx_rtd_theme 11 | tox 12 | tox-pyenv 13 | wheel 14 | -------------------------------------------------------------------------------- /requirements/requirements.txt: -------------------------------------------------------------------------------- 1 | -r common.txt -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | 4 | [tool:pytest] 5 | pep8ignore = E501 6 | 7 | [flake8] 8 | exclude = 9 | .git, 10 | .tox, 11 | build, 12 | dist 13 | max-complexity = 10 14 | ignore = E501, W503, W504 15 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | import sure # noqa: F401 2 | -------------------------------------------------------------------------------- /tests/spot/data_stream/margin/test_new_margin_listen_key.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | mock_exception = {"code": -1, "msg": "error message"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | 13 | orderListId = "1234567" 14 | 15 | 16 | @mock_http_response(responses.POST, "/sapi/v1/userDataStream", mock_item, 200) 17 | def test_new_listen_key(): 18 | """Tests the API endpoint to create a new listen key""" 19 | 20 | client = Client(key) 21 | response = client.new_margin_listen_key() 22 | response.should.equal(mock_item) 23 | -------------------------------------------------------------------------------- /tests/spot/data_stream/spot/test_new_listen_key.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | mock_exception = {"code": -1, "msg": "error message"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | 13 | 14 | @mock_http_response(responses.POST, "/api/v3/userDataStream", mock_item, 200) 15 | def test_new_listen_key(): 16 | """Tests the API endpoint to create a new listen key""" 17 | 18 | client = Client(key) 19 | response = client.new_listen_key() 20 | response.should.equal(mock_item) 21 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_adjust_ltv_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | client = Client(key, secret) 12 | 13 | 14 | @mock_http_response( 15 | responses.GET, 16 | "/sapi/v1/loan/ltv/adjustment/history\\?loanCoin=BUSD", 17 | mock_item, 18 | 200, 19 | ) 20 | def test_loan_adjust_ltv_history(): 21 | """Tests the API endpoint to get LTV adjustment history""" 22 | 23 | response = client.loan_adjust_ltv_history(loanCoin="BUSD") 24 | response.should.equal(mock_item) 25 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_borrow_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | client = Client(key, secret) 12 | 13 | 14 | @mock_http_response( 15 | responses.GET, 16 | "/sapi/v1/loan/borrow/history\\?loanCoin=BUSD", 17 | mock_item, 18 | 200, 19 | ) 20 | def test_loan_borrow_history(): 21 | """Tests the API endpoint to get borrow history""" 22 | 23 | response = client.loan_borrow_history(loanCoin="BUSD") 24 | response.should.equal(mock_item) 25 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_loanable_data.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from urllib.parse import urlencode 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | from binance.spot import Spot as Client 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | client = Client(key, secret) 13 | 14 | params = {"loanCoin": "BUSD", "vipLevel": 1} 15 | 16 | 17 | @mock_http_response( 18 | responses.GET, 19 | "/sapi/v1/loan/loanable/data\\?" + urlencode(params), 20 | mock_item, 21 | 200, 22 | ) 23 | def test_loan_loanable_data(): 24 | """Tests the API endpoint to get loanable asset data""" 25 | 26 | response = client.loan_loanable_data(**params) 27 | response.should.equal(mock_item) 28 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_repay_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | client = Client(key, secret) 12 | 13 | 14 | @mock_http_response( 15 | responses.GET, 16 | "/sapi/v1/loan/repay/history\\?loanCoin=BUSD", 17 | mock_item, 18 | 200, 19 | ) 20 | def test_loan_repay_history(): 21 | """Tests the API endpoint to get repay history""" 22 | 23 | response = client.loan_repay_history(loanCoin="BUSD") 24 | response.should.equal(mock_item) 25 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_vip_collateral_account.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from urllib.parse import urlencode 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | from binance.spot import Spot as Client 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | client = Client(key, secret) 13 | 14 | params = {"orderId": 100000001} 15 | 16 | 17 | @mock_http_response( 18 | responses.GET, 19 | "/sapi/v1/loan/vip/collateral/account\\?" + urlencode(params), 20 | mock_item, 21 | 200, 22 | ) 23 | def test_loan_vip_collateral_account(): 24 | """Tests the API endpoint to get vip loan collateral account""" 25 | 26 | response = client.loan_vip_collateral_account(**params) 27 | response.should.equal(mock_item) 28 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_vip_ongoing_orders.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from urllib.parse import urlencode 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | from binance.spot import Spot as Client 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | client = Client(key, secret) 13 | 14 | params = {"orderId": 100000001} 15 | 16 | 17 | @mock_http_response( 18 | responses.GET, 19 | "/sapi/v1/loan/vip/ongoing/orders\\?" + urlencode(params), 20 | mock_item, 21 | 200, 22 | ) 23 | def test_loan_vip_ongoing_orders(): 24 | """Tests the API endpoint to get vip loan ongoing orders""" 25 | 26 | response = client.loan_vip_ongoing_orders(**params) 27 | response.should.equal(mock_item) 28 | -------------------------------------------------------------------------------- /tests/spot/loan/test_loan_vip_repay_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from urllib.parse import urlencode 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | from binance.spot import Spot as Client 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | client = Client(key, secret) 13 | 14 | params = {"orderId": 100000001} 15 | 16 | 17 | @mock_http_response( 18 | responses.GET, 19 | "/sapi/v1/loan/vip/repay/history\\?" + urlencode(params), 20 | mock_item, 21 | 200, 22 | ) 23 | def test_loan_vip_repay_history(): 24 | """Tests the API endpoint to get vip loan history""" 25 | 26 | response = client.loan_vip_repay_history(**params) 27 | response.should.equal(mock_item) 28 | -------------------------------------------------------------------------------- /tests/spot/margin/test_bnbBurn_status.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/bnbBurn", mock_item, 200) 14 | def test_bnbBurn_status(): 15 | """Tests the API endpoint to get BNB Burn status""" 16 | 17 | client = Client(key, secret) 18 | response = client.bnbBurn_status() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/margin/test_cross_margin_collateral_ratio.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | mock_exception = {"code": -1, "msg": "error message"} 10 | 11 | key = random_str() 12 | secret = random_str() 13 | 14 | 15 | @mock_http_response( 16 | responses.GET, 17 | "/sapi/v1/margin/crossMarginCollateralRatio", 18 | mock_item, 19 | 200, 20 | ) 21 | def test_cross_margin_collateral_ratio(): 22 | """Tests the API endpoint to cross margin collateral ratio""" 23 | 24 | client = Client(key, secret) 25 | response = client.cross_margin_collateral_ratio() 26 | response.should.equal(mock_item) 27 | -------------------------------------------------------------------------------- /tests/spot/margin/test_isolated_margin_all_pairs.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | mock_exception = {"code": -1105, "msg": 'Parameter "orderId" was empty.'} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | 13 | 14 | @mock_http_response(responses.GET, "/sapi/v1/margin/isolated/allPairs", mock_item, 200) 15 | def test_isolated_margin_all_pairs(): 16 | """Tests the API endpoint to query isolated margin all pairs""" 17 | 18 | client = Client(key, secret) 19 | response = client.isolated_margin_all_pairs() 20 | response.should.equal(mock_item) 21 | -------------------------------------------------------------------------------- /tests/spot/margin/test_margin_all_assets.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/margin/allAssets", mock_item, 200) 14 | def test_margin_all_assets(): 15 | """Tests the API endpoint to margin all assets""" 16 | 17 | client = Client(key, secret) 18 | response = client.margin_all_assets() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/margin/test_margin_all_pairs.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/margin/allPairs", mock_item, 200) 14 | def test_margin_all_pairs(): 15 | """Tests the API endpoint to margin all pairs""" 16 | 17 | client = Client(key, secret) 18 | response = client.margin_all_pairs() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/margin/test_margin_open_orders.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from urllib.parse import urlencode 6 | from tests.util import mock_http_response 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | 10 | key = random_str() 11 | secret = random_str() 12 | 13 | params = {"symbol": "BNBUSDT", "recvWindow": 1000} 14 | 15 | 16 | @mock_http_response( 17 | responses.GET, "/sapi/v1/margin/openOrders\\?" + urlencode(params), mock_item, 200 18 | ) 19 | def test_margin_open_orders(): 20 | """Tests the API endpoint to query margin open orders""" 21 | 22 | client = Client(key, secret) 23 | response = client.margin_open_orders(**params) 24 | response.should.equal(mock_item) 25 | -------------------------------------------------------------------------------- /tests/spot/margin/test_toggle_bnbBurn.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.POST, "/sapi/v1/bnbBurn", mock_item, 200) 14 | def test_toggle_bnbBurn(): 15 | """Tests the API endpoint to Toggle BNBBurn On Spot Trade And Margin Interest""" 16 | 17 | client = Client(key, secret) 18 | response = client.toggle_bnbBurn() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/market/test_avg_price.py: -------------------------------------------------------------------------------- 1 | from binance.spot import Spot as Client 2 | import responses 3 | 4 | from tests.util import mock_http_response 5 | from binance.error import ParameterRequiredError 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | 10 | def test_avg_price_without_symbol(): 11 | """Tests the API endpoint to get avg price without symbol""" 12 | 13 | api = Client() 14 | api.avg_price.when.called_with("").should.throw(ParameterRequiredError) 15 | 16 | 17 | @mock_http_response(responses.GET, "/api/v3/avgPrice\\?symbol=BTCUSDT", mock_item, 200) 18 | def test_avg_price(): 19 | """Tests the API endpoint to avg price""" 20 | 21 | api = Client() 22 | response = api.avg_price("BTCUSDT") 23 | response.should.equal(mock_item) 24 | -------------------------------------------------------------------------------- /tests/spot/market/test_ping.py: -------------------------------------------------------------------------------- 1 | from binance.spot import Spot as Client 2 | import responses 3 | 4 | from tests.util import mock_http_response 5 | 6 | 7 | @mock_http_response(responses.GET, "/api/v3/ping", {}, 200) 8 | def test_ping(): 9 | """Tests the API endpoint to get connectivity""" 10 | 11 | api = Client() 12 | response = api.ping() 13 | response.should.equal({}) 14 | -------------------------------------------------------------------------------- /tests/spot/market/test_time.py: -------------------------------------------------------------------------------- 1 | from binance.spot import Spot as Client 2 | import responses 3 | 4 | from tests.util import mock_http_response 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | 8 | 9 | @mock_http_response(responses.GET, "/api/v3/time", mock_item, 200) 10 | def test_time(): 11 | """Tests the API endpoint to get exchange time""" 12 | 13 | api = Client() 14 | response = api.time() 15 | response.should.equal(mock_item) 16 | -------------------------------------------------------------------------------- /tests/spot/mining/test_mining_algo_list.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/mining/pub/algoList", mock_item, 200) 14 | def test_mining_algo_list(): 15 | """Tests the API endpoint to get algo list""" 16 | 17 | client = Client(key, secret) 18 | response = client.mining_algo_list() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/mining/test_mining_coin_list.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/mining/pub/coinList", mock_item, 200) 14 | def test_mining_coin_list(): 15 | """Tests the API endpoint to get coin list""" 16 | 17 | client = Client(key, secret) 18 | response = client.mining_coin_list() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/mining/test_mining_hashrate_resale_list.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/sapi/v1/mining/hash-transfer/config/details/list", mock_item, 200 15 | ) 16 | def test_mining_hashrate_resale_list(): 17 | """Tests the API endpoint to get hashrate resale list""" 18 | 19 | client = Client(key, secret) 20 | response = client.mining_hashrate_resale_list() 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/portfolio_margin/test_portfolio_margin_collateral_rate.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | mock_exception = {"code": -1, "msg": "error message"} 10 | 11 | key = random_str() 12 | secret = random_str() 13 | 14 | 15 | @mock_http_response( 16 | responses.GET, 17 | "/sapi/v1/portfolio/collateralRate", 18 | mock_item, 19 | 200, 20 | ) 21 | def test_portfolio_margin_collateral_rate(): 22 | """Tests the API endpoint to portfolio margin collateral rate""" 23 | 24 | client = Client(key, secret) 25 | response = client.portfolio_margin_collateral_rate() 26 | response.should.equal(mock_item) 27 | -------------------------------------------------------------------------------- /tests/spot/sub_account/test_sub_account_margin_account_summary.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/sapi/v1/sub-account/margin/accountSummary", mock_item, 200 15 | ) 16 | def test_sub_account_margin_account_summary(): 17 | """Tests the API endpoint to get sub account margin account summary""" 18 | 19 | client = Client(key, secret) 20 | response = client.sub_account_margin_account_summary() 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/sub_account/test_sub_account_spot_summary.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response(responses.GET, "/sapi/v1/sub-account/spotSummary", mock_item, 200) 14 | def test_sub_account_spot_summary(): 15 | """Tests the API endpoint to get BTC valued asset summary of subaccouts.""" 16 | 17 | client = Client(key, secret) 18 | response = client.sub_account_spot_summary() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/sub_account/test_sub_account_spot_transfer_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/sapi/v1/sub-account/sub/transfer/history", mock_item, 200 15 | ) 16 | def test_sub_account_spot_transfer_history(): 17 | """Tests the API endpoint to fetch sub-accounts spot transfer history""" 18 | 19 | client = Client(key, secret) 20 | response = client.sub_account_spot_transfer_history() 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/sub_account/test_sub_account_status.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/sapi/v1/sub-account/status\\?email=alice@test.com", mock_item, 200 15 | ) 16 | def test_sub_account_asset(): 17 | """Tests the API endpoint to get sub account asset""" 18 | 19 | client = Client(key, secret) 20 | response = client.sub_account_status(email="alice@test.com") 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/sub_account/test_sub_account_universal_transfer_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from tests.util import random_str 4 | from tests.util import mock_http_response 5 | from binance.spot import Spot as Client 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/sapi/v1/sub-account/universalTransfer", mock_item, 200 15 | ) 16 | def test_sub_account_universal_transfer_history(): 17 | """Tests the API endpoint to query universal transfer history within master account""" 18 | 19 | client = Client(key, secret) 20 | response = client.sub_account_universal_transfer_history() 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/trade/test_get_oco_open_orders.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from tests.util import mock_http_response 6 | 7 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 8 | 9 | key = random_str() 10 | secret = random_str() 11 | 12 | 13 | @mock_http_response( 14 | responses.GET, "/api/v3/openOrderList\\?recvWindow=1000", mock_item, 200 15 | ) 16 | def test_get_oco_open_orders(): 17 | """Tests the API endpoint to get all oco open orders""" 18 | 19 | client = Client(key, secret) 20 | response = client.get_oco_open_orders(recvWindow=1000) 21 | response.should.equal(mock_item) 22 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_account_status.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/account/status", mock_item, 200) 12 | def test_account_status(): 13 | """Tests the API endpoint to check account status""" 14 | 15 | client = Client(key, secret) 16 | response = client.account_status() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_api_key_permissions.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/account/apiRestrictions", mock_item, 200) 12 | def test_funding_wallet(): 13 | """Tests the API endpoint to obtain the api key's permissions""" 14 | 15 | client = Client(key, secret) 16 | response = client.api_key_permissions() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_api_trading_status.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/account/apiTradingStatus", mock_item, 200) 12 | def test_api_trading_status(): 13 | """Tests the API endpoint to check api trading status""" 14 | 15 | client = Client(key, secret) 16 | response = client.api_trading_status() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_asset_detail.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/asset/assetDetail", mock_item, 200) 12 | def test_asset_detail(): 13 | """Tests the API endpoint to check asset detail""" 14 | 15 | client = Client(key, secret) 16 | response = client.asset_detail() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_balance.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = [{"key_1": "value_1", "key_2": "value_2"}] 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/asset/wallet/balance", mock_item, 200) 12 | def test_balance(): 13 | """Tests the API endpoint to get balance""" 14 | 15 | client = Client(key, secret) 16 | response = client.balance() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_bnb_convertible_assets.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.POST, "/sapi/v1/asset/dust-btc", mock_item, 200) 12 | def test_bnb_convertible_assets(): 13 | """Tests the API endpoint to get Assets That Can Be Converted Into BNB""" 14 | 15 | client = Client(key, secret) 16 | response = client.bnb_convertible_assets() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_coin_info.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/capital/config/getall", mock_item, 200) 12 | def test_coin_info(): 13 | """Tests the API endpoint to check coin info""" 14 | 15 | client = Client(key, secret) 16 | response = client.coin_info() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_deposit_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/capital/deposit/hisrec", mock_item, 200) 12 | def test_deposit_history(): 13 | """Tests the API endpoint to get deposit history""" 14 | 15 | client = Client(key, secret) 16 | response = client.deposit_history() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_disable_fast_withdraw.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response( 12 | responses.POST, "/sapi/v1/account/disableFastWithdrawSwitch", mock_item, 200 13 | ) 14 | def test_disable_fast_withdraw(): 15 | """Tests the API endpoint to disable fast withdraw""" 16 | 17 | client = Client(key, secret) 18 | response = client.disable_fast_withdraw() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_dust_log.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/asset/dribblet", mock_item, 200) 12 | def test_dust_log(): 13 | """Tests the API endpoint to check dust log""" 14 | 15 | client = Client(key, secret) 16 | response = client.dust_log() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_enable_fast_withdraw.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response( 12 | responses.POST, "/sapi/v1/account/enableFastWithdrawSwitch", mock_item, 200 13 | ) 14 | def test_enable_fast_withdraw(): 15 | """Tests the API endpoint to enable fast withdraw""" 16 | 17 | client = Client(key, secret) 18 | response = client.enable_fast_withdraw() 19 | response.should.equal(mock_item) 20 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_funding_wallet.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.POST, "/sapi/v1/asset/get-funding-asset", mock_item, 200) 12 | def test_funding_wallet(): 13 | """Tests the API endpoint to obtain the assets from the funding wallet""" 14 | 15 | client = Client(key, secret) 16 | response = client.funding_wallet() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_system_status.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/system/status", mock_item, 200) 12 | def test_system_status(): 13 | """Tests the API endpoint to check system status""" 14 | 15 | client = Client(key, secret) 16 | response = client.system_status() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_trade_fee.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/asset/tradeFee", mock_item, 200) 12 | def test_trade_fee(): 13 | """Tests the API endpoint to get trading fee""" 14 | 15 | client = Client(key, secret) 16 | response = client.trade_fee() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_user_asset.py: -------------------------------------------------------------------------------- 1 | import responses 2 | 3 | from binance.spot import Spot as Client 4 | from tests.util import random_str 5 | from urllib.parse import urlencode 6 | from tests.util import mock_http_response 7 | 8 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 9 | mock_exception = {"code": -1, "msg": "error message"} 10 | 11 | key = random_str() 12 | secret = random_str() 13 | 14 | params = {"asset": "BNB", "recvWindow": 5000} 15 | 16 | 17 | @mock_http_response( 18 | responses.POST, 19 | "/sapi/v3/asset/getUserAsset\\?" + urlencode(params), 20 | mock_item, 21 | 200, 22 | ) 23 | def test_user_asset(): 24 | """Tests the API endpoint to user asset""" 25 | 26 | client = Client(key, secret) 27 | response = client.user_asset(**params) 28 | response.should.equal(mock_item) 29 | -------------------------------------------------------------------------------- /tests/spot/wallet/test_withdraw_history.py: -------------------------------------------------------------------------------- 1 | import responses 2 | from binance.spot import Spot as Client 3 | from tests.util import mock_http_response 4 | from tests.util import random_str 5 | 6 | mock_item = {"key_1": "value_1", "key_2": "value_2"} 7 | key = random_str() 8 | secret = random_str() 9 | 10 | 11 | @mock_http_response(responses.GET, "/sapi/v1/capital/withdraw/history", mock_item, 200) 12 | def test_withdraw_history(): 13 | """Tests the API endpoint to get withdraw history""" 14 | 15 | client = Client(key, secret) 16 | response = client.withdraw_history() 17 | response.should.equal(mock_item) 18 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py38,py39,310,311 3 | 4 | [testenv] 5 | deps = 6 | -rrequirements/requirements-test.txt 7 | commands = 8 | pytest 9 | --------------------------------------------------------------------------------