├── .flake8 ├── .github ├── FUNDING.yml └── workflows │ └── python-publish.yml ├── .gitignore ├── .travis.yml ├── ACTIVE_CODE.txt ├── LICENSE.txt ├── README.md ├── coverage.xml ├── deploy.sh ├── docs ├── account │ └── account.md ├── all │ ├── all.md │ └── image │ │ └── top_assets_updated.png ├── binary option │ ├── binary option.md │ └── expiration_time.png ├── candle │ ├── candle.md │ └── image │ │ └── time_interval.png ├── digital │ ├── digital.md │ └── image │ │ ├── near.png │ │ ├── profit_after_sale.png │ │ └── spot.png ├── fef │ ├── fef.md │ ├── image │ │ ├── cancel_order.png │ │ ├── change_ID_Name_order_id.png │ │ ├── change_ID_Name_position_id.png │ │ ├── close_position.png │ │ ├── get_pending.png │ │ ├── get_position.png │ │ ├── get_position_history.png │ │ └── get_positions.png │ └── instrument.txt ├── image │ └── icon │ │ ├── brain.png │ │ ├── iq.ico │ │ └── mars.png ├── index.md └── javascripts │ ├── .Rhistory │ └── extra.js ├── ejtraderIQ ├── __init__.py ├── api.py ├── constants.py ├── country_id.py ├── easyapi.py ├── expiration.py ├── global_value.py ├── http │ ├── __init__.py │ ├── appinit.py │ ├── auth.py │ ├── billing.py │ ├── buyback.py │ ├── changebalance.py │ ├── events.py │ ├── getprofile.py │ ├── getregdata.py │ ├── login.py │ ├── loginv2.py │ ├── logout.py │ ├── profile.py │ ├── register.py │ ├── resource.py │ └── token.py ├── stable_api.py └── ws │ ├── __init__.py │ ├── chanels │ ├── __init__.py │ ├── api_game_betinfo.py │ ├── api_game_getoptions.py │ ├── base.py │ ├── buy_place_order_temp.py │ ├── buyback.py │ ├── buyv2.py │ ├── buyv3.py │ ├── cancel_order.py │ ├── candles.py │ ├── change_auto_margin_call.py │ ├── change_tpsl.py │ ├── changebalance.py │ ├── close_position.py │ ├── digital_option.py │ ├── get_available_leverages.py │ ├── get_balances.py │ ├── get_deferred_orders.py │ ├── get_financial_information.py │ ├── get_order.py │ ├── get_overnight_fee.py │ ├── get_positions.py │ ├── heartbeat.py │ ├── instruments.py │ ├── leaderboard.py │ ├── sell_option.py │ ├── setactives.py │ ├── ssid.py │ ├── strike_list.py │ ├── subscribe.py │ ├── traders_mood.py │ ├── unsubscribe.py │ └── user.py │ ├── client.py │ └── objects │ ├── __init__.py │ ├── base.py │ ├── betinfo.py │ ├── candles.py │ ├── listinfodata.py │ ├── profile.py │ └── timesync.py ├── examples └── mhi-martingaleBot.py ├── image ├── 83521925_616885489131244_2922459279078195200_n.jpg ├── asset_close.png ├── cancel_order.png ├── change_ID_Name_order_id.png ├── change_ID_Name_position_id.png ├── close_position.png ├── expiration_time.png ├── get_pending.png ├── get_position.png ├── get_position_history.png ├── get_positions.png ├── profit_after_sale.png └── time_interval.png ├── instrument.txt ├── old_document.md ├── pylint.rc ├── pylintrc ├── pylintrcconda ├── requirements.txt ├── setup.py ├── test.ipynb └── tests ├── __init__.py ├── iq.py ├── test_Binary_Option.py ├── test_Candle.py └── test_Login.py /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 100 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: paypal.me/ejtraderIQ 13 | -------------------------------------------------------------------------------- /.github/workflows/python-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will upload a Python Package using Twine when a release is created 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Upload Python Package 10 | 11 | on: 12 | release: 13 | types: [published] 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | deploy: 20 | 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | - name: Set up Python 26 | uses: actions/setup-python@v3 27 | with: 28 | python-version: '3.x' 29 | - name: Install dependencies 30 | run: | 31 | python -m pip install --upgrade pip 32 | pip install build 33 | - name: Build package 34 | run: python -m build 35 | - name: Publish package 36 | uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 37 | with: 38 | user: __token__ 39 | password: ${{ secrets.PYPI_API_TOKEN }} 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | build/ 3 | dist/ 4 | *.egg-info/ 5 | .vscode/ 6 | test.py 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | language: 4 | - python 5 | python: 6 | - '2.7' 7 | - '3.7' 8 | install: 9 | - pip install -r requirements.txt 10 | - pip install codecov 11 | - pip install pytest-cov 12 | script: 13 | - pytest --cov=./ --cov-report=xml tests/ 14 | after_success: 15 | - codecov --file coverage.xml --token $CODECOV_TOKEN 16 | 17 | 18 | -------------------------------------------------------------------------------- /ACTIVE_CODE.txt: -------------------------------------------------------------------------------- 1 | 2018/5/7 2 | EURUSD 1 3 | EURGBP 2 4 | GBPJPY 3 5 | EURJPY 4 6 | GBPUSD 5 7 | USDJPY 6 8 | AUDCAD 7 9 | NZDUSD 8 10 | USDRUB 10 11 | AMAZON 31 12 | APPLE 32 13 | BAIDU 33 14 | CISCO 34 15 | FACEBOOK 35 16 | GOOGLE 36 17 | INTEL 37 18 | MSFT 38 19 | YAHOO 40 20 | AIG 41 21 | CITI 45 22 | COKE 46 23 | GE 48 24 | GM 49 25 | GS 50 26 | JPM 51 27 | MCDON 52 28 | MORSTAN 53 29 | NIKE 54 30 | USDCHF 72 31 | XAUUSD 74 32 | EURUSD-OTC 76 33 | EURGBP-OTC 77 34 | USDCHF-OTC 78 35 | NZDUSD-OTC 80 36 | GBPUSD-OTC 81 37 | AUDCAD-OTC 86 38 | ALIBABA 87 39 | YANDEX 95 40 | AUDUSD 99 41 | USDCAD 100 42 | AUDJPY 101 43 | GBPCAD 102 44 | GBPCHF 103 45 | GBPAUD 104 46 | EURCAD 105 47 | CHFJPY 106 48 | CADCHF 107 49 | EURAUD 108 50 | TWITTER 113 51 | FERRARI 133 52 | TESLA 167 53 | USDNOK 168 54 | EURNZD 212 55 | USDSEK 219 56 | USDTRY 220 57 | MMM:US 252 58 | ABT:US 253 59 | ABBV:US 254 60 | ACN:US 255 61 | ATVI:US 256 62 | ADBE:US 258 63 | AAP:US 259 64 | AA:US 269 65 | MO:US 278 66 | AMGN:US 290 67 | T:US 303 68 | BAC:US 313 69 | BBY:US 320 70 | BA:US 324 71 | BMY:US 328 72 | CAT:US 338 73 | CVX:US 349 74 | CL:US 365 75 | CMCSA:US 366 76 | COP:US 370 77 | COST:US 374 78 | CVS:US 379 79 | DHR:US 381 80 | DAL:US 386 81 | EBAY:US 407 82 | XOM:US 429 83 | FDX:US 434 84 | GILD:US 460 85 | HAS:US 471 86 | HON:US 480 87 | IBM:US 491 88 | KHC:US 513 89 | LMT:US 528 90 | MA:US 542 91 | MDT:US 548 92 | MU:US 553 93 | NFLX:US 569 94 | NEE:US 575 95 | NVDA:US 586 96 | PYPL:US 597 97 | PFE:US 603 98 | PM:US 605 99 | PG:US 617 100 | QCOM:US 626 101 | RTN:US 630 102 | CRM:US 645 103 | SLB:US 647 104 | SBUX:US 666 105 | SYK:US 670 106 | TWX:US 692 107 | VZ:US 723 108 | V:US 726 109 | WMT:US 729 110 | WBA:US 730 111 | WFC:US 733 112 | SNAP 756 113 | DUBAI 757 114 | TA25 758 115 | AMD 760 116 | ALGN 761 117 | ANSS 762 118 | DRE 772 119 | IDXX 775 120 | RMD 781 121 | SU 783 122 | TFX 784 123 | TMUS 785 124 | QQQ 796 125 | SPY 808 126 | BTCUSD 816 127 | XRPUSD 817 128 | ETHUSD 818 129 | LTCUSD 819 130 | DSHUSD 821 131 | BCHUSD 824 132 | OMGUSD 825 133 | ZECUSD 826 134 | ETCUSD 829 135 | BTGUSD 837 136 | QTMUSD 845 137 | TRXUSD 858 138 | EOSUSD 864 139 | USDINR 865 140 | USDPLN 866 141 | USDBRL 867 142 | USDZAR 868 143 | DBX 889 144 | SPOT 891 145 | USDSGD 892 146 | USDHKD 893 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Pypi Publish](https://github.com/ejtraderLabs/ejtraderIQ/actions/workflows/python-publish.yml/badge.svg) 2 | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/ejtraderLabs/ejtraderIQ) 3 | [![License](https://img.shields.io/github/license/ejtraderLabs/ejtraderIQ)](https://github.com/ejtraderLabs/ejtraderIQ/blob/main/LICENSE.txt) 4 | # IQoption API 5 | 6 | ### ToDo 7 | 8 | - [x] Account Balance 9 | - [x] trade buy and sell "Digital & Turbo" 10 | - [x] Check Win 11 | - [x] check open Markets 12 | - [x] remaning time 13 | - [x] real time quote 14 | - [x] ohlc dataframe history 15 | - [x] payout 16 | - [x] get server time 17 | - [x] get powerbar - market depth 18 | 19 | MHI Martingale Bot Example 20 | 21 | You can find the bot under the examples directory in our repository here. 22 | 23 | 24 | ## Installation 25 | #### Tested on python 3.7 to 3.9 26 | ``` 27 | pip install ejtraderIQ -U 28 | ``` 29 | #### Or install from source 30 | 31 | ``` 32 | git clone https://github.com/ejtraderLabs/ejtraderIQ 33 | cd ejtraderIQ 34 | python setup.py install 35 | 36 | ``` 37 | 38 | ### Import librarys 39 | 40 | ```python 41 | from ejtraderIQ import IQOption 42 | 43 | ``` 44 | 45 | ### Login to IQ Options 46 | 47 | ```python 48 | # account type DEMO OR REAL 49 | api = IQOption('email','passowrd','DEMO') 50 | 51 | symbol = "EURUSD" 52 | timeframe= "M1" 53 | ``` 54 | ### Real time quote 55 | 56 | ##### Subscribe quote stream 57 | ```python 58 | api.subscribe(symbol,timeframe) 59 | ``` 60 | ##### symbols quote 61 | ```python 62 | quote = api.quote() 63 | print(quote) 64 | 65 | # Output 66 | 67 | open high low close volume 68 | date 69 | 2022-08-22 22:39:00 0.994245 0.994415 0.994215 0.994365 120 70 | ``` 71 | ##### Unsubscribe quote stream 72 | ```python 73 | api.unsubscribe(symbol,timeframe) 74 | 75 | # Output 76 | "Unsubscribed from EURUSD" 77 | ``` 78 | 79 | #### Symbols History Dataframe 80 | ```python 81 | candles = 1000 # max history 1000 periods 82 | 83 | history = api.history(symbol,timeframe,candles) 84 | print(quote) 85 | 86 | # Output 87 | open high low close volume 88 | date 89 | 2022-08-17 12:20:00 1.016235 1.016565 1.015925 1.016005 1225 90 | 2022-08-17 12:25:00 1.016015 1.016265 1.015585 1.016195 947 91 | 2022-08-17 12:30:00 1.016015 1.016905 1.014535 1.014635 3280 92 | 2022-08-17 12:35:00 1.014635 1.015415 1.014605 1.015315 1646 93 | 2022-08-17 12:40:00 1.015305 1.016015 1.015305 1.015985 1685 94 | ... ... ... ... ... ... 95 | 2022-08-22 23:15:00 0.993955 0.994035 0.993435 0.993475 779 96 | 2022-08-22 23:20:00 0.993475 0.993635 0.993365 0.993405 547 97 | 2022-08-22 23:25:00 0.993405 0.993585 0.993335 0.993455 577 98 | 2022-08-22 23:30:00 0.993475 0.993495 0.993305 0.993435 519 99 | 2022-08-22 23:35:00 0.993415 0.993655 0.993375 0.993635 527 100 | 101 | [1000 rows x 5 columns] 102 | ``` 103 | 104 | 105 | 106 | ##### Trade Position 107 | 108 | ```python 109 | volume = 1 # position size $1 110 | 111 | 112 | # Buy Digital 113 | api.buy(volume,symbol,timeframe) 114 | 115 | # Buy turbo 116 | api.buy(volume,symbol,timeframe,turbo=True) 117 | 118 | # Sell Digital 119 | api.sell(volume,symbol,timeframe) 120 | 121 | # Sell turbo 122 | api.sell(volume,symbol,timeframe,turbo=True) 123 | 124 | ``` 125 | 126 | 127 | 128 | #### Trade & Account Fuctions 129 | 130 | ##### check Payout 131 | ```python 132 | 133 | payout = api.payout(symbol) 134 | print(("Payout: {:.2f}%".format(payout))) 135 | ``` 136 | ##### Check balance 137 | ```python 138 | balance = api.balance() 139 | print(f'Balance : {balance}') 140 | ``` 141 | 142 | ##### Remaning tim to trade 143 | ```python 144 | expire = api.remaning(timeframe) 145 | print(f'Remaning : {expire}') 146 | ``` 147 | ##### Market depth 148 | ```python 149 | # start streaming 150 | api.powerbar_start(symbol) 151 | 152 | # get live data SELL side % 153 | api.powerbar_get(symbol) 154 | 155 | # get all history from the time start streaming 156 | api.powerbar_get_all() 157 | 158 | # stop streaming 159 | api.powerbar_stop(symbol) 160 | ``` 161 | 162 | ##### Server time 163 | ```python 164 | 165 | st = api.server_time() 166 | 167 | st.year 168 | st.day 169 | st.hour 170 | st.minute 171 | st.second 172 | 173 | 174 | ``` 175 | 176 | ##### Check Win 177 | ```python 178 | api.checkwin(id) 179 | 180 | # example check win Digital 181 | id = api.buy(volume,symbol,timeframe) 182 | win = api.checkwin(id) 183 | 184 | if win > 0: 185 | print(("WIN"+'\n')) 186 | elif win < 0: 187 | print(("LOSS"+'\n')) 188 | else: 189 | print(('Tied '+'\n')) 190 | 191 | 192 | # example check win Turbo 193 | id = api.buy(volume,symbol,timeframe,turbo=True) 194 | win = api.checkwin(id,turbo=True) 195 | 196 | if win > 0: 197 | print(("WIN"+'\n')) 198 | elif win < 0: 199 | print(("LOSS"+'\n')) 200 | else: 201 | print(('Tied '+'\n')) 202 | ``` 203 | 204 | ##### Check markets state 205 | ```python 206 | markets = api.isOpen() 207 | print(markets) 208 | 209 | # Output 210 | 211 | Asset Type Status 212 | 0 USDZAR-OTC binary close 213 | 1 EURUSD binary close 214 | 2 GBPJPY-OTC binary close 215 | 3 BTCUSD binary close 216 | 4 USDCHF binary close 217 | .. ... ... ... 218 | 371 BNBUSD-L crypto open 219 | 372 VETUSD-L crypto open 220 | 373 ETCUSD crypto open 221 | 374 DOGEUSD-L crypto open 222 | 375 ETCUSD-L crypto open 223 | 224 | [376 rows x 3 columns] 225 | 226 | ``` 227 | 228 | 229 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf dist/* 4 | python setup.py sdist bdist_wheel 5 | twine upload dist/* -------------------------------------------------------------------------------- /docs/account/account.md: -------------------------------------------------------------------------------- 1 | # Account 2 | 3 | ## get_balance() 4 | ```python 5 | api.get_balance() 6 | ``` 7 | 8 | ## get_balance_v2() 9 | 10 | more accuracy 11 | 12 | ```python 13 | api.get_balance_v2() 14 | ``` 15 | 16 | ## get_currency() 17 | 18 | you will check what currency you use 19 | 20 | ```python 21 | api.get_currency() 22 | ``` 23 | 24 | ## reset_practice_balance() 25 | 26 | reset practice balance to $10000 27 | 28 | ```python 29 | from ejtraderIQ.stable_api import IQ_Option 30 | api=IQ_Option("email","password") 31 | api.connect()#connect to iqoption 32 | print(api.reset_practice_balance()) 33 | ``` 34 | 35 | ## Change real/practice Account 36 | 37 | MODE="PRACTICE"/"REAL" 38 | ```python 39 | api.change_balance(MODE) 40 | #MODE: "PRACTICE"/"REAL" 41 | ``` 42 | 43 | ## get Other People stratagy 44 | 45 | 46 | ### sample 47 | ```python 48 | from ejtraderIQ.stable_api import IQ_Option 49 | import logging 50 | import time 51 | 52 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 53 | api=IQ_Option("email","password") 54 | api.connect()#connect to iqoption 55 | while_run_time=10 56 | 57 | #For digital option 58 | 59 | name="live-deal-digital-option" #"live-deal-binary-option-placed"/"live-deal-digital-option" 60 | active="EURUSD" 61 | _type="PT1M"#"PT1M"/"PT5M"/"PT15M" 62 | buffersize=10# 63 | print("_____________subscribe_live_deal_______________") 64 | api.subscribe_live_deal(name,active,_type,buffersize) 65 | 66 | 67 | start_t=time.time() 68 | while True: 69 | #data size is below buffersize 70 | #data[0] is the last data 71 | data=(api.get_live_deal(name,active,_type)) 72 | print("__For_digital_option__ data size:"+str(len(data))) 73 | print(data) 74 | print("\n\n") 75 | time.sleep(1) 76 | if time.time()-start_t>while_run_time: 77 | break 78 | print("_____________unscribe_live_deal_______________") 79 | api.unscribe_live_deal(name,active,_type) 80 | 81 | 82 | #For binary option 83 | 84 | name="live-deal-binary-option-placed" 85 | active="EURUSD" 86 | _type="turbo"#"turbo"/"binary" 87 | buffersize=10# 88 | print("_____________subscribe_live_deal_______________") 89 | api.subscribe_live_deal(name,active,_type,buffersize) 90 | 91 | start_t=time.time() 92 | while True: 93 | #data size is below buffersize 94 | #data[0] is the last data 95 | data=(api.get_live_deal(name,active,_type)) 96 | print("__For_binary_option__ data size:"+str(len(data))) 97 | print(data) 98 | print("\n\n") 99 | time.sleep(1) 100 | if time.time()-start_t>while_run_time: 101 | break 102 | print("_____________unscribe_live_deal_______________") 103 | api.unscribe_live_deal(name,active,_type) 104 | ``` 105 | 106 | ### subscribe_live_deal 107 | 108 | ```python 109 | api.subscribe_live_deal(name,active,_type,buffersize) 110 | ``` 111 | 112 | ### unscribe_live_deal 113 | 114 | ```python 115 | api.unscribe_live_deal(name,active,_type) 116 | ``` 117 | 118 | ### get_live_deal 119 | 120 | ```python 121 | api.get_live_deal(name,active,_type) 122 | ``` 123 | ### pop_live_deal 124 | 125 | pop the data from list 126 | ```python 127 | api.pop_live_deal(name,active,_type) 128 | ``` 129 | ## get Other people detail 130 | 131 | ### sample 132 | ```python 133 | from ejtraderIQ.stable_api import IQ_Option 134 | import logging 135 | import time 136 | 137 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 138 | api=IQ_Option("email","password") 139 | api.connect()#connect to iqoption 140 | while_run_time=10 141 | 142 | #For binary option 143 | name="live-deal-binary-option-placed" 144 | active="EURUSD" 145 | _type="turbo"#"turbo"/"binary" 146 | buffersize=10# 147 | print("_____________subscribe_live_deal_______________") 148 | print("\n\n") 149 | api.subscribe_live_deal(name,active,_type,buffersize) 150 | 151 | last_trade_data=api.get_live_deal(name,active,_type)[0] 152 | 153 | user_id=last_trade_data["user_id"] 154 | counutry_id=last_trade_data["country_id"] 155 | print("_______get_user_profile_client__________") 156 | print(api.get_user_profile_client(user_id)) 157 | pro_data=api.get_user_profile_client(user_id) 158 | print("\n\n") 159 | 160 | print("___________request_leaderboard_userinfo_deals_client______") 161 | print(api.request_leaderboard_userinfo_deals_client(user_id,counutry_id)) 162 | user_data=api.request_leaderboard_userinfo_deals_client(user_id,counutry_id) 163 | worldwide=user_data["result"]["entries_by_country"]["0"]["position"] 164 | profit=user_data["result"]["entries_by_country"]["0"]["score"] 165 | print("\n") 166 | print("user_name:"+pro_data["user_name"]) 167 | print("This week worldwide:"+str(worldwide)) 168 | print("This week's gross profit:"+str(profit)) 169 | print("\n\n") 170 | 171 | print("___________get_users_availability____________") 172 | print(api.get_users_availability(user_id)) 173 | print("\n\n") 174 | print("_____________unscribe_live_deal_______________") 175 | api.unscribe_live_deal(name,active,_type) 176 | 177 | ``` 178 | 179 | ### get_user_profile_client() 180 | this api can get user name and image 181 | ```python 182 | api.get_user_profile_client(user_id) 183 | ``` 184 | 185 | ### request_leaderboard_userinfo_deals_client() 186 | this api can get user detail 187 | 188 | ```python 189 | api.request_leaderboard_userinfo_deals_client(user_id,counutry_id) 190 | ``` 191 | 192 | ### get_users_availability() 193 | 194 | ```python 195 | api.get_users_availability(user_id) 196 | ``` -------------------------------------------------------------------------------- /docs/all/all.md: -------------------------------------------------------------------------------- 1 | # For all 2 | 3 | this api can work for option&digital&Forex&Stock&Commodities&Crypto&ETFs 4 | 5 | ## Check Asset if open or not 6 | 7 | be careful get_all_open_time() is very heavy for network. 8 | 9 | get_all_open_time() return the DICT 10 | 11 | "cfd" is include Stock,Commodities,ETFs asset 12 | 13 | DICT["forex"/"cfd"/"crypto"/"digital"/"turbo"/"binary"][Asset Name]["open"] 14 | 15 | it will return True/False 16 | 17 | ```python 18 | from ejtraderIQ.stable_api import IQ_Option 19 | import logging 20 | import random 21 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 22 | api=IQ_Option("email","password") 23 | api.connect()#connect to iqoption 24 | ALL_Asset=api.get_all_open_time() 25 | #check if open or not 26 | print(ALL_Asset["forex"]["EURUSD"]["open"]) 27 | print(ALL_Asset["cfd"]["FACEBOOK"]["open"])#Stock,Commodities,ETFs 28 | print(ALL_Asset["crypto"]["BTCUSD-L"]["open"]) 29 | print(ALL_Asset["digital"]["EURUSD-OTC"]["open"]) 30 | 31 | #Binary have two diffenence type:"turbo","binary" 32 | print(ALL_Asset["turbo"]["EURUSD-OTC"]["open"]) 33 | print(ALL_Asset["binary"]["EURUSD-OTC"]["open"]) 34 | 35 | 36 | #!!!! exception "" 37 | print(ALL_Asset["binary"]["not exist asset"]["open"])#it will return "{}" a None of the dict 38 | 39 | #!!!!print all!!!! 40 | for type_name, data in ALL_Asset.items(): 41 | for Asset,value in data.items(): 42 | print(type_name,Asset,value["open"]) 43 | ``` 44 | 45 | ## View all ACTIVES Name 46 | 47 | ``` 48 | print(api.get_all_ACTIVES_OPCODE()) 49 | ``` 50 | ## update ACTIVES OPCODE 51 | ``` 52 | api.update_ACTIVES_OPCODE() 53 | ``` 54 | ## get_async_order() 55 | 56 | ```python 57 | from ejtraderIQ.stable_api import IQ_Option 58 | import logging 59 | import time 60 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 61 | api=IQ_Option("email","password") 62 | api.connect()#connect to iqoption 63 | ACTIVES="EURUSD" 64 | duration=1#minute 1 or 5 65 | amount=1 66 | action="call"#put 67 | 68 | print("__For_Binary_Option__") 69 | _,id=api.buy(amount,ACTIVES,action,duration) 70 | while api.get_async_order(id)==None: 71 | pass 72 | print(api.get_async_order(id)) 73 | print("\n\n") 74 | 75 | print("__For_Digital_Option__spot") 76 | _,id=api.buy_digital_spot(ACTIVES,amount,action,duration) 77 | while api.get_async_order(id)==None: 78 | pass 79 | order_data=api.get_async_order(id) 80 | print(api.get_async_order(id)) 81 | print("\n\n") 82 | 83 | print("__For_Forex_Stock_Commodities_Crypto_ETFs") 84 | instrument_type="crypto" 85 | instrument_id="BTCUSD" 86 | side="buy" 87 | amount=1.23 88 | leverage=3 89 | type="market" 90 | limit_price=None 91 | stop_price=None 92 | stop_lose_kind="percent" 93 | stop_lose_value=95 94 | take_profit_kind=None 95 | take_profit_value=None 96 | use_trail_stop=True 97 | auto_margin_call=False 98 | use_token_for_commission=False 99 | check,id=api.buy_order(instrument_type=instrument_type, instrument_id=instrument_id, 100 | side=side, amount=amount,leverage=leverage, 101 | type=type,limit_price=limit_price, stop_price=stop_price, 102 | stop_lose_value=stop_lose_value, stop_lose_kind=stop_lose_kind, 103 | take_profit_value=take_profit_value, take_profit_kind=take_profit_kind, 104 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call, 105 | use_token_for_commission=use_token_for_commission) 106 | while api.get_async_order(id)==None: 107 | pass 108 | order_data=api.get_async_order(id) 109 | print(api.get_async_order(id)) 110 | ``` 111 | 112 | ## get_commission_change() 113 | 114 | instrument_type: "binary-option"/"turbo-option"/"digital-option"/"crypto"/"forex"/"cfd" 115 | 116 | api.subscribe_commission_changed(instrument_type) api.get_commission_change(instrument_type) api.unsubscribe_commission_changed(instrument_type) 117 | 118 | Sample code 119 | 120 | ```python 121 | import time 122 | from ejtraderIQ.stable_api import IQ_Option 123 | api=IQ_Option("email","password") 124 | api.connect()#connect to iqoption 125 | #instrument_type: "binary-option"/"turbo-option"/"digital-option"/"crypto"/"forex"/"cfd" 126 | instrument_type=["binary-option","turbo-option","digital-option","crypto","forex","cfd"] 127 | for ins in instrument_type: 128 | api.subscribe_commission_changed(ins) 129 | print("Start stream please wait profit change...") 130 | while True: 131 | for ins in instrument_type: 132 | commissio_data=api.get_commission_change(ins) 133 | if commissio_data!={}: 134 | for active_name in commissio_data: 135 | if commissio_data[active_name]!={}: 136 | the_min_timestamp=min(commissio_data[active_name].keys()) 137 | commissio=commissio_data[active_name][the_min_timestamp] 138 | profit=(100-commissio)/100 139 | print("instrument_type: "+str(ins)+" active_name: "+str(active_name)+" profit change to: "+str(profit)) 140 | #Data have been update so need del 141 | del api.get_commission_change(ins)[active_name][the_min_timestamp] 142 | time.sleep(1) 143 | ``` 144 | 145 | 146 | ## Get top_assets_updated 147 | 148 | 149 | ### smaple 150 | 151 | instrument_type="binary-option"/"digital-option"/"forex"/"cfd"/"crypto" 152 | ```python 153 | from ejtraderIQ.stable_api import IQ_Option 154 | import logging 155 | import time 156 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 157 | api=IQ_Option("email","password") 158 | api.connect()#connect to iqoption 159 | instrument_type="digital-option"#"binary-option"/"digital-option"/"forex"/"cfd"/"crypto" 160 | api.subscribe_top_assets_updated(instrument_type) 161 | 162 | print("__Please_wait_for_sec__") 163 | while True: 164 | if api.get_top_assets_updated(instrument_type)!=None: 165 | print(api.get_top_assets_updated(instrument_type)) 166 | print("\n\n") 167 | time.sleep(1) 168 | api.unsubscribe_top_assets_updated(instrument_type) 169 | ``` 170 | ### subscribe_top_assets_updated() 171 | 172 | ```python 173 | instrument_type="digital-option"#"binary-option"/"digital-option"/"forex"/"cfd"/"crypto" 174 | api.subscribe_top_assets_updated(instrument_type) 175 | ``` 176 | 177 | ### get_top_assets_updated() 178 | 179 | need call get_top_assets_updated() after subscribe_top_assets_updated() 180 | ```python 181 | api.get_top_assets_updated(instrument_type) 182 | ``` 183 | 184 | 185 | ### unsubscribe_top_assets_updated() 186 | 187 | if you not using please close stram for safe network 188 | 189 | ```python 190 | api.unsubscribe_top_assets_updated(instrument_type) 191 | ``` 192 | 193 | ### get sort by popularity 194 | 195 | ![](image/top_assets_updated.png) 196 | 197 | 198 | #### sample 199 | ```python 200 | from ejtraderIQ.stable_api import IQ_Option 201 | import logging 202 | import time 203 | import operator 204 | 205 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 206 | def opcode_to_name(opcode_data,opcode): 207 | return list(opcode_data.keys())[list(opcode_data.values()).index(opcode)] 208 | 209 | api=IQ_Option("email","password") 210 | api.connect()#connect to iqoption 211 | api.update_ACTIVES_OPCODE() 212 | opcode_data=api.get_all_ACTIVES_OPCODE() 213 | 214 | instrument_type="digital-option"#"binary-option"/"digital-option"/"forex"/"cfd"/"crypto" 215 | api.subscribe_top_assets_updated(instrument_type) 216 | 217 | 218 | print("__Please_wait_for_sec__") 219 | while True: 220 | if api.get_top_assets_updated(instrument_type)!=None: 221 | break 222 | 223 | top_assets=api.get_top_assets_updated(instrument_type) 224 | popularity={} 225 | for asset in top_assets: 226 | opcode=asset["active_id"] 227 | popularity_value=asset["popularity"]["value"] 228 | try: 229 | name=opcode_to_name(opcode_data,opcode) 230 | popularity[name]=popularity_value 231 | except: 232 | pass 233 | 234 | 235 | sorted_popularity = sorted(popularity.items(), key=operator.itemgetter(1)) 236 | print("__Popularity_min_to_max__") 237 | for lis in sorted_popularity: 238 | print(lis) 239 | 240 | api.unsubscribe_top_assets_updated(instrument_type) 241 | ``` 242 | 243 | ## get_leader_board 244 | 245 | Get leader board data 246 | 247 | ```python 248 | from ejtraderIQ.stable_api import IQ_Option 249 | api=IQ_Option(email,password) 250 | api.connect()#connect to iqoption 251 | 252 | country="TW" 253 | from_position=1 254 | to_position=1 255 | near_traders_count=0 256 | 257 | print(api.get_leader_board(country,from_position,to_position,near_traders_count)) 258 | ``` 259 | 260 | !!! country 261 | ID = {"Worldwide":0, 262 | "AF": 1, 263 | "AL": 2, 264 | "DZ": 3, 265 | "AD": 5, 266 | "AO": 6, 267 | "AI": 7, 268 | "AG": 9, 269 | "AR": 10, 270 | "AM": 11, 271 | "AW": 12, 272 | "AT": 14, 273 | "AZ": 15, 274 | "BS": 16, 275 | "BH": 17, 276 | "BD": 18, 277 | "BB": 19, 278 | "BY": 20, 279 | "BZ": 22, 280 | "BJ": 23, 281 | "BM": 24, 282 | "BO": 26, 283 | "BA": 27, 284 | "BW": 28, 285 | "BV": 29, 286 | "BR": 30, 287 | "BN": 31, 288 | "BG": 32, 289 | "BF": 33, 290 | "BI": 34, 291 | "KH": 35, 292 | "CM": 36, 293 | "CV": 38, 294 | "KY": 39, 295 | "TD": 41, 296 | "CL": 42, 297 | "CN": 43, 298 | "CC": 45, 299 | "CO": 46, 300 | "KM": 47, 301 | "CG": 48, 302 | "CK": 49, 303 | "CR": 50, 304 | "CI": 51, 305 | "HR": 52, 306 | "CU": 53, 307 | "CY": 54, 308 | "CZ": 55, 309 | "DK": 56, 310 | "DJ": 57, 311 | "DM": 58, 312 | "DO": 59, 313 | "TL": 60, 314 | "EC": 61, 315 | "EG": 62, 316 | "SV": 63, 317 | "EE": 66, 318 | "ET": 67, 319 | "FO": 69, 320 | "FJ": 70, 321 | "FI": 71, 322 | "FR": 72, 323 | "GF": 73, 324 | "PF": 74, 325 | "GA": 75, 326 | "GM": 76, 327 | "GE": 77, 328 | "DE": 78, 329 | "GH": 79, 330 | "GR": 81, 331 | "GD": 83, 332 | "GP": 84, 333 | "GT": 86, 334 | "GN": 87, 335 | "GY": 88, 336 | "HT": 89, 337 | "HN": 90, 338 | "HK": 91, 339 | "HU": 92, 340 | "IS": 93, 341 | "ID": 94, 342 | "IQ": 95, 343 | "IE": 96, 344 | "IT": 97, 345 | "JM": 98, 346 | "JO": 100, 347 | "KZ": 101, 348 | "KE": 102, 349 | "KI": 103, 350 | "KW": 104, 351 | "KG": 105, 352 | "LA": 106, 353 | "LV": 107, 354 | "LB": 108, 355 | "LS": 109, 356 | "LR": 110, 357 | "LY": 111, 358 | "LT": 113, 359 | "LU": 114, 360 | "MO": 115, 361 | "MK": 116, 362 | "MG": 117, 363 | "MW": 118, 364 | "MY": 119, 365 | "MV": 120, 366 | "ML": 121, 367 | "MT": 122, 368 | "MQ": 124, 369 | "MR": 125, 370 | "MU": 126, 371 | "MX": 128, 372 | "FM": 129, 373 | "MD": 130, 374 | "MC": 131, 375 | "MN": 132, 376 | "MA": 134, 377 | "MZ": 135, 378 | "MM": 136, 379 | "NA": 137, 380 | "NP": 139, 381 | "NL": 140, 382 | "AN": 141, 383 | "NC": 142, 384 | "NZ": 143, 385 | "NI": 144, 386 | "NE": 145, 387 | "NG": 146, 388 | "NO": 149, 389 | "OM": 150, 390 | "PK": 151, 391 | "PW": 152, 392 | "PA": 153, 393 | "PG": 154, 394 | "PY": 155, 395 | "PE": 156, 396 | "PH": 157, 397 | "PL": 159, 398 | "PT": 160, 399 | "QA": 162, 400 | "RE": 163, 401 | "RO": 164, 402 | "RW": 166, 403 | "KN": 167, 404 | "LC": 168, 405 | "SA": 171, 406 | "SN": 172, 407 | "SC": 173, 408 | "SG": 175, 409 | "SK": 176, 410 | "SI": 177, 411 | "SO": 179, 412 | "ZA": 180, 413 | "KR": 181, 414 | "ES": 182, 415 | "LK": 183, 416 | "SH": 184, 417 | "SR": 186, 418 | "SZ": 187, 419 | "SE": 188, 420 | "CH": 189, 421 | "TW": 191, 422 | "TJ": 192, 423 | "TZ": 193, 424 | "TH": 194, 425 | "TG": 195, 426 | "TT": 198, 427 | "TN": 199, 428 | "TR": 200, 429 | "TM": 201, 430 | "UG": 203, 431 | "UA": 204, 432 | "AE": 205, 433 | "GB": 206, 434 | "UY": 207, 435 | "UZ": 208, 436 | "VE": 211, 437 | "VN": 212, 438 | "VG": 213, 439 | "YE": 216, 440 | "ZM": 218, 441 | "ZW": 219, 442 | "RS": 220, 443 | "ME": 221, 444 | "IN": 225, 445 | "TC": 234, 446 | "CD": 235, 447 | "GG": 236, 448 | "IM": 237, 449 | "JE": 239, 450 | "CW": 246, } 451 | -------------------------------------------------------------------------------- /docs/all/image/top_assets_updated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/all/image/top_assets_updated.png -------------------------------------------------------------------------------- /docs/binary option/binary option.md: -------------------------------------------------------------------------------- 1 | #For Binary Option 2 | 3 | 4 | ## buy 5 | 6 | buy the binary option 7 | 8 | ### buy() 9 | 10 | sample 11 | 12 | ```python 13 | from ejtraderIQ.stable_api import IQ_Option 14 | import logging 15 | import time 16 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 17 | api=IQ_Option("email","pass") 18 | goal="EURUSD" 19 | print("get candles") 20 | print(api.get_candles(goal,60,111,time.time())) 21 | Money=1 22 | ACTIVES="EURUSD" 23 | ACTION="call"#or "put" 24 | expirations_mode=1 25 | 26 | check,id=api.buy(Money,ACTIVES,ACTION,expirations_mode) 27 | if check: 28 | print("!buy!") 29 | else: 30 | print("buy fail") 31 | ``` 32 | 33 | ```python 34 | api.buy(Money,ACTIVES,ACTION,expirations) 35 | #Money:How many you want to buy type(int) 36 | #ACTIVES:sample input "EURUSD" OR "EURGBP".... you can view by get_all_ACTIVES_OPCODE 37 | #ACTION:"call"/"put" type(str) 38 | #expirations:input minute,careful too large will false to buy(Closed market time)thank Darth-Carrotpie's code (int)https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 39 | #return:if sucess return (True,id_number) esle return(Fale,None) 40 | ``` 41 | ### buy_multi() 42 | 43 | ```python 44 | from ejtraderIQ.stable_api import IQ_Option 45 | api=IQ_Option("email","password") 46 | api.connect()#connect to iqoption 47 | Money=[] 48 | ACTIVES=[] 49 | ACTION=[] 50 | expirations_mode=[] 51 | 52 | Money.append(1) 53 | ACTIVES.append("EURUSD") 54 | ACTION.append("call")#put 55 | expirations_mode.append(1) 56 | 57 | Money.append(1) 58 | ACTIVES.append("EURAUD") 59 | ACTION.append("call")#put 60 | expirations_mode.append(1) 61 | 62 | print("buy multi") 63 | id_list=api.buy_multi(Money,ACTIVES,ACTION,expirations_mode) 64 | 65 | print("check win only one id (id_list[0])") 66 | print(api.check_win_v2(id_list[0],2)) 67 | ``` 68 | ### buy_by_raw_expirations() 69 | 70 | buy the binary optoin by expired 71 | 72 | ```python 73 | price=2 74 | active="EURUSD" 75 | direction="call"#put 76 | option="turbo"#binary 77 | expired=1293923# this expried time you need to count or get by your self 78 | api.buy_by_raw_expirations(price, active, direction, option,expired) 79 | ``` 80 | 81 | ## get_remaning() 82 | 83 | purchase time=remaning time - 30 84 | ```python 85 | from ejtraderIQ.stable_api import IQ_Option 86 | api=IQ_Option("email","password") 87 | api.connect()#connect to iqoption 88 | Money=1 89 | ACTIVES="EURUSD" 90 | ACTION="call"#or "put" 91 | expirations_mode=1 92 | while True: 93 | remaning_time=api.get_remaning(expirations_mode) 94 | purchase_time=remaning_time-30 95 | if purchase_time<4:#buy the binary option at purchase_time<4 96 | api.buy(Money,ACTIVES,ACTION,expirations_mode) 97 | break 98 | ``` 99 | 100 | ## sell_option() 101 | 102 | ```python 103 | api.sell_option(sell_all)#input int or list order id 104 | ``` 105 | Sample 106 | 107 | ```python 108 | from ejtraderIQ.stable_api import IQ_Option 109 | import time 110 | print("login...") 111 | api=IQ_Option("email","password") 112 | api.connect()#connect to iqoption 113 | Money=1 114 | ACTIVES="EURUSD" 115 | ACTION="call"#or "put" 116 | expirations_mode=1 117 | 118 | id=api.buy(Money,ACTIVES,ACTION,expirations_mode) 119 | id2=api.buy(Money,ACTIVES,ACTION,expirations_mode) 120 | 121 | time.sleep(5) 122 | sell_all=[] 123 | sell_all.append(id) 124 | sell_all.append(id2) 125 | print(api.sell_option(sell_all)) 126 | ``` 127 | 128 | ## check win 129 | 130 | It will do loop until get win or loose 131 | 132 | ### check_win() 133 | 134 | ```python 135 | from ejtraderIQ.stable_api import IQ_Option 136 | api=IQ_Option("email","password") 137 | api.connect()#connect to iqoption 138 | check,id = api.buy(1, "EURUSD", "call", 1) 139 | print("start check win please wait") 140 | print(api.check_win(id)) 141 | ``` 142 | 143 | ```python 144 | api.check_win(23243221) 145 | #""you need to get id_number from buy function"" 146 | #api.check_win(id_number) 147 | #this function will do loop check your bet until if win/equal/loose 148 | ``` 149 | 150 | ### check_win_v2() 151 | 152 | ```python 153 | from ejtraderIQ.stable_api import IQ_Option 154 | api=IQ_Option("email","password") 155 | api.connect()#connect to iqoption 156 | check,id = api.buy(1, "EURUSD", "call", 1) 157 | print("start check win please wait") 158 | polling_time=3 159 | print(api.check_win_v2(id,polling_time)) 160 | ``` 161 | 162 | ### check_win_v3() 163 | 164 | great way 165 | 166 | ```python 167 | from ejtraderIQ.stable_api import IQ_Option 168 | api=IQ_Option("email","password") 169 | api.connect()#connect to iqoption 170 | check,id = api.buy(1, "EURUSD", "call", 1) 171 | print("start check win please wait") 172 | print(api.check_win_v3(id)) 173 | ``` 174 | 175 | ## get_binary_option_detail() 176 | ![](expiration_time.png) 177 | 178 | sample 179 | ```python 180 | from ejtraderIQ.stable_api import IQ_Option 181 | print("login...") 182 | api=IQ_Option("email","password") 183 | api.connect()#connect to iqoption 184 | d=api.get_binary_option_detail() 185 | print(d["CADCHF"]["turbo"]) 186 | print(d["CADCHF"]["binary"]) 187 | ``` 188 | ## get_all_init() 189 | 190 | get_binary_option_detail is base on this api 191 | 192 | you will get the raw detail about binary option 193 | ``` 194 | api.get_all_init() 195 | ``` 196 | 197 | ## get_all_profit() 198 | 199 | sample 200 | 201 | ```python 202 | from ejtraderIQ.stable_api import IQ_Option 203 | print("login...") 204 | api=IQ_Option("email","password") 205 | api.connect()#connect to iqoption 206 | d=api.get_all_profit() 207 | print(d["CADCHF"]["turbo"]) 208 | print(d["CADCHF"]["binary"]) 209 | ``` 210 | 211 | if you want realtime profit try this 212 | [get real time profit](/all/#get_commission_change) 213 | 214 | ## get_betinfo() 215 | 216 | if order not close yet or wrong id it will return False 217 | ```python 218 | isSuccessful,dict=api.get_betinfo(4452272449) 219 | #api.get_betinfo 220 | #INPUT: order id 221 | #OUTPUT:isSuccessful,dict 222 | ``` 223 | ## get_optioninfo 224 | 225 | ### get_optioninfo() 226 | 227 | input how many data you want to get from Trading History(only for binary option) 228 | ```python 229 | print(api.get_optioninfo(10)) 230 | ``` 231 | 232 | ### get_optioninfo_v2() 233 | 234 | input how many data you want to get from Trading History(only for binary option) 235 | ```python 236 | print(api.get_optioninfo_v2(10)) 237 | ``` 238 | ### get_option_open_by_other_pc() 239 | 240 | if your account is login in other plance/PC and doing buy option 241 | 242 | you can get the option by this function 243 | 244 | ```python 245 | import time 246 | from ejtraderIQ.stable_api import IQ_Option 247 | api=IQ_Option("email","password") 248 | api.connect()#connect to iqoption 249 | while True: 250 | #please open website iqoption and buy some binary option 251 | if api.get_option_open_by_other_pc()!={}: 252 | break 253 | time.sleep(1) 254 | print("Get option from other Pc and same account") 255 | print(api.get_option_open_by_other_pc()) 256 | 257 | id=list(api.get_option_open_by_other_pc().keys())[0] 258 | api.del_option_open_by_other_pc(id) 259 | print("After del by id") 260 | print(api.get_option_open_by_other_pc()) 261 | ``` 262 | 263 | ## Get mood 264 | 265 | ### sample 266 | 267 | ```python 268 | from ejtraderIQ.stable_api import IQ_Option 269 | api=IQ_Option("email","password") 270 | api.connect()#connect to iqoption 271 | goal="EURUSD" 272 | api.start_mood_stream(goal) 273 | print(api.get_traders_mood(goal)) 274 | api.stop_mood_stream(goal) 275 | ``` 276 | 277 | ### start_mood_stream() 278 | 279 | ```python 280 | api.start_mood_stream(goal) 281 | ``` 282 | 283 | ### get_traders_mood() 284 | 285 | call get_traders_mood() after start_mood_stream 286 | 287 | ```python 288 | api.get_traders_mood(goal) 289 | ``` 290 | 291 | ### get_all_traders_mood() 292 | 293 | it will get all trade mood what you start stream 294 | 295 | ```python 296 | api.get_all_traders_mood() 297 | #output:(dict) all mood you start 298 | ``` 299 | 300 | ### stop_mood_stream() 301 | 302 | if you not using the mood ,please stop safe network 303 | 304 | ```python 305 | api.stop_mood_stream(goal) 306 | ``` 307 | 308 | -------------------------------------------------------------------------------- /docs/binary option/expiration_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/binary option/expiration_time.png -------------------------------------------------------------------------------- /docs/candle/candle.md: -------------------------------------------------------------------------------- 1 | # Candle 2 | 3 | ## get candles 4 | 5 | only get close clndle, not realtime 6 | 7 | ``` 8 | api.get_candles(ACTIVES,interval,count,endtime) 9 | #ACTIVES:sample input "EURUSD" OR "EURGBP".... youcan 10 | #interval:duration of candles 11 | #count:how many candles you want to get from now to past 12 | #endtime:get candles from past to "endtime" 13 | ``` 14 | 15 | ### sample 16 | 17 | ```python 18 | from ejtraderIQ.stable_api import IQ_Option 19 | import time 20 | api=IQ_Option("email","password") 21 | api.connect()#connect to iqoption 22 | end_from_time=time.time() 23 | ANS=[] 24 | for i in range(70): 25 | data=api.get_candles("EURUSD", 60, 1000, end_from_time) 26 | ANS =data+ANS 27 | end_from_time=int(data[0]["from"])-1 28 | print(ANS) 29 | ``` 30 | 31 | ## get realtime candles 32 | 33 | ### indicator sample 34 | 35 | ```python 36 | 37 | from talib.abstract import * 38 | from ejtraderIQ.stable_api import IQ_Option 39 | import time 40 | import numpy as np 41 | print("login...") 42 | api=IQ_Option("email","password") 43 | api.connect()#connect to iqoption 44 | goal="EURUSD" 45 | size=10#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"] 46 | timeperiod=10 47 | maxdict=20 48 | print("start stream...") 49 | api.start_candles_stream(goal,size,maxdict) 50 | print("Start EMA Sample") 51 | while True: 52 | candles=api.get_realtime_candles(goal,size) 53 | 54 | inputs = { 55 | 'open': np.array([]), 56 | 'high': np.array([]), 57 | 'low': np.array([]), 58 | 'close': np.array([]), 59 | 'volume': np.array([]) 60 | } 61 | for timestamp in candles: 62 | 63 | inputs["open"]=np.append(inputs["open"],candles[timestamp]["open"] ) 64 | inputs["high"]=np.append(inputs["open"],candles[timestamp]["max"] ) 65 | inputs["low"]=np.append(inputs["open"],candles[timestamp]["min"] ) 66 | inputs["close"]=np.append(inputs["open"],candles[timestamp]["close"] ) 67 | inputs["volume"]=np.append(inputs["open"],candles[timestamp]["volume"] ) 68 | 69 | 70 | print("Show EMA") 71 | print(EMA(inputs, timeperiod=timeperiod)) 72 | print("\n") 73 | time.sleep(1) 74 | api.stop_candles_stream(goal,size) 75 | ``` 76 | 77 | ### Sample 78 | 79 | ```python 80 | from ejtraderIQ.stable_api import IQ_Option 81 | import logging 82 | import time 83 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 84 | print("login...") 85 | api=IQ_Option("email","password") 86 | api.connect()#connect to iqoption 87 | goal="EURUSD" 88 | size="all"#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"] 89 | maxdict=10 90 | print("start stream...") 91 | api.start_candles_stream(goal,size,maxdict) 92 | #DO something 93 | print("Do something...") 94 | time.sleep(10) 95 | 96 | print("print candles") 97 | cc=api.get_realtime_candles(goal,size) 98 | for k in cc: 99 | print(goal,"size",k,cc[k]) 100 | print("stop candle") 101 | api.stop_candles_stream(goal,size) 102 | ``` 103 | 104 | ### size 105 | 106 | ![](image/time_interval.png) 107 | 108 | ### start_candles_stream() 109 | 110 | ```python 111 | goal="EURUSD" 112 | size="all"#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"] 113 | maxdict=10 114 | print("start stream...") 115 | api.start_candles_stream(goal,size,maxdict) 116 | ``` 117 | 118 | ### get_realtime_candles() 119 | 120 | get_realtime_candles() after call start_candles_stream() 121 | 122 | ``` 123 | api.get_realtime_candles(goal,size) 124 | ``` 125 | 126 | ### stop_candles_stream() 127 | 128 | if you not using get_realtime_candles() anymore please close the stream 129 | 130 | ```python 131 | api.stop_candles_stream(goal,size) 132 | ``` -------------------------------------------------------------------------------- /docs/candle/image/time_interval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/candle/image/time_interval.png -------------------------------------------------------------------------------- /docs/digital/digital.md: -------------------------------------------------------------------------------- 1 | # Digital 2 | 3 | 4 | ## Nearest strike mode 5 | ![](image/near.png) 6 | ### sample 7 | 8 | ```python 9 | from ejtraderIQ.stable_api import IQ_Option 10 | import time 11 | import random 12 | api=IQ_Option("email","password") 13 | api.connect()#connect to iqoption 14 | ACTIVES="EURUSD" 15 | duration=1#minute 1 or 5 16 | amount=1 17 | api.subscribe_strike_list(ACTIVES,duration) 18 | #get strike_list 19 | data=api.get_realtime_strike_list(ACTIVES, duration) 20 | print("get strike data") 21 | print(data) 22 | """data 23 | {'1.127100': 24 | { 'call': 25 | { 'profit': None, 26 | 'id': 'doEURUSD201811120649PT1MC11271' 27 | }, 28 | 'put': 29 | { 'profit': 566.6666666666666, 30 | 'id': 'doEURUSD201811120649PT1MP11271' 31 | } 32 | }............ 33 | } 34 | """ 35 | #get price list 36 | price_list=list(data.keys()) 37 | #random choose Strategy 38 | choose_price=price_list[random.randint(0,len(price_list)-1)] 39 | #get instrument_id 40 | instrument_id=data[choose_price]["call"]["id"] 41 | #get profit 42 | profit=data[choose_price]["call"]["profit"] 43 | print("choose you want to buy") 44 | print("price:",choose_price,"side:call","instrument_id:",instrument_id,"profit:",profit) 45 | #put instrument_id to buy 46 | buy_check,id=api.buy_digital(amount,instrument_id) 47 | polling_time=5 48 | if buy_check: 49 | print("wait for check win") 50 | #check win 51 | while True: 52 | check_close,win_money=api.check_win_digital_v2(id,polling_time) 53 | if check_close: 54 | if float(win_money)>0: 55 | win_money=("%.2f" % (win_money)) 56 | print("you win",win_money,"money") 57 | else: 58 | print("you loose") 59 | break 60 | api.unsubscribe_strike_list(ACTIVES,duration) 61 | else: 62 | print("fail to buy,please run again") 63 | ``` 64 | 65 | ### Get all strike list data 66 | 67 | smaple 68 | ```python 69 | from ejtraderIQ.stable_api import IQ_Option 70 | import time 71 | api=IQ_Option("email","password") 72 | api.connect()#connect to iqoption 73 | ACTIVES="EURUSD" 74 | duration=1#minute 1 or 5 75 | api.subscribe_strike_list(ACTIVES,duration) 76 | while True: 77 | data=api.get_realtime_strike_list(ACTIVES, duration) 78 | for price in data: 79 | print("price",price,data[price]) 80 | time.sleep(5) 81 | api.unsubscribe_strike_list(ACTIVES,duration) 82 | ``` 83 | #### subscribe_strike_list() 84 | 85 | ```python 86 | api.subscribe_strike_list(ACTIVES,duration) 87 | ``` 88 | 89 | #### get_realtime_strike_list 90 | 91 | you need call subscribe_strike_list() before get_realtime_strike_list() 92 | ```python 93 | api.get_realtime_strike_list(ACTIVES,duration) 94 | ``` 95 | 96 | #### unsubscribe_strike_list() 97 | ```python 98 | api.unsubscribe_strike_list(ACTIVES,duration) 99 | ``` 100 | ### buy_digital() 101 | 102 | ```python 103 | buy_check,id=api.buy_digital(amount,instrument_id) 104 | #get instrument_id from api.get_realtime_strike_list 105 | ``` 106 | 107 | ## Current price mode 108 | 109 | ![](image/spot.png) 110 | 111 | 112 | 113 | ### buy_digital_spot 114 | buy the digit in current price 115 | 116 | return check and id 117 | 118 | ```python 119 | from ejtraderIQ.stable_api import IQ_Option 120 | 121 | api=IQ_Option("email","password") 122 | api.connect()#connect to iqoption 123 | ACTIVES="EURUSD" 124 | duration=1#minute 1 or 5 125 | amount=1 126 | action="call"#put 127 | print(api.buy_digital_spot(ACTIVES,amount,action,duration)) 128 | ``` 129 | 130 | ### get_digital_spot_profit_after_sale() 131 | 132 | get Profit After Sale(P/L) 133 | 134 | ![](image/profit_after_sale.png) 135 | 136 | sample 137 | 138 | ```python 139 | from ejtraderIQ.stable_api import IQ_Option 140 | api=IQ_Option("email","passord") 141 | ACTIVES="EURUSD" 142 | duration=1#minute 1 or 5 143 | amount=100 144 | action="put"#put 145 | 146 | api.subscribe_strike_list(ACTIVES,duration) 147 | _,id=api.buy_digital_spot(ACTIVES,amount,action,duration) 148 | 149 | while True: 150 | PL=api.get_digital_spot_profit_after_sale(id) 151 | if PL!=None: 152 | print(PL) 153 | ``` 154 | 155 | ### get_digital_current_profit() 156 | 157 | ```python 158 | from ejtraderIQ.stable_api import IQ_Option 159 | import time 160 | import logging 161 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 162 | api=IQ_Option("email","password") 163 | api.connect()#connect to iqoption 164 | ACTIVES="EURUSD" 165 | duration=1#minute 1 or 5 166 | api.subscribe_strike_list(ACTIVES,duration) 167 | while True: 168 | data=api.get_digital_current_profit(ACTIVES, duration) 169 | print(data)#from first print it may be get false,just wait a second you can get the profit 170 | time.sleep(1) 171 | api.unsubscribe_strike_list(ACTIVES,duration) 172 | ``` 173 | 174 | ## check win for digital 175 | 176 | ### check_win_digital() 177 | 178 | this api is implement by get_digital_position() 179 | 180 | this function is polling , so need to set polling time 181 | ```python 182 | api.check_win_digital(id,polling_time)#get the id from api.buy_digital 183 | ``` 184 | ### check_win_digital_v2() 185 | 186 | this api is asynchronous get id data,it only can get id data before you call the buy action. if you restart the program,the asynchronous id data can not get again,so check_win_digital_v2 may not working,so you need to use "check_win_digital"! 187 | 188 | ```python 189 | api.check_win_digital_v2(id)#get the id from api.buy_digital 190 | #return:check_close,win_money 191 | #return sample 192 | #if you loose:Ture,o 193 | #if you win:True,1232.3 194 | #if trade not clode yet:False,None 195 | ``` 196 | 197 | sample code 198 | 199 | ```python 200 | from ejtraderIQ.stable_api import IQ_Option 201 | import logging 202 | import random 203 | import time 204 | import datetime 205 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 206 | api=IQ_Option("email","password") 207 | api.connect()#connect to iqoption 208 | ACTIVES="EURUSD" 209 | duration=1#minute 1 or 5 210 | amount=1 211 | action="call"#put 212 | _,id=(api.buy_digital_spot(ACTIVES,amount,action,duration)) 213 | print(id) 214 | if id !="error": 215 | while True: 216 | check,win=api.check_win_digital_v2(id) 217 | if check==True: 218 | break 219 | if win<0: 220 | print("you loss "+str(win)+"$") 221 | else: 222 | print("you win "+str(win)+"$") 223 | else: 224 | print("please try again") 225 | ``` 226 | 227 | ## close_digital_option() 228 | 229 | ```python 230 | api.close_digital_option(id) 231 | ``` 232 | 233 | ## get digital data 234 | 235 | smaple1 236 | ```python 237 | from ejtraderIQ.stable_api import IQ_Option 238 | import logging 239 | import time 240 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 241 | api=IQ_Option("email","password") 242 | api.connect()#connect to iqoption 243 | ACTIVES="EURUSD-OTC" 244 | duration=1#minute 1 or 5 245 | amount=1 246 | action="call"#put 247 | from datetime import datetime 248 | 249 | _,id=api.buy_digital_spot(ACTIVES,amount,action,duration) 250 | 251 | while True: 252 | check,_=api.check_win_digital(id) 253 | if check: 254 | break 255 | print(api.get_digital_position(id)) 256 | print(api.check_win_digital(id)) 257 | ``` 258 | 259 | sample2 260 | 261 | ```python 262 | print(api.get_positions("digital-option")) 263 | print(api.get_digital_position(2323433))#in put the id 264 | print(api.get_position_history("digital-option")) 265 | ``` -------------------------------------------------------------------------------- /docs/digital/image/near.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/digital/image/near.png -------------------------------------------------------------------------------- /docs/digital/image/profit_after_sale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/digital/image/profit_after_sale.png -------------------------------------------------------------------------------- /docs/digital/image/spot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/digital/image/spot.png -------------------------------------------------------------------------------- /docs/fef/fef.md: -------------------------------------------------------------------------------- 1 | # Forex&Stock&Commodities&Crypto&ETFs 2 | 3 | ## instrument_type and instrument_id 4 | you can search instrument_type and instrument_id from this file 5 | 6 | search [instrument_type and instrument_id](instrument.txt) 7 | 8 | ## sample 9 | 10 | ```python 11 | from ejtraderIQ.stable_api import IQ_Option 12 | api=IQ_Option("email","password") 13 | api.connect()#connect to iqoption 14 | instrument_type="crypto" 15 | instrument_id="BTCUSD" 16 | side="buy"#input:"buy"/"sell" 17 | amount=1.23#input how many Amount you want to play 18 | 19 | #"leverage"="Multiplier" 20 | leverage=3#you can get more information in get_available_leverages() 21 | 22 | type="market"#input:"market"/"limit"/"stop" 23 | 24 | #for type="limit"/"stop" 25 | 26 | # only working by set type="limit" 27 | limit_price=None#input:None/value(float/int) 28 | 29 | # only working by set type="stop" 30 | stop_price=None#input:None/value(float/int) 31 | 32 | #"percent"=Profit Percentage 33 | #"price"=Asset Price 34 | #"diff"=Profit in Money 35 | 36 | stop_lose_kind="percent"#input:None/"price"/"diff"/"percent" 37 | stop_lose_value=95#input:None/value(float/int) 38 | 39 | take_profit_kind=None#input:None/"price"/"diff"/"percent" 40 | take_profit_value=None#input:None/value(float/int) 41 | 42 | #"use_trail_stop"="Trailing Stop" 43 | use_trail_stop=True#True/False 44 | 45 | #"auto_margin_call"="Use Balance to Keep Position Open" 46 | auto_margin_call=False#True/False 47 | #if you want "take_profit_kind"& 48 | # "take_profit_value"& 49 | # "stop_lose_kind"& 50 | # "stop_lose_value" all being "Not Set","auto_margin_call" need to set:True 51 | 52 | use_token_for_commission=False#True/False 53 | 54 | check,order_id=api.buy_order(instrument_type=instrument_type, instrument_id=instrument_id, 55 | side=side, amount=amount,leverage=leverage, 56 | type=type,limit_price=limit_price, stop_price=stop_price, 57 | stop_lose_value=stop_lose_value, stop_lose_kind=stop_lose_kind, 58 | take_profit_value=take_profit_value, take_profit_kind=take_profit_kind, 59 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call, 60 | use_token_for_commission=use_token_for_commission) 61 | print(api.get_order(order_id)) 62 | print(api.get_positions("crypto")) 63 | print(api.get_position_history("crypto")) 64 | print(api.get_available_leverages("crypto","BTCUSD")) 65 | print(api.close_position(order_id)) 66 | print(api.get_overnight_fee("crypto","BTCUSD")) 67 | ``` 68 | 69 | ## buy_order() 70 | return (True/False,buy_order_id/False) 71 | 72 | if Buy sucess return (True,buy_order_id) 73 | 74 | "percent"=Profit Percentage 75 | 76 | "price"=Asset Price 77 | 78 | "diff"=Profit in Money 79 | 80 | 81 | |parameter||||| 82 | --|--|--|--|--| 83 | instrument_type|[instrument_type](#instrumenttypeid) 84 | instrument_id| [instrument_id](#instrumenttypeid) 85 | side|"buy"|"sell" 86 | amount|value(float/int) 87 | leverage|value(int) 88 | type|"market"|"limit"|"stop" 89 | limit_price|None|value(float/int):Only working by set type="limit" 90 | stop_price|None|value(float/int):Only working by set type="stop" 91 | stop_lose_kind|None|"price"|"diff"|"percent" 92 | stop_lose_value|None|value(float/int) 93 | take_profit_kind|None|"price"|"diff"|"percent" 94 | take_profit_value|None|value(float/int) 95 | use_trail_stop|True|False 96 | auto_margin_call|True|False 97 | use_token_for_commission|True|False 98 | 99 | ```python 100 | check,order_id=api.buy_order( 101 | instrument_type=instrument_type, instrument_id=instrument_id, 102 | side=side, amount=amount,leverage=leverage, 103 | type=type,limit_price=limit_price, stop_price=stop_price, 104 | stop_lose_kind=stop_lose_kind, 105 | stop_lose_value=stop_lose_value, 106 | take_profit_kind=take_profit_kind, 107 | take_profit_value=take_profit_value, 108 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call, 109 | use_token_for_commission=use_token_for_commission) 110 | 111 | ``` 112 | 113 | ## change_order() 114 | ID_Name=""order_id" | ID_Name="position_id" 115 | :-------------------------:|:-------------------------: 116 | ![](image/change_ID_Name_order_id.png) | ![](image/change_ID_Name_position_id.png) 117 | 118 | 119 | |parameter||||| 120 | --|--|--|--|--| 121 | ID_Name|"position_id"|"order_id" 122 | order_id|"you need to get order_id from buy_order()" 123 | stop_lose_kind|None|"price"|"diff"|"percent" 124 | stop_lose_value|None|value(float/int) 125 | take_profit_kind|None|"price"|"diff"|"percent" 126 | take_profit_value|None|value(float/int) 127 | use_trail_stop|True|False 128 | auto_margin_call|True|False 129 | 130 | ### sample 131 | 132 | ```python 133 | ID_Name="order_id"#"position_id"/"order_id" 134 | stop_lose_kind=None 135 | stop_lose_value=None 136 | take_profit_kind="percent" 137 | take_profit_value=200 138 | use_trail_stop=False 139 | auto_margin_call=True 140 | api.change_order(ID_Name=ID_Name,order_id=order_id, 141 | stop_lose_kind=stop_lose_kind,stop_lose_value=stop_lose_value, 142 | take_profit_kind=take_profit_kind,take_profit_value=take_profit_value, 143 | use_trail_stop=use_trail_stop,auto_margin_call=auto_margin_call) 144 | ``` 145 | 146 | ## get_order() 147 | 148 | get infomation about buy_order_id 149 | 150 | return (True/False,get_order,None) 151 | 152 | ```python 153 | api.get_order(buy_order_id) 154 | ``` 155 | 156 | ## get_pending() 157 | 158 | you will get there data 159 | 160 | ![](image/get_pending.png) 161 | 162 | ```python 163 | api.get_pending(instrument_type) 164 | ``` 165 | 166 | ## get_positions() 167 | 168 | you will get there data 169 | 170 | ![](image/get_positions.png) 171 | 172 | 173 | return (True/False,get_positions,None) 174 | 175 | not support ""turbo-option"" 176 | 177 | instrument_type="crypto","forex","fx-option","multi-option","cfd","digital-option" 178 | 179 | ```python 180 | api.get_positions(instrument_type) 181 | ``` 182 | 183 | ## get_position() 184 | 185 | you will get there data 186 | 187 | 188 | ![](image/get_position.png) 189 | 190 | you will get one position by buy_order_id 191 | 192 | return (True/False,position data,None) 193 | 194 | ```python 195 | api.get_positions(buy_order_id) 196 | ``` 197 | 198 | ## get_position_history 199 | you will get there data 200 | 201 | ![](image/get_position_history.png) 202 | 203 | ### get_position_history() 204 | 205 | return (True/False,position_history,None) 206 | 207 | ``` 208 | api.get_position_history(instrument_type) 209 | ``` 210 | 211 | ### get_position_history_v2 212 | 213 | instrument_type="crypto","forex","fx-option","turbo-option","multi-option","cfd","digital-option" 214 | 215 | get_position_history_v2(instrument_type,limit,offset,start,end) 216 | 217 | ```python 218 | from ejtraderIQ.stable_api import IQ_Option 219 | import logging 220 | import random 221 | import time 222 | import datetime 223 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 224 | api=IQ_Option("email","password") 225 | api.connect()#connect to iqoption 226 | #instrument_type="crypto","forex","fx-option","turbo-option","multi-option","cfd","digital-option" 227 | instrument_type="digital-option" 228 | limit=2#How many you want to get 229 | offset=0#offset from end time,if end time is 0,it mean get the data from now 230 | start=0#start time Timestamp 231 | end=0#Timestamp 232 | data=api.get_position_history_v2(instrument_type,limit,offset,start,end) 233 | 234 | print(data) 235 | 236 | #--------- this will get data start from 2019/7/1(end) to 2019/1/1(start) and only get 2(limit) data and offset is 0 237 | instrument_type="digital-option" 238 | limit=2#How many you want to get 239 | offset=0#offset from end time,if end time is 0,it mean get the data from now 240 | start=int(time.mktime(datetime.datetime.strptime("2019/1/1", "%Y/%m/%d").timetuple())) 241 | end=int(time.mktime(datetime.datetime.strptime("2019/7/1", "%Y/%m/%d").timetuple())) 242 | data=api.get_position_history_v2(instrument_type,limit,offset,start,end) 243 | print(data) 244 | ``` 245 | 246 | ## get_available_leverages() 247 | 248 | get available leverages 249 | 250 | return (True/False,available_leverages,None) 251 | 252 | ```python 253 | api.get_available_leverages(instrument_type,actives) 254 | ``` 255 | 256 | ## cancel_order() 257 | 258 | you will do this 259 | 260 | ![](image/cancel_order.png) 261 | 262 | return (True/False) 263 | 264 | ```python 265 | api.cancel_order(buy_order_id) 266 | ``` 267 | 268 | ## close_position() 269 | 270 | you will do this 271 | 272 | ![](image/close_position.png) 273 | 274 | return (True/False) 275 | 276 | ```python 277 | api.close_position(buy_order_id) 278 | ``` 279 | 280 | ## get_overnight_fee() 281 | 282 | return (True/False,overnight_fee,None) 283 | 284 | ```python 285 | api.get_overnight_fee(instrument_type,active) 286 | ``` -------------------------------------------------------------------------------- /docs/fef/image/cancel_order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/cancel_order.png -------------------------------------------------------------------------------- /docs/fef/image/change_ID_Name_order_id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/change_ID_Name_order_id.png -------------------------------------------------------------------------------- /docs/fef/image/change_ID_Name_position_id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/change_ID_Name_position_id.png -------------------------------------------------------------------------------- /docs/fef/image/close_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/close_position.png -------------------------------------------------------------------------------- /docs/fef/image/get_pending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/get_pending.png -------------------------------------------------------------------------------- /docs/fef/image/get_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/get_position.png -------------------------------------------------------------------------------- /docs/fef/image/get_position_history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/get_position_history.png -------------------------------------------------------------------------------- /docs/fef/image/get_positions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/fef/image/get_positions.png -------------------------------------------------------------------------------- /docs/image/icon/brain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/image/icon/brain.png -------------------------------------------------------------------------------- /docs/image/icon/iq.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/image/icon/iq.ico -------------------------------------------------------------------------------- /docs/image/icon/mars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/image/icon/mars.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Get start 2 | 3 | ## document version 4 | 5 | last update:2020/3/13 6 | 7 | Version:6.8.9 8 | 9 | fix some ssl problem 10 | 11 | Version:6.8.8 12 | 13 | more stable 14 | 15 | fix login and auto logout 16 | 17 | fix check_connect 18 | 19 | Version:6.8.7 20 | 21 | add get_leader_board 22 | 23 | 24 | ## install ejtraderIQ 25 | 26 | download the source code and run this 27 | 28 | ``` 29 | python setup.py install 30 | ``` 31 | ## little sample 32 | 33 | ```python 34 | import time 35 | from ejtraderIQ.stable_api import IQ_Option 36 | api=IQ_Option("email","password") 37 | api.connect()#connect to iqoption 38 | goal="EURUSD" 39 | print("get candles") 40 | print(api.get_candles(goal,60,111,time.time())) 41 | ``` 42 | 43 | ## Import 44 | 45 | ```python 46 | from ejtraderIQ.stable_api import IQ_Option 47 | ``` 48 | ## Login 49 | 50 | api.connect() will return (check,reason) 51 | 52 | if connect sucess return True,None 53 | 54 | if connect fail return False,reason 55 | 56 | ```python 57 | from ejtraderIQ.stable_api import IQ_Option 58 | import logging 59 | 60 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 61 | api=IQ_Option("email","password") 62 | check, reason=api.connect()#connect to iqoption 63 | print(check, reason) 64 | ``` 65 | ## Debug mode on 66 | 67 | ```python 68 | import logging 69 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 70 | ``` 71 | 72 | ## Connect&Check connect 73 | 74 | some time connect will close so this way can check connect and reconnect 75 | 76 | try close your network and restart network in this sample 77 | 78 | ```python 79 | from ejtraderIQ.stable_api import IQ_Option 80 | error_password="""{"code":"invalid_credentials","message":"You entered the wrong credentials. Please check that the login/password is correct."}""" 81 | iqoption = IQ_Option("email", "password") 82 | check,reason=iqoption.connect() 83 | if check: 84 | print("Start your robot") 85 | #if see this you can close network for test 86 | while True: 87 | if iqoption.check_connect()==False:#detect the websocket is close 88 | print("try reconnect") 89 | check,reason=iqoption.connect() 90 | if check: 91 | print("Reconnect successfully") 92 | else: 93 | if reason==error_password: 94 | print("Error Password") 95 | else: 96 | print("No Network") 97 | 98 | else: 99 | 100 | if reason=="[Errno -2] Name or service not known": 101 | print("No Network") 102 | elif reason==error_password: 103 | print("Error Password") 104 | ``` 105 | ## set_session 106 | 107 | Default User-Agent is "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" 108 | 109 | ```python 110 | from ejtraderIQ.stable_api import IQ_Option 111 | import logging 112 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 113 | 114 | api=IQ_Option("email","password") 115 | 116 | #Default is "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" 117 | 118 | header={"User-Agent":r"Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"} 119 | cookie={"api":"GOOD"} 120 | 121 | api.set_session(header,cookie) 122 | 123 | api.connect()#connect to iqoption 124 | ``` 125 | 126 | ## Check version 127 | 128 | ```python 129 | from ejtraderIQ.stable_api import IQ_Option 130 | print(IQ_Option.__version__) 131 | ``` 132 | 133 | ## Check connect 134 | 135 | return True/False 136 | ``` 137 | print(api.check_connect()) 138 | ``` 139 | 140 | ## Reconnect 141 | 142 | ```python 143 | api.connect() 144 | ``` 145 | 146 | ## time 147 | 148 | get_server_timestamp 149 | the get_server_timestamp time is sync with iqoption 150 | 151 | ```python 152 | api.get_server_timestamp() 153 | ``` 154 | -------------------------------------------------------------------------------- /docs/javascripts/.Rhistory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/docs/javascripts/.Rhistory -------------------------------------------------------------------------------- /docs/javascripts/extra.js: -------------------------------------------------------------------------------- 1 | window.MathJax = { 2 | jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"], 3 | extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "a11y/accessibility-menu.js"], 4 | TeX: { 5 | extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] 6 | }, 7 | tex2jax: { 8 | inlineMath: [ ["\\(","\\)"] ], 9 | displayMath: [ ["\\[","\\]"] ] 10 | }, 11 | TeX: { 12 | TagSide: "right", 13 | TagIndent: ".8em", 14 | MultLineWidth: "85%", 15 | equationNumbers: { 16 | autoNumber: "AMS", 17 | }, 18 | unicode: { 19 | fonts: "STIXGeneral,'Arial Unicode MS'" 20 | } 21 | }, 22 | displayAlign: "left", 23 | showProcessingMessages: false, 24 | messageStyle: "none" 25 | }; 26 | 27 | 28 | -------------------------------------------------------------------------------- /ejtraderIQ/__init__.py: -------------------------------------------------------------------------------- 1 | """A python wrapper for IQ Option API.""" 2 | from .easyapi import IQOption 3 | import logging 4 | 5 | def _prepare_logging(): 6 | """Prepare logger for module IQ Option API.""" 7 | logger = logging.getLogger(__name__) 8 | #logger.setLevel(logging.DEBUG) 9 | logger.addHandler(logging.NullHandler()) 10 | 11 | websocket_logger = logging.getLogger("websocket") 12 | websocket_logger.setLevel(logging.DEBUG) 13 | websocket_logger.addHandler(logging.NullHandler()) 14 | 15 | _prepare_logging() 16 | -------------------------------------------------------------------------------- /ejtraderIQ/constants.py: -------------------------------------------------------------------------------- 1 | "" 2 | "Module for IQ Option API constants." 3 | "" 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 | 'PIRCM-CHIX': 929, 235 | 'PSTM-CHIX': 930, 236 | 'TITM-CHIX': 931, 237 | 'CSGNZ-CHIX': 933, 238 | 'NESNZ-CHIX': 934, 239 | 'ROGZ-CHIX': 935, 240 | 'UBSGZ-CHIX': 936, 241 | 'SANE-CHIX': 937, 242 | 'BBVAE-CHIX': 938, 243 | 'TEFE-CHIX': 939, 244 | 'AIRP-CHIX': 940, 245 | 'HEIOA-CHIX': 941, 246 | 'ORP-CHIX': 942, 247 | 'AUDCHF': 943, 248 | 'AUDNZD': 944, 249 | 'CADJPY': 945, 250 | 'EURCHF': 946, 251 | 'GBPNZD': 947, 252 | 'NZDCAD': 948, 253 | 'NZDJPY': 949, 254 | 'EURNOK': 951, 255 | 'CHFSGD': 952, 256 | 'EURSGD': 955, 257 | 'USDMXN': 957, 258 | 'JUVEM': 958, 259 | 'ASRM': 959, 260 | 'MANU': 966, 261 | 'UKOUSD': 969, 262 | 'XPTUSD': 970, 263 | 'USOUSD': 971, 264 | 'W1': 977, 265 | 'AUDDKK': 983, 266 | 'AUDMXN': 985, 267 | 'AUDNOK': 986, 268 | 'AUDSEK': 988, 269 | 'AUDSGD': 989, 270 | 'AUDTRY': 990, 271 | 'CADMXN': 992, 272 | 'CADNOK': 993, 273 | 'CADPLN': 994, 274 | 'CADTRY': 995, 275 | 'CHFDKK': 996, 276 | 'CHFNOK': 998, 277 | 'CHFSEK': 1000, 278 | 'CHFTRY': 1001, 279 | 'DKKPLN': 1004, 280 | 'DKKSGD': 1005, 281 | 'EURDKK': 1007, 282 | 'EURMXN': 1008, 283 | 'EURTRY': 1010, 284 | 'EURZAR': 1011, 285 | 'GBPILS': 1013, 286 | 'GBPMXN': 1014, 287 | 'GBPNOK': 1015, 288 | 'GBPPLN': 1016, 289 | 'GBPSEK': 1017, 290 | 'GBPSGD': 1018, 291 | 'GBPTRY': 1019, 292 | 'NOKDKK': 1023, 293 | 'NOKJPY': 1024, 294 | 'NOKSEK': 1025, 295 | 'NZDDKK': 1026, 296 | 'NZDMXN': 1027, 297 | 'NZDNOK': 1028, 298 | 'NZDSEK': 1030, 299 | 'NZDSGD': 1031, 300 | 'NZDTRY': 1032, 301 | 'NZDZAR': 1033, 302 | 'PLNSEK': 1036, 303 | 'SEKDKK': 1037, 304 | 'SEKJPY': 1038, 305 | 'SGDJPY': 1041, 306 | 'USDDKK': 1045, 307 | 'NZDCHF': 1048, 308 | 'GBPHUF': 1049, 309 | 'USDCZK': 1050, 310 | 'USDHUF': 1051, 311 | 'CADSGD': 1054, 312 | 'EURCZK': 1056, 313 | 'EURHUF': 1057, 314 | 'USDTHB': 1062, 315 | 'IOTUSD-L': 1116, 316 | 'XLMUSD-L': 1117, 317 | 'NEOUSD-L': 1118, 318 | 'ADAUSD-L': 1119, 319 | 'XEMUSD-L': 1120, 320 | 'XRPUSD-L': 1122, 321 | 'EEM': 1203, 322 | 'FXI': 1204, 323 | 'IWM': 1205, 324 | 'GDX': 1206, 325 | 'XOP': 1209, 326 | 'XLK': 1210, 327 | 'XLE': 1211, 328 | 'XLU': 1212, 329 | 'IEMG': 1213, 330 | 'XLY': 1214, 331 | 'IYR': 1215, 332 | 'SQQQ': 1216, 333 | 'OIH': 1217, 334 | 'SMH': 1218, 335 | 'EWJ': 1219, 336 | 'XLB': 1221, 337 | 'DIA': 1222, 338 | 'TLT': 1223, 339 | 'SDS': 1224, 340 | 'EWW': 1225, 341 | 'XME': 1227, 342 | 'QID': 1229, 343 | 'AUS200': 1230, 344 | 'FRANCE40': 1231, 345 | 'GERMANY30': 1232, 346 | 'HONGKONG50': 1233, 347 | 'SPAIN35': 1234, 348 | 'US30': 1235, 349 | 'USNDAQ100': 1236, 350 | 'JAPAN225': 1237, 351 | 'USSPX500': 1239, 352 | 'UK100': 1241, 353 | 'TRXUSD-L': 1242, 354 | 'EOSUSD-L': 1244, 355 | 'BNBUSD-L': 1279, 356 | 'ACB': 1288, 357 | 'CGC': 1289, 358 | 'CRON': 1290, 359 | 'GWPH': 1291, 360 | 'MJ': 1292, 361 | 'TLRY': 1293, 362 | 'BUD': 1294, 363 | 'LYFT': 1313, 364 | 'PINS': 1315, 365 | 'ZM': 1316, 366 | 'UBER': 1334, 367 | 'MELI': 1335, 368 | 'BYND': 1336, 369 | 'BSVUSD-L': 1338, 370 | 'ONTUSD-L': 1339, 371 | 'ATOMUSD-L': 1340, 372 | 'WORK': 1343, 373 | 'FDJP': 1350, 374 | 'CAN': 1351, 375 | 'VIAC': 1352, 376 | 'TFC': 1353 377 | } -------------------------------------------------------------------------------- /ejtraderIQ/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 | -------------------------------------------------------------------------------- /ejtraderIQ/easyapi.py: -------------------------------------------------------------------------------- 1 | from .stable_api import IQ_Option 2 | import logging 3 | import time 4 | from datetime import datetime 5 | import pandas as pd 6 | import os 7 | from dateutil import tz 8 | 9 | class IQOption: 10 | __version__ = "7.8.9.1" 11 | 12 | 13 | def __init__(self, email, password, account_type, verbose = False, checkConnection = False): 14 | self.email = email 15 | self.password = password 16 | self.account_type = account_type 17 | self.debug = verbose 18 | self.iq = None 19 | self.checkConnection = checkConnection 20 | 21 | 22 | if self.debug: 23 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 24 | 25 | if self.iq == None: 26 | self.connect() 27 | 28 | 29 | 30 | def connect(self): 31 | print("Trying to connect to IqOption") 32 | self.iq = IQ_Option(self.email,self.password) 33 | self.iq.connect() 34 | 35 | 36 | if self.iq != None: 37 | while True: 38 | if self.iq.check_connect() == False: 39 | 40 | print('Error when trying to connect') 41 | print(self.iq) 42 | print("Retrying") 43 | self.iq.connect() 44 | else: 45 | if not self.checkConnection: 46 | print('Successfully Connected! Account type : ' + self.account_type) 47 | break 48 | time.sleep(3) 49 | if self.account_type == "DEMO": 50 | self.iq.change_balance("PRACTICE") # PRACTICE or REAL 51 | 52 | elif self.account_type == "REAL": 53 | self.iq.change_balance("REAL") # PRACTICE or REAL 54 | 55 | 56 | 57 | def timeframe_to_seconds(self,timeframe): 58 | # Timeframe dictionary 59 | convert = { 60 | "S30": 30, 61 | "M1": 60, 62 | "M2": 120, 63 | "M3": 180, 64 | "M4": 240, 65 | "M5": 300, 66 | "M15": 900, 67 | "M30": 1800, 68 | "H1": 3600, 69 | 70 | } 71 | return convert[timeframe] 72 | 73 | def timeframe_to_integer(self,timeframe): 74 | # Timeframe dictionary 75 | convert = { 76 | "S30": 1, 77 | "M1": 1, 78 | "M2": 2, 79 | "M3": 3, 80 | "M4": 4, 81 | "M5": 5, 82 | "M15": 15, 83 | "M30": 30, 84 | "H1": 60, 85 | 86 | } 87 | return convert[timeframe] 88 | 89 | def buy(self, contract, symbol, timeframe, turbo=None): 90 | timeframe = self.timeframe_to_integer(timeframe) 91 | if turbo: 92 | done, id = self.iq.buy(contract, symbol, "call", int(timeframe)) 93 | else: 94 | done, id = self.iq.buy_digital_spot(symbol, contract, "call", int(timeframe)) 95 | 96 | 97 | if not done: 98 | print('Error call') 99 | print(done, id) 100 | exit(0) 101 | 102 | return id 103 | 104 | 105 | def sell(self, contract, symbol, timeframe, turbo=None): 106 | timeframe = self.timeframe_to_integer(timeframe) 107 | if turbo: 108 | done, id = self.iq.buy(contract, symbol, "put", int(timeframe)) 109 | else: 110 | done, id = self.iq.buy_digital_spot(symbol, contract, "put", int(timeframe)) 111 | 112 | if not done: 113 | print('Error put') 114 | print(done, id) 115 | exit(0) 116 | 117 | return id 118 | 119 | 120 | def trade(self, contract, symbol, timeframe, direction, turbo=None): 121 | timeframe = self.timeframe_to_integer(timeframe) 122 | if turbo: 123 | done, id = self.iq.buy(contract, symbol, direction, int(timeframe)) 124 | else: 125 | done, id = self.iq.buy_digital_spot(symbol, contract, direction, int(timeframe)) 126 | 127 | if not done: 128 | print('Error put') 129 | print(done, id) 130 | exit(0) 131 | 132 | return done, id 133 | 134 | def balance(self): 135 | return self.iq.get_balance() 136 | 137 | def get_all_open_time(self): 138 | return self.iq.get_all_open_time() 139 | 140 | def isOpen(self): 141 | isOpen = [] 142 | opened_market=self.iq.get_all_open_time() 143 | 144 | for type_name, data in opened_market.items(): 145 | for Asset,value in data.items(): 146 | if value['open'] == True: 147 | value = 'open' 148 | else: 149 | value = 'close' 150 | result = { 151 | "Asset": Asset, 152 | "Type" : type_name, 153 | "Status" : value 154 | } 155 | isOpen.append(result) 156 | 157 | return pd.DataFrame(isOpen) 158 | 159 | def payout(self, symbol, turbo=None): 160 | if turbo: 161 | payout = self.iq.get_all_profit() 162 | payout = payout[symbol]['turbo'] 163 | else: 164 | self.iq.subscribe_strike_list(symbol, 1) 165 | while True: 166 | data = self.iq.get_digital_current_profit(symbol, 1) 167 | if data: 168 | payout = data 169 | self.iq.unsubscribe_strike_list(symbol, 1) 170 | break 171 | return payout 172 | 173 | def remaning(self, timeframe): 174 | t = self.timeframe_to_integer(timeframe) 175 | remaning_time=self.iq.get_remaning(t) 176 | purchase_time=remaning_time 177 | return purchase_time 178 | 179 | def checkwin(self,id,turbo=None): 180 | if turbo: 181 | win = self.iq.check_win_v3(id) 182 | else: 183 | if id !="error": 184 | while True: 185 | check,win = self.iq.check_win_digital_v2(id) 186 | if check==True: 187 | break 188 | 189 | return win 190 | 191 | 192 | def powerbar_start(self, symbol): 193 | return self.iq.start_mood_stream(symbol) 194 | 195 | def powerbar_stop(self, symbol): 196 | return self.iq.stop_mood_stream(symbol) 197 | 198 | def powerbar_get(self, symbol): 199 | return self.iq.get_traders_mood(symbol) 200 | 201 | def powerbar_get_all(self): 202 | return self.iq.get_all_traders_mood() 203 | 204 | 205 | 206 | 207 | def history(self, symbol, timeframe,candles): 208 | candles = candles + 1 209 | timestamp = self.iq.get_server_timestamp() 210 | timeframe = self.timeframe_to_seconds(timeframe) 211 | 212 | 213 | 214 | x = self.iq.get_candles(symbol, int(timeframe), candles, timestamp) 215 | 216 | 217 | 218 | dataframe = pd.DataFrame(x) 219 | dataframe.sort_values(by=["from"], inplace=True, ascending=True) 220 | dataframe.drop(dataframe.tail(1).index, inplace=True) 221 | dataframe = dataframe.rename(columns = {'from': 'date', 'min': 'low','max':'high'}) 222 | dataframe = dataframe.set_index(['date']) 223 | dataframe.index = pd.to_datetime(dataframe.index, unit='s') 224 | return dataframe[["open", "high", "low","close", "volume"]] 225 | 226 | 227 | 228 | def latest_candles(self, symbol, timeframe,candles): 229 | 230 | timeframe = self.timeframe_to_seconds(timeframe) 231 | 232 | 233 | 234 | timestamp = self.iq.get_server_timestamp() 235 | x = self.iq.get_candles(symbol, int(timeframe), candles, timestamp) 236 | timestamp = int(x[0]["from"]) - 1 237 | 238 | 239 | dataframe = pd.DataFrame(x) 240 | dataframe.sort_values(by=["from"], inplace=True, ascending=True) 241 | #dataframe.drop(dataframe.tail(1).index, inplace=True) 242 | dataframe = dataframe.rename(columns = {'from': 'date', 'min': 'low','max':'high'}) 243 | dataframe = dataframe.set_index(['date']) 244 | dataframe.index = pd.to_datetime(dataframe.index, unit='s') 245 | return dataframe[["open", "high", "low","close", "volume"]] 246 | 247 | 248 | 249 | 250 | def subscribe(self,symbol,timeframe): 251 | timeframe = self.timeframe_to_seconds(timeframe) 252 | self.iq.start_candles_stream(symbol,int(timeframe),1) 253 | print("starting stream") 254 | time.sleep(0.5) 255 | self.vela = self.iq.get_realtime_candles(symbol,int(timeframe)) 256 | 257 | def unsubscribe(self,symbol,timeframe): 258 | timeframe = self.timeframe_to_seconds(timeframe) 259 | self.iq.stop_candles_stream(symbol,int(timeframe)) 260 | return f"Unsubscribed from {symbol} " 261 | 262 | def quote(self): 263 | 264 | for velas in list(self.vela): 265 | date = self.vela[velas]["from"] 266 | open = self.vela[velas]["open"] 267 | high = self.vela[velas]["max"] 268 | low = self.vela[velas]["min"] 269 | close = self.vela[velas]["close"] 270 | volume = self.vela[velas]["volume"] 271 | data = [ date, open, high, low, close, volume] 272 | 273 | df = pd.DataFrame ([data], columns = ['date','open','high','low','close','volume']) 274 | 275 | main = df.set_index(['date']) 276 | main.index = pd.to_datetime(main.index, unit='s') 277 | return main 278 | 279 | def get_candles(self,symbol,timeframe,interval): 280 | timestamp = self.iq.get_server_timestamp() 281 | return self.iq.get_candles(symbol,timeframe,interval,timestamp) 282 | 283 | 284 | def server_time(self): 285 | return self.timestamp_converter( 286 | self.iq.get_server_timestamp() 287 | ) 288 | 289 | 290 | def timestamp_converter(self,x): 291 | time = datetime.strptime( 292 | datetime.utcfromtimestamp(x).strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S" 293 | ) 294 | return time 295 | -------------------------------------------------------------------------------- /ejtraderIQ/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 | -------------------------------------------------------------------------------- /ejtraderIQ/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 -------------------------------------------------------------------------------- /ejtraderIQ/http/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API http resources.""" 2 | -------------------------------------------------------------------------------- /ejtraderIQ/http/appinit.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option appinit http resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/auth.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http auth resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/billing.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option billing resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/buyback.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option buyback resource.""" 2 | 3 | from ejtraderIQ.http.resource import Resource 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/changebalance.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option changebalance resource.""" 2 | 3 | from ejtraderIQ.http.resource import Resource 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/events.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/getprofile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http getprofile resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/getregdata.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http getregdata resource.""" 2 | 3 | from ejtraderIQ.http.resource import Resource 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/login.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/loginv2.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http loginv2 resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/logout.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http login resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/profile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option profile resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/register.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option register resource.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/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 | -------------------------------------------------------------------------------- /ejtraderIQ/http/token.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option http token resource.""" 2 | 3 | from ejtraderIQ.http.resource import Resource 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket.""" 2 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option API websocket chanels.""" 2 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/api_game_betinfo.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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) -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/api_game_getoptions.py: -------------------------------------------------------------------------------- 1 | #python 2 | """Module for IQ option candles websocket chanel.""" 3 | 4 | from ejtraderIQ.ws.chanels.base import Base 5 | import time 6 | import ejtraderIQ.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) -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/base.py: -------------------------------------------------------------------------------- 1 | """Module for base IQ Option base websocket chanel.""" 2 | 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 | return self.api.send_websocket_request(name, msg,request_id) 24 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/buy_place_order_temp.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/buyback.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyback websocket chanel.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/buyv2.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyV2 websocket chanel.""" 2 | import datetime 3 | import time 4 | from ejtraderIQ.ws.chanels.base import Base 5 | import logging 6 | from ejtraderIQ.expiration import get_expiration_time 7 | from datetime import datetime,timedelta 8 | import ejtraderIQ.global_value as global_value 9 | 10 | class Buyv2(Base): 11 | """Class for IQ option buy websocket chanel.""" 12 | # pylint: disable=too-few-public-methods 13 | 14 | name = "buyV2" 15 | 16 | def __call__(self, price, active, direction,duration): 17 | """Method to send message to buyv2 websocket chanel. 18 | 19 | :param price: The buying price. 20 | :param active: The buying active. 21 | :param direction: The buying direction. 22 | """ 23 | # thank Darth-Carrotpie's code 24 | #https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 25 | 26 | exp,idx=get_expiration_time(int(self.api.timesync.server_timestamp),duration) 27 | 28 | if idx<5: 29 | option="turbo" 30 | else: 31 | option="binary" 32 | 33 | 34 | 35 | data = { 36 | "price": price, 37 | "act": active, 38 | "exp":int(exp), 39 | "type": option, 40 | "direction": direction.lower(), 41 | "user_balance_id":int(global_value.balance_id), 42 | "time": self.api.timesync.server_timestamp 43 | } 44 | 45 | self.send_websocket_request(self.name, data) 46 | 47 | # thank Darth-Carrotpie's code 48 | #https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 49 | """ def get_expiration_time(self, duration): 50 | exp=int(self.api.timesync.server_timestamp) 51 | if duration>=1 and duration<=5: 52 | option="turbo" 53 | #Round to next full minute 54 | #datetime.datetime.now().second>30 55 | if (exp % 60) > 30: 56 | exp = exp - (exp % 60) + 60*(duration+1) 57 | else: 58 | exp = exp - (exp % 60)+60*(duration) 59 | elif duration > 5: 60 | option = "binary" 61 | period = int(round(duration / 15)) 62 | tmp_exp = exp - (exp % 60)#nuima sekundes 63 | tmp_exp = tmp_exp - (tmp_exp%3600)#nuimam minutes 64 | j=0 65 | while exp > tmp_exp + (j)*15*60:#find quarter 66 | j = j+1 67 | if exp - tmp_exp > 5 * 60: 68 | quarter = tmp_exp + (j)*15*60 69 | exp = quarter + period*15*60 70 | else: 71 | quarter = tmp_exp + (j+1)*15*60 72 | exp = quarter + period*15*60 73 | else: 74 | logging.error("ERROR get_expiration_time DO NOT LESS 1") 75 | exit(1) 76 | return exp, option""" -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/buyv3.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import logging 5 | import ejtraderIQ.global_value as global_value 6 | from ejtraderIQ.expiration import get_expiration_time 7 | class Buyv3(Base): 8 | 9 | name = "sendMessage" 10 | 11 | def __call__(self, price, active, direction, duration,request_id): 12 | 13 | # thank Darth-Carrotpie's code 14 | # https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 15 | exp,idx=get_expiration_time(int(self.api.timesync.server_timestamp),duration) 16 | if idx<5: 17 | option = 3#"turbo" 18 | else: 19 | option = 1#"binary" 20 | data = { 21 | "body": {"price": price, 22 | "active_id": active, 23 | "expired": int(exp), 24 | "direction": direction.lower(), 25 | "option_type_id":option, 26 | "user_balance_id":int(global_value.balance_id) 27 | }, 28 | "name": "binary-options.open-option", 29 | "version": "1.0" 30 | } 31 | self.send_websocket_request(self.name, data,str(request_id)) 32 | 33 | 34 | class Buyv3_by_raw_expired(Base): 35 | 36 | name = "sendMessage" 37 | 38 | def __call__(self, price, active, direction, option,expired,request_id): 39 | 40 | # thank Darth-Carrotpie's code 41 | # https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 42 | 43 | if option=="turbo": 44 | option_id = 3#"turbo" 45 | elif option=="binary": 46 | option_id = 1#"binary" 47 | data = { 48 | "body": {"price": price, 49 | "active_id": active, 50 | "expired": int(expired), 51 | "direction": direction.lower(), 52 | "option_type_id":option_id, 53 | "user_balance_id":int(global_value.balance_id) 54 | }, 55 | "name": "binary-options.open-option", 56 | "version": "1.0" 57 | } 58 | self.send_websocket_request(self.name, data,str(request_id)) 59 | """ 60 | # thank Darth-Carrotpie's code 61 | # https://github.com/Lu-Yi-Hsun/ejtraderIQ/issues/6 62 | def get_expiration_time(self, duration): 63 | exp = time.time() 64 | if duration >= 1 and duration <= 5: 65 | option = 3#"turbo" 66 | # Round to next full minute 67 | # datetime.datetime.now().second>30 68 | if (exp % 60) > 30: 69 | exp = exp - (exp % 60) + 60*(duration+1) 70 | else: 71 | exp = exp - (exp % 60)+60*(duration) 72 | elif duration > 5: 73 | option = 1#"binary" 74 | period = int(round(duration / 15)) 75 | tmp_exp = exp - (exp % 60) # nuima sekundes 76 | tmp_exp = tmp_exp - (tmp_exp % 3600) # nuimam minutes 77 | j = 0 78 | while exp > tmp_exp + (j)*15*60: # find quarter 79 | j = j+1 80 | if exp - tmp_exp > 5 * 60: 81 | quarter = tmp_exp + (j)*15*60 82 | exp = quarter + period*15*60 83 | else: 84 | quarter = tmp_exp + (j+1)*15*60 85 | exp = quarter + period*15*60 86 | else: 87 | logging.error("ERROR get_expiration_time DO NOT LESS 1") 88 | exit(1) 89 | return exp, option 90 | """ -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/cancel_order.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/candles.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option candles websocket chanel.""" 2 | 3 | from ejtraderIQ.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/ejtraderIQ/issues/88 21 | data = {"name":"get-candles", 22 | "version":"2.0", 23 | "body":{ 24 | "active_id":int(active_id), 25 | "size":interval,#time size sample:if interval set 1 mean get time 0~1 candle 26 | "to":int(endtime), #int(self.api.timesync.server_timestamp), 27 | "count":count,#get how many candle 28 | "":active_id 29 | } 30 | } 31 | 32 | self.send_websocket_request(self.name, data) 33 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/change_auto_margin_call.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/change_tpsl.py: -------------------------------------------------------------------------------- 1 | #python 2 | 3 | import datetime 4 | import time 5 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/changebalance.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option buyV2 websocket chanel.""" 2 | import datetime 3 | 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/close_position.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/digital_option.py: -------------------------------------------------------------------------------- 1 | #python 2 | 3 | import datetime 4 | import time 5 | from ejtraderIQ.ws.chanels.base import Base 6 | import ejtraderIQ.global_value as global_value 7 | #work for forex digit cfd(stock) 8 | 9 | class Digital_options_place_digital_option(Base): 10 | name = "sendMessage" 11 | def __call__(self,instrument_id,amount): 12 | data = { 13 | "name": "digital-options.place-digital-option", 14 | "version":"1.0", 15 | "body":{ 16 | "user_balance_id":int(global_value.balance_id), 17 | "instrument_id":str(instrument_id), 18 | "amount":str(amount) 19 | 20 | } 21 | } 22 | self.send_websocket_request(self.name, data) 23 | 24 | class Digital_options_close_position(Base): 25 | name = "sendMessage" 26 | def __call__(self,position_id): 27 | data = { 28 | "name": "digital-options.close-position", 29 | "version":"1.0", 30 | "body":{ 31 | "position_id":int(position_id) 32 | } 33 | } 34 | self.send_websocket_request(self.name, data) 35 | 36 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_available_leverages.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_balances.py: -------------------------------------------------------------------------------- 1 | 2 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_deferred_orders.py: -------------------------------------------------------------------------------- 1 | from ejtraderIQ.ws.chanels.base import Base 2 | import time 3 | import ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_financial_information.py: -------------------------------------------------------------------------------- 1 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_order.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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}}} -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_overnight_fee.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/get_positions.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/heartbeat.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/instruments.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/leaderboard.py: -------------------------------------------------------------------------------- 1 | 2 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/sell_option.py: -------------------------------------------------------------------------------- 1 | 2 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/setactives.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option setactives websocket chanel.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/ssid.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option API ssid websocket chanel.""" 2 | 3 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/strike_list.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/subscribe.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option subscribe websocket chanel.""" 2 | 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import datetime 5 | import ejtraderIQ.constants as OP_code 6 | class Subscribe(Base): 7 | """Class for IQ option candles websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "subscribeMessage" 11 | 12 | def __call__(self, active_id,size): 13 | #{"name":"subscribeMessage","msg":{"name":"candle-generated","params":{"routingFilters":{"active_id":1,"size":1}}}} 14 | 15 | data = {"name":"candle-generated", 16 | "params":{ 17 | "routingFilters":{ 18 | "active_id":str(active_id), 19 | "size":int(size) 20 | } 21 | } 22 | } 23 | 24 | self.send_websocket_request(self.name, data) 25 | 26 | class Subscribe_candles(Base): 27 | """Class for IQ option candles websocket chanel.""" 28 | # pylint: disable=too-few-public-methods 29 | 30 | name = "subscribeMessage" 31 | 32 | def __call__(self, active_id): 33 | 34 | data = {"name":"candles-generated", 35 | "params":{ 36 | "routingFilters":{ 37 | "active_id":str(active_id) 38 | } 39 | } 40 | } 41 | 42 | self.send_websocket_request(self.name, data) 43 | 44 | class Subscribe_Instrument_Quites_Generated(Base): 45 | name = "subscribeMessage" 46 | 47 | def __call__(self,ACTIVE,expiration_period): 48 | data = { 49 | "name": "instrument-quotes-generated", 50 | "params":{ 51 | "routingFilters":{ 52 | "active":int(OP_code.ACTIVES[ACTIVE]), 53 | "expiration_period":int(expiration_period*60), 54 | "kind":"digital-option", 55 | 56 | }, 57 | }, 58 | "version": "1.0" 59 | } 60 | self.send_websocket_request(self.name, data) 61 | 62 | def get_digital_expiration_time(self, duration): 63 | exp=int(self.api.timesync.server_timestamp) 64 | value = datetime.datetime.fromtimestamp(exp) 65 | minute = int(value.strftime('%M')) 66 | second=int(value.strftime('%S')) 67 | ans=exp-exp%60#delete second 68 | ans=ans+(duration-minute%duration)*60 69 | if exp>ans-10: 70 | ans=ans+(duration)*60 71 | 72 | return ans 73 | 74 | 75 | class Subscribe_top_assets_updated(Base): 76 | name = "subscribeMessage" 77 | 78 | def __call__(self, instrument_type): 79 | 80 | data = {"name":"top-assets-updated", 81 | "params":{ 82 | "routingFilters":{ 83 | "instrument_type":str(instrument_type) 84 | 85 | } 86 | }, 87 | "version":"1.2" 88 | } 89 | self.send_websocket_request(self.name, data) 90 | 91 | 92 | 93 | """ 94 | {"name":"subscribeMessage","request_id":"s_114","msg":{"name":"commission-changed","version":"1.0","params":{"routingFilters":{"instrument_type":"digital-option","user_group_id":1}}}} 95 | """ 96 | #instrument_type: "binary-option"/"turbo-option"/"digital-option"/"crypto"/"forex"/"cfd" 97 | class Subscribe_commission_changed(Base): 98 | name = "subscribeMessage" 99 | def __call__(self, instrument_type): 100 | 101 | data = {"name":"commission-changed", 102 | "params":{ 103 | "routingFilters":{ 104 | "instrument_type":str(instrument_type) 105 | } 106 | }, 107 | "version":"1.0" 108 | } 109 | self.send_websocket_request(self.name, data) 110 | 111 | 112 | class Subscribe_live_deal(Base): 113 | name = "subscribeMessage" 114 | 115 | def __call__(self,name,active_id,_type): 116 | #"live-deal-binary-option-placed" 117 | #"live-deal-digital-option" 118 | if name=="live-deal-binary-option-placed": 119 | _type_name="option_type"#turbo/binary 120 | _active_id="active_id" 121 | elif name=="live-deal-digital-option": 122 | _type_name="expiration_type"# 123 | _active_id="instrument_active_id" 124 | elif name=="live-deal": 125 | _type_name="instrument_type"# 126 | _active_id="instrument_active_id" 127 | 128 | 129 | data = {"name":name, 130 | "params":{ 131 | "routingFilters":{ 132 | _active_id:int(active_id), 133 | _type_name:str(_type) 134 | } 135 | }, 136 | "version":"2.0" 137 | } 138 | self.send_websocket_request(self.name, data) 139 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/traders_mood.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from ejtraderIQ.ws.chanels.base import Base 4 | 5 | 6 | class Traders_mood_subscribe(Base): 7 | 8 | name = "subscribeMessage" 9 | 10 | def __call__(self,active): 11 | 12 | 13 | data = { 14 | "name": "traders-mood-changed", 15 | "params": 16 | { 17 | "routingFilters": 18 | { 19 | "instrument":"turbo-option", 20 | "asset_id":active 21 | } 22 | } 23 | 24 | } 25 | 26 | self.send_websocket_request(self.name, data) 27 | 28 | class Traders_mood_unsubscribe(Base): 29 | 30 | name = "unsubscribeMessage" 31 | 32 | def __call__(self,active): 33 | 34 | 35 | data = { 36 | "name": "traders-mood-changed", 37 | "params": 38 | { 39 | "routingFilters": 40 | { 41 | "instrument":"turbo-option", 42 | "asset_id":active 43 | } 44 | } 45 | 46 | } 47 | 48 | self.send_websocket_request(self.name, data) 49 | 50 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/unsubscribe.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option unsubscribe websocket chanel.""" 2 | 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import datetime 5 | import ejtraderIQ.constants as OP_code 6 | class Unsubscribe(Base): 7 | """Class for IQ option candles websocket chanel.""" 8 | # pylint: disable=too-few-public-methods 9 | 10 | name = "unsubscribeMessage" 11 | 12 | def __call__(self, active_id,size=1): 13 | 14 | data = {"name":"candle-generated", 15 | "params":{ 16 | "routingFilters":{ 17 | "active_id":str(active_id), 18 | "size":int(size) 19 | } 20 | } 21 | } 22 | 23 | self.send_websocket_request(self.name, data) 24 | 25 | class Unsubscribe_candles(Base): 26 | """Class for IQ option candles websocket chanel.""" 27 | # pylint: disable=too-few-public-methods 28 | 29 | name = "unsubscribeMessage" 30 | 31 | def __call__(self, active_id,size=1): 32 | 33 | data = {"name":"candles-generated", 34 | "params":{ 35 | "routingFilters":{ 36 | "active_id":str(active_id) 37 | } 38 | } 39 | } 40 | 41 | self.send_websocket_request(self.name, data) 42 | 43 | class Unsubscribe_Instrument_Quites_Generated(Base): 44 | name = "unsubscribeMessage" 45 | 46 | def __call__(self,ACTIVE,expiration_period): 47 | data = { 48 | "name": "instrument-quotes-generated", 49 | "params":{ 50 | "routingFilters":{ 51 | "active":int(OP_code.ACTIVES[ACTIVE]), 52 | "expiration_period":int(expiration_period*60), 53 | "kind":"digital-option", 54 | }, 55 | }, 56 | "version": "1.0" 57 | } 58 | self.send_websocket_request(self.name, data) 59 | 60 | def get_digital_expiration_time(self, duration): 61 | exp=int(self.api.timesync.server_timestamp) 62 | value = datetime.datetime.fromtimestamp(exp) 63 | minute = int(value.strftime('%M')) 64 | second=int(value.strftime('%S')) 65 | ans=exp-exp%60#delete second 66 | ans=ans+(duration-minute%duration)*60 67 | if exp>ans-10: 68 | ans=ans+(duration)*60 69 | 70 | return ans 71 | 72 | class Unsubscribe_top_assets_updated(Base): 73 | name = "unsubscribeMessage" 74 | 75 | def __call__(self, instrument_type): 76 | 77 | data = {"name":"top-assets-updated", 78 | "params":{ 79 | "routingFilters":{ 80 | "instrument_type":str(instrument_type) 81 | 82 | } 83 | }, 84 | "version":"1.2" 85 | } 86 | self.send_websocket_request(self.name, data) 87 | 88 | class Unsubscribe_commission_changed(Base): 89 | name = "unsubscribeMessage" 90 | def __call__(self, instrument_type): 91 | 92 | data = {"name":"commission-changed", 93 | "params":{ 94 | "routingFilters":{ 95 | "instrument_type":str(instrument_type) 96 | } 97 | }, 98 | "version":"1.0" 99 | } 100 | self.send_websocket_request(self.name, data) 101 | 102 | class Unscribe_live_deal(Base): 103 | name = "unsubscribeMessage" 104 | 105 | def __call__(self,name,active_id,_type): 106 | if name=="live-deal-binary-option-placed": 107 | _type_name="option_type" 108 | _active_id="active_id" 109 | elif name=="live-deal-digital-option": 110 | _type_name="expiration_type" 111 | _active_id="instrument_active_id" 112 | elif name=="live-deal": 113 | _type_name="instrument_type"# 114 | _active_id="instrument_active_id" 115 | 116 | data = {"name":str(name), 117 | "params":{ 118 | "routingFilters":{ 119 | _active_id:int(active_id), 120 | _type_name:str(_type) 121 | } 122 | }, 123 | "version":"2.0" 124 | } 125 | self.send_websocket_request(self.name, data) -------------------------------------------------------------------------------- /ejtraderIQ/ws/chanels/user.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option unsubscribe websocket chanel.""" 2 | 3 | from ejtraderIQ.ws.chanels.base import Base 4 | import datetime 5 | import ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/client.py: -------------------------------------------------------------------------------- 1 | """Module for IQ option websocket.""" 2 | 3 | import json 4 | import logging 5 | import websocket 6 | import ejtraderIQ.constants as OP_code 7 | import ejtraderIQ.global_value as global_value 8 | 9 | 10 | 11 | class WebsocketClient(object): 12 | """Class for work with IQ option websocket.""" 13 | 14 | def __init__(self, api): 15 | """ 16 | :param api: The instance of :class:`IQOptionAPI 17 | `. 18 | """ 19 | self.api = api 20 | self.wss = websocket.WebSocketApp( 21 | self.api.wss_url, on_message=self.on_message, 22 | on_error=self.on_error, on_close=self.on_close, 23 | on_open=self.on_open) 24 | def dict_queue_add(self,dict,maxdict,key1,key2,key3,value): 25 | if key3 in dict[key1][key2]: 26 | dict[key1][key2][key3]=value 27 | else: 28 | while True: 29 | try: 30 | dic_size=len(dict[key1][key2]) 31 | except: 32 | dic_size=0 33 | if dic_size 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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/objects/listinfodata.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Candles websocket object.""" 2 | from collections import OrderedDict 3 | 4 | from ejtraderIQ.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 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/objects/profile.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option Profile websocket object.""" 2 | from ejtraderIQ.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 | 17 | 18 | @property 19 | def skey(self): 20 | """Property to get skey value. 21 | 22 | :returns: The skey value. 23 | """ 24 | return self.__skey 25 | 26 | @skey.setter 27 | def skey(self, skey): 28 | """Method to set skey value.""" 29 | self.__skey = skey 30 | #---------------------------------------------------------------- 31 | @property 32 | def balance(self): 33 | """Property to get balance value. 34 | 35 | :returns: The balance value. 36 | """ 37 | return self.__balance 38 | 39 | @balance.setter 40 | def balance(self, balance): 41 | """Method to set balance value.""" 42 | self.__balance = balance 43 | 44 | #--------------------------------------------------------------------- 45 | @property 46 | def balance_id(self): 47 | """Property to get balance value. 48 | 49 | :returns: The balance value. 50 | """ 51 | return self.__balance_id 52 | @balance_id.setter 53 | def balance_id(self, balance_id): 54 | """Method to set balance value.""" 55 | self.__balance_id = balance_id 56 | 57 | 58 | #------------------------------------------------------------------------ 59 | @property 60 | def balance_type(self): 61 | """Property to get balance value. 62 | 63 | :returns: The balance value. 64 | """ 65 | return self.__balance_type 66 | @balance_type.setter 67 | def balance_type(self, balance_type): 68 | """Method to set balance value.""" 69 | self.__balance_type = balance_type 70 | 71 | 72 | 73 | 74 | #---------------------------------------- 75 | @property 76 | def balances(self): 77 | """Property to get balance value. 78 | 79 | :returns: The balance value. 80 | """ 81 | return self.__balances 82 | @balances.setter 83 | def balances(self, balances): 84 | """Method to set balance value.""" 85 | self.__balances = balances 86 | 87 | #------------ 88 | @property 89 | def msg(self): 90 | return self.__msg 91 | @msg.setter 92 | def msg(self, msg): 93 | self.__msg = msg 94 | -------------------------------------------------------------------------------- /ejtraderIQ/ws/objects/timesync.py: -------------------------------------------------------------------------------- 1 | """Module for IQ Option TimeSync websocket object.""" 2 | 3 | import time 4 | import datetime 5 | 6 | from ejtraderIQ.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 | return self.__server_timestamp / 1000 25 | 26 | @server_timestamp.setter 27 | def server_timestamp(self, timestamp): 28 | """Method to set server timestamp.""" 29 | self.__server_timestamp = timestamp 30 | 31 | @property 32 | def server_datetime(self): 33 | """Property to get server datetime. 34 | 35 | :returns: The server datetime. 36 | """ 37 | return datetime.datetime.fromtimestamp(self.server_timestamp) 38 | 39 | @property 40 | def expiration_time(self): 41 | """Property to get expiration time. 42 | 43 | :returns: The expiration time. 44 | """ 45 | return self.__expiration_time 46 | 47 | @expiration_time.setter 48 | def expiration_time(self, minutes): 49 | """Method to set expiration time 50 | 51 | :param int minutes: The expiration time in minutes. 52 | """ 53 | self.__expiration_time = minutes 54 | 55 | @property 56 | def expiration_datetime(self): 57 | """Property to get expiration datetime. 58 | 59 | :returns: The expiration datetime. 60 | """ 61 | return self.server_datetime + datetime.timedelta(minutes=self.expiration_time) 62 | 63 | @property 64 | def expiration_timestamp(self): 65 | """Property to get expiration timestamp. 66 | 67 | :returns: The expiration timestamp. 68 | """ 69 | return time.mktime(self.expiration_datetime.timetuple()) 70 | -------------------------------------------------------------------------------- /examples/mhi-martingaleBot.py: -------------------------------------------------------------------------------- 1 | from ejtraderIQ import IQOption 2 | import time 3 | 4 | def stop_profit_loss(profit, stop_gain, stop_loss): 5 | if profit <= float('-' + str(abs(stop_loss))): 6 | print('\nStop Loss hit!') 7 | exit() 8 | if profit >= stop_gain: 9 | print('\nStop Gain hit!') 10 | exit() 11 | 12 | def Martingale(entry_value, payout): 13 | return round(entry_value * 2.2, 2) 14 | 15 | api = IQOption("email", "password", "DEMO") # DEMO OR REAL 16 | 17 | # Parameters 18 | pair = "EURUSD" # or "EURUSD-OTC" 19 | timeframe = "M1" 20 | operation = 1 # 1 for "Digital", 2 for "Turbo" 21 | entry_value_b = 1 22 | stop_gain = 100 23 | stop_loss = 30 24 | martingale = 3 25 | profit = 0 26 | mhi_type = 1 # 1 for "MHI", 2 for "MHI2" 27 | enter = True 28 | 29 | # Additional parameters to track win/loss rate 30 | total_trades = 0 31 | winning_trades = 0 32 | 33 | while True: 34 | if enter: 35 | print('\n\nStarting operation!') 36 | direction = False 37 | print('Checking colors...', end='') 38 | 39 | candles = api.history(pair, timeframe, 3) 40 | 41 | candles_colors = ['g' if candle['open'] < candle['close'] else 'r' 42 | if candle['open'] > candle['close'] else 'd' 43 | for _, candle in candles.iterrows()] 44 | 45 | colors = ' '.join(candles_colors) 46 | print(colors) 47 | 48 | if colors.count('g') > colors.count('r') and colors.count('d') == 0 : direction = ('put' if mhi_type == 1 else 'call') 49 | if colors.count('r') > colors.count('g') and colors.count('d') == 0 : direction = ('call' if mhi_type == 1 else 'put') 50 | 51 | if direction: 52 | print('Direction:', direction) 53 | 54 | entry_value = entry_value_b 55 | for i in range(martingale): 56 | 57 | id = (api.buy(entry_value, pair, timeframe, turbo=True) 58 | if operation == 2 59 | else api.buy(entry_value, pair, timeframe)) 60 | 61 | win = api.checkwin(id) 62 | 63 | if win is not None: 64 | total_trades += 1 65 | value = win if win > 0 else float('-' + str(abs(entry_value))) 66 | if value > 0: 67 | winning_trades += 1 68 | profit += round(value, 2) 69 | 70 | print('Trade result: ', end='') 71 | print('WIN /' if value > 0 else 'LOSS /' , round(value, 2) ,'/', round(profit, 2),('/ '+str(i)+ ' GALE' if i > 0 else '' )) 72 | 73 | win_loss_rate = (winning_trades / total_trades) * 100 74 | print(f'Win/Loss Rate: {win_loss_rate:.2f}%') 75 | 76 | entry_value = Martingale(entry_value, api.payout(pair)) 77 | 78 | stop_profit_loss(profit, stop_gain, stop_loss) 79 | 80 | if value > 0 : break 81 | 82 | else: 83 | print('\nERROR IN TRADE EXECUTION\n\n') 84 | 85 | time.sleep 86 | -------------------------------------------------------------------------------- /image/83521925_616885489131244_2922459279078195200_n.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/83521925_616885489131244_2922459279078195200_n.jpg -------------------------------------------------------------------------------- /image/asset_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/asset_close.png -------------------------------------------------------------------------------- /image/cancel_order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/cancel_order.png -------------------------------------------------------------------------------- /image/change_ID_Name_order_id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/change_ID_Name_order_id.png -------------------------------------------------------------------------------- /image/change_ID_Name_position_id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/change_ID_Name_position_id.png -------------------------------------------------------------------------------- /image/close_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/close_position.png -------------------------------------------------------------------------------- /image/expiration_time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/expiration_time.png -------------------------------------------------------------------------------- /image/get_pending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/get_pending.png -------------------------------------------------------------------------------- /image/get_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/get_position.png -------------------------------------------------------------------------------- /image/get_position_history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/get_position_history.png -------------------------------------------------------------------------------- /image/get_positions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/get_positions.png -------------------------------------------------------------------------------- /image/profit_after_sale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/profit_after_sale.png -------------------------------------------------------------------------------- /image/time_interval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/image/time_interval.png -------------------------------------------------------------------------------- /instrument.txt: -------------------------------------------------------------------------------- 1 | Name: NZD/SEK instrument_id: "NZDSEK" instrument_type: "forex" 2 | Name: NZD/USD instrument_id: "NZDUSD" instrument_type: "forex" 3 | Name: CAD/TRY instrument_id: "CADTRY" instrument_type: "forex" 4 | Name: EUR/CHF instrument_id: "EURCHF" instrument_type: "forex" 5 | Name: USD/THB instrument_id: "USDTHB" instrument_type: "forex" 6 | Name: EUR/TRY instrument_id: "EURTRY" instrument_type: "forex" 7 | Name: GBP/AUD instrument_id: "GBPAUD" instrument_type: "forex" 8 | Name: AUD/USD instrument_id: "AUDUSD" instrument_type: "forex" 9 | Name: EUR/MXN instrument_id: "EURMXN" instrument_type: "forex" 10 | Name: USD/CHF instrument_id: "USDCHF" instrument_type: "forex" 11 | Name: NOK/DKK instrument_id: "NOKDKK" instrument_type: "forex" 12 | Name: EUR/NOK instrument_id: "EURNOK" instrument_type: "forex" 13 | Name: SEK/JPY instrument_id: "SEKJPY" instrument_type: "forex" 14 | Name: CAD/NOK instrument_id: "CADNOK" instrument_type: "forex" 15 | Name: NOK/SEK instrument_id: "NOKSEK" instrument_type: "forex" 16 | Name: GBP/HUF instrument_id: "GBPHUF" instrument_type: "forex" 17 | Name: GBP/SGD instrument_id: "GBPSGD" instrument_type: "forex" 18 | Name: AUD/NZD instrument_id: "AUDNZD" instrument_type: "forex" 19 | Name: GBP/JPY instrument_id: "GBPJPY" instrument_type: "forex" 20 | Name: CHF/SEK instrument_id: "CHFSEK" instrument_type: "forex" 21 | Name: AUD/NOK instrument_id: "AUDNOK" instrument_type: "forex" 22 | Name: GBP/NOK instrument_id: "GBPNOK" instrument_type: "forex" 23 | Name: AUD/DKK instrument_id: "AUDDKK" instrument_type: "forex" 24 | Name: EUR/AUD instrument_id: "EURAUD" instrument_type: "forex" 25 | Name: AUD/CHF instrument_id: "AUDCHF" instrument_type: "forex" 26 | Name: GBP/CHF instrument_id: "GBPCHF" instrument_type: "forex" 27 | Name: AUD/CAD instrument_id: "AUDCAD" instrument_type: "forex" 28 | Name: CHF/DKK instrument_id: "CHFDKK" instrument_type: "forex" 29 | Name: AUD/TRY instrument_id: "AUDTRY" instrument_type: "forex" 30 | Name: NZD/CHF instrument_id: "NZDCHF" instrument_type: "forex" 31 | Name: USD/SEK instrument_id: "USDSEK" instrument_type: "forex" 32 | Name: GBP/NZD instrument_id: "GBPNZD" instrument_type: "forex" 33 | Name: EUR/DKK instrument_id: "EURDKK" instrument_type: "forex" 34 | Name: NZD/DKK instrument_id: "NZDDKK" instrument_type: "forex" 35 | Name: CAD/SGD instrument_id: "CADSGD" instrument_type: "forex" 36 | Name: EUR/GBP instrument_id: "EURGBP" instrument_type: "forex" 37 | Name: EUR/CAD instrument_id: "EURCAD" instrument_type: "forex" 38 | Name: USD/CZK instrument_id: "USDCZK" instrument_type: "forex" 39 | Name: AUD/MXN instrument_id: "AUDMXN" instrument_type: "forex" 40 | Name: EUR/NZD instrument_id: "EURNZD" instrument_type: "forex" 41 | Name: GBP/PLN instrument_id: "GBPPLN" instrument_type: "forex" 42 | Name: NZD/NOK instrument_id: "NZDNOK" instrument_type: "forex" 43 | Name: AUD/SGD instrument_id: "AUDSGD" instrument_type: "forex" 44 | Name: GBP/SEK instrument_id: "GBPSEK" instrument_type: "forex" 45 | Name: NZD/CAD instrument_id: "NZDCAD" instrument_type: "forex" 46 | Name: NZD/MXN instrument_id: "NZDMXN" instrument_type: "forex" 47 | Name: NZD/TRY instrument_id: "NZDTRY" instrument_type: "forex" 48 | Name: CHF/SGD instrument_id: "CHFSGD" instrument_type: "forex" 49 | Name: USD/MXN instrument_id: "USDMXN" instrument_type: "forex" 50 | Name: EUR/HUF instrument_id: "EURHUF" instrument_type: "forex" 51 | Name: GBP/CAD instrument_id: "GBPCAD" instrument_type: "forex" 52 | Name: USD/TRY instrument_id: "USDTRY" instrument_type: "forex" 53 | Name: USD/JPY instrument_id: "USDJPY" instrument_type: "forex" 54 | Name: EUR/USD instrument_id: "EURUSD" instrument_type: "forex" 55 | Name: AUD/SEK instrument_id: "AUDSEK" instrument_type: "forex" 56 | Name: CHF/NOK instrument_id: "CHFNOK" instrument_type: "forex" 57 | Name: USD/PLN instrument_id: "USDPLN" instrument_type: "forex" 58 | Name: USD/HUF instrument_id: "USDHUF" instrument_type: "forex" 59 | Name: CHF/JPY instrument_id: "CHFJPY" instrument_type: "forex" 60 | Name: GBP/ILS instrument_id: "GBPILS" instrument_type: "forex" 61 | Name: NZD/JPY instrument_id: "NZDJPY" instrument_type: "forex" 62 | Name: CHF/TRY instrument_id: "CHFTRY" instrument_type: "forex" 63 | Name: CAD/JPY instrument_id: "CADJPY" instrument_type: "forex" 64 | Name: USD/RUB instrument_id: "USDRUB" instrument_type: "forex" 65 | Name: SGD/JPY instrument_id: "SGDJPY" instrument_type: "forex" 66 | Name: GBP/USD instrument_id: "GBPUSD" instrument_type: "forex" 67 | Name: CAD/PLN instrument_id: "CADPLN" instrument_type: "forex" 68 | Name: DKK/SGD instrument_id: "DKKSGD" instrument_type: "forex" 69 | Name: NZD/SGD instrument_id: "NZDSGD" instrument_type: "forex" 70 | Name: AUD/JPY instrument_id: "AUDJPY" instrument_type: "forex" 71 | Name: NOK/JPY instrument_id: "NOKJPY" instrument_type: "forex" 72 | Name: PLN/SEK instrument_id: "PLNSEK" instrument_type: "forex" 73 | Name: USD/SGD instrument_id: "USDSGD" instrument_type: "forex" 74 | Name: GBP/MXN instrument_id: "GBPMXN" instrument_type: "forex" 75 | Name: USD/CAD instrument_id: "USDCAD" instrument_type: "forex" 76 | Name: SEK/DKK instrument_id: "SEKDKK" instrument_type: "forex" 77 | Name: DKK/PLN instrument_id: "DKKPLN" instrument_type: "forex" 78 | Name: CAD/MXN instrument_id: "CADMXN" instrument_type: "forex" 79 | Name: GBP/TRY instrument_id: "GBPTRY" instrument_type: "forex" 80 | Name: EUR/SGD instrument_id: "EURSGD" instrument_type: "forex" 81 | Name: NZD/ZAR instrument_id: "NZDZAR" instrument_type: "forex" 82 | Name: EUR/CZK instrument_id: "EURCZK" instrument_type: "forex" 83 | Name: EUR/JPY instrument_id: "EURJPY" instrument_type: "forex" 84 | Name: CAD/CHF instrument_id: "CADCHF" instrument_type: "forex" 85 | Name: USD/INR instrument_id: "USDINR" instrument_type: "forex" 86 | Name: USD/BRL instrument_id: "USDBRL" instrument_type: "forex" 87 | Name: USD/NOK instrument_id: "USDNOK" instrument_type: "forex" 88 | Name: USD/DKK instrument_id: "USDDKK" instrument_type: "forex" 89 | Name: China Large-Cap ETF instrument_id: "FXI" instrument_type: "cfd" 90 | Name: IBM Corporation instrument_id: "IBM:US" instrument_type: "cfd" 91 | Name: IDEXX Laboratories instrument_id: "IDXX" instrument_type: "cfd" 92 | Name: Siemens instrument_id: "SIED-CHIX" instrument_type: "cfd" 93 | Name: Roche instrument_id: "ROGZ-CHIX" instrument_type: "cfd" 94 | Name: Airbus SE instrument_id: "AIRP-CHIX" instrument_type: "cfd" 95 | Name: AbbVie instrument_id: "ABBV:US" instrument_type: "cfd" 96 | Name: Concho Resources instrument_id: "CXO:US" instrument_type: "cfd" 97 | Name: Verizon instrument_id: "VZ:US" instrument_type: "cfd" 98 | Name: Unilever instrument_id: "ULVRL-CHIX" instrument_type: "cfd" 99 | Name: Lockheed Martin instrument_id: "LMT:US" instrument_type: "cfd" 100 | Name: NextEra Energy instrument_id: "NEE:US" instrument_type: "cfd" 101 | Name: US 100 instrument_id: "USNDAQ100" instrument_type: "cfd" 102 | Name: Entergy instrument_id: "ETR:US" instrument_type: "cfd" 103 | Name: QQQ Trust, Series 1 instrument_id: "QQQ" instrument_type: "cfd" 104 | Name: DTE Energy instrument_id: "DTE:US" instrument_type: "cfd" 105 | Name: Tesco instrument_id: "TSCOL-CHIX" instrument_type: "cfd" 106 | Name: First Solar instrument_id: "FSLR:US" instrument_type: "cfd" 107 | Name: Pfizer instrument_id: "PFE:US" instrument_type: "cfd" 108 | Name: Eastman Chemical instrument_id: "EMN:US" instrument_type: "cfd" 109 | Name: JP Morgan Chase instrument_id: "JPM" instrument_type: "cfd" 110 | Name: Google instrument_id: "GOOGLE" instrument_type: "cfd" 111 | Name: Fastenal instrument_id: "FAST:US" instrument_type: "cfd" 112 | Name: HSBC Holdings PLC instrument_id: "HSBAL-CHIX" instrument_type: "cfd" 113 | Name: DaVita instrument_id: "DVA:US" instrument_type: "cfd" 114 | Name: Utilities SPDR instrument_id: "XLU" instrument_type: "cfd" 115 | Name: Federal Realty instrument_id: "FRT:US" instrument_type: "cfd" 116 | Name: Commerzbank instrument_id: "CBKD-CHIX" instrument_type: "cfd" 117 | Name: Amgen instrument_id: "AMGN:US" instrument_type: "cfd" 118 | Name: Silver instrument_id: "XAGUSD" instrument_type: "cfd" 119 | Name: Resmed Inc instrument_id: "RMD" instrument_type: "cfd" 120 | Name: Equifax instrument_id: "EFX:US" instrument_type: "cfd" 121 | Name: Digital Realty Trust instrument_id: "DLR:US" instrument_type: "cfd" 122 | Name: Adobe Systems instrument_id: "ADBE:US" instrument_type: "cfd" 123 | Name: Autodesk instrument_id: "ADSK:US" instrument_type: "cfd" 124 | Name: Barclays instrument_id: "BARCL-CHIX" instrument_type: "cfd" 125 | Name: Spotify instrument_id: "SPOT" instrument_type: "cfd" 126 | Name: Standard Chartered instrument_id: "STANL-CHIX" instrument_type: "cfd" 127 | Name: Alibaba instrument_id: "ALIBABA" instrument_type: "cfd" 128 | Name: Freeport-McMoRan instrument_id: "FCX:US" instrument_type: "cfd" 129 | Name: Delta Air Lines instrument_id: "DAL:US" instrument_type: "cfd" 130 | Name: Materials Select Sector SPDR instrument_id: "XLB" instrument_type: "cfd" 131 | Name: Amazon instrument_id: "AMAZON" instrument_type: "cfd" 132 | Name: Semiconductor ETF instrument_id: "SMH" instrument_type: "cfd" 133 | Name: S&P 500 ETF instrument_id: "SPY" instrument_type: "cfd" 134 | Name: Caterpillar instrument_id: "CAT:US" instrument_type: "cfd" 135 | Name: US 30 instrument_id: "US30" instrument_type: "cfd" 136 | Name: ConocoPhillips instrument_id: "COP:US" instrument_type: "cfd" 137 | Name: Flowserve instrument_id: "FLS:US" instrument_type: "cfd" 138 | Name: Goldman Sachs instrument_id: "GS" instrument_type: "cfd" 139 | Name: AU 200 instrument_id: "AUS200" instrument_type: "cfd" 140 | Name: Edison instrument_id: "EIX:US" instrument_type: "cfd" 141 | Name: Crude Oil WTI instrument_id: "USOUSD" instrument_type: "cfd" 142 | Name: MSCI Mexico ETF instrument_id: "EWW" instrument_type: "cfd" 143 | Name: General Electric instrument_id: "GE" instrument_type: "cfd" 144 | Name: Micron Technology instrument_id: "MU:US" instrument_type: "cfd" 145 | Name: Telefónica instrument_id: "TEFE-CHIX" instrument_type: "cfd" 146 | Name: Procter & Gamble instrument_id: "PG:US" instrument_type: "cfd" 147 | Name: Accenture instrument_id: "ACN:US" instrument_type: "cfd" 148 | Name: Costco instrument_id: "COST:US" instrument_type: "cfd" 149 | Name: Medtronic instrument_id: "MDT:US" instrument_type: "cfd" 150 | Name: MSCI Emerging Markets ETF instrument_id: "EEM" instrument_type: "cfd" 151 | Name: Expeditors instrument_id: "EXPD:US" instrument_type: "cfd" 152 | Name: Facebook instrument_id: "FACEBOOK" instrument_type: "cfd" 153 | Name: Tesla instrument_id: "TESLA" instrument_type: "cfd" 154 | Name: Merck instrument_id: "MRKD-CHIX" instrument_type: "cfd" 155 | Name: FirstEnergy instrument_id: "FE:US" instrument_type: "cfd" 156 | Name: Altria instrument_id: "MO:US" instrument_type: "cfd" 157 | Name: Core MSCI Emerging Markets instrument_id: "IEMG" instrument_type: "cfd" 158 | Name: AS Roma instrument_id: "ASRM" instrument_type: "cfd" 159 | Name: Bayer instrument_id: "BAYND-CHIX" instrument_type: "cfd" 160 | Name: Continental instrument_id: "COND-CHIX" instrument_type: "cfd" 161 | Name: Qualcomm instrument_id: "QCOM:US" instrument_type: "cfd" 162 | Name: Vodafone Group PLC instrument_id: "VODL-CHIX" instrument_type: "cfd" 163 | Name: Visa instrument_id: "V:US" instrument_type: "cfd" 164 | Name: AT&T instrument_id: "T:US" instrument_type: "cfd" 165 | Name: FedEx instrument_id: "FDX:US" instrument_type: "cfd" 166 | Name: Frontier Communications instrument_id: "FTR:US" instrument_type: "cfd" 167 | Name: Teleflex Inc instrument_id: "TFX" instrument_type: "cfd" 168 | Name: Twitter Inc instrument_id: "TWITTER" instrument_type: "cfd" 169 | Name: Royal Bank of Scotland instrument_id: "RBSL-CHIX" instrument_type: "cfd" 170 | Name: S&P Oil & Gas Explor & Product instrument_id: "XOP" instrument_type: "cfd" 171 | Name: Deutsche Post instrument_id: "DPWD-CHIX" instrument_type: "cfd" 172 | Name: General Motors instrument_id: "GM" instrument_type: "cfd" 173 | Name: US 500 instrument_id: "USSPX500" instrument_type: "cfd" 174 | Name: Bank of America instrument_id: "BAC:US" instrument_type: "cfd" 175 | Name: Nike instrument_id: "NIKE" instrument_type: "cfd" 176 | Name: Darden Restaurants instrument_id: "DRI:US" instrument_type: "cfd" 177 | Name: UBS instrument_id: "UBSGZ-CHIX" instrument_type: "cfd" 178 | Name: Discover Financial Services instrument_id: "DFS:US" instrument_type: "cfd" 179 | Name: Emerson Electric instrument_id: "EMR:US" instrument_type: "cfd" 180 | Name: Advance Auto Parts instrument_id: "AAP:US" instrument_type: "cfd" 181 | Name: Duke Realty Corp instrument_id: "DRE" instrument_type: "cfd" 182 | Name: Rolls-Royce instrument_id: "RRL-CHIX" instrument_type: "cfd" 183 | Name: Wells Fargo instrument_id: "WFC:US" instrument_type: "cfd" 184 | Name: CitiGroup instrument_id: "CITI" instrument_type: "cfd" 185 | Name: Cisco Systems instrument_id: "CISCO" instrument_type: "cfd" 186 | Name: Apple instrument_id: "APPLE" instrument_type: "cfd" 187 | Name: MSCI Japan ETF instrument_id: "EWJ" instrument_type: "cfd" 188 | Name: F5 Networks instrument_id: "FFIV:US" instrument_type: "cfd" 189 | Name: Heinz instrument_id: "KHC:US" instrument_type: "cfd" 190 | Name: British American Tobacco instrument_id: "BATSL-CHIX" instrument_type: "cfd" 191 | Name: Nvidia instrument_id: "NVDA:US" instrument_type: "cfd" 192 | Name: E.ON instrument_id: "EOAND-CHIX" instrument_type: "cfd" 193 | Name: Citrix Systems instrument_id: "CTXS:US" instrument_type: "cfd" 194 | Name: UK 100 instrument_id: "UK100" instrument_type: "cfd" 195 | Name: BBVA instrument_id: "BBVAE-CHIX" instrument_type: "cfd" 196 | Name: Philip Morris Int. instrument_id: "PM:US" instrument_type: "cfd" 197 | Name: Consolidated Edison instrument_id: "ED:US" instrument_type: "cfd" 198 | Name: Netflix instrument_id: "NFLX:US" instrument_type: "cfd" 199 | Name: Allianz instrument_id: "ALVD-CHIX" instrument_type: "cfd" 200 | Name: FR 40 instrument_id: "FRANCE40" instrument_type: "cfd" 201 | Name: Schlumberger instrument_id: "SLB:US" instrument_type: "cfd" 202 | Name: Platinum instrument_id: "XPTUSD" instrument_type: "cfd" 203 | Name: Consumer Discretionary SPDR instrument_id: "XLY" instrument_type: "cfd" 204 | Name: BHP Billiton instrument_id: "BLTL-CHIX" instrument_type: "cfd" 205 | Name: Credit Suisse instrument_id: "CSGNZ-CHIX" instrument_type: "cfd" 206 | Name: Activision Blizzard instrument_id: "ATVI:US" instrument_type: "cfd" 207 | Name: Hasbro instrument_id: "HAS:US" instrument_type: "cfd" 208 | Name: Bristol-Myers Squibb instrument_id: "BMY:US" instrument_type: "cfd" 209 | Name: Equity Residential instrument_id: "EQR:US" instrument_type: "cfd" 210 | Name: Suncor Energy Inc. instrument_id: "SU" instrument_type: "cfd" 211 | Name: Cintas instrument_id: "CTAS:US" instrument_type: "cfd" 212 | Name: Morgan Stanley instrument_id: "MORSTAN" instrument_type: "cfd" 213 | Name: Devon Energy instrument_id: "DVN:US" instrument_type: "cfd" 214 | Name: Dun & Bradstreet instrument_id: "DNB:US" instrument_type: "cfd" 215 | Name: S&P Metals & Mining ETF instrument_id: "XME" instrument_type: "cfd" 216 | Name: SP 35 instrument_id: "SPAIN35" instrument_type: "cfd" 217 | Name: Boeing instrument_id: "BA:US" instrument_type: "cfd" 218 | Name: Ferrari instrument_id: "FERRARI" instrument_type: "cfd" 219 | Name: US Real Estate ETF instrument_id: "IYR" instrument_type: "cfd" 220 | Name: Dover instrument_id: "DOV:US" instrument_type: "cfd" 221 | Name: Honeywell instrument_id: "HON:US" instrument_type: "cfd" 222 | Name: Marks & Spencer instrument_id: "MKSL-CHIX" instrument_type: "cfd" 223 | Name: BMW instrument_id: "BMWD-CHIX" instrument_type: "cfd" 224 | Name: HK 50 instrument_id: "HONGKONG50" instrument_type: "cfd" 225 | Name: PayPal instrument_id: "PYPL:US" instrument_type: "cfd" 226 | Name: Alcoa instrument_id: "AA:US" instrument_type: "cfd" 227 | Name: CVS Health instrument_id: "CVS:US" instrument_type: "cfd" 228 | Name: iShares Russell 2000 ETF instrument_id: "IWM" instrument_type: "cfd" 229 | Name: Walgreens Boots All. instrument_id: "WBA:US" instrument_type: "cfd" 230 | Name: ANSYS instrument_id: "ANSS" instrument_type: "cfd" 231 | Name: Energy SPDR instrument_id: "XLE" instrument_type: "cfd" 232 | Name: Wheat instrument_id: "W1" instrument_type: "cfd" 233 | Name: Ecolab instrument_id: "ECL:US" instrument_type: "cfd" 234 | Name: Starbucks instrument_id: "SBUX:US" instrument_type: "cfd" 235 | Name: Heineken Holding NV instrument_id: "HEIOA-CHIX" instrument_type: "cfd" 236 | Name: Quest Diagnostics instrument_id: "DGX:US" instrument_type: "cfd" 237 | Name: easyJet instrument_id: "EZJL-CHIX" instrument_type: "cfd" 238 | Name: JP 225 instrument_id: "JAPAN225" instrument_type: "cfd" 239 | Name: AMD instrument_id: "AMD" instrument_type: "cfd" 240 | Name: Colgate-Palmolive instrument_id: "CL:US" instrument_type: "cfd" 241 | Name: Salesforce.com instrument_id: "CRM:US" instrument_type: "cfd" 242 | Name: Technology SPDR instrument_id: "XLK" instrument_type: "cfd" 243 | Name: Dropbox instrument_id: "DBX" instrument_type: "cfd" 244 | Name: Fidelity National Information Services instrument_id: "FIS:US" instrument_type: "cfd" 245 | Name: 3M Company instrument_id: "MMM:US" instrument_type: "cfd" 246 | Name: Daimler instrument_id: "DAID-CHIX" instrument_type: "cfd" 247 | Name: Baidu instrument_id: "BAIDU" instrument_type: "cfd" 248 | Name: Wal-Mart Stores instrument_id: "WMT:US" instrument_type: "cfd" 249 | Name: Exxon Mobil instrument_id: "XOM:US" instrument_type: "cfd" 250 | Name: Raytheon instrument_id: "RTN:US" instrument_type: "cfd" 251 | Name: eBay instrument_id: "EBAY:US" instrument_type: "cfd" 252 | Name: Discovery – Class A instrument_id: "DISCA:US" instrument_type: "cfd" 253 | Name: Oil Services ETF instrument_id: "OIH" instrument_type: "cfd" 254 | Name: Microsoft instrument_id: "MSFT" instrument_type: "cfd" 255 | Name: Chevron instrument_id: "CVX:US" instrument_type: "cfd" 256 | Name: Lloyds Banking Group PLC instrument_id: "LLOYL-CHIX" instrument_type: "cfd" 257 | Name: 20+ Year Treasury Bond ETF instrument_id: "TLT" instrument_type: "cfd" 258 | Name: Adidas instrument_id: "ADSD-CHIX" instrument_type: "cfd" 259 | Name: Comcast – Class A instrument_id: "CMCSA:US" instrument_type: "cfd" 260 | Name: Danaher instrument_id: "DHR:US" instrument_type: "cfd" 261 | Name: Align Technology instrument_id: "ALGN" instrument_type: "cfd" 262 | Name: Volkswagen instrument_id: "VOW3D-CHIX" instrument_type: "cfd" 263 | Name: Fiserv instrument_id: "FISV:US" instrument_type: "cfd" 264 | Name: L'Oreal instrument_id: "ORP-CHIX" instrument_type: "cfd" 265 | Name: D. R. Horton instrument_id: "DHI:US" instrument_type: "cfd" 266 | Name: Deutsche Telekom instrument_id: "DTED-CHIX" instrument_type: "cfd" 267 | Name: Gold Miners ETF instrument_id: "GDX" instrument_type: "cfd" 268 | Name: Gold instrument_id: "XAUUSD" instrument_type: "cfd" 269 | Name: Extra Space Storage instrument_id: "EXR:US" instrument_type: "cfd" 270 | Name: Manchester United instrument_id: "MANU" instrument_type: "cfd" 271 | Name: Banco Santander instrument_id: "SANE-CHIX" instrument_type: "cfd" 272 | Name: Abbott Labs instrument_id: "ABT:US" instrument_type: "cfd" 273 | Name: FMC Corporation instrument_id: "FMC:US" instrument_type: "cfd" 274 | Name: Snapchat instrument_id: "SNAP" instrument_type: "cfd" 275 | Name: ThyssenKrupp instrument_id: "TKAD-CHIX" instrument_type: "cfd" 276 | Name: GER 30 instrument_id: "GERMANY30" instrument_type: "cfd" 277 | Name: Fortune Brands Home & Security instrument_id: "FBHS:US" instrument_type: "cfd" 278 | Name: Crude Oil Brent instrument_id: "UKOUSD" instrument_type: "cfd" 279 | Name: Coca Cola instrument_id: "COKE" instrument_type: "cfd" 280 | Name: Essex Property Trust instrument_id: "ESS:US" instrument_type: "cfd" 281 | Name: Wm Morrison Supermarkets instrument_id: "MRWL-CHIX" instrument_type: "cfd" 282 | Name: Gilead Sciences instrument_id: "GILD:US" instrument_type: "cfd" 283 | Name: MasterCard instrument_id: "MA:US" instrument_type: "cfd" 284 | Name: Nestlé instrument_id: "NESNZ-CHIX" instrument_type: "cfd" 285 | Name: CenturyLink instrument_id: "CTL:US" instrument_type: "cfd" 286 | Name: Deutsche Bank instrument_id: "DBKD-CHIX" instrument_type: "cfd" 287 | Name: T-Mobile US, Inc. instrument_id: "TMUS" instrument_type: "cfd" 288 | Name: McDonald's instrument_id: "MCDON" instrument_type: "cfd" 289 | Name: Diamond Offshore Drilling instrument_id: "DO:US" instrument_type: "cfd" 290 | Name: Intel instrument_id: "INTEL" instrument_type: "cfd" 291 | Name: Fifth Third Bank instrument_id: "FITB:US" instrument_type: "cfd" 292 | Name: Best Buy instrument_id: "BBY:US" instrument_type: "cfd" 293 | Name: EQT Corporation instrument_id: "EQT:US" instrument_type: "cfd" 294 | Name: BP PLC instrument_id: "BPL-CHIX" instrument_type: "cfd" 295 | Name: E-Trade instrument_id: "ETFC:US" instrument_type: "cfd" 296 | Name: Stryker instrument_id: "SYK:US" instrument_type: "cfd" 297 | Name: Dow Jones Industrial Average ETF instrument_id: "DIA" instrument_type: "cfd" 298 | Name: NEM ×20 instrument_id: "XEMUSD-L" instrument_type: "crypto" 299 | Name: Ethereum instrument_id: "ETHUSD" instrument_type: "crypto" 300 | Name: EOS ×20 instrument_id: "EOSUSD-L" instrument_type: "crypto" 301 | Name: Qtum instrument_id: "QTMUSD" instrument_type: "crypto" 302 | Name: EOS instrument_id: "EOSUSD" instrument_type: "crypto" 303 | Name: Bitcoin Cash ×20 instrument_id: "BCHUSD-L" instrument_type: "crypto" 304 | Name: Bitcoin instrument_id: "BTCUSD" instrument_type: "crypto" 305 | Name: TRON instrument_id: "TRXUSD" instrument_type: "crypto" 306 | Name: Ripple ×20 instrument_id: "XRPUSD-L" instrument_type: "crypto" 307 | Name: Stellar ×20 instrument_id: "XLMUSD-L" instrument_type: "crypto" 308 | Name: Ethereum ×50 instrument_id: "ETHUSD-L" instrument_type: "crypto" 309 | Name: ZCash instrument_id: "ZECUSD" instrument_type: "crypto" 310 | Name: Litecoin instrument_id: "LTCUSD" instrument_type: "crypto" 311 | Name: Bitcoin Cash instrument_id: "BCHUSD" instrument_type: "crypto" 312 | Name: Bitcoin ×100 instrument_id: "BTCUSD-L" instrument_type: "crypto" 313 | Name: OmiseGo instrument_id: "OMGUSD" instrument_type: "crypto" 314 | Name: TRON ×50 instrument_id: "TRXUSD-L" instrument_type: "crypto" 315 | Name: Cardano ×20 instrument_id: "ADAUSD-L" instrument_type: "crypto" 316 | Name: Dash instrument_id: "DSHUSD" instrument_type: "crypto" 317 | Name: Litecoin ×20 instrument_id: "LTCUSD-L" instrument_type: "crypto" 318 | Name: Ripple instrument_id: "XRPUSD" instrument_type: "crypto" -------------------------------------------------------------------------------- /pylint.rc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | disable=locally-disabled, duplicate-code, useless-super-delegation 3 | 4 | [DESIGN] 5 | min-public-methods=0 6 | 7 | [FORMAT] 8 | max-line-length=100 9 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pylint 2 | requests 3 | websocket-client==0.56 4 | pandas 5 | dateutil -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """The python wrapper for IQ Option API package setup.""" 2 | from setuptools import (setup, find_packages) 3 | 4 | 5 | setup( 6 | name="ejtraderIQ", 7 | version="1.1.1", 8 | license='GPL-3.0', 9 | packages=find_packages(), 10 | install_requires=["pylint","requests","websocket-client==0.56"], 11 | include_package_data = True, 12 | description="IQ Option API for python", 13 | long_description="IQ Option API for python", 14 | url="https://github.com/ejtraderLabs/ejtraderIQ", 15 | author="Emerson Pedroso", 16 | author_email="emerson@ejtrader.com", 17 | zip_safe=False 18 | ) 19 | -------------------------------------------------------------------------------- /test.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/test.ipynb -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/ejtraderIQ/b2d14d782ca46db2ed6741c16453b6136818e09e/tests/__init__.py -------------------------------------------------------------------------------- /tests/iq.py: -------------------------------------------------------------------------------- 1 | from ejtraderIQ import IQOption 2 | 3 | 4 | api = IQOption('email','password','DEMO') 5 | 6 | 7 | for _ in range(5): 8 | id = api.buy(1,'EURUSD','M1') 9 | win = api.checkwin(id) 10 | print(win) 11 | -------------------------------------------------------------------------------- /tests/test_Binary_Option.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from ejtraderIQ.stable_api import IQ_Option 4 | import logging 5 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 6 | 7 | email=os.getenv("email") 8 | password=os.getenv("password") 9 | class TestBinaryOption(unittest.TestCase): 10 | 11 | def test_binary_option(self): 12 | #login 13 | api=IQ_Option(email,password) 14 | api.change_balance("PRACTICE") 15 | api.reset_practice_balance() 16 | self.assertEqual(api.check_connect(), True) 17 | #start test binary option 18 | ALL_Asset=api.get_all_open_time() 19 | if ALL_Asset["turbo"]["EURUSD"]["open"]: 20 | ACTIVES="EURUSD" 21 | else: 22 | ACTIVES="EURUSD-OTC" 23 | Money=1 24 | ACTION_call="call"#or "put" 25 | expirations_mode=1 26 | check_call,id_call=api.buy(Money,ACTIVES,ACTION_call,expirations_mode) 27 | self.assertTrue(check_call) 28 | self.assertTrue(type(id_call) is int) 29 | api.sell_option(id_call) 30 | 31 | ACTION_call="put" 32 | check_put,id_put=api.buy(Money,ACTIVES,ACTION_call,expirations_mode) 33 | self.assertTrue(check_put) 34 | self.assertTrue(type(id_put) is int) 35 | api.sell_option(id_put) 36 | api.check_win_v2(id_put) 37 | 38 | 39 | api.get_binary_option_detail() 40 | 41 | api.get_all_profit() 42 | 43 | isSuccessful,dict=api.get_betinfo(id_put) 44 | self.assertTrue(isSuccessful) 45 | api.get_optioninfo(10) 46 | -------------------------------------------------------------------------------- /tests/test_Candle.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from ejtraderIQ.stable_api import IQ_Option 4 | import logging 5 | import time 6 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') 7 | 8 | email=os.getenv("email") 9 | password=os.getenv("password") 10 | class TestCandle(unittest.TestCase): 11 | 12 | def test_Candle(self): 13 | #login 14 | api=IQ_Option(email,password) 15 | api.change_balance("PRACTICE") 16 | api.reset_practice_balance() 17 | self.assertEqual(api.check_connect(), True) 18 | #start test binary option 19 | ALL_Asset=api.get_all_open_time() 20 | if ALL_Asset["turbo"]["EURUSD"]["open"]: 21 | ACTIVES="EURUSD" 22 | else: 23 | ACTIVES="EURUSD-OTC" 24 | 25 | api.get_candles(ACTIVES, 60, 1000, time.time()) 26 | #realtime candle 27 | size="all" 28 | api.start_candles_stream(ACTIVES,size,10) 29 | api.get_realtime_candles(ACTIVES,size) 30 | api.stop_candles_stream(ACTIVES,size) 31 | 32 | -------------------------------------------------------------------------------- /tests/test_Login.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from ejtraderIQ.stable_api import IQ_Option 4 | 5 | email=os.getenv("email") 6 | password=os.getenv("password") 7 | class TestLogin(unittest.TestCase): 8 | 9 | def test_login(self): 10 | api=IQ_Option(email,password) 11 | api.change_balance("PRACTICE") 12 | api.reset_practice_balance() 13 | self.assertEqual(api.check_connect(), True) 14 | 15 | --------------------------------------------------------------------------------