├── .tool-versions ├── python_version.txt ├── .gitignore ├── iqoptionapi ├── version_control.py ├── ws │ ├── __init__.py │ ├── chanels │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── base.cpython-310.pyc │ │ │ ├── buyv2.cpython-310.pyc │ │ │ ├── buyv3.cpython-310.pyc │ │ │ ├── ssid.cpython-310.pyc │ │ │ ├── user.cpython-310.pyc │ │ │ ├── __init__.cpython-310.pyc │ │ │ ├── candles.cpython-310.pyc │ │ │ ├── change_tpsl.cpython-310.pyc │ │ │ ├── get_order.cpython-310.pyc │ │ │ ├── heartbeat.cpython-310.pyc │ │ │ ├── instruments.cpython-310.pyc │ │ │ ├── leaderboard.cpython-310.pyc │ │ │ ├── sell_option.cpython-310.pyc │ │ │ ├── setactives.cpython-310.pyc │ │ │ ├── strike_list.cpython-310.pyc │ │ │ ├── subscribe.cpython-310.pyc │ │ │ ├── unsubscribe.cpython-310.pyc │ │ │ ├── cancel_order.cpython-310.pyc │ │ │ ├── get_balances.cpython-310.pyc │ │ │ ├── get_positions.cpython-310.pyc │ │ │ ├── traders_mood.cpython-310.pyc │ │ │ ├── api_game_betinfo.cpython-310.pyc │ │ │ ├── close_position.cpython-310.pyc │ │ │ ├── digital_option.cpython-310.pyc │ │ │ ├── get_overnight_fee.cpython-310.pyc │ │ │ ├── api_game_getoptions.cpython-310.pyc │ │ │ ├── buy_place_order_temp.cpython-310.pyc │ │ │ ├── get_deferred_orders.cpython-310.pyc │ │ │ ├── sell_digital_option.cpython-310.pyc │ │ │ ├── technical_indicators.cpython-310.pyc │ │ │ ├── change_auto_margin_call.cpython-310.pyc │ │ │ ├── get_available_leverages.cpython-310.pyc │ │ │ └── get_financial_information.cpython-310.pyc │ │ ├── buyback.py │ │ ├── get_balances.py │ │ ├── cancel_order.py │ │ ├── close_position.py │ │ ├── heartbeat.py │ │ ├── ssid.py │ │ ├── instruments.py │ │ ├── get_order.py │ │ ├── change_auto_margin_call.py │ │ ├── get_available_leverages.py │ │ ├── get_overnight_fee.py │ │ ├── technical_indicators.py │ │ ├── setactives.py │ │ ├── get_deferred_orders.py │ │ ├── api_game_betinfo.py │ │ ├── sell_option.py │ │ ├── changebalance.py │ │ ├── base.py │ │ ├── api_game_getoptions.py │ │ ├── change_tpsl.py │ │ ├── sell_digital_option.py │ │ ├── strike_list.py │ │ ├── traders_mood.py │ │ ├── get_financial_information.py │ │ ├── buyv2.py │ │ ├── candles.py │ │ ├── leaderboard.py │ │ ├── user.py │ │ ├── digital_option.py │ │ ├── buy_place_order_temp.py │ │ ├── get_positions.py │ │ ├── buyv3.py │ │ ├── unsubscribe.py │ │ └── subscribe.py │ ├── objects │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── base.cpython-310.pyc │ │ │ ├── __init__.cpython-310.pyc │ │ │ ├── betinfo.cpython-310.pyc │ │ │ ├── candles.cpython-310.pyc │ │ │ ├── profile.cpython-310.pyc │ │ │ ├── timesync.cpython-310.pyc │ │ │ └── listinfodata.cpython-310.pyc │ │ ├── base.py │ │ ├── listinfodata.py │ │ ├── betinfo.py │ │ ├── timesync.py │ │ ├── candles.py │ │ └── profile.py │ ├── received │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── order.cpython-310.pyc │ │ │ ├── candles.cpython-310.pyc │ │ │ ├── option.cpython-310.pyc │ │ │ ├── profile.cpython-310.pyc │ │ │ ├── result.cpython-310.pyc │ │ │ ├── __init__.cpython-310.pyc │ │ │ ├── balances.cpython-310.pyc │ │ │ ├── heartbeat.cpython-310.pyc │ │ │ ├── live_deal.cpython-310.pyc │ │ │ ├── position.cpython-310.pyc │ │ │ ├── positions.cpython-310.pyc │ │ │ ├── time_sync.cpython-310.pyc │ │ │ ├── buy_complete.cpython-310.pyc │ │ │ ├── instruments.cpython-310.pyc │ │ │ ├── sold_options.cpython-310.pyc │ │ │ ├── strike_list.cpython-310.pyc │ │ │ ├── tpsl_changed.cpython-310.pyc │ │ │ ├── balance_changed.cpython-310.pyc │ │ │ ├── deferred_orders.cpython-310.pyc │ │ │ ├── list_info_data.cpython-310.pyc │ │ │ ├── option_closed.cpython-310.pyc │ │ │ ├── option_opened.cpython-310.pyc │ │ │ ├── order_canceled.cpython-310.pyc │ │ │ ├── overnight_fee.cpython-310.pyc │ │ │ ├── position_closed.cpython-310.pyc │ │ │ ├── underlying_list.cpython-310.pyc │ │ │ ├── candle_generated.cpython-310.pyc │ │ │ ├── history_positions.cpython-310.pyc │ │ │ ├── order_placed_temp.cpython-310.pyc │ │ │ ├── position_changed.cpython-310.pyc │ │ │ ├── position_history.cpython-310.pyc │ │ │ ├── available_leverages.cpython-310.pyc │ │ │ ├── candle_generated_v2.cpython-310.pyc │ │ │ ├── commission_changed.cpython-310.pyc │ │ │ ├── initialization_data.cpython-310.pyc │ │ │ ├── socket_option_closed.cpython-310.pyc │ │ │ ├── socket_option_opened.cpython-310.pyc │ │ │ ├── technical_indicators.cpython-310.pyc │ │ │ ├── top_assets_updated.cpython-310.pyc │ │ │ ├── traders_mood_changed.cpython-310.pyc │ │ │ ├── user_profile_client.cpython-310.pyc │ │ │ ├── users_availability.cpython-310.pyc │ │ │ ├── client_price_generated.cpython-310.pyc │ │ │ ├── digital_option_placed.cpython-310.pyc │ │ │ ├── financial_information.cpython-310.pyc │ │ │ ├── training_balance_reset.cpython-310.pyc │ │ │ ├── api_game_betinfo_result.cpython-310.pyc │ │ │ ├── auto_margin_call_changed.cpython-310.pyc │ │ │ ├── leaderboard_deals_client.cpython-310.pyc │ │ │ ├── live_deal_digital_option.cpython-310.pyc │ │ │ ├── api_game_getoptions_result.cpython-310.pyc │ │ │ ├── api_option_init_all_result.cpython-310.pyc │ │ │ ├── instrument_quotes_generated.cpython-310.pyc │ │ │ ├── live_deal_binary_option_placed.cpython-310.pyc │ │ │ └── leaderboard_userinfo_deals_client.cpython-310.pyc │ │ ├── order.py │ │ ├── balances.py │ │ ├── options.py │ │ ├── position.py │ │ ├── positions.py │ │ ├── result.py │ │ ├── strike_list.py │ │ ├── overnight_fee.py │ │ ├── instruments.py │ │ ├── order_canceled.py │ │ ├── sold_options.py │ │ ├── time_sync.py │ │ ├── deferred_orders.py │ │ ├── position_history.py │ │ ├── tpsl_changed.py │ │ ├── option.py │ │ ├── history_positions.py │ │ ├── available_leverages.py │ │ ├── underlying_list.py │ │ ├── users_availability.py │ │ ├── order_placed_temp.py │ │ ├── user_profile_client.py │ │ ├── financial_information.py │ │ ├── initialization_data.py │ │ ├── api_game_getoptions_result.py │ │ ├── auto_margin_call_changed.py │ │ ├── heartbeat.py │ │ ├── leaderboard_deals_client.py │ │ ├── option_opened.py │ │ ├── api_option_init_all_result.py │ │ ├── position_closed.py │ │ ├── traders_mood_changed.py │ │ ├── training_balance_reset.py │ │ ├── candles.py │ │ ├── socket_option_closed.py │ │ ├── socket_option_opened.py │ │ ├── top_assets_updated.py │ │ ├── leaderboard_userinfo_deals_client.py │ │ ├── list_info_data.py │ │ ├── buy_complete.py │ │ ├── api_game_betinfo_result.py │ │ ├── option_closed.py │ │ ├── client_price_generated.py │ │ ├── technical_indicators.py │ │ ├── balance_changed.py │ │ ├── commission_changed.py │ │ ├── digital_option_placed.py │ │ ├── position_changed.py │ │ ├── candle_generated.py │ │ ├── live_deal.py │ │ ├── candle_generated_v2.py │ │ ├── live_deal_binary_option_placed.py │ │ ├── live_deal_digital_option.py │ │ ├── profile.py │ │ └── instrument_quotes_generated.py │ ├── __pycache__ │ │ ├── client.cpython-310.pyc │ │ └── __init__.cpython-310.pyc │ └── client.py ├── http │ ├── __init__.py │ ├── __pycache__ │ │ ├── auth.cpython-310.pyc │ │ ├── appinit.cpython-310.pyc │ │ ├── billing.cpython-310.pyc │ │ ├── buyback.cpython-310.pyc │ │ ├── events.cpython-310.pyc │ │ ├── login.cpython-310.pyc │ │ ├── loginv2.cpython-310.pyc │ │ ├── logout.cpython-310.pyc │ │ ├── profile.cpython-310.pyc │ │ ├── token.cpython-310.pyc │ │ ├── verify.cpython-310.pyc │ │ ├── __init__.cpython-310.pyc │ │ ├── login2fa.cpython-310.pyc │ │ ├── resource.cpython-310.pyc │ │ ├── send_sms.cpython-310.pyc │ │ ├── getprofile.cpython-310.pyc │ │ └── changebalance.cpython-310.pyc │ ├── auth.py │ ├── billing.py │ ├── profile.py │ ├── register.py │ ├── loginv2.py │ ├── logout.py │ ├── getprofile.py │ ├── appinit.py │ ├── getregdata.py │ ├── token.py │ ├── buyback.py │ ├── resource.py │ ├── changebalance.py │ ├── events.py │ ├── login.py │ ├── login2fa.py │ ├── send_sms.py │ └── verify.py ├── __pycache__ │ ├── api.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ ├── constants.cpython-310.pyc │ ├── country_id.cpython-310.pyc │ ├── expiration.cpython-310.pyc │ ├── global_value.cpython-310.pyc │ ├── stable_api.cpython-310.pyc │ └── version_control.cpython-310.pyc ├── global_value.py ├── __init__.py ├── expiration.py ├── country_id.py ├── constants.py └── api.py ├── project_journal.txt ├── readme.md ├── requirements.txt ├── database.py ├── LICENSE ├── strategy.py ├── main.py ├── indicators.py └── trader.py /.tool-versions: -------------------------------------------------------------------------------- 1 | python 3.10.6 2 | -------------------------------------------------------------------------------- /python_version.txt: -------------------------------------------------------------------------------- 1 | Python 3.10.6 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CONSTANTS.py 2 | __pycache__ 3 | -------------------------------------------------------------------------------- /iqoptionapi/version_control.py: -------------------------------------------------------------------------------- 1 | api_version = "7.1.1" -------------------------------------------------------------------------------- /iqoptionapi/ws/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket.""" 2 | -------------------------------------------------------------------------------- /iqoptionapi/http/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API http resources.""" 2 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket chanels.""" 2 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket objects.""" 2 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket received.""" 2 | -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/api.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/api.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/constants.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/constants.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/auth.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/auth.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/__pycache__/client.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/__pycache__/client.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/country_id.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/country_id.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/expiration.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/expiration.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/global_value.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/global_value.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/stable_api.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/stable_api.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/appinit.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/appinit.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/billing.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/billing.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/buyback.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/buyback.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/events.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/events.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/login.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/login.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/loginv2.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/loginv2.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/logout.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/logout.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/profile.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/profile.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/token.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/token.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/verify.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/verify.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/login2fa.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/login2fa.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/resource.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/resource.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/send_sms.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/send_sms.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/__pycache__/version_control.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/__pycache__/version_control.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/getprofile.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/getprofile.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/base.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/base.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/buyv2.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/buyv2.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/buyv3.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/buyv3.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/ssid.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/ssid.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/user.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/user.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/base.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/base.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/order.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/order.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/http/__pycache__/changebalance.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/http/__pycache__/changebalance.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/candles.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/candles.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/betinfo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/betinfo.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/profile.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/profile.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/candles.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/candles.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/option.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/option.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/profile.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/profile.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/result.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/result.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/change_tpsl.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/change_tpsl.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_order.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_order.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/heartbeat.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/heartbeat.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/instruments.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/instruments.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/leaderboard.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/leaderboard.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/sell_option.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/sell_option.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/setactives.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/setactives.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/strike_list.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/strike_list.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/subscribe.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/subscribe.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/unsubscribe.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/unsubscribe.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/balances.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/balances.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/heartbeat.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/heartbeat.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/live_deal.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/live_deal.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/position.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/position.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/positions.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/positions.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/time_sync.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/time_sync.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/cancel_order.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/cancel_order.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_balances.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_balances.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_positions.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_positions.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/traders_mood.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/traders_mood.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/__pycache__/listinfodata.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/objects/__pycache__/listinfodata.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/buy_complete.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/buy_complete.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/instruments.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/instruments.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/sold_options.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/sold_options.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/strike_list.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/strike_list.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/tpsl_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/tpsl_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/order.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def order(api, message): 4 | if message["name"] == "order": 5 | api.order_data = message 6 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/api_game_betinfo.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/api_game_betinfo.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/close_position.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/close_position.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/digital_option.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/digital_option.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/balance_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/balance_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/deferred_orders.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/deferred_orders.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/list_info_data.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/list_info_data.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/option_closed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/option_closed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/option_opened.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/option_opened.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/order_canceled.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/order_canceled.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/overnight_fee.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/overnight_fee.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/position_closed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/position_closed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/underlying_list.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/underlying_list.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/balances.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def balances(api, message): 4 | if message["name"] == "balances": 5 | api.balances_raw = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/options.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def option(api, message): 4 | if message["name"] == "options": 5 | api.get_options_v2_data = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/position.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def position(api, message): 4 | if message["name"] == "position": 5 | api.position = message 6 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_overnight_fee.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_overnight_fee.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/candle_generated.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/candle_generated.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/history_positions.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/history_positions.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/order_placed_temp.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/order_placed_temp.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/position_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/position_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/position_history.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/position_history.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/positions.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def positions(api, message): 4 | if message["name"] == "positions": 5 | api.positions = message 6 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/result.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def result(api, message): 4 | if message["name"] == "result": 5 | api.result = message["msg"]["success"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/strike_list.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def strike_list(api, message): 4 | if message["name"] == "strike-list": 5 | api.strike_list = message -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/api_game_getoptions.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/api_game_getoptions.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/buy_place_order_temp.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/buy_place_order_temp.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_deferred_orders.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_deferred_orders.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/sell_digital_option.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/sell_digital_option.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/technical_indicators.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/technical_indicators.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/available_leverages.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/available_leverages.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/candle_generated_v2.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/candle_generated_v2.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/commission_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/commission_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/initialization_data.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/initialization_data.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/socket_option_closed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/socket_option_closed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/socket_option_opened.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/socket_option_opened.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/technical_indicators.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/technical_indicators.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/top_assets_updated.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/top_assets_updated.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/traders_mood_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/traders_mood_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/user_profile_client.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/user_profile_client.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/users_availability.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/users_availability.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/change_auto_margin_call.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/change_auto_margin_call.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_available_leverages.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_available_leverages.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/client_price_generated.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/client_price_generated.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/digital_option_placed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/digital_option_placed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/financial_information.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/financial_information.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/training_balance_reset.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/training_balance_reset.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/overnight_fee.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def overnight_fee(api, message): 4 | if message["name"] == "overnight-fee": 5 | api.overnight_fee = message -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/__pycache__/get_financial_information.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/chanels/__pycache__/get_financial_information.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/api_game_betinfo_result.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/api_game_betinfo_result.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/auto_margin_call_changed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/auto_margin_call_changed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/leaderboard_deals_client.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/leaderboard_deals_client.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/live_deal_digital_option.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/live_deal_digital_option.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/instruments.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def instruments(api, message): 4 | if message["name"] == "instruments": 5 | api.instruments = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/order_canceled.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def order_canceled(api, message): 4 | if message["name"] == "order-canceled": 5 | api.order_canceled = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/sold_options.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def sold_options(api, message): 4 | if message["name"] == "sold-options": 5 | api.sold_options_respond = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/time_sync.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def time_sync(api, message): 4 | if message["name"] == "timeSync": 5 | api.timesync.server_timestamp = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/api_game_getoptions_result.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/api_game_getoptions_result.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/api_option_init_all_result.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/api_option_init_all_result.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/instrument_quotes_generated.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/instrument_quotes_generated.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/deferred_orders.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def deferred_orders(api, message): 4 | if message["name"] == "deferred-orders": 5 | api.deferred_orders = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/position_history.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def position_history(api, message): 4 | if message["name"] == "position-history": 5 | api.position_history = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/tpsl_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def tpsl_changed(api, message): 4 | if message["name"] == "tpsl-changed": 5 | api.tpsl_changed_respond = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/live_deal_binary_option_placed.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/live_deal_binary_option_placed.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/option.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def option(api, message): 4 | if message["name"] == "option": 5 | api.buy_multi_option[str(message["request_id"])] = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/history_positions.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def history_positions(api, message): 4 | if message["name"] == "history-positions": 5 | api.position_history_v2 = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/__pycache__/leaderboard_userinfo_deals_client.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rena-biaobock/profit-ia/HEAD/iqoptionapi/ws/received/__pycache__/leaderboard_userinfo_deals_client.cpython-310.pyc -------------------------------------------------------------------------------- /iqoptionapi/ws/received/available_leverages.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def available_leverages(api, message): 4 | if message["name"] == "available-leverages": 5 | api.available_leverages = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/underlying_list.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def underlying_list(api, message): 4 | if message["name"] == "underlying-list": 5 | api.underlying_list_data = message["msg"] 6 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/users_availability.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def users_availability(api, message): 4 | if message["name"] == "users-availability": 5 | api.users_availability = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/order_placed_temp.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def order_placed_temp(api, message): 4 | if message["name"] == "order-placed-temp": 5 | api.buy_order_id = message["msg"]["id"] 6 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/user_profile_client.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def user_profile_client(api, message): 4 | if message["name"] == "user-profile-client": 5 | api.user_profile_client = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/financial_information.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def financial_information(api, message): 4 | if message["name"] == "financial-information": 5 | api.financial_information = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/initialization_data.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def initialization_data(api, message): 4 | if message["name"] == "initialization-data": 5 | api.api_option_init_all_result_v2 = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/api_game_getoptions_result.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def api_game_getoptions_result(api, message): 4 | if message["name"] == "api_game_getoptions_result": 5 | api.api_game_getoptions_result = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/auto_margin_call_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def auto_margin_call_changed(api, message): 4 | if message["name"] == "auto-margin-call-changed": 5 | api.auto_margin_call_changed_respond = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/heartbeat.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def heartbeat(api, message): 4 | if message["name"] == "heartbeat": 5 | try: 6 | api.heartbeat(message["msg"]) 7 | except: 8 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/leaderboard_deals_client.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def leaderboard_deals_client(api, message): 4 | if message["name"] == "leaderboard-deals-client": 5 | api.leaderboard_deals_client = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/option_opened.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def option_opened(api, message): 4 | if message["name"] == "option-opened": 5 | api.order_async[int(message["msg"]["option_id"])][message["name"]] = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/api_option_init_all_result.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def api_option_init_all_result(api, message): 4 | if message["name"] == "api_option_init_all_result": 5 | api.api_option_init_all_result = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/position_closed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def position_closed(api, message): 4 | if message["name"] == "position-closed": 5 | api.close_position_data = message 6 | api.sold_digital_options_respond = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/traders_mood_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def traders_mood_changed(api, message): 4 | if message["name"] == "traders-mood-changed": 5 | api.traders_mood[message["msg"]["asset_id"]] = message["msg"]["value"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/training_balance_reset.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def training_balance_reset(api, message): 4 | if message["name"] == "training-balance-reset": 5 | api.training_balance_reset_request = message["msg"]["isSuccessful"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/candles.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def candles(api, message): 4 | if message['name'] == 'candles': 5 | try: 6 | api.candles.candles_data = message["msg"]["candles"] 7 | except: 8 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/socket_option_closed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def socket_option_closed(api, message): 4 | if message["name"] == "socket-option-closed": 5 | id = message["msg"]["id"] 6 | api.socket_option_closed[id] = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/socket_option_opened.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def socket_option_opened(api, message): 4 | if message["name"] == "socket-option-opened": 5 | id = message["msg"]["id"] 6 | api.socket_option_opened[id] = message -------------------------------------------------------------------------------- /iqoptionapi/ws/received/top_assets_updated.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def top_assets_updated(api, message): 4 | if message["name"] == "top-assets-updated": 5 | api.top_assets_updated_data[str(message["msg"]["instrument_type"])] = message["msg"]["data"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/leaderboard_userinfo_deals_client.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def leaderboard_userinfo_deals_client(api, message): 4 | if message["name"] == "leaderboard-userinfo-deals-client": 5 | api.leaderboard_userinfo_deals_client = message["msg"] -------------------------------------------------------------------------------- /iqoptionapi/ws/received/list_info_data.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def list_info_data(api, message): 4 | if message["name"] == "listInfoData": 5 | for get_m in message["msg"]: 6 | api.listinfodata.set(get_m["win"], get_m["game_state"], get_m["id"]) -------------------------------------------------------------------------------- /project_journal.txt: -------------------------------------------------------------------------------- 1 | [08/08/2022] 2 | Created RDS database on amazon AWS, created database conection, created database tables: entries and candles, done IQOption API intalation and configuration. In synthesis, all base configuration is done and ready to begin the main funtionalities. 3 | 4 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Binary Options trading bot with Artificial Inteligence. 2 | 3 | Copyright (c) 2022 renabiaobock 4 | 5 | Project planing on Notion: 6 | https://real-tapir-e52.notion.site/ProfitAI-6360a68c55c04432b72538df3911bda4 7 | 8 | API: https://github.com/iqoptionapi/iqoptionapi 9 | -------------------------------------------------------------------------------- /iqoptionapi/http/auth.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http auth resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Auth(Resource): 7 | """Class for IQ Option http auth resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "auth" 11 | -------------------------------------------------------------------------------- /iqoptionapi/http/billing.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option billing resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Billing(Resource): 7 | """Class for IQ option billing resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "billing" 11 | -------------------------------------------------------------------------------- /iqoptionapi/http/profile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option profile resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Profile(Resource): 7 | """Class for IQ option profile resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "profile" 11 | -------------------------------------------------------------------------------- /iqoptionapi/http/register.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option register resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Register(Resource): 7 | """Class for IQ option register resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "register" 11 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/buy_complete.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def buy_complete(api, message): 4 | if message['name'] == 'buyComplete': 5 | try: 6 | api.buy_successful = message["msg"]["isSuccessful"] 7 | api.buy_id = message["msg"]["result"]["id"] 8 | except: 9 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/api_game_betinfo_result.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def api_game_betinfo_result(api, message): 4 | if message["name"] == "api_game_betinfo_result": 5 | try: 6 | api.game_betinfo.isSuccessful = message["msg"]["isSuccessful"] 7 | api.game_betinfo.dict = message["msg"] 8 | except: 9 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/option_closed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def option_closed(api, message): 4 | if message["name"] == "option-closed": 5 | api.order_async[int(message["msg"]["option_id"])][message["name"]] = message 6 | if message["microserviceName"] == "binary-options": 7 | api.order_binary[message["msg"]["option_id"]] = message['msg'] -------------------------------------------------------------------------------- /iqoptionapi/http/loginv2.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http loginv2 resource.""" 2 | 3 | from iqoptionapi.http.login import Login 4 | 5 | 6 | class Loginv2(Login): 7 | """Class for IQ option loginv2 resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "/".join((Login.url, "v2")) 11 | 12 | def __init__(self, api): 13 | super(Loginv2, self).__init__(api) 14 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/client_price_generated.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def client_price_generated(api, message): 4 | if message["name"] == "client-price-generated": 5 | ask_price = [d for d in message["msg"]["prices"] if d['strike'] == 'SPT'][0]['call']['ask'] 6 | api.digital_payout = int(((100-ask_price)*100)/ask_price) 7 | api.client_price_generated = message["msg"] 8 | else: 9 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/buyback.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyback websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Buyback(Base): 7 | """Class for IQ option subscribe to buyback websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "buyback" 11 | 12 | def __call__(self): 13 | """Method to send message to buyback websocket chanel.""" 14 | pass 15 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_balances.py: -------------------------------------------------------------------------------- 1 | 2 | from iqoptionapi.ws.chanels.base import Base 3 | import time 4 | 5 | class Get_Balances(Base): 6 | name = "sendMessage" 7 | def __call__(self): 8 | """ 9 | :param options_ids: list or int 10 | """ 11 | 12 | 13 | data = {"name":"get-balances", 14 | "version":"1.0" 15 | } 16 | 17 | self.send_websocket_request(self.name, data) 18 | -------------------------------------------------------------------------------- /iqoptionapi/global_value.py: -------------------------------------------------------------------------------- 1 | #python 2 | check_websocket_if_connect=None 3 | # try fix ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2361) 4 | ssl_Mutual_exclusion=False#mutex read write 5 | #if false websocket can sent self.websocket.send(data) 6 | #else can not sent self.websocket.send(data) 7 | ssl_Mutual_exclusion_write=False#if thread wirite 8 | 9 | SSID=None 10 | 11 | check_websocket_if_error=False 12 | websocket_error_reason=None 13 | 14 | balance_id=None -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/cancel_order.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Cancel_order(Base): 7 | name = "sendMessage" 8 | def __call__(self,order_id): 9 | data = { 10 | "name":"cancel-order", 11 | "version":"1.0", 12 | "body":{ 13 | "order_id":order_id 14 | } 15 | } 16 | self.send_websocket_request(self.name, data) 17 | 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/base.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Base websocket object.""" 2 | 3 | 4 | class Base(object): 5 | """Class for IQ Option Base websocket object.""" 6 | # pylint: disable=too-few-public-methods 7 | 8 | def __init__(self): 9 | self.__name = None 10 | 11 | @property 12 | def name(self): 13 | """Property to get websocket object name. 14 | 15 | :returns: The name of websocket object. 16 | """ 17 | return self.__name 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/close_position.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Close_position(Base): 7 | name = "sendMessage" 8 | def __call__(self,position_id): 9 | data = { 10 | "name":"close-position", 11 | "version":"1.0", 12 | "body":{ 13 | "position_id":position_id 14 | } 15 | } 16 | self.send_websocket_request(self.name, data) 17 | 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/heartbeat.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from iqoptionapi.ws.chanels.base import Base 3 | class Heartbeat(Base): 4 | name = "heartbeat" 5 | 6 | def __call__(self,heartbeatTime): 7 | 8 | data = { 9 | "msg": { 10 | "heartbeatTime":int(heartbeatTime), 11 | "userTime":int(self.api.timesync.server_timestamp*1000) 12 | } 13 | 14 | } 15 | self.send_websocket_request(self.name, data,no_force_send=False) 16 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/ssid.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option API ssid websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Ssid(Base): 7 | """Class for IQ option API ssid websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "ssid" 11 | 12 | def __call__(self, ssid): 13 | """Method to send message to ssid websocket chanel. 14 | 15 | :param ssid: The session identifier. 16 | """ 17 | self.send_websocket_request(self.name, ssid) 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/instruments.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Get_instruments(Base): 7 | """Class for IQ option buy websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "sendMessage" 11 | 12 | def __call__(self,types): 13 | 14 | 15 | data = { 16 | "name":"get-instruments", 17 | "version":"4.0", 18 | "body":{"type":types} 19 | } 20 | 21 | self.send_websocket_request(self.name, data) 22 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_order.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Get_order(Base): 7 | name = "sendMessage" 8 | def __call__(self,order_id): 9 | data = { 10 | "name":"get-order", 11 | "body":{ 12 | "order_id":int(order_id) 13 | } 14 | } 15 | self.send_websocket_request(self.name, data) 16 | 17 | 18 | 19 | #{"name":"sendMessage","request_id":"140","msg":{"name":"get-order","version":"1.0","body":{"order_id":664130181}}} -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/change_auto_margin_call.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | class ChangeAutoMarginCall(Base): 5 | name = "sendMessage" 6 | def __call__(self,ID_Name,ID,auto_margin_call): 7 | data = { 8 | "name":"change-auto-margin-call", 9 | "version":"2.0", 10 | "body":{ 11 | ID_Name: ID, 12 | "auto_margin_call": bool(auto_margin_call) 13 | } 14 | } 15 | self.send_websocket_request(self.name, data) 16 | 17 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_available_leverages.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Get_available_leverages(Base): 7 | name = "sendMessage" 8 | def __call__(self,instrument_type,actives): 9 | data = { 10 | "name":"get-available-leverages", 11 | "version":"2.0", 12 | "body":{ 13 | "instrument_type":instrument_type, 14 | "actives":[actives] 15 | } 16 | } 17 | self.send_websocket_request(self.name, data) 18 | 19 | -------------------------------------------------------------------------------- /iqoptionapi/__init__.py: -------------------------------------------------------------------------------- 1 | """A python wrapper for IQ Option API.""" 2 | 3 | import logging 4 | 5 | def _prepare_logging(): 6 | """Prepare logger for module IQ Option API.""" 7 | logger = logging.getLogger(__name__) 8 | #https://github.com/Lu-Yi-Hsun/iqoptionapi_private/issues/1 9 | #try to fix this problem 10 | #logger.setLevel(logging.DEBUG) 11 | logger.addHandler(logging.NullHandler()) 12 | 13 | websocket_logger = logging.getLogger("websocket") 14 | websocket_logger.setLevel(logging.DEBUG) 15 | websocket_logger.addHandler(logging.NullHandler()) 16 | 17 | _prepare_logging() 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_overnight_fee.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Get_overnight_fee(Base): 7 | name = "sendMessage" 8 | def __call__(self,instrument_type,active_id): 9 | data = { 10 | "name":"get-overnight-fee", 11 | "version":"1.0", 12 | "body":{ 13 | "user_group_id":1, 14 | "instrument_type":instrument_type, 15 | "active_id":active_id 16 | } 17 | } 18 | self.send_websocket_request(self.name, data) 19 | 20 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/technical_indicators.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Technical_indicators(Base): 7 | name = "sendMessage" 8 | 9 | def __call__(self, active): 10 | data = { 11 | "name": "trading-signals.get-technical-indicators", 12 | "version": "1.0", 13 | "body": { 14 | "id": active 15 | } 16 | } 17 | request_id = str(time.time()).split('.')[1] 18 | self.send_websocket_request(self.name, data, request_id) 19 | return request_id 20 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/setactives.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option setactives websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class SetActives(Base): 7 | """Class for IQ option setactives websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "setActives" 11 | 12 | def __call__(self, actives): 13 | """Method to send message to setactives websocket chanel. 14 | 15 | :param actives: The list of actives identifiers. 16 | """ 17 | data = {"actives": actives} 18 | self.send_websocket_request(self.name, data) 19 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/technical_indicators.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def technical_indicators(api, message, api_dict_clean): 4 | if message["name"] == "technical-indicators": 5 | if message["msg"].get("indicators") != None: 6 | api_dict_clean(api.technical_indicators) 7 | api.technical_indicators[message["request_id"]] = message["msg"]["indicators"] 8 | else: 9 | api.technical_indicators[message["request_id"]] = { 10 | "code": "no_technical_indicator_available", 11 | "message": message["msg"]["message"] 12 | } -------------------------------------------------------------------------------- /iqoptionapi/ws/received/balance_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def balance_changed(api, message): 4 | if message['name'] == 'balance-changed': 5 | balance = message['msg']['current_balance'] 6 | # if self.api.get_active_account_type() == balance['type']: 7 | try: 8 | api.profile.balance = balance["amount"] 9 | except: 10 | pass 11 | 12 | try: 13 | api.profile.balance_id = balance["id"] 14 | except: 15 | pass 16 | 17 | try: 18 | api.profile.balance_type = balance["type"] 19 | except: 20 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/commission_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | 4 | def commission_changed(api, message): 5 | if message["name"] == "commission-changed": 6 | instrument_type = message["msg"]["instrument_type"] 7 | active_id = message["msg"]["active_id"] 8 | Active_name = list(OP_code.ACTIVES.keys())[list( 9 | OP_code.ACTIVES.values()).index(active_id)] 10 | commission = message["msg"]["commission"]["value"] 11 | api.subscribe_commission_changed_data[instrument_type][Active_name][api.timesync.server_timestamp] = int( 12 | commission) -------------------------------------------------------------------------------- /iqoptionapi/ws/received/digital_option_placed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def digital_option_placed(api, message, api_dict_clean): 4 | if message["name"] == "digital-option-placed": 5 | if message["msg"].get("id") != None: 6 | api_dict_clean(api.digital_option_placed_id) 7 | api.digital_option_placed_id[message["request_id"] 8 | ] = message["msg"]["id"] 9 | else: 10 | api.digital_option_placed_id[message["request_id"]] = { 11 | "code": "error_place_digital_order", 12 | "message": message["msg"]["message"] 13 | } -------------------------------------------------------------------------------- /iqoptionapi/ws/received/position_changed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | def position_changed(api, message): 4 | if message["name"] == "position-changed": 5 | if message["microserviceName"] == "portfolio" and (message["msg"]["source"] == "digital-options") or message["msg"]["source"] == "trading": 6 | api.order_async[int(message["msg"]["raw_event"]["order_ids"][0])][message["name"]] = message 7 | elif message["microserviceName"] == "portfolio" and message["msg"]["source"] == "binary-options": 8 | api.order_async[int(message["msg"]["external_id"])][message["name"]] = message 9 | else: 10 | api.position_changed = message -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_deferred_orders.py: -------------------------------------------------------------------------------- 1 | from iqoptionapi.ws.chanels.base import Base 2 | import time 3 | import iqoptionapi.global_value as global_value 4 | class GetDeferredOrders(Base): 5 | 6 | name = "sendMessage" 7 | 8 | def __call__(self,instrument_type): 9 | 10 | data = {"name":"get-deferred-orders", 11 | "version":"1.0", 12 | "body":{ 13 | "user_balance_id":int(global_value.balance_id), 14 | "instrument_type":instrument_type 15 | 16 | } 17 | } 18 | 19 | self.send_websocket_request(self.name, data) 20 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/api_game_betinfo.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | import logging 5 | class Game_betinfo(Base): 6 | name = "api_game_betinfo" 7 | def __call__(self, id_number_list): 8 | data = {"currency": "USD"} 9 | if type(id_number_list) is list: 10 | for idx, val in enumerate(id_number_list): 11 | data["id["+str(idx)+"]"]=int(val) 12 | elif id_number_list is None: 13 | logging.error('**error** Game_betinfo can not input None type,please input buy id') 14 | else : 15 | data["id[0]"]=int(id_number_list) 16 | self.send_websocket_request(self.name, data) -------------------------------------------------------------------------------- /iqoptionapi/http/logout.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Logout(Resource): 7 | """Class for IQ option login resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "" 11 | 12 | def _post(self, data=None, headers=None): 13 | """Send get request for IQ Option API login http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v1.0/logout",data=data, headers=headers) 18 | 19 | def __call__(self): 20 | 21 | return self._post() 22 | 23 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/sell_option.py: -------------------------------------------------------------------------------- 1 | 2 | from iqoptionapi.ws.chanels.base import Base 3 | import time 4 | 5 | class Sell_Option(Base): 6 | name = "sendMessage" 7 | def __call__(self, options_ids): 8 | """ 9 | :param options_ids: list or int 10 | """ 11 | if type(options_ids) != list: 12 | id_list=[] 13 | id_list.append(options_ids) 14 | options_ids=id_list 15 | 16 | data = {"name":"sell-options", 17 | "version":"2.0", 18 | "body":{ 19 | "options_ids":(options_ids) 20 | } 21 | } 22 | 23 | self.send_websocket_request(self.name, data) 24 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/listinfodata.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Candles websocket object.""" 2 | from collections import OrderedDict 3 | 4 | from iqoptionapi.ws.objects.base import Base 5 | 6 | class ListInfoData(Base): 7 | """Class for IQ Option Candles websocket object.""" 8 | 9 | def __init__(self): 10 | super(ListInfoData, self).__init__() 11 | self.__name = "listInfoData" 12 | self.listinfodata_dict = {} 13 | #-------------------- 14 | def set(self,win,game_state,id_number): 15 | self.listinfodata_dict[id_number]={"win":win,"game_state":game_state} 16 | def delete(self,id_number): 17 | del self.listinfodata_dict[id_number] 18 | def get(self, id_number): 19 | return self.listinfodata_dict[id_number] 20 | 21 | -------------------------------------------------------------------------------- /iqoptionapi/http/getprofile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http getprofile resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Getprofile(Resource): 7 | """Class for IQ option getprofile resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "getprofile" 11 | 12 | def _get(self): 13 | """Send get request for IQ Option API getprofile http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.send_http_request("GET") 18 | 19 | def __call__(self): 20 | """Method to get IQ Option API getprofile http request. 21 | 22 | :returns: The instance of :class:`requests.Response`. 23 | """ 24 | return self._get() 25 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | astroid==2.9.3 2 | beautifulsoup4==4.11.1 3 | bs4==0.0.1 4 | certifi==2022.6.15 5 | charset-normalizer==2.1.0 6 | ez-setup==0.9 7 | future==0.18.2 8 | gevent==21.12.0 9 | greenlet==1.1.2 10 | idna==3.3 11 | iqoptionapi==7.1.1 12 | iso8601==1.0.2 13 | isort==5.10.1 14 | jedi==0.18.1 15 | lazy-object-proxy==1.7.1 16 | mccabe==0.6.1 17 | parso==0.8.3 18 | platformdirs==2.4.1 19 | psycopg2==2.9.3 20 | psycopg2-binary==2.9.3 21 | pycodestyle==2.8.0 22 | pydocstyle==6.1.1 23 | pyflakes==2.4.0 24 | pylama==8.3.7 25 | pylint==2.12.2 26 | PyYAML==6.0 27 | requests==2.28.1 28 | serial==0.0.97 29 | six==1.16.0 30 | snowballstemmer==2.2.0 31 | soupsieve==2.3.2.post1 32 | toml==0.10.2 33 | urllib3==1.26.11 34 | websocket-client==0.56.0 35 | wrapt==1.13.3 36 | zope.event==4.5.0 37 | zope.interface==5.4.0 38 | -------------------------------------------------------------------------------- /iqoptionapi/http/appinit.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option appinit http resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Appinit(Resource): 7 | """Class for IQ option login resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "appinit" 11 | 12 | def _get(self, data=None, headers=None): 13 | """Send get request for IQ Option API appinit http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.send_http_request("GET", data=data, headers=headers) 18 | 19 | def __call__(self): 20 | """Method to get IQ Option API appinit http request. 21 | 22 | :returns: The instance of :class:`requests.Response`. 23 | """ 24 | return self._get() 25 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/changebalance.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyV2 websocket chanel.""" 2 | import datetime 3 | 4 | from iqoptionapi.ws.chanels.base import Base 5 | class Changebalance(Base): 6 | """Class for IQ option buy websocket chanel.""" 7 | # pylint: disable=too-few-public-methods 8 | 9 | name = "api_profile_changebalance" 10 | 11 | def __call__(self, balance_id): 12 | """Method to send message to buyv2 websocket chanel. 13 | 14 | :param price: The buying price. 15 | :param active: The buying active. 16 | :param option: The buying option. 17 | :param direction: The buying direction. 18 | """ 19 | 20 | 21 | data = { 22 | "balance_id":balance_id 23 | } 24 | 25 | self.send_websocket_request(self.name, data) 26 | -------------------------------------------------------------------------------- /database.py: -------------------------------------------------------------------------------- 1 | import psycopg2 2 | import CONSTANTS 3 | 4 | # database connection 5 | con = psycopg2.connect(host=CONSTANTS.HOST, 6 | database=CONSTANTS.DATABASE, 7 | user=CONSTANTS.USER, 8 | password=CONSTANTS.PASSWORD) 9 | 10 | #database cursor 11 | cur = con.cursor() 12 | 13 | 14 | def insert_new_entry_on_database(entry_id, date_time, trade_type, asset, payout, stake): 15 | sql = f"insert into entries values (default, '{date_time}', '{entry_id}', '{trade_type}', '{asset}', {payout}, {stake})" 16 | cur.execute(sql) 17 | con.commit() 18 | 19 | 20 | def update_entry_result_and_profit(entry_id, result, profit): 21 | sql = f"UPDATE entries SET result = '{result}', profit = {profit} WHERE entry_id = '{entry_id}'" 22 | cur.execute(sql) 23 | con.commit() 24 | 25 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/candle_generated.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | import iqoptionapi.global_value as global_value 4 | 5 | def candle_generated_realtime(api, message, dict_queue_add): 6 | if message["name"] == "candle-generated": 7 | Active_name = list(OP_code.ACTIVES.keys())[list( 8 | OP_code.ACTIVES.values()).index(message["msg"]["active_id"])] 9 | 10 | active = str(Active_name) 11 | size = int(message["msg"]["size"]) 12 | from_ = int(message["msg"]["from"]) 13 | msg = message["msg"] 14 | maxdict = api.real_time_candles_maxdict_table[Active_name][size] 15 | 16 | dict_queue_add(api.real_time_candles, 17 | maxdict, active, size, from_, msg) 18 | api.candle_generated_check[active][size] = True -------------------------------------------------------------------------------- /iqoptionapi/http/getregdata.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http getregdata resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | from iqoptionapi.http.register import Register 5 | 6 | 7 | class Getprofile(Resource): 8 | """Class for IQ option getregdata resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "/".join((Register.url, "getregdata")) 12 | 13 | def _get(self): 14 | """Send get request for IQ Option API getregdata http resource. 15 | 16 | :returns: The instance of :class:`requests.Response`. 17 | """ 18 | return self.send_http_request("GET") 19 | 20 | def __call__(self): 21 | """Method to get IQ Option API getregdata http request. 22 | 23 | :returns: The instance of :class:`requests.Response`. 24 | """ 25 | return self._get() 26 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/betinfo.py: -------------------------------------------------------------------------------- 1 | #python 2 | """Module for IQ Option Profile websocket object.""" 3 | from iqoptionapi.ws.objects.base import Base 4 | 5 | 6 | class Game_betinfo_data(Base): 7 | """Class for IQ Option Profile websocket object.""" 8 | 9 | def __init__(self): 10 | super(Game_betinfo_data, self).__init__() 11 | self.__isSuccessful = None 12 | self.__dict = {} 13 | 14 | @property 15 | def isSuccessful(self): 16 | return self.__isSuccessful 17 | 18 | @isSuccessful.setter 19 | def isSuccessful(self, isSuccessful): 20 | 21 | self.__isSuccessful = isSuccessful 22 | #-------------------------------------- 23 | @property 24 | def dict(self): 25 | return self.__dict 26 | 27 | @dict.setter 28 | def dict(self, dict): 29 | self.__dict = dict 30 | 31 | 32 | -------------------------------------------------------------------------------- /iqoptionapi/http/token.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http token resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | from iqoptionapi.http.auth import Auth 5 | 6 | 7 | class Token(Resource): 8 | """Class for IQ Option http token resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "/".join((Auth.url, "token")) 12 | 13 | def __init__(self, api): 14 | super(Token, self).__init__(api) 15 | 16 | def _get(self): 17 | """Send get request for IQ Option API token http resource. 18 | 19 | :returns: The instance of :class:`requests.Response`. 20 | """ 21 | return self.send_http_request("GET") 22 | 23 | def __call__(self): 24 | """Method to get IQ Option API token http request. 25 | 26 | :returns: The instance of :class:`requests.Response`. 27 | """ 28 | return self._get() 29 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/base.py: -------------------------------------------------------------------------------- 1 | """Module for base IQ Option base websocket chanel.""" 2 | import time 3 | 4 | class Base(object): 5 | """Class for base IQ Option websocket chanel.""" 6 | # pylint: disable=too-few-public-methods 7 | 8 | def __init__(self, api): 9 | """ 10 | :param api: The instance of :class:`IQOptionAPI 11 | `. 12 | """ 13 | self.api = api 14 | 15 | def send_websocket_request(self, name, msg,request_id=""): 16 | """Send request to IQ Option server websocket. 17 | 18 | :param str name: The websocket chanel name. 19 | :param dict msg: The websocket chanel msg. 20 | 21 | :returns: The instance of :class:`requests.Response`. 22 | """ 23 | if request_id == '': 24 | request_id = int(str(time.time()).split('.')[1]) 25 | return self.api.send_websocket_request(name, msg,request_id) 26 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/api_game_getoptions.py: -------------------------------------------------------------------------------- 1 | #python 2 | """Module for IQ option candles websocket chanel.""" 3 | 4 | from iqoptionapi.ws.chanels.base import Base 5 | import time 6 | import iqoptionapi.global_value as global_value 7 | class Get_options(Base): 8 | 9 | name = "api_game_getoptions" 10 | 11 | def __call__(self,limit): 12 | 13 | data = {"limit":int(limit), 14 | "user_balance_id":int(global_value.balance_id) 15 | } 16 | 17 | self.send_websocket_request(self.name, data) 18 | 19 | class Get_options_v2(Base): 20 | name = "sendMessage" 21 | def __call__(self,limit,instrument_type): 22 | data = { 23 | "name":"get-options" , 24 | "body":{ 25 | "limit":limit, 26 | "instrument_type":instrument_type, 27 | "user_balance_id":int(global_value.balance_id) 28 | } 29 | } 30 | self.send_websocket_request(self.name, data) -------------------------------------------------------------------------------- /iqoptionapi/http/buyback.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option buyback resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | from iqoptionapi.http.billing import Billing 5 | 6 | 7 | class Buyback(Resource): 8 | """Class for IQ option buyback resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "/".join((Billing.url, "buyback")) 12 | 13 | def _post(self, data=None, headers=None): 14 | """Send get request for IQ Option API buyback http resource. 15 | 16 | :returns: The instance of :class:`requests.Response`. 17 | """ 18 | return self.send_http_request("POST", data=data, headers=headers) 19 | 20 | def __call__(self, option_id): 21 | """Method to get IQ Option API buyback http request. 22 | 23 | :param str option_id: The option identifier. 24 | 25 | :returns: The instance of :class:`requests.Response`. 26 | """ 27 | data = {"option_id": [option_id]} 28 | return self._post(data=data) 29 | -------------------------------------------------------------------------------- /iqoptionapi/http/resource.py: -------------------------------------------------------------------------------- 1 | """Module for base IQ Option http base resource.""" 2 | 3 | 4 | class Resource(object): 5 | """Class for base IQ Option API http resource.""" 6 | # pylint: disable=too-few-public-methods 7 | 8 | def __init__(self, api): 9 | """ 10 | :param api: The instance of :class:`IQOptionAPI 11 | `. 12 | """ 13 | self.api = api 14 | 15 | def send_http_request(self, method, data=None, params=None, headers=None): 16 | """Send http request to IQ Option API. 17 | 18 | :param str method: The http request method. 19 | :param dict data: (optional) The http request data. 20 | :param dict params: (optional) The http request params. 21 | :param dict headers: (optional) The http request headers. 22 | 23 | :returns: The instance of :class:`requests.Response`. 24 | """ 25 | return self.api.send_http_request(self, method, data=data, params=params, headers=headers) 26 | -------------------------------------------------------------------------------- /iqoptionapi/http/changebalance.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option changebalance resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | from iqoptionapi.http.profile import Profile 5 | 6 | 7 | class Changebalance(Resource): 8 | """Class for IQ option changebalance resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "/".join((Profile.url, "changebalance")) 12 | 13 | def _post(self, data=None, headers=None): 14 | """Send get request for IQ Option API changebalance http resource. 15 | 16 | :returns: The instance of :class:`requests.Response`. 17 | """ 18 | return self.send_http_request("POST", data=data, headers=headers) 19 | 20 | def __call__(self,balance_id): 21 | """Method to get IQ Option API changebalance http request. 22 | 23 | :param str balance_id: The balance identifier. 24 | 25 | :returns: The instance of :class:`requests.Response`. 26 | """ 27 | data = {"balance_id": balance_id} 28 | return self._post(data) 29 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/live_deal.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | from threading import Thread 4 | 5 | def live_deal(api, message): 6 | if message["name"] == "live-deal": 7 | # name = message["name"] 8 | active_id = message["msg"]["instrument_active_id"] 9 | active = list(OP_code.ACTIVES.keys())[ 10 | list(OP_code.ACTIVES.values()).index(active_id)] 11 | _type = message["msg"]["instrument_type"] 12 | try: 13 | # api.live_deal_data[name][active][_type].appendleft( 14 | # message["msg"]) 15 | if hasattr(api.live_deal_cb, '__call__'): 16 | cb_data = { 17 | "active": active, 18 | **message["msg"] 19 | } 20 | livedeal = Thread(target=api.live_deal_cb, 21 | kwargs=(cb_data)) 22 | livedeal.daemon = True 23 | livedeal.start() 24 | except: 25 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/candle_generated_v2.py: -------------------------------------------------------------------------------- 1 | import iqoptionapi.constants as OP_code 2 | 3 | def candle_generated_v2(api, message, dict_queue_add): 4 | if message["name"] == "candles-generated": 5 | Active_name = list(OP_code.ACTIVES.keys())[list( 6 | OP_code.ACTIVES.values()).index(message["msg"]["active_id"])] 7 | active = str(Active_name) 8 | for k, v in message["msg"]["candles"].items(): 9 | v["active_id"] = message["msg"]["active_id"] 10 | v["at"] = message["msg"]["at"] 11 | v["ask"] = message["msg"]["ask"] 12 | v["bid"] = message["msg"]["bid"] 13 | v["close"] = message["msg"]["value"] 14 | v["size"] = int(k) 15 | size = int(v["size"]) 16 | from_ = int(v["from"]) 17 | maxdict = api.real_time_candles_maxdict_table[Active_name][size] 18 | msg = v 19 | dict_queue_add(api.real_time_candles, maxdict, active, size, from_, msg) 20 | 21 | api.candle_generated_all_size_check[active] = True -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/change_tpsl.py: -------------------------------------------------------------------------------- 1 | #python 2 | 3 | import datetime 4 | import time 5 | from iqoptionapi.ws.chanels.base import Base 6 | class Change_Tpsl(Base): 7 | name = "sendMessage" 8 | def __call__(self,ID_Name,ID, 9 | stop_lose_kind,stop_lose_value, 10 | take_profit_kind,take_profit_value, 11 | use_trail_stop): 12 | data = { 13 | "name":"change-tpsl", 14 | "version":"2.0", 15 | "body":{ 16 | ID_Name: ID, 17 | "stop_lose_kind": stop_lose_kind, 18 | "stop_lose_value": stop_lose_value, 19 | "take_profit_kind": take_profit_kind, 20 | "take_profit_value": take_profit_value, 21 | "use_trail_stop": use_trail_stop, 22 | "extra":{ 23 | "stop_lose_kind":stop_lose_kind, 24 | "take_profit_kind":take_profit_kind 25 | } 26 | } 27 | } 28 | self.send_websocket_request(self.name, data) 29 | 30 | -------------------------------------------------------------------------------- /iqoptionapi/http/events.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Events(Resource): 7 | """Class for IQ option login resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "" 11 | 12 | def send_http(self,method, data=None, headers=None): 13 | """Send get request for IQ Option API login http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.api.send_http_request_v2(method=method, url="https://event.iqoption.com/api/v1/events",data=data) 18 | 19 | def __call__(self,method,data,headers=None): 20 | """Method to get IQ Option API login http request. 21 | 22 | :param str username: The username of a IQ Option server. 23 | :param str password: The password of a IQ Option server. 24 | 25 | :returns: The instance of :class:`requests.Response`. 26 | """ 27 | 28 | 29 | return self.send_http(method=method,data=data,headers=headers) 30 | -------------------------------------------------------------------------------- /iqoptionapi/http/login.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Login(Resource): 7 | """Class for IQ option login resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "" 11 | 12 | def _post(self, data=None, headers=None): 13 | """Send get request for IQ Option API login http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v2/login",data=data, headers=headers) 18 | 19 | def __call__(self, username, password): 20 | """Method to get IQ Option API login http request. 21 | 22 | :param str username: The username of a IQ Option server. 23 | :param str password: The password of a IQ Option server. 24 | 25 | :returns: The instance of :class:`requests.Response`. 26 | """ 27 | data = {"identifier": username, 28 | "password": password} 29 | 30 | return self._post(data=data) 31 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/live_deal_binary_option_placed.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | from threading import Thread 4 | 5 | def live_deal_binary_option_placed(api, message): 6 | if message["name"] == "live-deal-binary-option-placed": 7 | # name = message["name"] 8 | active_id = message["msg"]["active_id"] 9 | active = list(OP_code.ACTIVES.keys())[ 10 | list(OP_code.ACTIVES.values()).index(active_id)] 11 | _type = message["msg"]["option_type"] 12 | try: 13 | # self.api.live_deal_data[name][active][_type].appendleft( 14 | # message["msg"]) 15 | if hasattr(api.binary_live_deal_cb, '__call__'): 16 | cb_data = { 17 | "active": active, 18 | **message["msg"] 19 | } 20 | realbinary = Thread(target=api.binary_live_deal_cb, 21 | kwargs=(cb_data)) 22 | realbinary.daemon = True 23 | realbinary.start() 24 | except: 25 | pass -------------------------------------------------------------------------------- /iqoptionapi/ws/received/live_deal_digital_option.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | from threading import Thread 4 | 5 | def live_deal_digital_option(api, message): 6 | if message["name"] == "live-deal-digital-option": 7 | # name = message["name"] 8 | active_id = message["msg"]["instrument_active_id"] 9 | active = list(OP_code.ACTIVES.keys())[ 10 | list(OP_code.ACTIVES.values()).index(active_id)] 11 | _type = message["msg"]["expiration_type"] 12 | try: 13 | # self.api.live_deal_data[name][active][_type].appendleft( 14 | # message["msg"]) 15 | if hasattr(api.digital_live_deal_cb, '__call__'): 16 | cb_data = { 17 | "active": active, 18 | **message["msg"] 19 | } 20 | realdigital = Thread(target=api.digital_live_deal_cb, 21 | kwargs=(cb_data)) 22 | realdigital.daemon = True 23 | realdigital.start() 24 | except: 25 | pass -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 renabiaobock 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/sell_digital_option.py: -------------------------------------------------------------------------------- 1 | 2 | from iqoptionapi.ws.chanels.base import Base 3 | import time 4 | 5 | class Sell_Digital_Option(Base): 6 | name = "sendMessage" 7 | def __call__(self, position_ids): 8 | """ 9 | :param options_ids: list or int 10 | """ 11 | if type(position_ids) == list: 12 | id_list=[] 13 | id_list.append(position_ids) 14 | position_ids=id_list 15 | 16 | data = {"name":"digital-options.close-position-batch", 17 | "version":"1.0", 18 | "body":{ 19 | "position_ids":(position_ids) 20 | } 21 | } 22 | else: 23 | data = {"name":"digital-options.close-position", 24 | "version":"1.0", 25 | "body":{ 26 | "position_id":position_ids 27 | } 28 | } 29 | request_id = int(str(time.time()).split('.')[1]) 30 | self.send_websocket_request(self.name, data, request_id) 31 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/strike_list.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from iqoptionapi.ws.chanels.base import Base 3 | import logging 4 | class Strike_list(Base): 5 | name = "sendMessage" 6 | 7 | def __call__(self,name,duration): 8 | """ 9 | duration:minute 10 | """ 11 | exp=self.get_digital_expiration_time(duration) 12 | data = { 13 | "name": "get-strike-list", 14 | "body":{"type":"digital-option", 15 | "underlying":name, 16 | "expiration":int(exp)*1000, 17 | "period": duration*60 18 | }, 19 | "version": "4.0" 20 | } 21 | self.send_websocket_request(self.name, data) 22 | 23 | def get_digital_expiration_time(self, duration): 24 | exp=int(self.api.timesync.server_timestamp) 25 | value = datetime.datetime.fromtimestamp(exp) 26 | minute = int(value.strftime('%M')) 27 | second=int(value.strftime('%S')) 28 | ans=exp-exp%60#delete second 29 | ans=ans+(duration-minute%duration)*60 30 | if exp>ans-10: 31 | ans=ans+(duration)*60 32 | 33 | return ans 34 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/profile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.global_value as global_value 3 | 4 | def profile(api, message): 5 | if message["name"] == "profile": 6 | api.profile.msg = message["msg"] 7 | if api.profile.msg != False: 8 | # --------------------------- 9 | try: 10 | api.profile.balance = message["msg"]["balance"] 11 | except: 12 | pass 13 | # Set Default account 14 | if global_value.balance_id == None: 15 | for balance in message["msg"]["balances"]: 16 | if balance["type"] == 4: 17 | global_value.balance_id = balance["id"] 18 | break 19 | try: 20 | api.profile.balance_id = message["msg"]["balance_id"] 21 | except: 22 | pass 23 | 24 | try: 25 | api.profile.balance_type = message["msg"]["balance_type"] 26 | except: 27 | pass 28 | 29 | try: 30 | api.profile.balances = message["msg"]["balances"] 31 | except: 32 | pass -------------------------------------------------------------------------------- /iqoptionapi/http/login2fa.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | 5 | 6 | class Login2FA(Resource): 7 | """Class for IQ option login resource.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | url = "" 11 | 12 | def _post(self, data=None, headers=None): 13 | """Send get request for IQ Option API login http resource. 14 | 15 | :returns: The instance of :class:`requests.Response`. 16 | """ 17 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v2/login",data=data, headers=headers) 18 | 19 | def __call__(self, username, password, token_login): 20 | """Method to get IQ Option API login http request. 21 | 22 | :param str username: The username of a IQ Option server. 23 | :param str password: The password of a IQ Option server. 24 | :param str token: The token of a IQ Option server 2FA. 25 | 26 | :returns: The instance of :class:`requests.Response`. 27 | """ 28 | data = {"identifier": username, 29 | "password": password, 30 | "token": token_login} 31 | 32 | return self._post(data=data) 33 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/traders_mood.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | 5 | 6 | class Traders_mood_subscribe(Base): 7 | name = "subscribeMessage" 8 | 9 | def __call__(self, active, instrument="turbo-option"): 10 | data = { 11 | "name": "traders-mood-changed", 12 | "params": 13 | { 14 | "routingFilters": 15 | { 16 | "instrument": instrument, 17 | "asset_id": active 18 | } 19 | } 20 | 21 | } 22 | 23 | self.send_websocket_request(self.name, data) 24 | 25 | 26 | class Traders_mood_unsubscribe(Base): 27 | name = "unsubscribeMessage" 28 | 29 | def __call__(self, active, instrument="turbo-option"): 30 | data = { 31 | "name": "traders-mood-changed", 32 | "params": 33 | { 34 | "routingFilters": 35 | { 36 | "instrument": instrument, 37 | "asset_id": active 38 | } 39 | } 40 | 41 | } 42 | 43 | self.send_websocket_request(self.name, data) 44 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_financial_information.py: -------------------------------------------------------------------------------- 1 | from iqoptionapi.ws.chanels.base import Base 2 | class GetFinancialInformation(Base): 3 | name = "sendMessage" 4 | def __call__(self,activeId): 5 | data = { 6 | "name":"get-financial-information", 7 | "version":"1.0", 8 | "body":{ 9 | "query":"query GetAssetProfileInfo($activeId:ActiveID!, $locale: LocaleName){\n active(id: $activeId) {\n id\n name(source: TradeRoom, locale: $locale)\n ticker\n media {\n siteBackground\n }\n charts {\n dtd {\n change\n }\n m1 {\n change\n }\n y1 {\n change\n }\n ytd {\n change\n }\n }\n index_fininfo: fininfo {\n ... on Index {\n description(locale: $locale)\n }\n }\n fininfo {\n ... on Pair {\n type\n description(locale: $locale)\n currency {\n name(locale: $locale)\n }\n base {\n name(locale: $locale)\n ... on Stock {\n company {\n country {\n nameShort\n }\n gics {\n sector\n industry\n }\n site\n domain\n }\n keyStat {\n marketCap\n peRatioHigh\n }\n }\n ... on CryptoCurrency {\n site\n domain\n coinsInCirculation\n maxCoinsQuantity\n volume24h\n marketCap\n }\n }\n }\n }\n }\n }", 10 | "operationName": "GetAssetProfileInfo", 11 | "variables":{ 12 | "activeId":activeId 13 | } 14 | } 15 | } 16 | self.send_websocket_request(self.name, data) 17 | 18 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/buyv2.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyV2 websocket chanel.""" 2 | from datetime import datetime, timedelta 3 | import iqoptionapi.global_value as global_value 4 | from iqoptionapi.ws.chanels.base import Base 5 | from iqoptionapi.expiration import get_expiration_time 6 | 7 | 8 | class Buyv2(Base): 9 | """Class for IQ option buy websocket chanel.""" 10 | # pylint: disable=too-few-public-methods 11 | 12 | name = "sendMessage" 13 | 14 | def __call__(self, price, active, direction, duration): 15 | """Method to send message to buyv2 websocket chanel. 16 | :param price: The buying price. 17 | :param active: The buying active. 18 | :param direction: The buying direction. 19 | """ 20 | 21 | exp, idx = get_expiration_time( 22 | int(self.api.timesync.server_timestamp), duration) 23 | 24 | if idx < 5: 25 | option = 3 # turbo 26 | else: 27 | option = 1 # non-turbo / binary 28 | 29 | data = { 30 | "price": price, 31 | "act": active, 32 | "exp": int(exp), 33 | "type": option, 34 | "direction": direction.lower(), 35 | "user_balance_id": int(global_value.balance_id), 36 | "time": self.api.timesync.server_timestamp 37 | } 38 | 39 | self.send_websocket_request(self.name, data) 40 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/candles.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option candles websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | import time 5 | 6 | class GetCandles(Base): 7 | """Class for IQ option candles websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "sendMessage" 11 | 12 | def __call__(self, active_id, interval, count,endtime): 13 | """Method to send message to candles websocket chanel. 14 | 15 | :param active_id: The active/asset identifier. 16 | :param duration: The candle duration (timeframe for the candles). 17 | :param amount: The number of candles you want to have 18 | """ 19 | #thank SeanStayn share new request 20 | #https://github.com/n1nj4z33/iqoptionapi/issues/88 21 | data = {"name":"get-candles", 22 | "version":"2.0", 23 | "body":{ 24 | "active_id":int(active_id), 25 | "split_normalization": True, 26 | "size":interval,#time size sample:if interval set 1 mean get time 0~1 candle 27 | "to":int(endtime), #int(self.api.timesync.server_timestamp), 28 | "count":count,#get how many candle 29 | "":active_id 30 | } 31 | } 32 | 33 | self.send_websocket_request(self.name, data) 34 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/leaderboard.py: -------------------------------------------------------------------------------- 1 | 2 | from iqoptionapi.ws.chanels.base import Base 3 | import time 4 | """ 5 | {"name":"sendMessage","request_id":"356","msg":{"name":"request-leaderboard-deals-client","version":"1.0","body":{"country_id":0,"user_country_id":191,"from_position":1,"to_position":64,"near_traders_country_count":64,"near_traders_count":64,"top_country_count":64,"top_count":64,"top_type":2}}} 6 | """ 7 | class Leader_Board(Base): 8 | name = "sendMessage" 9 | def __call__(self, country_id,user_country_id,from_position,to_position,near_traders_country_count,near_traders_count,top_country_count,top_count,top_type): 10 | 11 | data = {"name":"request-leaderboard-deals-client", 12 | "version":"1.0", 13 | "body":{ 14 | "country_id":country_id, 15 | "user_country_id":user_country_id, 16 | "from_position":from_position, 17 | "to_position":to_position, 18 | "near_traders_country_count":near_traders_country_count, 19 | "near_traders_count":near_traders_count, 20 | "top_country_count":top_country_count, 21 | "top_count":top_count, 22 | "top_type":top_type 23 | } 24 | } 25 | 26 | self.send_websocket_request(self.name, data) 27 | -------------------------------------------------------------------------------- /iqoptionapi/ws/received/instrument_quotes_generated.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | import iqoptionapi.constants as OP_code 3 | 4 | def instrument_quotes_generated(api, message): 5 | if message["name"] == "instrument-quotes-generated": 6 | 7 | Active_name = list(OP_code.ACTIVES.keys())[list(OP_code.ACTIVES.values()).index(message["msg"]["active"])] 8 | period = message["msg"]["expiration"]["period"] 9 | ans = {} 10 | for data in message["msg"]["quotes"]: 11 | # FROM IQ OPTION SOURCE CODE 12 | if data["price"]["ask"] == None: 13 | ProfitPercent = None 14 | else: 15 | askPrice = (float)(data["price"]["ask"]) 16 | ProfitPercent = ((100-askPrice)*100)/askPrice 17 | 18 | for symble in data["symbols"]: 19 | try: 20 | """ 21 | ID SAMPLE:doUSDJPY-OTC201811111204PT1MC11350481 22 | """ 23 | 24 | """ 25 | dict ID-prodit:{ID:profit} 26 | """ 27 | 28 | ans[symble] = ProfitPercent 29 | except: 30 | pass 31 | api.instrument_quites_generated_timestamp[Active_name][ 32 | period] = message["msg"]["expiration"]["timestamp"] 33 | api.instrument_quites_generated_data[Active_name][period] = ans 34 | 35 | api.instrument_quotes_generated_raw_data[Active_name][period] = message -------------------------------------------------------------------------------- /iqoptionapi/http/send_sms.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http sms resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | import json 5 | 6 | 7 | class SMS_Sender(Resource): 8 | """Class for IQ option sms resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "" 12 | 13 | def _post(self, data=None, headers=None): 14 | """Send get request for IQ Option API sms http resource. 15 | 16 | :returns: The instance of :class:`requests.Response`. 17 | """ 18 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v2/verify/2fa",data=json.dumps(data), headers=headers) 19 | 20 | def __call__(self, token_reason): 21 | """Method to get IQ Option API sms http request. 22 | 23 | :param str method: The method of a IQ Option server 2FA. 24 | :param str token_reason: The token of a IQ Option server 2FA. 25 | 26 | :returns: The instance of :class:`requests.Response`. 27 | """ 28 | data = {"method": "sms", 29 | "token": token_reason} 30 | 31 | headers = { 32 | 'Accept': 'application/json', 33 | 'Content-Type': 'application/json', 34 | 'Referer': 'https://iqoption.com/en/login', 35 | 'Sec-Fetch-Mode': 'cors', 36 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36' 37 | } 38 | 39 | return self._post(data=data, headers=headers) 40 | -------------------------------------------------------------------------------- /iqoptionapi/http/verify.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http verify resource.""" 2 | 3 | from iqoptionapi.http.resource import Resource 4 | import json 5 | 6 | 7 | class Verify(Resource): 8 | """Class for IQ option verify resource.""" 9 | # pylint: disable=too-few-public-methods 10 | 11 | url = "" 12 | 13 | def _post(self, data=None, headers=None): 14 | """Send get request for IQ Option API verify http resource. 15 | 16 | :returns: The instance of :class:`requests.Response`. 17 | """ 18 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v2/verify/2fa",data=json.dumps(data), headers=headers) 19 | 20 | def __call__(self, sms_received, token_sms): 21 | """Method to get IQ Option API verify http request. 22 | 23 | :param str sms_received: The sms received of a IQ Option server 2FA. 24 | :param str token_sms: The token of a IQ Option server 2FA. 25 | 26 | :returns: The instance of :class:`requests.Response`. 27 | """ 28 | data = {"code": str(sms_received), 29 | "token": token_sms} 30 | 31 | headers = { 32 | 'Accept': 'application/json', 33 | 'Content-Type': 'application/json', 34 | 'Referer': 'https://iqoption.com/en/login', 35 | 'Sec-Fetch-Mode': 'cors', 36 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36' 37 | } 38 | 39 | return self._post(data=data, headers=headers) 40 | -------------------------------------------------------------------------------- /strategy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Module that check for entries based on some strategy 3 | """ 4 | 5 | import indicators 6 | 7 | def check_entry_BOLLINGER_BANDS_EMA(asset, timeframe_in_minutes, 8 | BB_time_period, BB_dev_up, BB_dev_down, 9 | EMA_time_period): 10 | price = indicators.generate_candle_data_from_candle_stream(asset, timeframe_in_minutes)['close'][-1] 11 | #Bollinger 12 | bollinger_bands = indicators.calculate_asset_BB(asset, timeframe_in_minutes, 13 | BB_time_period, BB_dev_up, BB_dev_down) 14 | bollinger_bands_last_upper = bollinger_bands['upper'][-1] 15 | bollinger_bands_last_lower = bollinger_bands['lower'][-1] 16 | #EMA 17 | ema = indicators.calculate_asset_EMA(asset, timeframe_in_minutes, EMA_time_period)[-1] 18 | #Last candle disruption 19 | last_candle_close = indicators.generate_candle_data_from_candle_stream(asset, timeframe_in_minutes)['close'][-2] 20 | last_candle_bollinger_bands_upper = bollinger_bands['upper'][-2] 21 | last_candle_bollinger_bands_lower = bollinger_bands['lower'][-2] 22 | # Strategy logic 23 | if (price > bollinger_bands_last_upper) and\ 24 | (ema > bollinger_bands_last_upper) and\ 25 | (last_candle_close < last_candle_bollinger_bands_upper): 26 | return 'put' 27 | elif (price < bollinger_bands_last_lower) and\ 28 | (ema < bollinger_bands_last_lower) and\ 29 | (last_candle_close > last_candle_bollinger_bands_lower): 30 | return 'call' 31 | else: 32 | return None 33 | 34 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/user.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option unsubscribe websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | import datetime 5 | import iqoptionapi.constants as OP_code 6 | 7 | 8 | class Get_user_profile_client(Base): 9 | 10 | name = "sendMessage" 11 | 12 | def __call__(self, user_id): 13 | 14 | data = {"name": "get-user-profile-client", 15 | "body": { 16 | "user_id": int(user_id) 17 | }, 18 | "version":"1.0" 19 | } 20 | 21 | self.send_websocket_request(self.name, data) 22 | 23 | class Request_leaderboard_userinfo_deals_client(Base): 24 | """Class for IQ option candles websocket chanel.""" 25 | # pylint: disable=too-few-public-methods 26 | name = "sendMessage" 27 | 28 | def __call__(self, user_id,country_id): 29 | 30 | data = {"name": "request-leaderboard-userinfo-deals-client", 31 | "body": {"country_ids":[country_id], 32 | "requested_user_id": int(user_id) 33 | }, 34 | "version":"1.0" 35 | } 36 | 37 | self.send_websocket_request(self.name, data) 38 | 39 | class Get_users_availability(Base): 40 | """Class for IQ option candles websocket chanel.""" 41 | # pylint: disable=too-few-public-methods 42 | name = "sendMessage" 43 | 44 | def __call__(self, user_id): 45 | 46 | data = {"name": "get-users-availability", 47 | "body": { 48 | "user_ids": [user_id] 49 | }, 50 | "version":"1.0" 51 | } 52 | 53 | self.send_websocket_request(self.name, data) 54 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import time 3 | import schedule 4 | 5 | import CONSTANTS 6 | import trader 7 | import strategy 8 | 9 | 10 | def check_connection_and_update_open_assets(): 11 | "check conection" 12 | if not trader.IQ.check_connect: 13 | trader.connect_to_iq() 14 | "update open assets" 15 | open_assets = trader.get_open_assets() 16 | for asset in open_assets: 17 | trader.subscribe_to_candle_stream(asset, CONSTANTS.TIMEFRAME, 200) 18 | 19 | 20 | #1: Conect to IQ account and update open assets" 21 | trader.connect_to_iq() 22 | open_assets = trader.get_open_assets() 23 | for asset in open_assets: 24 | trader.subscribe_to_candle_stream(asset, CONSTANTS.TIMEFRAME, 200) 25 | 26 | #2: Change trade type 27 | trader.change_trade_type(CONSTANTS.TRADETYPE) 28 | 29 | #3: Create scheduler to check conection and update open assets every 1 minute 30 | schedule.every().minute.at(':10').do(check_connection_and_update_open_assets) 31 | 32 | #4: Start trading loop 33 | while True: 34 | schedule.run_pending() 35 | for asset in open_assets: 36 | direction = strategy.check_entry_BOLLINGER_BANDS_EMA(asset, CONSTANTS.TIMEFRAME, 37 | CONSTANTS.BB_PERIOD, 38 | CONSTANTS.BB_DEV_UP, 39 | CONSTANTS.BB_DEV_DOWN, 40 | CONSTANTS.EMA) 41 | if direction and asset not in trader.trading_assets: 42 | trader.trading_assets.append(asset) 43 | stake = trader.get_stake_by_percentage_of_balance(CONSTANTS.STAKE_PERCENTAGE) 44 | trader.buy_and_wait_for_result_as_thread(asset, CONSTANTS.TIMEFRAME, stake, direction) 45 | time.sleep(0.2) 46 | 47 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/digital_option.py: -------------------------------------------------------------------------------- 1 | # python 2 | 3 | import datetime 4 | import time 5 | from iqoptionapi.ws.chanels.base import Base 6 | import iqoptionapi.global_value as global_value 7 | from random import randint 8 | # work for forex digit cfd(stock) 9 | 10 | 11 | class Digital_options_place_digital_option(Base): 12 | name = "sendMessage" 13 | 14 | def __call__(self, instrument_id, amount, user_balance_id=None): 15 | if user_balance_id == None: 16 | user_balance_id = int(self.api.profile.balance_id) 17 | 18 | data = { 19 | "name": "digital-options.place-digital-option", 20 | "version": "1.0", 21 | "body": { 22 | "user_balance_id": int(global_value.balance_id), 23 | "instrument_id": str(instrument_id), 24 | "amount": str(amount) 25 | } 26 | } 27 | request_id = str(randint(0, 100000)) 28 | self.send_websocket_request(self.name, data, request_id) 29 | return request_id 30 | 31 | 32 | class Digital_options_close_position(Base): 33 | name = "sendMessage" 34 | 35 | def __call__(self, position_id): 36 | data = { 37 | "name": "digital-options.close-position", 38 | "version": "1.0", 39 | "body": { 40 | "position_id": int(position_id) 41 | } 42 | } 43 | self.send_websocket_request(self.name, data) 44 | 45 | 46 | class DigitalOptionsPlaceDigitalOptionV2(Base): 47 | name = "sendMessage" 48 | 49 | def __call__(self, instrument_id, asset_id, amount): 50 | data = { 51 | "name": "digital-options.place-digital-option", 52 | "version": "2.0", 53 | "body": { 54 | "amount": str(amount), 55 | "asset_id": int(asset_id), 56 | "instrument_id": instrument_id, 57 | "instrument_index": 0, 58 | "user_balance_id": int(global_value.balance_id) 59 | } 60 | } 61 | 62 | request_id = str(randint(0, 100000)) 63 | self.send_websocket_request(self.name, data, request_id) 64 | 65 | return request_id 66 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/timesync.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option TimeSync websocket object.""" 2 | 3 | import time 4 | import datetime 5 | 6 | from iqoptionapi.ws.objects.base import Base 7 | 8 | 9 | class TimeSync(Base): 10 | """Class for IQ Option TimeSync websocket object.""" 11 | 12 | def __init__(self): 13 | super(TimeSync, self).__init__() 14 | self.__name = "timeSync" 15 | self.__server_timestamp = time.time() 16 | self.__expiration_time = 1 17 | 18 | @property 19 | def server_timestamp(self): 20 | """Property to get server timestamp. 21 | 22 | :returns: The server timestamp. 23 | """ 24 | while self.__server_timestamp==None: 25 | time.sleep(0.2) 26 | pass 27 | 28 | return self.__server_timestamp / 1000 29 | 30 | @server_timestamp.setter 31 | def server_timestamp(self, timestamp): 32 | """Method to set server timestamp.""" 33 | self.__server_timestamp = timestamp 34 | 35 | @property 36 | def server_datetime(self): 37 | """Property to get server datetime. 38 | 39 | :returns: The server datetime. 40 | """ 41 | return datetime.datetime.fromtimestamp(self.server_timestamp) 42 | 43 | @property 44 | def expiration_time(self): 45 | """Property to get expiration time. 46 | 47 | :returns: The expiration time. 48 | """ 49 | return self.__expiration_time 50 | 51 | @expiration_time.setter 52 | def expiration_time(self, minutes): 53 | """Method to set expiration time 54 | 55 | :param int minutes: The expiration time in minutes. 56 | """ 57 | self.__expiration_time = minutes 58 | 59 | @property 60 | def expiration_datetime(self): 61 | """Property to get expiration datetime. 62 | 63 | :returns: The expiration datetime. 64 | """ 65 | return self.server_datetime + datetime.timedelta(minutes=self.expiration_time) 66 | 67 | @property 68 | def expiration_timestamp(self): 69 | """Property to get expiration timestamp. 70 | 71 | :returns: The expiration timestamp. 72 | """ 73 | return time.mktime(self.expiration_datetime.timetuple()) 74 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/buy_place_order_temp.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | import iqoptionapi.global_value as global_value 5 | #work for forex digit cfd(stock) 6 | 7 | class Buy_place_order_temp(Base): 8 | name = "sendMessage" 9 | def __call__(self, 10 | instrument_type,instrument_id, 11 | side,amount,leverage, 12 | type,limit_price,stop_price, 13 | 14 | stop_lose_kind,stop_lose_value, 15 | take_profit_kind,take_profit_value, 16 | 17 | use_trail_stop,auto_margin_call, 18 | use_token_for_commission): 19 | data = { 20 | "name": "place-order-temp", 21 | "version":"4.0", 22 | "body":{ 23 | "instrument_type":str(instrument_type), 24 | "instrument_id":str(instrument_id), 25 | "side":str(side),#"buy"/"sell" 26 | "amount":float(amount),#money you want buy/sell 27 | "leverage":int(leverage), 28 | 29 | "type":type,#"market"/"limit"/"stop" 30 | #for type="limit"/"stop" 31 | "limit_price":(limit_price),#only working by set type="limit" 32 | "stop_price":(stop_price),#only working by set type="stop" 33 | 34 | #/************set stop loose/take *******************/ 35 | "stop_lose_kind":(stop_lose_kind), 36 | "stop_lose_value":(stop_lose_value), 37 | 38 | "take_profit_kind":(take_profit_kind), 39 | "take_profit_value":(take_profit_value), 40 | 41 | "use_trail_stop":bool(use_trail_stop),#Trailing Stop 42 | "auto_margin_call":bool(auto_margin_call),#this is "Use Balance to Keep Position Open",if you want take_profit_value and stop_lose_value all be "Not Set",auto_margin_call need to True 43 | 44 | 45 | "use_token_for_commission":bool(use_token_for_commission), 46 | "user_balance_id":int(global_value.balance_id), 47 | "client_platform_id":"9",#important can not delete,9 mean your platform is linux 48 | } 49 | } 50 | self.send_websocket_request(self.name, data) 51 | 52 | -------------------------------------------------------------------------------- /indicators.py: -------------------------------------------------------------------------------- 1 | """ 2 | Module that calculate indicators from candle data 3 | """ 4 | 5 | import time 6 | import numpy as np 7 | from talib.abstract import (EMA, BBANDS) 8 | 9 | import trader 10 | 11 | 12 | def generate_candle_data_from_candle_stream(asset, timeframe_in_minutes): 13 | "convert a candle streaming data into numpy array to be used as data to calculate TA-Lib indicators" 14 | candles=trader.get_real_time_candles(asset, timeframe_in_minutes) 15 | 16 | candle_data = { 17 | 'open': np.array([]), 18 | 'high': np.array([]), 19 | 'low': np.array([]), 20 | 'close': np.array([]), 21 | 'volume': np.array([]) 22 | } 23 | 24 | for timestamp in tuple(candles): 25 | candle_data["open"] = np.append(candle_data["open"], candles[timestamp]["open"]) 26 | candle_data["high"] = np.append(candle_data["high"], candles[timestamp]["max"]) 27 | candle_data["low"] = np.append(candle_data["low"], candles[timestamp]["min"]) 28 | candle_data["close"] = np.append(candle_data["close"], candles[timestamp]["close"]) 29 | candle_data["volume"] = np.append(candle_data["volume"], candles[timestamp]["volume"]) 30 | return candle_data 31 | 32 | 33 | # EMA 34 | def calculate_EMA(candle_data, EMA_time_period): 35 | return EMA(candle_data, timeperiod=EMA_time_period) 36 | 37 | 38 | def calculate_asset_EMA(asset, timeframe_in_minutes, EMA_time_period): 39 | candle_data = generate_candle_data_from_candle_stream(asset, timeframe_in_minutes) 40 | return calculate_EMA(candle_data, EMA_time_period) 41 | 42 | 43 | #Bollinger Bands 44 | def calculate_bollinger_bands(candle_data, BB_time_period, BB_dev_up, BB_dev_down): 45 | upperband, middleband, lowerband = BBANDS(candle_data['close'], BB_time_period, BB_dev_up, BB_dev_down, matype=0) 46 | return upperband, middleband, lowerband 47 | 48 | 49 | def calculate_asset_BB(asset, timeframe_in_minutes, BB_time_period, BB_dev_up, BB_dev_down): 50 | candle_data = generate_candle_data_from_candle_stream(asset, timeframe_in_minutes) 51 | upperband, middleband, lowerband = calculate_bollinger_bands(candle_data, BB_time_period, BB_dev_up, BB_dev_down) 52 | return {'upper': upperband, 'middle': middleband, 'lower': lowerband} 53 | 54 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/get_positions.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | import iqoptionapi.global_value as global_value 5 | 6 | class Get_positions(Base): 7 | name = "sendMessage" 8 | def __call__(self,instrument_type): 9 | if instrument_type=="digital-option": 10 | name="digital-options.get-positions" 11 | elif instrument_type=="fx-option": 12 | name="trading-fx-option.get-positions" 13 | else: 14 | name="get-positions" 15 | data = { 16 | "name":name , 17 | "body":{ 18 | "instrument_type":instrument_type, 19 | "user_balance_id":int(global_value.balance_id) 20 | } 21 | } 22 | self.send_websocket_request(self.name, data) 23 | class Get_position(Base): 24 | name = "sendMessage" 25 | def __call__(self,position_id): 26 | data = { 27 | "name":"get-position", 28 | "body":{ 29 | "position_id":position_id, 30 | } 31 | } 32 | self.send_websocket_request(self.name, data) 33 | 34 | class Get_position_history(Base): 35 | name = "sendMessage" 36 | def __call__(self,instrument_type): 37 | data = { 38 | "name":"get-position-history", 39 | "body":{ 40 | "instrument_type":instrument_type, 41 | "user_balance_id":int(global_value.balance_id) 42 | } 43 | } 44 | self.send_websocket_request(self.name, data) 45 | 46 | class Get_position_history_v2(Base): 47 | name = "sendMessage" 48 | def __call__(self,instrument_types,limit,offset,start=0,end=0): 49 | data = { 50 | "name":"portfolio.get-history-positions", 51 | "body":{ 52 | "instrument_types":[instrument_types], 53 | "limit":limit, 54 | "offset":offset, 55 | "start":start, 56 | "end":end, 57 | "user_balance_id":int(global_value.balance_id) 58 | } 59 | } 60 | self.send_websocket_request(self.name, data) 61 | 62 | class Get_digital_position(Base): 63 | name = "sendMessage" 64 | def __call__(self,position_id): 65 | data = { 66 | "name":"digital-options.get-position", 67 | "body":{ 68 | "position_id":position_id, 69 | } 70 | } 71 | self.send_websocket_request(self.name, data) 72 | -------------------------------------------------------------------------------- /iqoptionapi/expiration.py: -------------------------------------------------------------------------------- 1 | # python 2 | import time 3 | from datetime import datetime, timedelta 4 | 5 | # https://docs.python.org/3/library/datetime.html 6 | # If optional argument tz is None or not specified, the timestamp is converted to the platform's local date and time, and the returned datetime object is naive. 7 | # time.mktime(dt.timetuple()) 8 | 9 | 10 | def date_to_timestamp(dt): 11 | # local timezone to timestamp support python2 pytohn3 12 | return time.mktime(dt.timetuple()) 13 | 14 | 15 | def get_expiration_time(timestamp, duration): 16 | # 17 | now_date = datetime.fromtimestamp(timestamp) 18 | exp_date = now_date.replace(second=0, microsecond=0) 19 | if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30: 20 | exp_date = exp_date+timedelta(minutes=1) 21 | 22 | else: 23 | exp_date = exp_date+timedelta(minutes=2) 24 | exp = [] 25 | for _ in range(5): 26 | exp.append(date_to_timestamp(exp_date)) 27 | exp_date = exp_date+timedelta(minutes=1) 28 | 29 | idx = 50 30 | index = 0 31 | now_date = datetime.fromtimestamp(timestamp) 32 | exp_date = now_date.replace(second=0, microsecond=0) 33 | while index < idx: 34 | if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5: 35 | exp.append(date_to_timestamp(exp_date)) 36 | index = index+1 37 | exp_date = exp_date+timedelta(minutes=1) 38 | 39 | remaning = [] 40 | 41 | for t in exp: 42 | remaning.append(int(t)-int(time.time())) 43 | 44 | close = [abs(x-60*duration) for x in remaning] 45 | 46 | return int(exp[close.index(min(close))]), int(close.index(min(close))) 47 | 48 | 49 | def get_remaning_time(timestamp): 50 | now_date = datetime.fromtimestamp(timestamp) 51 | exp_date = now_date.replace(second=0, microsecond=0) 52 | if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30: 53 | exp_date = exp_date+timedelta(minutes=1) 54 | 55 | else: 56 | exp_date = exp_date+timedelta(minutes=2) 57 | exp = [] 58 | for _ in range(5): 59 | exp.append(date_to_timestamp(exp_date)) 60 | exp_date = exp_date+timedelta(minutes=1) 61 | idx = 11 62 | index = 0 63 | now_date = datetime.fromtimestamp(timestamp) 64 | exp_date = now_date.replace(second=0, microsecond=0) 65 | while index < idx: 66 | if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5: 67 | exp.append(date_to_timestamp(exp_date)) 68 | index = index+1 69 | exp_date = exp_date+timedelta(minutes=1) 70 | 71 | remaning = [] 72 | 73 | for idx, t in enumerate(exp): 74 | if idx >= 5: 75 | dr = 15*(idx-4) 76 | else: 77 | dr = idx+1 78 | remaning.append((dr, int(t)-int(time.time()))) 79 | 80 | return remaning 81 | -------------------------------------------------------------------------------- /trader.py: -------------------------------------------------------------------------------- 1 | """ 2 | Module with all trade funcionalities 3 | """ 4 | from time import sleep 5 | from datetime import datetime 6 | from threading import Thread 7 | 8 | from iqoptionapi.stable_api import IQ_Option 9 | 10 | import CONSTANTS 11 | import database 12 | 13 | 14 | IQ = IQ_Option(CONSTANTS.IQUSER, CONSTANTS.IQPASSWORD) 15 | 16 | 17 | trading_assets = [] 18 | 19 | 20 | def connect_to_iq(): 21 | IQ.connect() 22 | 23 | 24 | def change_trade_type(trade_type): 25 | "PRACTICE/REAL" 26 | IQ.change_balance(trade_type) 27 | 28 | 29 | def get_open_assets(): 30 | "get only digital assets" 31 | assets_info = IQ.get_all_open_time() 32 | digital_assets_info = assets_info['digital'] 33 | open_assets = [] 34 | for asset in digital_assets_info: 35 | if digital_assets_info[asset]['open'] and asset not in open_assets: 36 | open_assets.append(asset) 37 | else: 38 | if asset in open_assets: 39 | open_assets.remove(asset) 40 | return open_assets 41 | 42 | 43 | def get_asset_payout(asset): 44 | return IQ.get_digital_payout(asset) 45 | 46 | 47 | def get_account_balance(): 48 | return IQ.get_balance() 49 | 50 | 51 | def get_stake_by_percentage_of_balance(percentage): 52 | return round((percentage/100) * get_account_balance(), 2) 53 | 54 | 55 | def buy(asset, timeframe_in_minutes, stake, action): 56 | check, entry_id = IQ.buy_digital_spot(asset, stake, action, timeframe_in_minutes) 57 | if check: 58 | date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') 59 | payout = get_asset_payout(asset) 60 | database.insert_new_entry_on_database(str(entry_id), date_time, CONSTANTS.TRADETYPE, asset, payout, stake) 61 | return check, entry_id 62 | 63 | 64 | def get_trade_result(entry_id): 65 | return IQ.check_win_digital_v2(entry_id) 66 | 67 | 68 | def buy_and_wait_for_result(asset, timeframe_in_minutes, stake, action): 69 | check, entry_id = buy(asset, timeframe_in_minutes, stake, action) 70 | if check: 71 | while not get_trade_result(entry_id)[0]: 72 | sleep(1) 73 | profit = round(get_trade_result(entry_id)[1], 2) 74 | trading_assets.remove(asset) 75 | if profit < 0: 76 | result = 'loss' 77 | elif profit > 0: 78 | result = 'win' 79 | elif profit == 0: 80 | result = 'tie' 81 | database.update_entry_result_and_profit(entry_id, result, profit) 82 | return result, profit 83 | 84 | 85 | def buy_and_wait_for_result_as_thread(asset, timeframe_in_minutes, stake, action): 86 | buy_thread = Thread(target=buy_and_wait_for_result, args=(asset, timeframe_in_minutes, stake, action)) 87 | buy_thread.start() 88 | 89 | 90 | def subscribe_to_candle_stream(asset, timeframe_in_minutes, n_candles): 91 | timeframe_in_seconds = timeframe_in_minutes * 60 92 | IQ.start_candles_stream(asset, timeframe_in_seconds, n_candles) 93 | 94 | 95 | def get_real_time_candles(asset, timeframe_in_minutes): 96 | "get real time candles need an active subscription to the candle stream" 97 | timeframe_in_seconds = timeframe_in_minutes * 60 98 | return IQ.get_realtime_candles(asset, timeframe_in_seconds) 99 | 100 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/candles.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Candles websocket object.""" 2 | 3 | from iqoptionapi.ws.objects.base import Base 4 | 5 | 6 | class Candle(object): 7 | """Class for IQ Option candle.""" 8 | 9 | def __init__(self, candle_data): 10 | """ 11 | :param candle_data: The list of candles data. 12 | """ 13 | self.__candle_data = candle_data 14 | 15 | @property 16 | def candle_time(self): 17 | """Property to get candle time. 18 | 19 | :returns: The candle time. 20 | """ 21 | return self.__candle_data[0] 22 | 23 | @property 24 | def candle_open(self): 25 | """Property to get candle open value. 26 | 27 | :returns: The candle open value. 28 | """ 29 | return self.__candle_data[1] 30 | 31 | @property 32 | def candle_close(self): 33 | """Property to get candle close value. 34 | 35 | :returns: The candle close value. 36 | """ 37 | return self.__candle_data[2] 38 | 39 | @property 40 | def candle_high(self): 41 | """Property to get candle high value. 42 | 43 | :returns: The candle high value. 44 | """ 45 | return self.__candle_data[3] 46 | 47 | @property 48 | def candle_low(self): 49 | """Property to get candle low value. 50 | 51 | :returns: The candle low value. 52 | """ 53 | return self.__candle_data[4] 54 | 55 | @property 56 | def candle_type(self): # pylint: disable=inconsistent-return-statements 57 | """Property to get candle type value. 58 | 59 | :returns: The candle type value. 60 | """ 61 | if self.candle_open < self.candle_close: 62 | return "green" 63 | elif self.candle_open > self.candle_close: 64 | return "red" 65 | 66 | 67 | class Candles(Base): 68 | """Class for IQ Option Candles websocket object.""" 69 | 70 | def __init__(self): 71 | super(Candles, self).__init__() 72 | self.__name = "candles" 73 | self.__candles_data = None 74 | 75 | @property 76 | def candles_data(self): 77 | """Property to get candles data. 78 | 79 | :returns: The list of candles data. 80 | """ 81 | return self.__candles_data 82 | 83 | @candles_data.setter 84 | def candles_data(self, candles_data): 85 | """Method to set candles data.""" 86 | self.__candles_data = candles_data 87 | 88 | @property 89 | def first_candle(self): 90 | """Method to get first candle. 91 | 92 | :returns: The instance of :class:`Candle 93 | `. 94 | """ 95 | return Candle(self.candles_data[0]) 96 | 97 | @property 98 | def second_candle(self): 99 | """Method to get second candle. 100 | 101 | :returns: The instance of :class:`Candle 102 | `. 103 | """ 104 | return Candle(self.candles_data[1]) 105 | 106 | @property 107 | def current_candle(self): 108 | """Method to get current candle. 109 | 110 | :returns: The instance of :class:`Candle 111 | `. 112 | """ 113 | return Candle(self.candles_data[-1]) 114 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/buyv3.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from iqoptionapi.ws.chanels.base import Base 4 | import logging 5 | import iqoptionapi.global_value as global_value 6 | from iqoptionapi.expiration import get_expiration_time 7 | 8 | 9 | class Buyv3(Base): 10 | 11 | name = "sendMessage" 12 | 13 | def __call__(self, price, active, direction, duration, request_id): 14 | 15 | # thank Darth-Carrotpie's code 16 | # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 17 | exp, idx = get_expiration_time( 18 | int(self.api.timesync.server_timestamp), duration) 19 | if idx < 5: 20 | option = 3 # "turbo" 21 | else: 22 | option = 1 # "binary" 23 | data = { 24 | "body": {"price": price, 25 | "active_id": active, 26 | "expired": int(exp), 27 | "direction": direction.lower(), 28 | "option_type_id": option, 29 | "user_balance_id": int(global_value.balance_id) 30 | }, 31 | "name": "binary-options.open-option", 32 | "version": "1.0" 33 | } 34 | self.send_websocket_request(self.name, data, str(request_id)) 35 | 36 | 37 | class Buyv3_by_raw_expired(Base): 38 | 39 | name = "sendMessage" 40 | 41 | def __call__(self, price, active, direction, option, expired, request_id): 42 | 43 | # thank Darth-Carrotpie's code 44 | # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 45 | 46 | if option == "turbo": 47 | option_id = 3 # "turbo" 48 | elif option == "binary": 49 | option_id = 1 # "binary" 50 | data = { 51 | "body": {"price": price, 52 | "active_id": active, 53 | "expired": int(expired), 54 | "direction": direction.lower(), 55 | "option_type_id": option_id, 56 | "user_balance_id": int(global_value.balance_id) 57 | }, 58 | "name": "binary-options.open-option", 59 | "version": "1.0" 60 | } 61 | self.send_websocket_request(self.name, data, str(request_id)) 62 | 63 | 64 | """ 65 | # thank Darth-Carrotpie's code 66 | # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 67 | def get_expiration_time(self, duration): 68 | exp = time.time() 69 | if duration >= 1 and duration <= 5: 70 | option = 3#"turbo" 71 | # Round to next full minute 72 | # datetime.datetime.now().second>30 73 | if (exp % 60) > 30: 74 | exp = exp - (exp % 60) + 60*(duration+1) 75 | else: 76 | exp = exp - (exp % 60)+60*(duration) 77 | elif duration > 5: 78 | option = 1#"binary" 79 | period = int(round(duration / 15)) 80 | tmp_exp = exp - (exp % 60) # nuima sekundes 81 | tmp_exp = tmp_exp - (tmp_exp % 3600) # nuimam minutes 82 | j = 0 83 | while exp > tmp_exp + (j)*15*60: # find quarter 84 | j = j+1 85 | if exp - tmp_exp > 5 * 60: 86 | quarter = tmp_exp + (j)*15*60 87 | exp = quarter + period*15*60 88 | else: 89 | quarter = tmp_exp + (j+1)*15*60 90 | exp = quarter + period*15*60 91 | else: 92 | logging.error("ERROR get_expiration_time DO NOT LESS 1") 93 | exit(1) 94 | return exp, option 95 | """ 96 | -------------------------------------------------------------------------------- /iqoptionapi/ws/objects/profile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Profile websocket object.""" 2 | from iqoptionapi.ws.objects.base import Base 3 | 4 | 5 | class Profile(Base): 6 | """Class for IQ Option Profile websocket object.""" 7 | 8 | def __init__(self): 9 | super(Profile, self).__init__() 10 | self.__name = "profile" 11 | self.__skey = None 12 | self.__balance = None 13 | self.__balance_id=None 14 | self.__balances=None 15 | self.__msg=None 16 | self.__currency=None 17 | self.__minimum_amount=1 18 | self.__balance_type=None 19 | self.__currency_char=None 20 | self.__time_zone=-3 21 | 22 | @property 23 | def skey(self): 24 | """Property to get skey value. 25 | 26 | :returns: The skey value. 27 | """ 28 | return self.__skey 29 | 30 | @skey.setter 31 | def skey(self, skey): 32 | """Method to set skey value.""" 33 | self.__skey = skey 34 | #---------------------------------------------------------------- 35 | @property 36 | def balance(self): 37 | """Property to get balance value. 38 | 39 | :returns: The balance value. 40 | """ 41 | return self.__balance 42 | 43 | @balance.setter 44 | def balance(self, balance): 45 | """Method to set balance value.""" 46 | self.__balance = balance 47 | 48 | #--------------------------------------------------------------------- 49 | @property 50 | def balance_id(self): 51 | """Property to get balance value. 52 | 53 | :returns: The balance value. 54 | """ 55 | return self.__balance_id 56 | @balance_id.setter 57 | def balance_id(self, balance_id): 58 | """Method to set balance value.""" 59 | self.__balance_id = balance_id 60 | 61 | 62 | #------------------------------------------------------------------------ 63 | @property 64 | def balance_type(self): 65 | """Property to get balance value. 66 | 67 | :returns: The balance value. 68 | """ 69 | return self.__balance_type 70 | @balance_type.setter 71 | def balance_type(self, balance_type): 72 | """Method to set balance value.""" 73 | self.__balance_type = balance_type 74 | 75 | 76 | 77 | 78 | #---------------------------------------- 79 | @property 80 | def balances(self): 81 | """Property to get balance value. 82 | 83 | :returns: The balance value. 84 | """ 85 | return self.__balances 86 | @balances.setter 87 | def balances(self, balances): 88 | """Method to set balance value.""" 89 | self.__balances = balances 90 | 91 | #------------ 92 | @property 93 | def msg(self): 94 | return self.__msg 95 | @msg.setter 96 | def msg(self, msg): 97 | self.__msg = msg 98 | 99 | #------------ 100 | @property 101 | def currency(self): 102 | return self.__currency 103 | 104 | @currency.setter 105 | def currency(self, currency): 106 | self.__currency = currency 107 | if self.__currency.upper() == "BRL": 108 | self.__minimum_amount = 2 109 | 110 | @property 111 | def minimum_amount(self): 112 | return self.__minimum_amount 113 | #------------ 114 | @property 115 | def currency_char(self): 116 | return self.__currency_char 117 | 118 | @currency_char.setter 119 | def currency_char(self, currency_char): 120 | self.__currency_char = currency_char 121 | #------------ 122 | @property 123 | def time_zone(self): 124 | return self.__time_zone 125 | 126 | @time_zone.setter 127 | def time_zone(self, time_zone): 128 | self.__time_zone = int(time_zone/60) -------------------------------------------------------------------------------- /iqoptionapi/country_id.py: -------------------------------------------------------------------------------- 1 | ID = {"Worldwide":0, 2 | "AF": 1, 3 | "AL": 2, 4 | "DZ": 3, 5 | "AD": 5, 6 | "AO": 6, 7 | "AI": 7, 8 | "AG": 9, 9 | "AR": 10, 10 | "AM": 11, 11 | "AW": 12, 12 | "AT": 14, 13 | "AZ": 15, 14 | "BS": 16, 15 | "BH": 17, 16 | "BD": 18, 17 | "BB": 19, 18 | "BY": 20, 19 | "BZ": 22, 20 | "BJ": 23, 21 | "BM": 24, 22 | "BO": 26, 23 | "BA": 27, 24 | "BW": 28, 25 | "BV": 29, 26 | "BR": 30, 27 | "BN": 31, 28 | "BG": 32, 29 | "BF": 33, 30 | "BI": 34, 31 | "KH": 35, 32 | "CM": 36, 33 | "CV": 38, 34 | "KY": 39, 35 | "TD": 41, 36 | "CL": 42, 37 | "CN": 43, 38 | "CC": 45, 39 | "CO": 46, 40 | "KM": 47, 41 | "CG": 48, 42 | "CK": 49, 43 | "CR": 50, 44 | "CI": 51, 45 | "HR": 52, 46 | "CU": 53, 47 | "CY": 54, 48 | "CZ": 55, 49 | "DK": 56, 50 | "DJ": 57, 51 | "DM": 58, 52 | "DO": 59, 53 | "TL": 60, 54 | "EC": 61, 55 | "EG": 62, 56 | "SV": 63, 57 | "EE": 66, 58 | "ET": 67, 59 | "FO": 69, 60 | "FJ": 70, 61 | "FI": 71, 62 | "FR": 72, 63 | "GF": 73, 64 | "PF": 74, 65 | "GA": 75, 66 | "GM": 76, 67 | "GE": 77, 68 | "DE": 78, 69 | "GH": 79, 70 | "GR": 81, 71 | "GD": 83, 72 | "GP": 84, 73 | "GT": 86, 74 | "GN": 87, 75 | "GY": 88, 76 | "HT": 89, 77 | "HN": 90, 78 | "HK": 91, 79 | "HU": 92, 80 | "IS": 93, 81 | "ID": 94, 82 | "IQ": 95, 83 | "IE": 96, 84 | "IT": 97, 85 | "JM": 98, 86 | "JO": 100, 87 | "KZ": 101, 88 | "KE": 102, 89 | "KI": 103, 90 | "KW": 104, 91 | "KG": 105, 92 | "LA": 106, 93 | "LV": 107, 94 | "LB": 108, 95 | "LS": 109, 96 | "LR": 110, 97 | "LY": 111, 98 | "LT": 113, 99 | "LU": 114, 100 | "MO": 115, 101 | "MK": 116, 102 | "MG": 117, 103 | "MW": 118, 104 | "MY": 119, 105 | "MV": 120, 106 | "ML": 121, 107 | "MT": 122, 108 | "MQ": 124, 109 | "MR": 125, 110 | "MU": 126, 111 | "MX": 128, 112 | "FM": 129, 113 | "MD": 130, 114 | "MC": 131, 115 | "MN": 132, 116 | "MA": 134, 117 | "MZ": 135, 118 | "MM": 136, 119 | "NA": 137, 120 | "NP": 139, 121 | "NL": 140, 122 | "AN": 141, 123 | "NC": 142, 124 | "NZ": 143, 125 | "NI": 144, 126 | "NE": 145, 127 | "NG": 146, 128 | "NO": 149, 129 | "OM": 150, 130 | "PK": 151, 131 | "PW": 152, 132 | "PA": 153, 133 | "PG": 154, 134 | "PY": 155, 135 | "PE": 156, 136 | "PH": 157, 137 | "PL": 159, 138 | "PT": 160, 139 | "QA": 162, 140 | "RE": 163, 141 | "RO": 164, 142 | "RW": 166, 143 | "KN": 167, 144 | "LC": 168, 145 | "SA": 171, 146 | "SN": 172, 147 | "SC": 173, 148 | "SG": 175, 149 | "SK": 176, 150 | "SI": 177, 151 | "SO": 179, 152 | "ZA": 180, 153 | "KR": 181, 154 | "ES": 182, 155 | "LK": 183, 156 | "SH": 184, 157 | "SR": 186, 158 | "SZ": 187, 159 | "SE": 188, 160 | "CH": 189, 161 | "TW": 191, 162 | "TJ": 192, 163 | "TZ": 193, 164 | "TH": 194, 165 | "TG": 195, 166 | "TT": 198, 167 | "TN": 199, 168 | "TR": 200, 169 | "TM": 201, 170 | "UG": 203, 171 | "UA": 204, 172 | "AE": 205, 173 | "GB": 206, 174 | "UY": 207, 175 | "UZ": 208, 176 | "VE": 211, 177 | "VN": 212, 178 | "VG": 213, 179 | "YE": 216, 180 | "ZM": 218, 181 | "ZW": 219, 182 | "RS": 220, 183 | "ME": 221, 184 | "IN": 225, 185 | "TC": 234, 186 | "CD": 235, 187 | "GG": 236, 188 | "IM": 237, 189 | "JE": 239, 190 | "CW": 246, } 191 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/unsubscribe.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option unsubscribe websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | import datetime 5 | import iqoptionapi.constants as OP_code 6 | 7 | 8 | class Unsubscribe(Base): 9 | """Class for IQ option candles websocket chanel.""" 10 | # pylint: disable=too-few-public-methods 11 | 12 | name = "unsubscribeMessage" 13 | 14 | def __call__(self, active_id, size=1): 15 | 16 | data = {"name": "candle-generated", 17 | "params": { 18 | "routingFilters": { 19 | "active_id": str(active_id), 20 | "size": int(size) 21 | } 22 | } 23 | } 24 | 25 | self.send_websocket_request(self.name, data) 26 | 27 | 28 | class Unsubscribe_candles(Base): 29 | """Class for IQ option candles websocket chanel.""" 30 | # pylint: disable=too-few-public-methods 31 | 32 | name = "unsubscribeMessage" 33 | 34 | def __call__(self, active_id, size=1): 35 | 36 | data = {"name": "candles-generated", 37 | "params": { 38 | "routingFilters": { 39 | "active_id": str(active_id) 40 | } 41 | } 42 | } 43 | 44 | self.send_websocket_request(self.name, data) 45 | 46 | 47 | class Unsubscribe_Instrument_Quites_Generated(Base): 48 | name = "unsubscribeMessage" 49 | 50 | def __call__(self, ACTIVE, expiration_period): 51 | data = { 52 | "name": "instrument-quotes-generated", 53 | "params": { 54 | "routingFilters": { 55 | "active": int(OP_code.ACTIVES[ACTIVE]), 56 | "expiration_period": int(expiration_period*60), 57 | "kind": "digital-option", 58 | }, 59 | }, 60 | "version": "1.0" 61 | } 62 | self.send_websocket_request(self.name, data) 63 | 64 | def get_digital_expiration_time(self, duration): 65 | exp = int(self.api.timesync.server_timestamp) 66 | value = datetime.datetime.fromtimestamp(exp) 67 | minute = int(value.strftime('%M')) 68 | # second=int(value.strftime('%S')) 69 | ans = exp-exp % 60 # delete second 70 | ans = ans+(duration-minute % duration)*60 71 | if exp > ans-10: 72 | ans = ans+(duration)*60 73 | 74 | return ans 75 | 76 | 77 | class Unsubscribe_top_assets_updated(Base): 78 | name = "unsubscribeMessage" 79 | 80 | def __call__(self, instrument_type): 81 | 82 | data = {"name": "top-assets-updated", 83 | "params": { 84 | "routingFilters": { 85 | "instrument_type": str(instrument_type) 86 | 87 | } 88 | }, 89 | "version": "1.2" 90 | } 91 | self.send_websocket_request(self.name, data) 92 | 93 | 94 | class Unsubscribe_commission_changed(Base): 95 | name = "unsubscribeMessage" 96 | def __call__(self, instrument_type): 97 | 98 | data = {"name": "commission-changed", 99 | "params": { 100 | "routingFilters": { 101 | "instrument_type": str(instrument_type) 102 | } 103 | }, 104 | "version": "1.0" 105 | } 106 | self.send_websocket_request(self.name, data) 107 | 108 | 109 | class Unscribe_live_deal(Base): 110 | name = "unsubscribeMessage" 111 | 112 | def __call__(self, name, active_id, _type): 113 | if name == "live-deal-binary-option-placed": 114 | _type_name = "option_type" 115 | _active_id = "active_id" 116 | elif name == "live-deal-digital-option": 117 | _type_name = "expiration_type" 118 | _active_id = "instrument_active_id" 119 | elif name == "live-deal": 120 | _type_name = "instrument_type" 121 | _active_id = "instrument_active_id" 122 | 123 | data = {"name": str(name), 124 | "params": { 125 | "routingFilters": { 126 | _active_id: int(active_id), 127 | _type_name: str(_type) 128 | } 129 | }, 130 | "version": "2.0" 131 | } 132 | self.send_websocket_request(self.name, data) 133 | 134 | 135 | class UnsubscribeDigitalPriceSplitter(Base): 136 | name = "unsubscribeMessage" 137 | 138 | def __call__(self, asset_id): 139 | data = { 140 | "name": "price-splitter.client-price-generated", 141 | "version": "1.0", 142 | "params": { 143 | "routingFilters": { 144 | "instrument_type": "digital-option", 145 | "asset_id": int(asset_id) 146 | } 147 | } 148 | } 149 | 150 | self.send_websocket_request(self.name, msg=data) 151 | -------------------------------------------------------------------------------- /iqoptionapi/ws/chanels/subscribe.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option subscribe websocket chanel.""" 2 | 3 | from iqoptionapi.ws.chanels.base import Base 4 | import datetime 5 | import iqoptionapi.constants as OP_code 6 | 7 | 8 | class Subscribe(Base): 9 | """Class for IQ option candles websocket chanel.""" 10 | # pylint: disable=too-few-public-methods 11 | 12 | name = "subscribeMessage" 13 | 14 | def __call__(self, active_id, size): 15 | # {"name":"subscribeMessage","msg":{"name":"candle-generated","params":{"routingFilters":{"active_id":1,"size":1}}}} 16 | 17 | data = {"name": "candle-generated", 18 | "params": { 19 | "routingFilters": { 20 | "active_id": str(active_id), 21 | "size": int(size) 22 | } 23 | } 24 | } 25 | 26 | self.send_websocket_request(self.name, data) 27 | 28 | 29 | class Subscribe_candles(Base): 30 | """Class for IQ option candles websocket chanel.""" 31 | # pylint: disable=too-few-public-methods 32 | 33 | name = "subscribeMessage" 34 | 35 | def __call__(self, active_id): 36 | 37 | data = {"name": "candles-generated", 38 | "params": { 39 | "routingFilters": { 40 | "active_id": str(active_id) 41 | } 42 | } 43 | } 44 | 45 | self.send_websocket_request(self.name, data) 46 | 47 | 48 | class Subscribe_Instrument_Quites_Generated(Base): 49 | name = "subscribeMessage" 50 | 51 | def __call__(self, ACTIVE, expiration_period): 52 | data = { 53 | "name": "instrument-quotes-generated", 54 | "params": { 55 | "routingFilters": { 56 | "active": int(OP_code.ACTIVES[ACTIVE]), 57 | "expiration_period": int(expiration_period*60), 58 | "kind": "digital-option", 59 | 60 | }, 61 | }, 62 | "version": "1.0" 63 | } 64 | self.send_websocket_request(self.name, data) 65 | 66 | def get_digital_expiration_time(self, duration): 67 | exp = int(self.api.timesync.server_timestamp) 68 | value = datetime.datetime.fromtimestamp(exp) 69 | minute = int(value.strftime('%M')) 70 | # second=int(value.strftime('%S')) 71 | ans = exp-exp % 60 # delete second 72 | ans = ans+(duration-minute % duration)*60 73 | if exp > ans-10: 74 | ans = ans+(duration)*60 75 | 76 | return ans 77 | 78 | 79 | class Subscribe_top_assets_updated(Base): 80 | name = "subscribeMessage" 81 | 82 | def __call__(self, instrument_type): 83 | 84 | data = {"name": "top-assets-updated", 85 | "params": { 86 | "routingFilters": { 87 | "instrument_type": str(instrument_type) 88 | 89 | } 90 | }, 91 | "version": "1.2" 92 | } 93 | self.send_websocket_request(self.name, data) 94 | 95 | 96 | """ 97 | {"name":"subscribeMessage","request_id":"s_114","msg":{"name":"commission-changed","version":"1.0","params":{"routingFilters":{"instrument_type":"digital-option","user_group_id":1}}}} 98 | """ 99 | #instrument_type: "binary-option"/"turbo-option"/"digital-option"/"crypto"/"forex"/"cfd" 100 | 101 | 102 | class Subscribe_commission_changed(Base): 103 | name = "subscribeMessage" 104 | def __call__(self, instrument_type): 105 | 106 | data = {"name": "commission-changed", 107 | "params": { 108 | "routingFilters": { 109 | "instrument_type": str(instrument_type) 110 | } 111 | }, 112 | "version": "1.0" 113 | } 114 | self.send_websocket_request(self.name, data) 115 | 116 | 117 | class Subscribe_live_deal(Base): 118 | name = "subscribeMessage" 119 | 120 | def __call__(self, name, active_id, _type): 121 | # "live-deal-binary-option-placed" 122 | # "live-deal-digital-option" 123 | if name == "live-deal-binary-option-placed": 124 | _type_name = "option_type" # turbo/binary 125 | _active_id = "active_id" 126 | elif name == "live-deal-digital-option": 127 | _type_name = "expiration_type" 128 | _active_id = "instrument_active_id" 129 | elif name == "live-deal": 130 | _type_name = "instrument_type" 131 | _active_id = "instrument_active_id" 132 | 133 | data = {"name": name, 134 | "params": { 135 | "routingFilters": { 136 | _active_id: int(active_id), 137 | _type_name: str(_type) 138 | } 139 | }, 140 | "version": "2.0" 141 | } 142 | self.send_websocket_request(self.name, data) 143 | 144 | 145 | class SubscribeDigitalPriceSplitter(Base): 146 | name = "subscribeMessage" 147 | 148 | def __call__(self, asset_id): 149 | data = { 150 | "name": "price-splitter.client-price-generated", 151 | "version": "1.0", 152 | "params": { 153 | "routingFilters": { 154 | "instrument_type": "digital-option", 155 | "asset_id": int(asset_id) 156 | } 157 | } 158 | } 159 | 160 | self.send_websocket_request(self.name, msg=data) 161 | -------------------------------------------------------------------------------- /iqoptionapi/constants.py: -------------------------------------------------------------------------------- 1 | "" 2 | "Module for IQ Option API constants." 3 | ""#~~~need to update~~~ 4 | ACTIVES = { 5 | "EURUSD": 1, 6 | "EURGBP": 2, 7 | "GBPJPY": 3, 8 | "EURJPY": 4, 9 | "GBPUSD": 5, 10 | "USDJPY": 6, 11 | "AUDCAD": 7, 12 | "NZDUSD": 8, 13 | "USDRUB": 10, 14 | "AMAZON": 31, 15 | "APPLE": 32, 16 | "BAIDU": 33, 17 | "CISCO": 34, 18 | "FACEBOOK": 35, 19 | "GOOGLE": 36, 20 | "INTEL": 37, 21 | "MSFT": 38, 22 | "YAHOO": 40, 23 | "AIG": 41, 24 | "CITI": 45, 25 | "COKE": 46, 26 | "GE": 48, 27 | "GM": 49, 28 | "GS": 50, 29 | "JPM": 51, 30 | "MCDON": 52, 31 | "MORSTAN": 53, 32 | "NIKE": 54, 33 | "USDCHF": 72, 34 | "XAUUSD": 74, 35 | "XAGUSD": 75, 36 | "EURUSD-OTC": 76, 37 | "EURGBP-OTC": 77, 38 | "USDCHF-OTC": 78, 39 | "EURJPY-OTC": 79, 40 | "NZDUSD-OTC": 80, 41 | "GBPUSD-OTC": 81, 42 | "GBPJPY-OTC": 84, 43 | "USDJPY-OTC": 85, 44 | "AUDCAD-OTC": 86, 45 | "ALIBABA": 87, 46 | "YANDEX": 95, 47 | "AUDUSD": 99, 48 | "USDCAD": 100, 49 | "AUDJPY": 101, 50 | "GBPCAD": 102, 51 | "GBPCHF": 103, 52 | "GBPAUD": 104, 53 | "EURCAD": 105, 54 | "CHFJPY": 106, 55 | "CADCHF": 107, 56 | "EURAUD": 108, 57 | "TWITTER": 113, 58 | "FERRARI": 133, 59 | "TESLA": 167, 60 | "USDNOK": 168, 61 | "EURNZD": 212, 62 | "USDSEK": 219, 63 | "USDTRY": 220, 64 | "MMM:US": 252, 65 | "ABT:US": 253, 66 | "ABBV:US": 254, 67 | "ACN:US": 255, 68 | "ATVI:US": 256, 69 | "ADBE:US": 258, 70 | "AAP:US": 259, 71 | "AA:US": 269, 72 | "AGN:US": 272, 73 | "MO:US": 278, 74 | "AMGN:US": 290, 75 | "T:US": 303, 76 | "ADSK:US": 304, 77 | "BAC:US": 313, 78 | "BBY:US": 320, 79 | "BA:US": 324, 80 | "BMY:US": 328, 81 | "CAT:US": 338, 82 | "CTL:US": 344, 83 | "CVX:US": 349, 84 | "CTAS:US": 356, 85 | "CTXS:US": 360, 86 | "CL:US": 365, 87 | "CMCSA:US": 366, 88 | "CXO:US": 369, 89 | "COP:US": 370, 90 | "ED:US": 371, 91 | "COST:US": 374, 92 | "CVS:US": 379, 93 | "DHI:US": 380, 94 | "DHR:US": 381, 95 | "DRI:US": 382, 96 | "DVA:US": 383, 97 | "DAL:US": 386, 98 | "DVN:US": 388, 99 | "DO:US": 389, 100 | "DLR:US": 390, 101 | "DFS:US": 391, 102 | "DISCA:US": 392, 103 | "DOV:US": 397, 104 | "DTE:US": 400, 105 | "DNB:US": 403, 106 | "ETFC:US": 404, 107 | "EMN:US": 405, 108 | "EBAY:US": 407, 109 | "ECL:US": 408, 110 | "EIX:US": 409, 111 | "EMR:US": 413, 112 | "ETR:US": 415, 113 | "EQT:US": 417, 114 | "EFX:US": 418, 115 | "EQR:US": 420, 116 | "ESS:US": 421, 117 | "EXPD:US": 426, 118 | "EXR:US": 428, 119 | "XOM:US": 429, 120 | "FFIV:US": 430, 121 | "FAST:US": 432, 122 | "FRT:US": 433, 123 | "FDX:US": 434, 124 | "FIS:US": 435, 125 | "FITB:US": 436, 126 | "FSLR:US": 437, 127 | "FE:US": 438, 128 | "FISV:US": 439, 129 | "FLS:US": 441, 130 | "FMC:US": 443, 131 | "FBHS:US": 448, 132 | "FCX:US": 450, 133 | "FTR:US": 451, 134 | "GILD:US": 460, 135 | "HAS:US": 471, 136 | "HON:US": 480, 137 | "IBM:US": 491, 138 | "KHC:US": 513, 139 | "LMT:US": 528, 140 | "MA:US": 542, 141 | "MDT:US": 548, 142 | "MU:US": 553, 143 | "NFLX:US": 569, 144 | "NEE:US": 575, 145 | "NVDA:US": 586, 146 | "PYPL:US": 597, 147 | "PFE:US": 603, 148 | "PM:US": 605, 149 | "PG:US": 617, 150 | "QCOM:US": 626, 151 | "DGX:US": 628, 152 | "RTN:US": 630, 153 | "CRM:US": 645, 154 | "SLB:US": 647, 155 | "SBUX:US": 666, 156 | "SYK:US": 670, 157 | "DIS:US": 689, 158 | "TWX:US": 692, 159 | "VZ:US": 723, 160 | "V:US": 726, 161 | "WMT:US": 729, 162 | "WBA:US": 730, 163 | "WFC:US": 733, 164 | "SNAP": 756, 165 | "DUBAI": 757, 166 | "TA25": 758, 167 | "AMD": 760, 168 | "ALGN": 761, 169 | "ANSS": 762, 170 | "DRE": 772, 171 | "IDXX": 775, 172 | "RMD": 781, 173 | "SU": 783, 174 | "TFX": 784, 175 | "TMUS": 785, 176 | "QQQ": 796, 177 | "SPY": 808, 178 | "BTCUSD": 816, 179 | "XRPUSD": 817, 180 | "ETHUSD": 818, 181 | "LTCUSD": 819, 182 | "DSHUSD": 821, 183 | "BCHUSD": 824, 184 | "OMGUSD": 825, 185 | "ZECUSD": 826, 186 | "ETCUSD": 829, 187 | "BTCUSD-L": 830, 188 | "ETHUSD-L": 831, 189 | "LTCUSD-L": 834, 190 | "BCHUSD-L": 836, 191 | "BTGUSD": 837, 192 | "QTMUSD": 845, 193 | "XLMUSD": 847, 194 | "TRXUSD": 858, 195 | "EOSUSD": 864, 196 | "USDINR": 865, 197 | "USDPLN": 866, 198 | "USDBRL": 867, 199 | "USDZAR": 868, 200 | "DBX": 889, 201 | "SPOT": 891, 202 | "USDSGD": 892, 203 | "USDHKD": 893, 204 | "LLOYL-CHIX": 894, 205 | "VODL-CHIX": 895, 206 | "BARCL-CHIX": 896, 207 | "TSCOL-CHIX": 897, 208 | "BPL-CHIX": 898, 209 | "HSBAL-CHIX": 899, 210 | "RBSL-CHIX": 900, 211 | "BLTL-CHIX": 901, 212 | "MRWL-CHIX": 902, 213 | "STANL-CHIX": 903, 214 | "RRL-CHIX": 904, 215 | "MKSL-CHIX": 905, 216 | "BATSL-CHIX": 906, 217 | "ULVRL-CHIX": 908, 218 | "EZJL-CHIX": 909, 219 | "ADSD-CHIX": 910, 220 | "ALVD-CHIX": 911, 221 | "BAYND-CHIX": 912, 222 | "BMWD-CHIX": 913, 223 | "CBKD-CHIX": 914, 224 | "COND-CHIX": 915, 225 | "DAID-CHIX": 916, 226 | "DBKD-CHIX": 917, 227 | "DPWD-CHIX": 919, 228 | "DTED-CHIX": 920, 229 | "EOAND-CHIX": 921, 230 | "MRKD-CHIX": 922, 231 | "SIED-CHIX": 923, 232 | "TKAD-CHIX": 924, 233 | "VOW3D-CHIX": 925, 234 | "ENELM-CHIX": 926, 235 | "ENIM-CHIX": 927, 236 | "PIRCM-CHIX": 929, 237 | "PSTM-CHIX": 930, 238 | "TITM-CHIX": 931, 239 | "UCGM-CHIX": 932, 240 | "CSGNZ-CHIX": 933, 241 | "NESNZ-CHIX": 934, 242 | "ROGZ-CHIX": 935, 243 | "UBSGZ-CHIX": 936, 244 | "SANE-CHIX": 937, 245 | "BBVAE-CHIX": 938, 246 | "TEFE-CHIX": 939, 247 | "AIRP-CHIX": 940, 248 | "HEIOA-CHIX": 941, 249 | "ORP-CHIX": 942, 250 | "AUDCHF": 943, 251 | "AUDNZD": 944, 252 | "CADJPY": 945, 253 | "EURCHF": 946, 254 | "GBPNZD": 947, 255 | "NZDCAD": 948, 256 | "NZDJPY": 949, 257 | "EURSEK": 950, 258 | "EURNOK": 951, 259 | "CHFSGD": 952, 260 | "EURSGD": 955, 261 | "USDMXN": 957, 262 | "JUVEM": 958, 263 | "ASRM": 959, 264 | "MANU": 966, 265 | "UKOUSD": 969, 266 | "XPTUSD": 970, 267 | "USOUSD": 971, 268 | "W1": 977, 269 | "AUDDKK": 983, 270 | "AUDMXN": 985, 271 | "AUDNOK": 986, 272 | "AUDSEK": 988, 273 | "AUDSGD": 989, 274 | "AUDTRY": 990, 275 | "CADMXN": 992, 276 | "CADNOK": 993, 277 | "CADPLN": 994, 278 | "CADTRY": 995, 279 | "CHFDKK": 996, 280 | "CHFNOK": 998, 281 | "CHFSEK": 1000, 282 | "CHFTRY": 1001, 283 | "DKKPLN": 1004, 284 | "DKKSGD": 1005, 285 | "EURDKK": 1007, 286 | "EURMXN": 1008, 287 | "EURTRY": 1010, 288 | "EURZAR": 1011, 289 | "GBPILS": 1013, 290 | "GBPMXN": 1014, 291 | "GBPNOK": 1015, 292 | "GBPPLN": 1016, 293 | "GBPSEK": 1017, 294 | "GBPSGD": 1018, 295 | "GBPTRY": 1019, 296 | "NOKDKK": 1023, 297 | "NOKJPY": 1024, 298 | "NOKSEK": 1025, 299 | "NZDDKK": 1026, 300 | "NZDMXN": 1027, 301 | "NZDNOK": 1028, 302 | "NZDSEK": 1030, 303 | "NZDSGD": 1031, 304 | "NZDTRY": 1032, 305 | "NZDZAR": 1033, 306 | "PLNSEK": 1036, 307 | "SEKDKK": 1037, 308 | "SEKJPY": 1038, 309 | "SGDJPY": 1041, 310 | "USDDKK": 1045, 311 | "NZDCHF": 1048, 312 | "GBPHUF": 1049, 313 | "USDCZK": 1050, 314 | "USDHUF": 1051, 315 | "CADSGD": 1054, 316 | "EURCZK": 1056, 317 | "EURHUF": 1057, 318 | "USDTHB": 1062, 319 | "IOTUSD-L": 1116, 320 | "XLMUSD-L": 1117, 321 | "NEOUSD-L": 1118, 322 | "ADAUSD-L": 1119, 323 | "XEMUSD-L": 1120, 324 | "XRPUSD-L": 1122, 325 | "EEM": 1203, 326 | "FXI": 1204, 327 | "IWM": 1205, 328 | "GDX": 1206, 329 | "XOP": 1209, 330 | "XLK": 1210, 331 | "XLE": 1211, 332 | "XLU": 1212, 333 | "IEMG": 1213, 334 | "XLY": 1214, 335 | "IYR": 1215, 336 | "SQQQ": 1216, 337 | "OIH": 1217, 338 | "SMH": 1218, 339 | "EWJ": 1219, 340 | "XLB": 1221, 341 | "DIA": 1222, 342 | "TLT": 1223, 343 | "SDS": 1224, 344 | "EWW": 1225, 345 | "XME": 1227, 346 | "QID": 1229, 347 | "AUS200": 1230, 348 | "FRANCE40": 1231, 349 | "GERMANY30": 1232, 350 | "HONGKONG50": 1233, 351 | "SPAIN35": 1234, 352 | "US30": 1235, 353 | "USNDAQ100": 1236, 354 | "JAPAN225": 1237, 355 | "USSPX500": 1239, 356 | "UK100": 1241, 357 | "TRXUSD-L": 1242, 358 | "EOSUSD-L": 1244, 359 | "BNBUSD-L": 1279, 360 | "ACB": 1288, 361 | "CGC": 1289, 362 | "CRON": 1290, 363 | "GWPH": 1291, 364 | "MJ": 1292, 365 | "TLRY": 1293, 366 | "BUD": 1294, 367 | "LYFT": 1313, 368 | "PINS": 1315, 369 | "ZM": 1316, 370 | "UBER": 1334, 371 | "MELI": 1335, 372 | "BYND": 1336, 373 | "BSVUSD-L": 1338, 374 | "ONTUSD-L": 1339, 375 | "ATOMUSD-L": 1340, 376 | "WORK": 1343, 377 | "FDJP": 1350, 378 | "CAN": 1351, 379 | "VIAC": 1352, 380 | "TFC": 1353, 381 | "USDXOF-OTC": 1379, 382 | "USDZAR-OTC": 1380, 383 | "USDSGD-OTC": 1381, 384 | "USDHKD-OTC": 1382, 385 | "USDINR-OTC": 1383, 386 | "DOGEUSD-L": 1406, 387 | } 388 | -------------------------------------------------------------------------------- /iqoptionapi/ws/client.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | import json 4 | import logging 5 | import websocket 6 | import iqoptionapi.constants as OP_code 7 | import iqoptionapi.global_value as global_value 8 | from threading import Thread 9 | from iqoptionapi.ws.received.technical_indicators import technical_indicators 10 | from iqoptionapi.ws.received.time_sync import time_sync 11 | from iqoptionapi.ws.received.heartbeat import heartbeat 12 | from iqoptionapi.ws.received.balances import balances 13 | from iqoptionapi.ws.received.profile import profile 14 | from iqoptionapi.ws.received.balance_changed import balance_changed 15 | from iqoptionapi.ws.received.candles import candles 16 | from iqoptionapi.ws.received.buy_complete import buy_complete 17 | from iqoptionapi.ws.received.option import option 18 | from iqoptionapi.ws.received.position_history import position_history 19 | from iqoptionapi.ws.received.list_info_data import list_info_data 20 | from iqoptionapi.ws.received.candle_generated import candle_generated_realtime 21 | from iqoptionapi.ws.received.candle_generated_v2 import candle_generated_v2 22 | from iqoptionapi.ws.received.commission_changed import commission_changed 23 | from iqoptionapi.ws.received.socket_option_opened import socket_option_opened 24 | from iqoptionapi.ws.received.api_option_init_all_result import api_option_init_all_result 25 | from iqoptionapi.ws.received.initialization_data import initialization_data 26 | from iqoptionapi.ws.received.underlying_list import underlying_list 27 | from iqoptionapi.ws.received.instruments import instruments 28 | from iqoptionapi.ws.received.financial_information import financial_information 29 | from iqoptionapi.ws.received.position_changed import position_changed 30 | from iqoptionapi.ws.received.option_opened import option_opened 31 | from iqoptionapi.ws.received.option_closed import option_closed 32 | from iqoptionapi.ws.received.top_assets_updated import top_assets_updated 33 | from iqoptionapi.ws.received.strike_list import strike_list 34 | from iqoptionapi.ws.received.api_game_betinfo_result import api_game_betinfo_result 35 | from iqoptionapi.ws.received.traders_mood_changed import traders_mood_changed 36 | from iqoptionapi.ws.received.order import order 37 | from iqoptionapi.ws.received.position import position 38 | from iqoptionapi.ws.received.positions import positions 39 | from iqoptionapi.ws.received.order_placed_temp import order_placed_temp 40 | from iqoptionapi.ws.received.deferred_orders import deferred_orders 41 | from iqoptionapi.ws.received.history_positions import history_positions 42 | from iqoptionapi.ws.received.available_leverages import available_leverages 43 | from iqoptionapi.ws.received.order_canceled import order_canceled 44 | from iqoptionapi.ws.received.position_closed import position_closed 45 | from iqoptionapi.ws.received.overnight_fee import overnight_fee 46 | from iqoptionapi.ws.received.api_game_getoptions_result import api_game_getoptions_result 47 | from iqoptionapi.ws.received.sold_options import sold_options 48 | from iqoptionapi.ws.received.tpsl_changed import tpsl_changed 49 | from iqoptionapi.ws.received.auto_margin_call_changed import auto_margin_call_changed 50 | from iqoptionapi.ws.received.digital_option_placed import digital_option_placed 51 | from iqoptionapi.ws.received.result import result 52 | from iqoptionapi.ws.received.instrument_quotes_generated import instrument_quotes_generated 53 | from iqoptionapi.ws.received.training_balance_reset import training_balance_reset 54 | from iqoptionapi.ws.received.socket_option_closed import socket_option_closed 55 | from iqoptionapi.ws.received.live_deal_binary_option_placed import live_deal_binary_option_placed 56 | from iqoptionapi.ws.received.live_deal_digital_option import live_deal_digital_option 57 | from iqoptionapi.ws.received.leaderboard_deals_client import leaderboard_deals_client 58 | from iqoptionapi.ws.received.live_deal import live_deal 59 | from iqoptionapi.ws.received.user_profile_client import user_profile_client 60 | from iqoptionapi.ws.received.leaderboard_userinfo_deals_client import leaderboard_userinfo_deals_client 61 | from iqoptionapi.ws.received.client_price_generated import client_price_generated 62 | from iqoptionapi.ws.received.users_availability import users_availability 63 | 64 | 65 | class WebsocketClient(object): 66 | """Class for work with IQ option websocket.""" 67 | 68 | def __init__(self, api): 69 | """ 70 | :param api: The instance of :class:`IQOptionAPI 71 | `. 72 | """ 73 | self.api = api 74 | self.wss = websocket.WebSocketApp( 75 | self.api.wss_url, on_message=self.on_message, 76 | on_error=self.on_error, on_close=self.on_close, 77 | on_open=self.on_open) 78 | 79 | def dict_queue_add(self, dict, maxdict, key1, key2, key3, value): 80 | if key3 in dict[key1][key2]: 81 | dict[key1][key2][key3] = value 82 | else: 83 | while True: 84 | try: 85 | dic_size = len(dict[key1][key2]) 86 | except: 87 | dic_size = 0 88 | if dic_size < maxdict: 89 | dict[key1][key2][key3] = value 90 | break 91 | else: 92 | # del mini key 93 | del dict[key1][key2][sorted( 94 | dict[key1][key2].keys(), reverse=False)[0]] 95 | 96 | def api_dict_clean(self, obj): 97 | if len(obj) > 5000: 98 | for k in obj.keys(): 99 | del obj[k] 100 | break 101 | 102 | def on_message(self, message): # pylint: disable=unused-argument 103 | """Method to process websocket messages.""" 104 | global_value.ssl_Mutual_exclusion = True 105 | logger = logging.getLogger(__name__) 106 | logger.debug(message) 107 | 108 | message = json.loads(str(message)) 109 | 110 | 111 | technical_indicators(self.api, message, self.api_dict_clean) 112 | time_sync(self.api, message) 113 | heartbeat(self.api, message) 114 | balances(self.api, message) 115 | profile(self.api, message) 116 | balance_changed(self.api, message) 117 | candles(self.api, message) 118 | buy_complete(self.api, message) 119 | option(self.api, message) 120 | position_history(self.api, message) 121 | list_info_data(self.api, message) 122 | candle_generated_realtime(self.api, message, self.dict_queue_add) 123 | candle_generated_v2(self.api, message, self.dict_queue_add) 124 | commission_changed(self.api, message) 125 | socket_option_opened(self.api, message) 126 | api_option_init_all_result(self.api, message) 127 | initialization_data(self.api, message) 128 | underlying_list(self.api, message) 129 | instruments(self.api, message) 130 | financial_information(self.api, message) 131 | position_changed(self.api, message) 132 | option_opened(self.api, message) 133 | option_closed(self.api, message) 134 | top_assets_updated(self.api, message) 135 | strike_list(self.api, message) 136 | api_game_betinfo_result(self.api, message) 137 | traders_mood_changed(self.api, message) 138 | # ------for forex&cfd&crypto.. 139 | order_placed_temp(self.api, message) 140 | order(self.api, message) 141 | position(self.api, message) 142 | positions(self.api, message) 143 | order_placed_temp(self.api, message) 144 | deferred_orders(self.api, message) 145 | history_positions(self.api, message) 146 | available_leverages(self.api, message) 147 | order_canceled(self.api, message) 148 | position_closed(self.api, message) 149 | overnight_fee(self.api, message) 150 | api_game_getoptions_result(self.api, message) 151 | sold_options(self.api, message) 152 | tpsl_changed(self.api, message) 153 | auto_margin_call_changed(self.api, message) 154 | digital_option_placed(self.api, message, self.api_dict_clean) 155 | result(self.api, message) 156 | instrument_quotes_generated(self.api, message) 157 | training_balance_reset(self.api, message) 158 | socket_option_closed(self.api, message) 159 | live_deal_binary_option_placed(self.api, message) 160 | live_deal_digital_option(self.api, message) 161 | leaderboard_deals_client(self.api, message) 162 | live_deal(self.api, message) 163 | user_profile_client(self.api, message) 164 | leaderboard_userinfo_deals_client(self.api, message) 165 | users_availability(self.api, message) 166 | client_price_generated(self.api, message) 167 | 168 | global_value.ssl_Mutual_exclusion = False 169 | 170 | @staticmethod 171 | def on_error(wss, error): # pylint: disable=unused-argument 172 | """Method to process websocket errors.""" 173 | logger = logging.getLogger(__name__) 174 | logger.error(error) 175 | global_value.websocket_error_reason = str(error) 176 | global_value.check_websocket_if_error = True 177 | 178 | @staticmethod 179 | def on_open(wss): # pylint: disable=unused-argument 180 | """Method to process websocket open.""" 181 | logger = logging.getLogger(__name__) 182 | logger.debug("Websocket client connected.") 183 | global_value.check_websocket_if_connect = 1 184 | 185 | @staticmethod 186 | def on_close(wss): # pylint: disable=unused-argument 187 | """Method to process websocket close.""" 188 | logger = logging.getLogger(__name__) 189 | logger.debug("Websocket connection closed.") 190 | global_value.check_websocket_if_connect = 0 191 | -------------------------------------------------------------------------------- /iqoptionapi/api.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API.""" 2 | 3 | import time 4 | import json 5 | import logging 6 | import threading 7 | import requests 8 | import ssl 9 | import atexit 10 | from collections import deque 11 | from iqoptionapi.http.login import Login 12 | from iqoptionapi.http.loginv2 import Loginv2 13 | from iqoptionapi.http.logout import Logout 14 | from iqoptionapi.http.login2fa import Login2FA 15 | from iqoptionapi.http.send_sms import SMS_Sender 16 | from iqoptionapi.http.verify import Verify 17 | from iqoptionapi.http.getprofile import Getprofile 18 | from iqoptionapi.http.auth import Auth 19 | from iqoptionapi.http.token import Token 20 | from iqoptionapi.http.appinit import Appinit 21 | from iqoptionapi.http.billing import Billing 22 | from iqoptionapi.http.buyback import Buyback 23 | from iqoptionapi.http.changebalance import Changebalance 24 | from iqoptionapi.http.events import Events 25 | from iqoptionapi.ws.client import WebsocketClient 26 | from iqoptionapi.ws.chanels.get_balances import * 27 | 28 | from iqoptionapi.ws.chanels.ssid import Ssid 29 | from iqoptionapi.ws.chanels.subscribe import * 30 | from iqoptionapi.ws.chanels.unsubscribe import * 31 | from iqoptionapi.ws.chanels.setactives import SetActives 32 | from iqoptionapi.ws.chanels.candles import GetCandles 33 | from iqoptionapi.ws.chanels.buyv2 import Buyv2 34 | from iqoptionapi.ws.chanels.buyv3 import * 35 | from iqoptionapi.ws.chanels.user import * 36 | from iqoptionapi.ws.chanels.api_game_betinfo import Game_betinfo 37 | from iqoptionapi.ws.chanels.instruments import Get_instruments 38 | from iqoptionapi.ws.chanels.get_financial_information import GetFinancialInformation 39 | from iqoptionapi.ws.chanels.strike_list import Strike_list 40 | from iqoptionapi.ws.chanels.leaderboard import Leader_Board 41 | 42 | from iqoptionapi.ws.chanels.traders_mood import Traders_mood_subscribe 43 | from iqoptionapi.ws.chanels.traders_mood import Traders_mood_unsubscribe 44 | from iqoptionapi.ws.chanels.technical_indicators import Technical_indicators 45 | from iqoptionapi.ws.chanels.buy_place_order_temp import Buy_place_order_temp 46 | from iqoptionapi.ws.chanels.get_order import Get_order 47 | from iqoptionapi.ws.chanels.get_deferred_orders import GetDeferredOrders 48 | from iqoptionapi.ws.chanels.get_positions import * 49 | 50 | from iqoptionapi.ws.chanels.get_available_leverages import Get_available_leverages 51 | from iqoptionapi.ws.chanels.cancel_order import Cancel_order 52 | from iqoptionapi.ws.chanels.close_position import Close_position 53 | from iqoptionapi.ws.chanels.get_overnight_fee import Get_overnight_fee 54 | from iqoptionapi.ws.chanels.heartbeat import Heartbeat 55 | 56 | 57 | from iqoptionapi.ws.chanels.digital_option import * 58 | from iqoptionapi.ws.chanels.api_game_getoptions import * 59 | from iqoptionapi.ws.chanels.sell_option import Sell_Option 60 | from iqoptionapi.ws.chanels.sell_digital_option import Sell_Digital_Option 61 | from iqoptionapi.ws.chanels.change_tpsl import Change_Tpsl 62 | from iqoptionapi.ws.chanels.change_auto_margin_call import ChangeAutoMarginCall 63 | 64 | from iqoptionapi.ws.objects.timesync import TimeSync 65 | from iqoptionapi.ws.objects.profile import Profile 66 | from iqoptionapi.ws.objects.candles import Candles 67 | from iqoptionapi.ws.objects.listinfodata import ListInfoData 68 | from iqoptionapi.ws.objects.betinfo import Game_betinfo_data 69 | import iqoptionapi.global_value as global_value 70 | from collections import defaultdict 71 | 72 | 73 | def nested_dict(n, type): 74 | if n == 1: 75 | return defaultdict(type) 76 | else: 77 | return defaultdict(lambda: nested_dict(n - 1, type)) 78 | 79 | 80 | # InsecureRequestWarning: Unverified HTTPS request is being made. 81 | # Adding certificate verification is strongly advised. 82 | # See: https://urllib3.readthedocs.org/en/latest/security.html 83 | requests.packages.urllib3.disable_warnings() # pylint: disable=no-member 84 | 85 | 86 | class IQOptionAPI(object): # pylint: disable=too-many-instance-attributes 87 | """Class for communication with IQ Option API.""" 88 | 89 | # pylint: disable=too-many-public-methods 90 | socket_option_opened = {} 91 | socket_option_closed = {} 92 | timesync = TimeSync() 93 | profile = Profile() 94 | candles = Candles() 95 | listinfodata = ListInfoData() 96 | api_option_init_all_result = [] 97 | api_option_init_all_result_v2 = [] 98 | # for digital 99 | underlying_list_data = None 100 | position_changed = None 101 | instrument_quites_generated_data = nested_dict(2, dict) 102 | instrument_quotes_generated_raw_data = nested_dict(2, dict) 103 | instrument_quites_generated_timestamp = nested_dict(2, dict) 104 | strike_list = None 105 | leaderboard_deals_client = None 106 | #position_changed_data = nested_dict(2, dict) 107 | # microserviceName_binary_options_name_option=nested_dict(2,dict) 108 | order_async = nested_dict(2, dict) 109 | order_binary = {} 110 | game_betinfo = Game_betinfo_data() 111 | instruments = None 112 | financial_information = None 113 | buy_id = None 114 | buy_order_id = None 115 | traders_mood = {} # get hight(put) % 116 | technical_indicators = {} 117 | order_data = None 118 | positions = None 119 | position = None 120 | deferred_orders = None 121 | position_history = None 122 | position_history_v2 = None 123 | available_leverages = None 124 | order_canceled = None 125 | close_position_data = None 126 | overnight_fee = None 127 | # ---for real time 128 | digital_option_placed_id = {} 129 | live_deal_data = nested_dict(3, deque) 130 | 131 | subscribe_commission_changed_data = nested_dict(2, dict) 132 | real_time_candles = nested_dict(3, dict) 133 | real_time_candles_maxdict_table = nested_dict(2, dict) 134 | candle_generated_check = nested_dict(2, dict) 135 | candle_generated_all_size_check = nested_dict(1, dict) 136 | # ---for api_game_getoptions_result 137 | api_game_getoptions_result = None 138 | sold_options_respond = None 139 | sold_digital_options_respond = None 140 | tpsl_changed_respond = None 141 | auto_margin_call_changed_respond = None 142 | top_assets_updated_data = {} 143 | get_options_v2_data = None 144 | # --for binary option multi buy 145 | buy_multi_result = None 146 | buy_multi_option = {} 147 | # 148 | result = None 149 | training_balance_reset_request = None 150 | balances_raw = None 151 | user_profile_client = None 152 | leaderboard_userinfo_deals_client = None 153 | users_availability = None 154 | # ------------------ 155 | digital_payout = None 156 | 157 | def __init__(self, host, username, password, proxies=None): 158 | """ 159 | :param str host: The hostname or ip address of a IQ Option server. 160 | :param str username: The username of a IQ Option server. 161 | :param str password: The password of a IQ Option server. 162 | :param dict proxies: (optional) The http request proxies. 163 | """ 164 | self.https_url = "https://{host}/api".format(host=host) 165 | self.wss_url = "wss://{host}/echo/websocket".format(host=host) 166 | self.websocket_client = None 167 | self.session = requests.Session() 168 | self.session.verify = False 169 | self.session.trust_env = False 170 | self.username = username 171 | self.password = password 172 | self.token_login2fa = None 173 | self.token_sms = None 174 | self.proxies = proxies 175 | # is used to determine if a buyOrder was set or failed. If 176 | # it is None, there had been no buy order yet or just send. 177 | # If it is false, the last failed 178 | # If it is true, the last buy order was successful 179 | self.buy_successful = None 180 | self.__active_account_type = None 181 | 182 | def prepare_http_url(self, resource): 183 | """Construct http url from resource url. 184 | 185 | :param resource: The instance of 186 | :class:`Resource `. 187 | 188 | :returns: The full url to IQ Option http resource. 189 | """ 190 | return "/".join((self.https_url, resource.url)) 191 | 192 | def send_http_request(self, resource, method, data=None, params=None, headers=None): # pylint: disable=too-many-arguments 193 | """Send http request to IQ Option server. 194 | 195 | :param resource: The instance of 196 | :class:`Resource `. 197 | :param str method: The http request method. 198 | :param dict data: (optional) The http request data. 199 | :param dict params: (optional) The http request params. 200 | :param dict headers: (optional) The http request headers. 201 | 202 | :returns: The instance of :class:`Response `. 203 | """ 204 | logger = logging.getLogger(__name__) 205 | url = self.prepare_http_url(resource) 206 | 207 | logger.debug(url) 208 | 209 | response = self.session.request(method=method, 210 | url=url, 211 | data=data, 212 | params=params, 213 | headers=headers, 214 | proxies=self.proxies) 215 | logger.debug(response) 216 | logger.debug(response.text) 217 | logger.debug(response.headers) 218 | logger.debug(response.cookies) 219 | 220 | response.raise_for_status() 221 | return response 222 | 223 | def send_http_request_v2(self, url, method, data=None, params=None, headers=None): # pylint: disable=too-many-arguments 224 | """Send http request to IQ Option server. 225 | 226 | :param resource: The instance of 227 | :class:`Resource `. 228 | :param str method: The http request method. 229 | :param dict data: (optional) The http request data. 230 | :param dict params: (optional) The http request params. 231 | :param dict headers: (optional) The http request headers. 232 | 233 | :returns: The instance of :class:`Response `. 234 | """ 235 | logger = logging.getLogger(__name__) 236 | 237 | logger.debug(method + ": " + url + " headers: " + str(self.session.headers) + 238 | " cookies: " + str(self.session.cookies.get_dict())) 239 | 240 | response = self.session.request(method=method, 241 | url=url, 242 | data=data, 243 | params=params, 244 | headers=headers, 245 | proxies=self.proxies) 246 | logger.debug(response) 247 | logger.debug(response.text) 248 | logger.debug(response.headers) 249 | logger.debug(response.cookies) 250 | 251 | # response.raise_for_status() 252 | return response 253 | 254 | @property 255 | def websocket(self): 256 | """Property to get websocket. 257 | 258 | :returns: The instance of :class:`WebSocket `. 259 | """ 260 | return self.websocket_client.wss 261 | 262 | def send_websocket_request(self, name, msg, request_id="", no_force_send=True): 263 | """Send websocket request to IQ Option server. 264 | 265 | :param str name: The websocket request name. 266 | :param dict msg: The websocket request msg. 267 | """ 268 | 269 | logger = logging.getLogger(__name__) 270 | 271 | data = json.dumps(dict(name=name, 272 | msg=msg, request_id=request_id)) 273 | 274 | while (global_value.ssl_Mutual_exclusion or global_value.ssl_Mutual_exclusion_write) and no_force_send: 275 | pass 276 | global_value.ssl_Mutual_exclusion_write = True 277 | self.websocket.send(data) 278 | logger.debug(data) 279 | global_value.ssl_Mutual_exclusion_write = False 280 | 281 | @property 282 | def logout(self): 283 | """Property for get IQ Option http login resource. 284 | 285 | :returns: The instance of :class:`Login 286 | `. 287 | """ 288 | return Logout(self) 289 | 290 | @property 291 | def login(self): 292 | """Property for get IQ Option http login resource. 293 | 294 | :returns: The instance of :class:`Login 295 | `. 296 | """ 297 | return Login(self) 298 | 299 | @property 300 | def login_2fa(self): 301 | """Property for get IQ Option http login 2FA resource. 302 | 303 | :returns: The instance of :class:`Login2FA 304 | `. 305 | """ 306 | return Login2FA(self) 307 | 308 | @property 309 | def send_sms_code(self): 310 | """Property for get IQ Option http send sms code resource. 311 | 312 | :returns: The instance of :class:`SMS_Sender 313 | `. 314 | """ 315 | return SMS_Sender(self) 316 | 317 | @property 318 | def verify_2fa(self): 319 | """Property for get IQ Option http verify 2fa resource. 320 | 321 | :returns: The instance of :class:`Verify 322 | `. 323 | """ 324 | return Verify(self) 325 | 326 | @property 327 | def loginv2(self): 328 | """Property for get IQ Option http loginv2 resource. 329 | 330 | :returns: The instance of :class:`Loginv2 331 | `. 332 | """ 333 | return Loginv2(self) 334 | 335 | @property 336 | def auth(self): 337 | """Property for get IQ Option http auth resource. 338 | 339 | :returns: The instance of :class:`Auth 340 | `. 341 | """ 342 | return Auth(self) 343 | 344 | @property 345 | def appinit(self): 346 | """Property for get IQ Option http appinit resource. 347 | 348 | :returns: The instance of :class:`Appinit 349 | `. 350 | """ 351 | return Appinit(self) 352 | 353 | @property 354 | def token(self): 355 | """Property for get IQ Option http token resource. 356 | 357 | :returns: The instance of :class:`Token 358 | `. 359 | """ 360 | return Token(self) 361 | 362 | # @property 363 | # def profile(self): 364 | # """Property for get IQ Option http profile resource. 365 | 366 | # :returns: The instance of :class:`Profile 367 | # `. 368 | # """ 369 | # return Profile(self) 370 | def reset_training_balance(self): 371 | # sendResults True/False 372 | # {"name":"sendMessage","request_id":"142","msg":{"name":"reset-training-balance","version":"2.0"}} 373 | 374 | self.send_websocket_request(name="sendMessage", msg={"name": "reset-training-balance", 375 | "version": "2.0"}) 376 | 377 | @property 378 | def changebalance(self): 379 | """Property for get IQ Option http changebalance resource. 380 | 381 | :returns: The instance of :class:`Changebalance 382 | `. 383 | """ 384 | return Changebalance(self) 385 | 386 | @property 387 | def events(self): 388 | return Events(self) 389 | 390 | @property 391 | def billing(self): 392 | """Property for get IQ Option http billing resource. 393 | 394 | :returns: The instance of :class:`Billing 395 | `. 396 | """ 397 | return Billing(self) 398 | 399 | @property 400 | def buyback(self): 401 | """Property for get IQ Option http buyback resource. 402 | 403 | :returns: The instance of :class:`Buyback 404 | `. 405 | """ 406 | return Buyback(self) 407 | # ------------------------------------------------------------------------ 408 | 409 | @property 410 | def getprofile(self): 411 | """Property for get IQ Option http getprofile resource. 412 | 413 | :returns: The instance of :class:`Login 414 | `. 415 | """ 416 | return Getprofile(self) 417 | # for active code ... 418 | 419 | @property 420 | def get_balances(self): 421 | """Property for get IQ Option http getprofile resource. 422 | 423 | :returns: The instance of :class:`Login 424 | `. 425 | """ 426 | return Get_Balances(self) 427 | 428 | @property 429 | def get_instruments(self): 430 | return Get_instruments(self) 431 | 432 | @property 433 | def get_financial_information(self): 434 | return GetFinancialInformation(self) 435 | # ---------------------------------------------------------------------------- 436 | 437 | @property 438 | def ssid(self): 439 | """Property for get IQ Option websocket ssid chanel. 440 | 441 | :returns: The instance of :class:`Ssid 442 | `. 443 | """ 444 | return Ssid(self) 445 | # -------------------------------------------------------------------------------- 446 | 447 | @property 448 | def Subscribe_Live_Deal(self): 449 | return Subscribe_live_deal(self) 450 | 451 | @property 452 | def Unscribe_Live_Deal(self): 453 | return Unscribe_live_deal(self) 454 | # -------------------------------------------------------------------------------- 455 | # trader mood 456 | 457 | @property 458 | def subscribe_Traders_mood(self): 459 | return Traders_mood_subscribe(self) 460 | 461 | @property 462 | def unsubscribe_Traders_mood(self): 463 | return Traders_mood_unsubscribe(self) 464 | 465 | # -------------------------------------------------------------------------------- 466 | # tecnical indicators 467 | 468 | @property 469 | def get_Technical_indicators(self): 470 | return Technical_indicators(self) 471 | 472 | # -------------------------------------------------------------------------------- 473 | # --------------------------subscribe&unsubscribe--------------------------------- 474 | # -------------------------------------------------------------------------------- 475 | @property 476 | def subscribe(self): 477 | "candle-generated" 478 | """Property for get IQ Option websocket subscribe chanel. 479 | 480 | :returns: The instance of :class:`Subscribe 481 | `. 482 | """ 483 | return Subscribe(self) 484 | 485 | @property 486 | def subscribe_all_size(self): 487 | return Subscribe_candles(self) 488 | 489 | @property 490 | def unsubscribe(self): 491 | """Property for get IQ Option websocket unsubscribe chanel. 492 | 493 | :returns: The instance of :class:`Unsubscribe 494 | `. 495 | """ 496 | return Unsubscribe(self) 497 | 498 | @property 499 | def unsubscribe_all_size(self): 500 | return Unsubscribe_candles(self) 501 | 502 | def portfolio(self, Main_Name, name, instrument_type, user_balance_id="", limit=1, offset=0, request_id=""): 503 | # Main name:"unsubscribeMessage"/"subscribeMessage"/"sendMessage"(only for portfolio.get-positions") 504 | # name:"portfolio.order-changed"/"portfolio.get-positions"/"portfolio.position-changed" 505 | # instrument_type="cfd"/"forex"/"crypto"/"digital-option"/"turbo-option"/"binary-option" 506 | logger = logging.getLogger(__name__) 507 | M_name = Main_Name 508 | request_id = str(request_id) 509 | if name == "portfolio.order-changed": 510 | msg = {"name": name, 511 | "version": "1.0", 512 | "params": { 513 | "routingFilters": {"instrument_type": str(instrument_type)} 514 | } 515 | } 516 | 517 | elif name == "portfolio.get-positions": 518 | msg = {"name": name, 519 | "version": "3.0", 520 | "body": { 521 | "instrument_type": str(instrument_type), 522 | "limit": int(limit), 523 | "offset": int(offset) 524 | } 525 | } 526 | 527 | elif name == "portfolio.position-changed": 528 | msg = {"name": name, 529 | "version": "2.0", 530 | "params": { 531 | "routingFilters": {"instrument_type": str(instrument_type), 532 | "user_balance_id": user_balance_id 533 | 534 | } 535 | } 536 | } 537 | 538 | self.send_websocket_request( 539 | name=M_name, msg=msg, request_id=request_id) 540 | 541 | def set_user_settings(self, balanceId, request_id=""): 542 | # Main name:"unsubscribeMessage"/"subscribeMessage"/"sendMessage"(only for portfolio.get-positions") 543 | # name:"portfolio.order-changed"/"portfolio.get-positions"/"portfolio.position-changed" 544 | # instrument_type="cfd"/"forex"/"crypto"/"digital-option"/"turbo-option"/"binary-option" 545 | 546 | msg = {"name": "set-user-settings", 547 | "version": "1.0", 548 | "body": { 549 | "name": "traderoom_gl_common", 550 | "version": 3, 551 | "config": { 552 | "balanceId": balanceId 553 | 554 | } 555 | 556 | } 557 | } 558 | self.send_websocket_request( 559 | name="sendMessage", msg=msg, request_id=str(request_id)) 560 | 561 | def subscribe_position_changed(self, name, instrument_type, request_id): 562 | # instrument_type="multi-option","crypto","forex","cfd" 563 | # name="position-changed","trading-fx-option.position-changed",digital-options.position-changed 564 | msg = {"name": name, 565 | "version": "1.0", 566 | "params": { 567 | "routingFilters": {"instrument_type": str(instrument_type)} 568 | 569 | } 570 | } 571 | self.send_websocket_request( 572 | name="subscribeMessage", msg=msg, request_id=str(request_id)) 573 | 574 | def setOptions(self, request_id, sendResults): 575 | # sendResults True/False 576 | 577 | msg = {"sendResults": sendResults} 578 | 579 | self.send_websocket_request( 580 | name="setOptions", msg=msg, request_id=str(request_id)) 581 | 582 | @property 583 | def Subscribe_Top_Assets_Updated(self): 584 | return Subscribe_top_assets_updated(self) 585 | 586 | @property 587 | def Unsubscribe_Top_Assets_Updated(self): 588 | return Unsubscribe_top_assets_updated(self) 589 | 590 | @property 591 | def Subscribe_Commission_Changed(self): 592 | return Subscribe_commission_changed(self) 593 | 594 | @property 595 | def Unsubscribe_Commission_Changed(self): 596 | return Unsubscribe_commission_changed(self) 597 | 598 | # -------------------------------------------------------------------------------- 599 | # ----------------------------------------------------------------------------------- 600 | 601 | @property 602 | def setactives(self): 603 | """Property for get IQ Option websocket setactives chanel. 604 | 605 | :returns: The instance of :class:`SetActives 606 | `. 607 | """ 608 | return SetActives(self) 609 | 610 | @property 611 | def Get_Leader_Board(self): 612 | return Leader_Board(self) 613 | 614 | @property 615 | def getcandles(self): 616 | """Property for get IQ Option websocket candles chanel. 617 | 618 | :returns: The instance of :class:`GetCandles 619 | `. 620 | """ 621 | return GetCandles(self) 622 | 623 | def get_api_option_init_all(self): 624 | self.send_websocket_request(name="api_option_init_all", msg="") 625 | 626 | def get_api_option_init_all_v2(self): 627 | 628 | msg = {"name": "get-initialization-data", 629 | "version": "3.0", 630 | "body": {} 631 | } 632 | self.send_websocket_request(name="sendMessage", msg=msg) 633 | # -------------get information------------- 634 | 635 | @property 636 | def get_betinfo(self): 637 | return Game_betinfo(self) 638 | 639 | @property 640 | def get_options(self): 641 | return Get_options(self) 642 | 643 | @property 644 | def get_options_v2(self): 645 | return Get_options_v2(self) 646 | 647 | # ____________for_______binary_______option_____________ 648 | 649 | @property 650 | def buyv3(self): 651 | return Buyv3(self) 652 | 653 | @property 654 | def buyv3_by_raw_expired(self): 655 | return Buyv3_by_raw_expired(self) 656 | 657 | @property 658 | def buy(self): 659 | """Property for get IQ Option websocket buyv2 request. 660 | 661 | :returns: The instance of :class:`Buyv2 662 | `. 663 | """ 664 | self.buy_successful = None 665 | return Buyv2(self) 666 | 667 | @property 668 | def sell_option(self): 669 | return Sell_Option(self) 670 | 671 | @property 672 | def sell_digital_option(self): 673 | return Sell_Digital_Option(self) 674 | # ____________________for_______digital____________________ 675 | 676 | def get_digital_underlying(self): 677 | msg = {"name": "get-underlying-list", 678 | "version": "2.0", 679 | "body": {"type": "digital-option"} 680 | } 681 | self.send_websocket_request(name="sendMessage", msg=msg) 682 | 683 | @property 684 | def get_strike_list(self): 685 | return Strike_list(self) 686 | 687 | @property 688 | def subscribe_instrument_quites_generated(self): 689 | return Subscribe_Instrument_Quites_Generated(self) 690 | 691 | @property 692 | def unsubscribe_instrument_quites_generated(self): 693 | return Unsubscribe_Instrument_Quites_Generated(self) 694 | 695 | @property 696 | def place_digital_option(self): 697 | return Digital_options_place_digital_option(self) 698 | 699 | @property 700 | def close_digital_option(self): 701 | return Digital_options_close_position(self) 702 | 703 | # ____BUY_for__Forex__&&__stock(cfd)__&&__ctrpto_____ 704 | @property 705 | def buy_order(self): 706 | return Buy_place_order_temp(self) 707 | 708 | @property 709 | def change_order(self): 710 | return Change_Tpsl(self) 711 | 712 | @property 713 | def change_auto_margin_call(self): 714 | return ChangeAutoMarginCall(self) 715 | 716 | @property 717 | def get_order(self): 718 | return Get_order(self) 719 | 720 | @property 721 | def get_pending(self): 722 | return GetDeferredOrders(self) 723 | 724 | @property 725 | def get_positions(self): 726 | return Get_positions(self) 727 | 728 | @property 729 | def get_position(self): 730 | return Get_position(self) 731 | 732 | @property 733 | def get_digital_position(self): 734 | return Get_digital_position(self) 735 | 736 | @property 737 | def get_position_history(self): 738 | return Get_position_history(self) 739 | 740 | @property 741 | def get_position_history_v2(self): 742 | return Get_position_history_v2(self) 743 | 744 | @property 745 | def get_available_leverages(self): 746 | return Get_available_leverages(self) 747 | 748 | @property 749 | def cancel_order(self): 750 | return Cancel_order(self) 751 | 752 | @property 753 | def close_position(self): 754 | return Close_position(self) 755 | 756 | @property 757 | def get_overnight_fee(self): 758 | return Get_overnight_fee(self) 759 | # ------------------------------------------------------- 760 | 761 | @property 762 | def heartbeat(self): 763 | return Heartbeat(self) 764 | # ------------------------------------------------------- 765 | 766 | def set_session(self, cookies, headers): 767 | """Method to set session cookies.""" 768 | 769 | self.session.headers.update(headers) 770 | 771 | self.session.cookies.clear_session_cookies() 772 | requests.utils.add_dict_to_cookiejar(self.session.cookies, cookies) 773 | 774 | def start_websocket(self): 775 | global_value.check_websocket_if_connect = None 776 | global_value.check_websocket_if_error = False 777 | global_value.websocket_error_reason = None 778 | 779 | self.websocket_client = WebsocketClient(self) 780 | 781 | self.websocket_thread = threading.Thread(target=self.websocket.run_forever, kwargs={'sslopt': { 782 | "check_hostname": False, "cert_reqs": ssl.CERT_NONE, "ca_certs": "cacert.pem"}}) # for fix pyinstall error: cafile, capath and cadata cannot be all omitted 783 | self.websocket_thread.daemon = True 784 | self.websocket_thread.start() 785 | while True: 786 | try: 787 | if global_value.check_websocket_if_error: 788 | return False, global_value.websocket_error_reason 789 | if global_value.check_websocket_if_connect == 0: 790 | return False, "Websocket connection closed." 791 | elif global_value.check_websocket_if_connect == 1: 792 | return True, None 793 | except: 794 | pass 795 | 796 | pass 797 | 798 | # @tokensms.setter 799 | def setTokenSMS(self, response): 800 | token_sms = response.json()['token'] 801 | self.token_sms = token_sms 802 | 803 | # @token2fa.setter 804 | def setToken2FA(self, response): 805 | token_2fa = response.json()['token'] 806 | self.token_login2fa = token_2fa 807 | 808 | def get_ssid(self): 809 | response = None 810 | try: 811 | if self.token_login2fa is None: 812 | response = self.login( 813 | self.username, self.password) # pylint: disable=not-callable 814 | else: 815 | response = self.login_2fa( 816 | self.username, self.password, self.token_login2fa) 817 | except Exception as e: 818 | logger = logging.getLogger(__name__) 819 | logger.error(e) 820 | return e 821 | return response 822 | 823 | def send_ssid(self): 824 | self.profile.msg = None 825 | self.ssid(global_value.SSID) # pylint: disable=not-callable 826 | while self.profile.msg == None: 827 | pass 828 | if self.profile.msg == False: 829 | return False 830 | else: 831 | return True 832 | 833 | def connect(self): 834 | 835 | global_value.ssl_Mutual_exclusion = False 836 | global_value.ssl_Mutual_exclusion_write = False 837 | """Method for connection to IQ Option API.""" 838 | try: 839 | self.close() 840 | except: 841 | pass 842 | check_websocket, websocket_reason = self.start_websocket() 843 | 844 | if check_websocket == False: 845 | return check_websocket, websocket_reason 846 | 847 | # doing temp ssid reconnect for speed up 848 | if global_value.SSID != None: 849 | 850 | check_ssid = self.send_ssid() 851 | 852 | if check_ssid == False: 853 | # ssdi time out need reget,if sent error ssid,the weksocket will close by iqoption server 854 | response = self.get_ssid() 855 | try: 856 | global_value.SSID = response.cookies["ssid"] 857 | except: 858 | return False, response.text 859 | atexit.register(self.logout) 860 | self.start_websocket() 861 | self.send_ssid() 862 | 863 | # the ssid is None need get ssid 864 | else: 865 | response = self.get_ssid() 866 | try: 867 | global_value.SSID = response.cookies["ssid"] 868 | except: 869 | self.close() 870 | return False, response.text 871 | atexit.register(self.logout) 872 | self.send_ssid() 873 | 874 | # set ssis cookie 875 | requests.utils.add_dict_to_cookiejar( 876 | self.session.cookies, {"ssid": global_value.SSID}) 877 | 878 | self.timesync.server_timestamp = None 879 | while True: 880 | try: 881 | if self.timesync.server_timestamp != None: 882 | break 883 | except: 884 | pass 885 | return True, None 886 | 887 | def connect2fa(self, sms_code): 888 | response = self.verify_2fa(sms_code, self.token_sms) 889 | 890 | if response.json()['code'] != 'success': 891 | return False, response.json()['message'] 892 | 893 | # token_2fa 894 | self.setToken2FA(response) 895 | if self.token_login2fa is None: 896 | return False, None 897 | return True, None 898 | 899 | def close(self): 900 | self.websocket.close() 901 | self.websocket_thread.join() 902 | 903 | def websocket_alive(self): 904 | return self.websocket_thread.is_alive() 905 | 906 | @property 907 | def Get_User_Profile_Client(self): 908 | return Get_user_profile_client(self) 909 | 910 | @property 911 | def Request_Leaderboard_Userinfo_Deals_Client(self): 912 | return Request_leaderboard_userinfo_deals_client(self) 913 | 914 | @property 915 | def Get_Users_Availability(self): 916 | return Get_users_availability(self) 917 | 918 | @property 919 | def subscribe_digital_price_splitter(self): 920 | return SubscribeDigitalPriceSplitter(self) 921 | 922 | @property 923 | def unsubscribe_digital_price_splitter(self): 924 | return UnsubscribeDigitalPriceSplitter(self) 925 | 926 | @property 927 | def place_digital_option_v2(self): 928 | return DigitalOptionsPlaceDigitalOptionV2(self) 929 | --------------------------------------------------------------------------------