├── .coverage
├── .gdb_history
├── .github
└── FUNDING.yml
├── .gitignore
├── .travis.yml
├── ACTIVE_CODE.txt
├── README.md
├── coverage.xml
├── docs
├── conf.py
├── index.rst
├── iqoptionapi.http.rst
├── iqoptionapi.rst
├── iqoptionapi.ws.chanels.rst
├── iqoptionapi.ws.objects.rst
├── iqoptionapi.ws.rst
└── modules.rst
├── image
├── 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
├── iqoptionapi
├── __init__.py
├── api.py
├── constants.py
├── expiration.py
├── global_value.py
├── http
│ ├── __init__.py
│ ├── appinit.py
│ ├── auth.py
│ ├── billing.py
│ ├── buyback.py
│ ├── changebalance.py
│ ├── getprofile.py
│ ├── getregdata.py
│ ├── login.py
│ ├── loginv2.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_deferred_orders.py
│ ├── get_financial_information.py
│ ├── get_order.py
│ ├── get_overnight_fee.py
│ ├── get_positions.py
│ ├── heartbeat.py
│ ├── instruments.py
│ ├── sell_digital_option.py
│ ├── sell_option.py
│ ├── setactives.py
│ ├── ssid.py
│ ├── strike_list.py
│ ├── subscribe.py
│ ├── traders_mood.py
│ └── unsubscribe.py
│ ├── client.py
│ └── objects
│ ├── __init__.py
│ ├── base.py
│ ├── betinfo.py
│ ├── candles.py
│ ├── listinfodata.py
│ ├── profile.py
│ └── timesync.py
├── pylint.rc
├── requirements.txt
├── setup.py
└── tests
├── __init__.py
├── test_Binary_Option.py
├── test_Candle.py
└── test_Login.py
/.coverage:
--------------------------------------------------------------------------------
1 | !coverage.py: This is a private format, don't read it directly!{"lines":{"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/tests/__init__.py":[1],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/tests/test_Login.py":[1,3,4,6,7,8,10,15,11,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/__init__.py":[1,3,5,15,7,8,9,11,12,13],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/stable_api.py":[2,3,4,5,6,7,9,10,11,14,21,22,24,46,49,52,105,115,118,127,133,139,154,160,165,172,199,213,268,282,304,315,328,341,354,370,397,418,434,443,462,469,477,500,514,537,558,570,575,579,584,596,604,628,641,663,676,683,694,711,714,718,754,762,797,806,816,826,854,881,891,923,928,942,953,963,976,987,999,1010,1020,1033,1047,25,26,27,28,29,30,31,32,33,35,36,38,39,41,53,54,55,56,57,59,60,61,62,63,64,67,69,70,76,77,82,83,89,90,91,92,93,94,95,97,43,316,317,318,319,305,306,307,308,309,310,320,321,326,107,108,111],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/api.py":[1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,28,29,30,31,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,50,52,53,54,55,56,57,58,60,61,62,63,64,65,66,69,79,82,83,86,87,88,89,90,91,93,94,95,70,73,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,116,118,119,120,121,71,123,124,125,126,129,130,132,135,157,167,198,228,236,249,258,267,276,285,303,312,321,331,341,345,350,361,365,372,382,386,395,399,418,433,442,451,459,472,476,482,486,496,501,513,517,521,525,529,534,538,542,546,550,554,558,562,566,570,574,578,582,587,592,598,633,637,142,143,144,145,146,147,148,149,150,155,599,601,256,602,210,212,214,215,216,217,218,219,220,221,222,223,225,226,603,604,594,595,596,605,607,234,608,609,610,612,613,614,616,617,623,357,242,244,245,246,247,624,625,626,627,629,630,628,631,420,421,422,423,427,428,589,402,403,404,405,406,408,415,416,338,179,180,165,182,184,185,186,187,188,189,190,191,192,193,195,196],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/__init__.py":[1],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/login.py":[1,3,6,7,10,12,19,27,28,30,17],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/resource.py":[1,4,5,8,15,13,25],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/loginv2.py":[1,3,6,7,10,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/getprofile.py":[1,3,6,7,10,12,19,24,17],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/auth.py":[1,3,6,7,10],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/token.py":[1,3,4,7,8,11,13,16,23],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/appinit.py":[1,3,6,7,10,12,19],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/billing.py":[1,3,6,7,10],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/buyback.py":[1,3,4,7,8,11,13,20],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/changebalance.py":[1,3,4,7,8,11,13,20],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/profile.py":[1,3,6,7,10],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/__init__.py":[1],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/client.py":[1,3,4,5,6,7,11,12,14,24,39,236,242,248,19,20,21,22,23,245,246,247,41,42,44,46,51,64,84,89,91,93,94,98,99,103,104,108,109,113,123,129,133,136,140,142,144,146,148,150,152,155,161,164,166,168,170,172,175,177,179,181,183,185,187,189,191,193,195,197,202,204,47,85,86,203],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/constants.py":[1,3],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/global_value.py":[2],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/__init__.py":[1],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/ssid.py":[1,3,6,7,10,12,17],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/base.py":[1,4,5,8,15,13,23],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/subscribe.py":[1,3,4,5,6,7,10,12,26,27,30,32,44,45,47,62],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/unsubscribe.py":[1,3,4,5,6,7,10,12,25,26,29,31,43,44,46,60],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/setactives.py":[1,3,6,7,10,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/candles.py":[1,3,4,6,7,10,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/buyv2.py":[1,2,3,4,5,6,7,9,10,13,15,75],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/expiration.py":[2,3,10,15,49],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/buyv3.py":[1,2,3,4,6,7,9,11,62],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/api_game_betinfo.py":[1,2,3,4,5,6,7],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/instruments.py":[1,3,6,7,10,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_financial_information.py":[1,2,3,4],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/strike_list.py":[1,2,3,4,5,7,23],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/traders_mood.py":[1,2,3,6,8,10,28,30,32],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/buy_place_order_temp.py":[1,2,3,7,8,9],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_order.py":[1,2,3,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_deferred_orders.py":[1,2,4,6,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_positions.py":[1,2,3,6,7,8,17,18,19,28,29,30,40,41,42],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_available_leverages.py":[1,2,3,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/cancel_order.py":[1,2,3,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/close_position.py":[1,2,3,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/get_overnight_fee.py":[1,2,3,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/heartbeat.py":[1,2,3,4,6,9,10,11,15],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/digital_option.py":[3,4,5,9,10,11,24,25,26],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/api_game_getoptions.py":[2,4,5,7,9,11],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/sell_option.py":[2,3,5,6,7],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/change_tpsl.py":[3,4,5,6,7,8],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/change_auto_margin_call.py":[1,2,3,4,5,6],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/__init__.py":[1],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/timesync.py":[1,3,4,6,9,10,12,18,26,31,39,47,55,63,13,14,15,16,29,24],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/base.py":[1,4,5,8,11,9],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/profile.py":[1,2,5,6,8,18,26,31,39,45,52,59,66,75,82,88,91,9,10,11,12,13,14,15,93,42,55,69,85,37],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/candles.py":[1,3,6,7,9,15,23,31,39,47,55,67,68,70,75,83,88,97,106,71,72,73],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/listinfodata.py":[1,2,4,6,7,9,14,16,18,10,11,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/objects/betinfo.py":[2,3,6,7,9,14,18,23,27,10,11,12],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/setup.py":[],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/register.py":[],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/http/getregdata.py":[],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/changebalance.py":[],"/home/lu-yi-hsun/WorkSpace/GitHub/iqoptionapi/iqoptionapi/ws/chanels/buyback.py":[]}}
--------------------------------------------------------------------------------
/.gdb_history:
--------------------------------------------------------------------------------
1 | q
2 |
--------------------------------------------------------------------------------
/.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/iqoptionapi
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.py[cod]
2 | build/
3 | dist/
4 | *.egg-info/
5 | .vscode/
6 | /.vs
7 | venv/
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 |
2 | # IQ Option API
3 |
4 | ## How to contribute:
5 |
6 | Fork this project.
7 |
8 | Clone your project.
9 |
10 | Remove default remote
11 | ```
12 | git remote remove origin
13 | ```
14 | Register in your local project the following remote:
15 |
16 | pull remote should be my repository
17 | ```
18 | git remote add origin git@github.com:evecimar/iqoptionapi.git
19 | ```
20 | push remote should be your repository
21 | ```
22 | git remote set-url --push origin git@github.com:your_repository/iqoptionapi.git
23 | ```
24 |
25 | Set like a default repository
26 |
27 | ```
28 | git branch --set-upstream-to=origin/master master
29 | ```
30 | make a pull request to send me your contribution
31 |
32 | [](https://travis-ci.org/Lu-Yi-Hsun/iqoptionapi)
33 | [](https://codecov.io/gh/Lu-Yi-Hsun/iqoptionapi)
34 |
35 | [](https://www.paypal.me/iqoptionapi)
36 |
37 | ## last update:2020/02/29
38 |
39 | ### Version: 5.1.1
40 |
41 | #### fix change_balance
42 |
43 | ```python
44 | from iqoptionapi.stable_api import IQ_Option
45 | email = "your@mail.ocm"
46 | password = "your_password"
47 | account_mode = "real" # real/practic
48 |
49 | I_want_money = IQ_Option(email,password, account_mode)
50 |
51 | balance_id = I_want_money.change_balance("practic")
52 |
53 | ```
54 | #### Add option balance_mode on create IQ_Option objetct.
55 |
56 | ```python
57 | from iqoptionapi.stable_api import IQ_Option
58 | email = "your@mail.ocm"
59 | password = "your_password"
60 | account_mode = "real" # real/practic
61 |
62 | I_want_money = IQ_Option(email,password, account_mode)
63 |
64 | ```
65 |
66 | last update:2019/11/22
67 |
68 | Version:5.1
69 | add[get_option_open_by_other_pc](#getoptionopenbyotherpc) api
70 |
71 |
72 | Version:5.0
73 |
74 | please donate >< get_digital_spot_profit_after_sale pay me lot of time
75 |
76 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/125
77 |
78 | add [get_digital_spot_profit_after_sale](#getdigitalspotprofitaftersale) api
79 |
80 | Version:4.5
81 |
82 | add [get_remaning](#getremaning) api
83 |
84 | Version:4.4
85 |
86 | fix check_win_digital(check_win_digital(Synchronous message) and check_win_digital_v2(Asynchronous messages) are different implement way)
87 |
88 | add get_digital_position()
89 |
90 | Version:4.3
91 |
92 | add subscribe_top_assets_updated & popularity
93 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/131
94 |
95 | Version:4.2
96 |
97 | add reconnect sample
98 | add get_async_order api
99 |
100 | Version:4.0.1
101 |
102 | fix get_positions()
103 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/132
104 |
105 | add get_optioninfo_v2
106 |
107 |
108 | Version:4.0.0
109 |
110 | :exclamation::exclamation::exclamation:
111 | update websocket-client==0.56
112 | :exclamation:
113 | please uninstall all websocket-client and update up websocket-client==0.56
114 | ```
115 | sudo pip uninstall websocket-client
116 | sudo pip install websocket-client==0.56
117 | ```
118 | :exclamation:
119 |
120 | ---
121 | ## About API
122 |
123 | only support US Dollar account
124 |
125 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/73#issue-406537365
126 |
127 | ```python
128 | #hight level api ,This api is write base on ""iqoptionapi.api" for more easy
129 | from iqoptionapi.stable_api import IQ_Option
130 | #low level api
131 | from iqoptionapi.api import IQOptionAPI
132 | ```
133 | ```bash
134 | .
135 | ├── docs
136 | ├── iqoptionapi(API code)
137 | ├── http(doing http get/post)
138 | └── ws
139 | ├── chanels(Doing websocket action)
140 | └── objects(Get back data from websocket action)
141 | ```
142 |
143 |
144 |
145 |
146 | ## Can not loging problem
147 |
148 | #### fix way 1
149 | ```bash
150 | sudo pip3 uninstall websocket-client
151 | sudo pip3 install websocket-client==0.56
152 | ```
153 |
154 |
155 |
156 | ### problem 2
157 |
158 | #### websocket conflict with websocket-client
159 |
160 | if you have this problem
161 |
162 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/66
163 |
164 | fix way
165 | ```bash
166 | sudo pip3 uninstall websocket
167 | sudo pip3 install websocket-client==0.47.0
168 | ```
169 |
170 | ---
171 |
172 | ## Installation & GET new version
173 | For Python3
174 | ```bash
175 | sudo pip3 install -U git+git://github.com/Lu-Yi-Hsun/iqoptionapi.git
176 | ```
177 | For Python2
178 | ```bash
179 | sudo pip2 install -U git+git://github.com/Lu-Yi-Hsun/iqoptionapi.git
180 | ```
181 | ---
182 | ## Littile sample
183 | ```python
184 | import time
185 | from iqoptionapi.stable_api import IQ_Option
186 | I_want_money=IQ_Option("email","password")
187 | goal="EURUSD"
188 | print("get candles")
189 | print(I_want_money.get_candles(goal,60,111,time.time()))
190 | ```
191 |
192 | ---
193 |
194 | ## Document
195 |
196 | ### Import
197 | ```python
198 | from iqoptionapi.stable_api import IQ_Option
199 | ```
200 | ---
201 | ### Debug mode on
202 |
203 | ```python
204 | import logging
205 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
206 | ```
207 | ---
208 | ### Login
209 | !!!
210 |
211 | Login NOT support SMS Authorization yet
212 |
213 | I suggest close it because your robot will stop to wait you to check sms code (on phone)....
214 |
215 | !!!
216 |
217 | ```python
218 | I_want_money=IQ_Option("email","password")
219 | ```
220 |
221 | ---
222 | ### set_max_reconnect
223 | default number is 5
224 |
225 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/22
226 |
227 | Protect if you get some error (iqoptionapi auto reconnect) too many time,IQoption will ban your IP
228 |
229 | ```
230 | I_want_money.set_max_reconnect(number)
231 | ```
232 |
233 | ---
234 | ### Reconnect&check connect
235 |
236 | some time connect will close so this way can check connect and reconnect
237 |
238 | try close your network and restart network in this sample
239 |
240 | ```python
241 | from iqoptionapi.stable_api import IQ_Option
242 | import logging
243 | import time
244 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
245 | I_want_money=IQ_Option("email","password")
246 | I_want_money.set_max_reconnect(-1)#allow unlimited reconnect
247 | while True:
248 | #you can !!close yuor network!! to simulation network fails
249 | if I_want_money.check_connect()==False:#detect the websocket is close
250 | print("try reconnect")
251 | I_want_money.connect()#try to connect
252 | print("reconnect Success")
253 | time.sleep(1)
254 | ```
255 |
256 |
257 |
258 | ---
259 | ### Check version
260 |
261 | ```python
262 | from iqoptionapi.stable_api import IQ_Option
263 | print(IQ_Option.__version__)
264 | ```
265 | ### Check connect
266 |
267 | return True/False
268 |
269 | ```python
270 | print(I_want_money.check_connect())
271 | ```
272 |
273 | ### Reconnect
274 | ```python
275 | I_want_money.connect()
276 | ```
277 | ---
278 |
279 | ### Check Asset if open or not
280 |
281 | :exclamation:be careful get_all_open_time() is very heavy for network.
282 |
283 | get_all_open_time() return the DICT
284 |
285 | "cfd" is include Stock,Commodities,ETFs asset
286 |
287 | DICT["forex"/"cfd"/"crypto"/"digital"/"turbo"/"binary"][Asset Name]["open"]
288 |
289 | it will return True/False
290 |
291 | ```python
292 | from iqoptionapi.stable_api import IQ_Option
293 | import logging
294 | import random
295 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
296 | I_want_money=IQ_Option("email","password")
297 | ALL_Asset=I_want_money.get_all_open_time()
298 | #check if open or not
299 | print(ALL_Asset["forex"]["EURUSD"]["open"])
300 | print(ALL_Asset["cfd"]["FACEBOOK"]["open"])#Stock,Commodities,ETFs
301 | print(ALL_Asset["crypto"]["BTCUSD-L"]["open"])
302 | print(ALL_Asset["digital"]["EURUSD-OTC"]["open"])
303 |
304 | #Binary have two diffenence type:"turbo","binary"
305 | print(ALL_Asset["turbo"]["EURUSD-OTC"]["open"])
306 | print(ALL_Asset["binary"]["EURUSD-OTC"]["open"])
307 |
308 |
309 | #!!!! exception ""
310 | print(ALL_Asset["binary"]["not exist asset"]["open"])#it will return "{}" a None of the dict
311 |
312 | #!!!!print all!!!!
313 | for type_name, data in ALL_Asset.items():
314 | for Asset,value in data.items():
315 | print(type_name,Asset,value["open"])
316 | ```
317 |
318 | ### View all ACTIVES Name
319 | you will get right all ACTIVES and code
320 |
321 | [ACTIVES](iqoptionapi/constants.py)
322 |
323 | ```python
324 | print(I_want_money.get_all_ACTIVES_OPCODE())
325 | ```
326 |
327 | ---
328 |
329 | ### For all
330 |
331 | this api can work for option&digital&Forex&Stock&Commodities&Crypto&ETFs
332 |
333 | #### get_async_order
334 |
335 | get the order data by id
336 |
337 | ```python
338 | from iqoptionapi.stable_api import IQ_Option
339 | import logging
340 | import time
341 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
342 | I_want_money=IQ_Option("email","password")
343 |
344 | ACTIVES="EURUSD"
345 | duration=1#minute 1 or 5
346 | amount=1
347 | action="call"#put
348 |
349 | print("__For_Binary_Option__")
350 | _,id=I_want_money.buy(amount,ACTIVES,action,duration)
351 | while I_want_money.get_async_order(id)==None:
352 | pass
353 | print(I_want_money.get_async_order(id))
354 | print("\n\n")
355 |
356 | print("__For_Digital_Option__spot")
357 | id=I_want_money.buy_digital_spot(ACTIVES,amount,action,duration)
358 | while I_want_money.get_async_order(id)==None:
359 | pass
360 | order_data=I_want_money.get_async_order(id)
361 | print(I_want_money.get_async_order(id))
362 | print("\n\n")
363 |
364 | print("__For_Forex_Stock_Commodities_Crypto_ETFs")
365 | instrument_type="crypto"
366 | instrument_id="BTCUSD"
367 | side="buy"
368 | amount=1.23
369 | leverage=3
370 | type="market"
371 | limit_price=None
372 | stop_price=None
373 | stop_lose_kind="percent"
374 | stop_lose_value=95
375 | take_profit_kind=None
376 | take_profit_value=None
377 | use_trail_stop=True
378 | auto_margin_call=False
379 | use_token_for_commission=False
380 | check,id=I_want_money.buy_order(instrument_type=instrument_type, instrument_id=instrument_id,
381 | side=side, amount=amount,leverage=leverage,
382 | type=type,limit_price=limit_price, stop_price=stop_price,
383 | stop_lose_value=stop_lose_value, stop_lose_kind=stop_lose_kind,
384 | take_profit_value=take_profit_value, take_profit_kind=take_profit_kind,
385 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call,
386 | use_token_for_commission=use_token_for_commission)
387 | while I_want_money.get_async_order(id)==None:
388 | pass
389 | order_data=I_want_money.get_async_order(id)
390 | print(I_want_money.get_async_order(id))
391 | ```
392 |
393 |
394 | ### For Options
395 |
396 | #### BUY
397 |
398 | Sample
399 | ```python
400 | from iqoptionapi.stable_api import IQ_Option
401 | import logging
402 | import time
403 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
404 | I_want_money=IQ_Option("email","pass")
405 | goal="EURUSD"
406 | print("get candles")
407 | print(I_want_money.get_candles(goal,60,111,time.time()))
408 | Money=1
409 | ACTIVES="EURUSD"
410 | ACTION="call"#or "put"
411 | expirations_mode=1
412 |
413 | I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode)
414 | ```
415 |
416 | ```python
417 | I_want_money.buy(Money,ACTIVES,ACTION,expirations)
418 | #Money:How many you want to buy type(int)
419 | #ACTIVES:sample input "EURUSD" OR "EURGBP".... you can view by get_all_ACTIVES_OPCODE
420 | #ACTION:"call"/"put" type(str)
421 | #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/iqoptionapi/issues/6
422 | #return:(None/id_number):if sucess return (id_number) esle return(None) 2.1.5 change this
423 | ```
424 | #### buy_multi
425 |
426 | Sample
427 | ```python
428 | from iqoptionapi.stable_api import IQ_Option
429 | I_want_money=IQ_Option("email","password")
430 | Money=[]
431 | ACTIVES=[]
432 | ACTION=[]
433 | expirations_mode=[]
434 |
435 | Money.append(1)
436 | ACTIVES.append("EURUSD")
437 | ACTION.append("call")#put
438 | expirations_mode.append(1)
439 |
440 | Money.append(1)
441 | ACTIVES.append("EURAUD")
442 | ACTION.append("call")#put
443 | expirations_mode.append(1)
444 |
445 | print("buy multi")
446 | id_list=I_want_money.buy_multi(Money,ACTIVES,ACTION,expirations_mode)
447 |
448 | print("check win only one id (id_list[0])")
449 | print(I_want_money.check_win_v2(id_list[0]))
450 | ```
451 |
452 | #### get_remaning
453 |
454 | purchase time=remaning time - 30
455 |
456 | ```python
457 | from iqoptionapi.stable_api import IQ_Option
458 | I_want_money=IQ_Option("email","password")
459 | Money=1
460 | ACTIVES="EURUSD"
461 | ACTION="call"#or "put"
462 | expirations_mode=1
463 | while True:
464 | remaning_time=I_want_money.get_remaning(expirations_mode)
465 | purchase_time=remaning_time-30
466 | if purchase_time<4:#buy the binary option at purchase_time<4
467 | I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode)
468 | break
469 | ```
470 |
471 | #### sell_option
472 |
473 | ```python
474 | I_want_money.sell_option(sell_all)#input int or list
475 | ```
476 |
477 | Sample
478 |
479 | ```python
480 | from iqoptionapi.stable_api import IQ_Option
481 | import time
482 | print("login...")
483 | I_want_money=IQ_Option("email","password")
484 |
485 | Money=1
486 | ACTIVES="EURUSD"
487 | ACTION="call"#or "put"
488 | expirations_mode=1
489 |
490 | id=I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode)
491 | id2=I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode)
492 |
493 | time.sleep(5)
494 | sell_all=[]
495 | sell_all.append(id)
496 | sell_all.append(id2)
497 | print(I_want_money.sell_option(sell_all))
498 | ```
499 | #### check win
500 |
501 | (only for option)
502 |
503 | It will do loop until get win or loose
504 |
505 | :exclamation:
506 |
507 | it have a little problem when network close and reconnect miss get "listInfoData"
508 |
509 | this function will doing Infinity loop
510 |
511 | ```python
512 | I_want_money.check_win(23243221)
513 | #""you need to get id_number from buy function""
514 | #I_want_money.check_win(id_number)
515 | #this function will do loop check your bet until if win/equal/loose
516 | ```
517 | ##### check_win_v2
518 |
519 | (only for option)
520 |
521 | more better way
522 |
523 | an other way to fix that(implement by get_betinfo)
524 |
525 | input by int
526 |
527 | ```python
528 | I_want_money.check_win_v2(23243221)
529 | #""you need to get id_number from buy function""
530 | #I_want_money.check_win_v2(id_number)
531 | #this function will do loop check your bet until if win/equal/loose
532 | ```
533 |
534 | ---
535 | "get_binary_option_detail" and "get_all_profit" are base on "get_all_init()",if you want raw data you can call
536 | ```python
537 | I_want_money.get_all_init()
538 | ```
539 |
540 | ---
541 |
542 |
543 |
544 | 
545 |
546 | #### get_binary_option_detail
547 |
548 | sample
549 | ```python
550 | from iqoptionapi.stable_api import IQ_Option
551 | print("login...")
552 | I_want_money=IQ_Option("email","password")
553 | d=I_want_money.get_binary_option_detail()
554 | print(d["CADCHF"]["turbo"])
555 | print(d["CADCHF"]["binary"])
556 | ```
557 |
558 | #### get all profit
559 | sample
560 | ```python
561 | from iqoptionapi.stable_api import IQ_Option
562 | print("login...")
563 | I_want_money=IQ_Option("email","password")
564 | d=I_want_money.get_all_profit()
565 | print(d["CADCHF"]["turbo"])
566 | print(d["CADCHF"]["binary"])
567 | ```
568 | ---
569 | #### get_betinfo
570 |
571 | (only for option)
572 |
573 | it will get infomation about Bet by "id"
574 |
575 | :exclamation:
576 |
577 | if your bet(id) not have answer yet(game_state) or wrong id it will return False
578 | input by int
579 |
580 | ```python
581 |
582 | isSuccessful,dict=I_want_money.get_betinfo(4452272449)
583 | #I_want_money.get_betinfo
584 | #INPUT: int
585 | #OUTPUT:isSuccessful,dict
586 |
587 | ```
588 | #### get_optioninfo
589 |
590 | input how many data you want to get from Trading History(only for binary option)
591 |
592 | ```
593 | print(I_want_money.get_optioninfo(10))
594 | ```
595 | #### get_optioninfo_v2
596 |
597 | input how many data you want to get from Trading History(only for binary option)
598 |
599 | ```
600 | print(I_want_money.get_optioninfo_v2(10))
601 | ```
602 | #### get_option_open_by_other_pc
603 |
604 | if your account is login in other plance/PC and doing buy option
605 |
606 | you can get the option by this function
607 |
608 | ```python
609 | import time
610 | from iqoptionapi.stable_api import IQ_Option
611 | I_want_money=IQ_Option("email","password")
612 | while True:
613 | #please open website iqoption and buy some binary option
614 | if I_want_money.get_option_open_by_other_pc()!={}:
615 | break
616 | time.sleep(1)
617 | print("Get option from other Pc and same account")
618 | print(I_want_money.get_option_open_by_other_pc())
619 |
620 | id=list(I_want_money.get_option_open_by_other_pc().keys())[0]
621 | I_want_money.del_option_open_by_other_pc(id)
622 | print("After del by id")
623 | print(I_want_money.get_option_open_by_other_pc())
624 | ```
625 |
626 | ___
627 | ---
628 | ### For Digital
629 | [Digital options buy with actual price sample code](https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/65#issuecomment-511660908)
630 |
631 | #### Sample
632 |
633 | ```python
634 | from iqoptionapi.stable_api import IQ_Option
635 | import time
636 | import random
637 | I_want_money=IQ_Option("email","password")
638 |
639 | ACTIVES="EURUSD"
640 | duration=1#minute 1 or 5
641 | amount=1
642 | I_want_money.subscribe_strike_list(ACTIVES,duration)
643 | #get strike_list
644 | data=I_want_money.get_realtime_strike_list(ACTIVES, duration)
645 | print("get strike data")
646 | print(data)
647 | """data
648 | {'1.127100':
649 | { 'call':
650 | { 'profit': None,
651 | 'id': 'doEURUSD201811120649PT1MC11271'
652 | },
653 | 'put':
654 | { 'profit': 566.6666666666666,
655 | 'id': 'doEURUSD201811120649PT1MP11271'
656 | }
657 | }............
658 | }
659 | """
660 | #get price list
661 | price_list=list(data.keys())
662 | #random choose Strategy
663 | choose_price=price_list[random.randint(0,len(price_list)-1)]
664 | #get instrument_id
665 | instrument_id=data[choose_price]["call"]["id"]
666 | #get profit
667 | profit=data[choose_price]["call"]["profit"]
668 | print("choose you want to buy")
669 | print("price:",choose_price,"side:call","instrument_id:",instrument_id,"profit:",profit)
670 | #put instrument_id to buy
671 | buy_check,id=I_want_money.buy_digital(amount,instrument_id)
672 | if buy_check:
673 | print("wait for check win")
674 | #check win
675 | while True:
676 | check_close,win_money=I_want_money.check_win_digital_v2(id)
677 | if check_close:
678 | if float(win_money)>0:
679 | win_money=("%.2f" % (win_money))
680 | print("you win",win_money,"money")
681 | else:
682 | print("you loose")
683 | break
684 | I_want_money.unsubscribe_strike_list(ACTIVES,duration)
685 | else:
686 | print("fail to buy,please run again")
687 | ```
688 | #### Get all strike list data
689 |
690 | ##### Data format
691 |
692 | ```python
693 |
694 | {'1.127100': { 'call': {'profit': None, 'id': 'doEURUSD201811120649PT1MC11271'}, 'put': {'profit': 566.6666666666666, 'id': 'doEURUSD201811120649PT1MP11271'} }.......}
695 | ```
696 |
697 | ##### sample
698 |
699 | ```python
700 | from iqoptionapi.stable_api import IQ_Option
701 | import time
702 | I_want_money=IQ_Option("email","password")
703 | ACTIVES="EURUSD"
704 | duration=1#minute 1 or 5
705 | I_want_money.subscribe_strike_list(ACTIVES,duration)
706 | while True:
707 | data=I_want_money.get_realtime_strike_list(ACTIVES, duration)
708 | for price in data:
709 | print("price",price,data[price])
710 | time.sleep(5)
711 | I_want_money.unsubscribe_strike_list(ACTIVES,duration)
712 | ```
713 |
714 | #### buy_digital_spot
715 |
716 | buy the digit in current price
717 |
718 | ```python
719 | from iqoptionapi.stable_api import IQ_Option
720 |
721 | I_want_money=IQ_Option("email","password")
722 |
723 | ACTIVES="EURUSD"
724 | duration=1#minute 1 or 5
725 | amount=1
726 | action="call"#put
727 | print(I_want_money.buy_digital_spot(ACTIVES,amount,action,duration))
728 | ```
729 |
730 | #### get_digital_spot_profit_after_sale
731 |
732 | get Profit After Sale(P/L)
733 | 
734 | ```python
735 | from iqoptionapi.stable_api import IQ_Option
736 | I_want_money=IQ_Option("email","passord")
737 | ACTIVES="EURUSD"
738 | duration=1#minute 1 or 5
739 | amount=100
740 | action="put"#put
741 |
742 | I_want_money.subscribe_strike_list(ACTIVES,duration)
743 | id=I_want_money.buy_digital_spot(ACTIVES,amount,action,duration)
744 |
745 | while True:
746 | PL=I_want_money.get_digital_spot_profit_after_sale(id)
747 | if PL!=None:
748 | print(PL)
749 |
750 | ```
751 |
752 | #### get_digital_current_profit
753 |
754 | get current price profit
755 |
756 |
757 | ```python
758 | from iqoptionapi.stable_api import IQ_Option
759 | import time
760 | import logging
761 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
762 | I_want_money=IQ_Option("email","password")
763 | ACTIVES="EURUSD"
764 | duration=1#minute 1 or 5
765 | I_want_money.subscribe_strike_list(ACTIVES,duration)
766 | while True:
767 | data=I_want_money.get_digital_current_profit(ACTIVES, duration)
768 | print(data)#from first print it may be get false,just wait a second you can get the profit
769 | time.sleep(1)
770 | I_want_money.unsubscribe_strike_list(ACTIVES,duration)
771 | ```
772 |
773 | #### Buy digit
774 | ```python
775 | buy_check,id=I_want_money.buy_digital(amount,instrument_id)
776 | #get instrument_id from I_want_money.get_realtime_strike_list
777 | ```
778 | #### check win for digital
779 |
780 | ##### check_win_digital
781 |
782 |
783 | this api is implement by get_digital_position()
784 |
785 | ```python
786 | I_want_money.check_win_digital(id)#get the id from I_want_money.buy_digital
787 | #return:check_close,win_money
788 | #return sample
789 | #if you loose:Ture,o
790 | #if you win:True,1232.3
791 | #if trade not clode yet:False,None
792 | ```
793 | ##### check_win_digital_v2
794 |
795 | :exclamation::exclamation: 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"!
796 |
797 | ```python
798 | I_want_money.check_win_digital_v2(id)#get the id from I_want_money.buy_digital
799 | #return:check_close,win_money
800 | #return sample
801 | #if you loose:Ture,o
802 | #if you win:True,1232.3
803 | #if trade not clode yet:False,None
804 | ```
805 |
806 | sample code
807 |
808 | ```python
809 | from iqoptionapi.stable_api import IQ_Option
810 | import logging
811 | import random
812 | import time
813 | import datetime
814 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
815 | I_want_money=IQ_Option("email","password")
816 |
817 |
818 | ACTIVES="EURUSD"
819 | duration=1#minute 1 or 5
820 | amount=1
821 | action="call"#put
822 | id=(I_want_money.buy_digital_spot(ACTIVES,amount,action,duration))
823 | print(id)
824 | if id !="error":
825 | while True:
826 | check,win=I_want_money.check_win_digital_v2(id)
827 | if check==True:
828 | break
829 | if win<0:
830 | print("you loss "+str(win)+"$")
831 | else:
832 | print("you win "+str(win)+"$")
833 | else:
834 | print("please try again")
835 | ```
836 |
837 |
838 | #### close digital
839 | ```python
840 | I_want_money.close_digital_option(id)
841 | ```
842 | #### get digital data
843 |
844 | ##### sample1
845 |
846 | ```python
847 | from iqoptionapi.stable_api import IQ_Option
848 | import logging
849 | import time
850 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
851 | I_want_money=IQ_Option("email","password")
852 | ACTIVES="EURUSD-OTC"
853 | duration=1#minute 1 or 5
854 | amount=1
855 | action="call"#put
856 | from datetime import datetime
857 |
858 | id=I_want_money.buy_digital_spot(ACTIVES,amount,action,duration)
859 |
860 | while True:
861 | check,_=I_want_money.check_win_digital(id)
862 | if check:
863 | break
864 | print(I_want_money.get_digital_position(id))
865 | print(I_want_money.check_win_digital(id))
866 | ```
867 | #####sample 2
868 |
869 | ```python
870 | #print(I_want_money.get_order(id))#not work for digital
871 | print(I_want_money.get_positions("digital-option"))
872 | print(I_want_money.get_digital_position(2323433))#in put the id
873 | print(I_want_money.get_position_history("digital-option"))
874 | ```
875 |
876 |
877 | ---
878 | ### For Forex&Stock&Commodities&Crypto&ETFs
879 |
880 | #### you need to check Asset is open or close!
881 |
882 | try this api [get_all_open_time](#checkopen)
883 | 
884 |
885 |
886 |
887 | #### About instrument_type and instrument_id
888 |
889 | you can search instrument_type and instrument_id from this file
890 |
891 | [search instrument_type and instrument_id](instrument.txt)
892 |
893 |
894 | #### Sample
895 | ```python
896 | from iqoptionapi.stable_api import IQ_Option
897 | I_want_money=IQ_Option("email","password")
898 |
899 | instrument_type="crypto"
900 | instrument_id="BTCUSD"
901 | side="buy"#input:"buy"/"sell"
902 | amount=1.23#input how many Amount you want to play
903 |
904 | #"leverage"="Multiplier"
905 | leverage=3#you can get more information in get_available_leverages()
906 |
907 | type="market"#input:"market"/"limit"/"stop"
908 |
909 | #for type="limit"/"stop"
910 |
911 | # only working by set type="limit"
912 | limit_price=None#input:None/value(float/int)
913 |
914 | # only working by set type="stop"
915 | stop_price=None#input:None/value(float/int)
916 |
917 | #"percent"=Profit Percentage
918 | #"price"=Asset Price
919 | #"diff"=Profit in Money
920 |
921 | stop_lose_kind="percent"#input:None/"price"/"diff"/"percent"
922 | stop_lose_value=95#input:None/value(float/int)
923 |
924 | take_profit_kind=None#input:None/"price"/"diff"/"percent"
925 | take_profit_value=None#input:None/value(float/int)
926 |
927 | #"use_trail_stop"="Trailing Stop"
928 | use_trail_stop=True#True/False
929 |
930 | #"auto_margin_call"="Use Balance to Keep Position Open"
931 | auto_margin_call=False#True/False
932 | #if you want "take_profit_kind"&
933 | # "take_profit_value"&
934 | # "stop_lose_kind"&
935 | # "stop_lose_value" all being "Not Set","auto_margin_call" need to set:True
936 |
937 | use_token_for_commission=False#True/False
938 |
939 | check,order_id=I_want_money.buy_order(instrument_type=instrument_type, instrument_id=instrument_id,
940 | side=side, amount=amount,leverage=leverage,
941 | type=type,limit_price=limit_price, stop_price=stop_price,
942 | stop_lose_value=stop_lose_value, stop_lose_kind=stop_lose_kind,
943 | take_profit_value=take_profit_value, take_profit_kind=take_profit_kind,
944 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call,
945 | use_token_for_commission=use_token_for_commission)
946 | print(I_want_money.get_order(order_id))
947 | print(I_want_money.get_positions("crypto"))
948 | print(I_want_money.get_position_history("crypto"))
949 | print(I_want_money.get_available_leverages("crypto","BTCUSD"))
950 | print(I_want_money.close_position(order_id))
951 | print(I_want_money.get_overnight_fee("crypto","BTCUSD"))
952 | ```
953 |
954 |
955 |
956 |
957 | #### Buy
958 |
959 | return (True/False,buy_order_id/False)
960 |
961 | if Buy sucess return (True,buy_order_id)
962 |
963 | "percent"=Profit Percentage
964 |
965 | "price"=Asset Price
966 |
967 | "diff"=Profit in Money
968 |
969 | |parameter|||||
970 | --|--|--|--|--|
971 | instrument_type|[instrument_type](#instrumenttypeid)
972 | instrument_id| [instrument_id](#instrumenttypeid)
973 | side|"buy"|"sell"
974 | amount|value(float/int)
975 | leverage|value(int)
976 | type|"market"|"limit"|"stop"
977 | limit_price|None|value(float/int):Only working by set type="limit"
978 | stop_price|None|value(float/int):Only working by set type="stop"
979 | stop_lose_kind|None|"price"|"diff"|"percent"
980 | stop_lose_value|None|value(float/int)
981 | take_profit_kind|None|"price"|"diff"|"percent"
982 | take_profit_value|None|value(float/int)
983 | use_trail_stop|True|False
984 | auto_margin_call|True|False
985 | use_token_for_commission|True|False
986 |
987 | ```python
988 | check,order_id=I_want_money.buy_order(
989 | instrument_type=instrument_type, instrument_id=instrument_id,
990 | side=side, amount=amount,leverage=leverage,
991 | type=type,limit_price=limit_price, stop_price=stop_price,
992 | stop_lose_kind=stop_lose_kind,
993 | stop_lose_value=stop_lose_value,
994 | take_profit_kind=take_profit_kind,
995 | take_profit_value=take_profit_value,
996 | use_trail_stop=use_trail_stop, auto_margin_call=auto_margin_call,
997 | use_token_for_commission=use_token_for_commission)
998 |
999 | ```
1000 | #### change_order
1001 |
1002 | ##### change PENDING
1003 | 
1004 |
1005 | ##### change Position
1006 | 
1007 |
1008 | |parameter|||||
1009 | --|--|--|--|--|
1010 | ID_Name|"position_id"|"order_id"
1011 | order_id|"you need to get order_id from buy_order()"
1012 | stop_lose_kind|None|"price"|"diff"|"percent"
1013 | stop_lose_value|None|value(float/int)
1014 | take_profit_kind|None|"price"|"diff"|"percent"
1015 | take_profit_value|None|value(float/int)
1016 | use_trail_stop|True|False
1017 | auto_margin_call|True|False
1018 |
1019 |
1020 | ##### sample
1021 | ```python
1022 | ID_Name="order_id"#"position_id"/"order_id"
1023 | stop_lose_kind=None
1024 | stop_lose_value=None
1025 | take_profit_kind="percent"
1026 | take_profit_value=200
1027 | use_trail_stop=False
1028 | auto_margin_call=True
1029 | I_want_money.change_order(ID_Name=ID_Name,order_id=order_id,
1030 | stop_lose_kind=stop_lose_kind,stop_lose_value=stop_lose_value,
1031 | take_profit_kind=take_profit_kind,take_profit_value=take_profit_value,
1032 | use_trail_stop=use_trail_stop,auto_margin_call=auto_margin_call)
1033 | ```
1034 |
1035 | ---
1036 |
1037 |
1038 | #### get_order
1039 |
1040 |
1041 | get infomation about buy_order_id
1042 |
1043 | return (True/False,get_order,None)
1044 |
1045 | ```python
1046 | I_want_money.get_order(buy_order_id)
1047 | ```
1048 |
1049 | #### get_pending
1050 | you will get there data
1051 |
1052 | 
1053 |
1054 | ```python
1055 | I_want_money.get_pending(instrument_type)
1056 | ```
1057 | #### get_positions
1058 |
1059 | you will get there data
1060 |
1061 | 
1062 |
1063 | return (True/False,get_positions,None)
1064 |
1065 |
1066 | :exclamation: not support ""turbo-option""
1067 |
1068 | instrument_type="crypto","forex","fx-option","multi-option","cfd","digital-option"
1069 |
1070 | ```python
1071 | I_want_money.get_positions(instrument_type)
1072 | ```
1073 |
1074 | #### get_position
1075 | you will get there data
1076 |
1077 | 
1078 |
1079 | you will get one position by buy_order_id
1080 |
1081 | return (True/False,position data,None)
1082 |
1083 | ```python
1084 | I_want_money.get_positions(buy_order_id)
1085 | ```
1086 |
1087 | #### get_position_history
1088 |
1089 | you will get there data
1090 |
1091 | 
1092 |
1093 | return (True/False,position_history,None)
1094 |
1095 | ```python
1096 | I_want_money.get_position_history(instrument_type)
1097 | ```
1098 | #### get_position_history_v2
1099 |
1100 | instrument_type="crypto","forex","fx-option","turbo-option","multi-option","cfd","digital-option"
1101 |
1102 | get_position_history_v2(instrument_type,limit,offset,start,end)
1103 |
1104 | ```python
1105 | from iqoptionapi.stable_api import IQ_Option
1106 | import logging
1107 | import random
1108 | import time
1109 | import datetime
1110 | logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
1111 | I_want_money=IQ_Option("email","password")
1112 |
1113 | #instrument_type="crypto","forex","fx-option","turbo-option","multi-option","cfd","digital-option"
1114 | instrument_type="digital-option"
1115 | limit=2#How many you want to get
1116 | offset=0#offset from end time,if end time is 0,it mean get the data from now
1117 | start=0#start time Timestamp
1118 | end=0#Timestamp
1119 | data=I_want_money.get_position_history_v2(instrument_type,limit,offset,start,end)
1120 |
1121 | print(data)
1122 |
1123 | #--------- 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
1124 | instrument_type="digital-option"
1125 | limit=2#How many you want to get
1126 | offset=0#offset from end time,if end time is 0,it mean get the data from now
1127 | start=int(time.mktime(datetime.datetime.strptime("2019/1/1", "%Y/%m/%d").timetuple()))
1128 | end=int(time.mktime(datetime.datetime.strptime("2019/7/1", "%Y/%m/%d").timetuple()))
1129 | data=I_want_money.get_position_history_v2(instrument_type,limit,offset,start,end)
1130 | print(data)
1131 |
1132 | ```
1133 |
1134 | #### get_available_leverages
1135 |
1136 | get available leverages
1137 |
1138 | return (True/False,available_leverages,None)
1139 |
1140 | ```python
1141 | I_want_money.get_available_leverages(instrument_type,actives)
1142 | ```
1143 | #### cancel_order
1144 |
1145 | you will do this
1146 |
1147 | 
1148 |
1149 | return (True/False)
1150 |
1151 | ```python
1152 | I_want_money.cancel_order(buy_order_id)
1153 | ```
1154 |
1155 | #### close_position
1156 |
1157 | you will do this
1158 |
1159 | 
1160 |
1161 | return (True/False)
1162 |
1163 | ```python
1164 | I_want_money.close_position(buy_order_id)
1165 | ```
1166 |
1167 | #### get_overnight_fee
1168 |
1169 | return (True/False,overnight_fee,None)
1170 |
1171 | ```python
1172 | I_want_money.get_overnight_fee(instrument_type,active)
1173 | ```
1174 | ---
1175 | ---
1176 |
1177 | ### Candle
1178 |
1179 | #### get candles
1180 | :exclamation:
1181 |
1182 | get_candles can not get "real time data" ,it will late about 30sec
1183 |
1184 | if you very care about real time you need use
1185 |
1186 | "get realtime candles" OR "collect realtime candles"
1187 |
1188 | sample
1189 |
1190 | ""now"" time 1:30:45sec
1191 |
1192 | 1. you want to get candles 1:30:45sec now
1193 |
1194 | you may get 1:30:15sec data have been late approximately 30sec
1195 |
1196 | 2. you want to get candles 1:00:33sec
1197 |
1198 | you will get the right data
1199 |
1200 | ```python
1201 | I_want_money.get_candles(ACTIVES,interval,count,endtime)
1202 | #ACTIVES:sample input "EURUSD" OR "EURGBP".... youcan
1203 | #interval:duration of candles
1204 | #count:how many candles you want to get from now to past
1205 | #endtime:get candles from past to "endtime"
1206 | ```
1207 | :exclamation:
1208 | try this code to get more than 1000 candle
1209 | ```python
1210 | from iqoptionapi.stable_api import IQ_Option
1211 | import time
1212 | I_want_money=IQ_Option("email","password")
1213 | end_from_time=time.time()
1214 | ANS=[]
1215 | for i in range(70):
1216 | data=I_want_money.get_candles("EURUSD", 60, 1000, end_from_time)
1217 | ANS =data+ANS
1218 | end_from_time=int(data[0]["from"])-1
1219 | print(ANS)
1220 | ```
1221 |
1222 | #### get realtime candles
1223 |
1224 | ##### Sample
1225 | ```python
1226 | from iqoptionapi.stable_api import IQ_Option
1227 | import logging
1228 | import time
1229 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
1230 | print("login...")
1231 | I_want_money=IQ_Option("email","password")
1232 | goal="EURUSD"
1233 | size="all"#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
1234 | maxdict=10
1235 | print("start stream...")
1236 | I_want_money.start_candles_stream(goal,size,maxdict)
1237 | #DO something
1238 | print("Do something...")
1239 | time.sleep(10)
1240 |
1241 | print("print candles")
1242 | cc=I_want_money.get_realtime_candles(goal,size)
1243 | for k in cc:
1244 | print(goal,"size",k,cc[k])
1245 | print("stop candle")
1246 | I_want_money.stop_candles_stream(goal,size)
1247 | ```
1248 |
1249 | ##### start_candles_stream
1250 |
1251 | * input:
1252 | * goal:"EURUSD"...
1253 | * size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
1254 | * maxdict:set max buffer you want to save
1255 |
1256 | size
1257 |
1258 | 
1259 |
1260 | ##### get_realtime_candles
1261 | * input:
1262 | * goal:"EURUSD"...
1263 | * size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
1264 | * output:
1265 | * dict
1266 | ##### stop_candles_stream
1267 | * input:
1268 | * goal:"EURUSD"...
1269 | * size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
1270 |
1271 | ---
1272 | ### time
1273 |
1274 | #### get_server_timestamp
1275 | the get_server_timestamp time is sync with iqoption
1276 | ```python
1277 | I_want_money.get_server_timestamp()
1278 | ```
1279 |
1280 | #### Purchase Time
1281 | this sample get the Purchase time clock
1282 | ```python
1283 | import time
1284 |
1285 | #get the end of the timestamp by expiration time
1286 | def get_expiration_time(t):
1287 | exp=time.time()#or I_want_money.get_server_timestamp() to get more Precision
1288 | if (exp % 60) > 30:
1289 | end = exp - (exp % 60) + 60*(t+1)
1290 | else:
1291 | end = exp - (exp % 60)+60*(t)
1292 | return end
1293 |
1294 | expiration_time=2
1295 |
1296 | end_time=0
1297 | while True:
1298 | if end_time-time.time()-30<=0:
1299 | end_time = get_expiration_time(expiration_time)
1300 | print(end_time-time.time()-30)
1301 | time.sleep(1)
1302 | ```
1303 | ---
1304 | ### Get top_assets_updated
1305 |
1306 | instrument_type="binary-option"/"digital-option"/"forex"/"cfd"/"crypto"
1307 |
1308 | ```python
1309 | from iqoptionapi.stable_api import IQ_Option
1310 | import logging
1311 | import time
1312 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
1313 | I_want_money=IQ_Option("email","password")
1314 | instrument_type="digital-option"#"binary-option"/"digital-option"/"forex"/"cfd"/"crypto"
1315 | I_want_money.subscribe_top_assets_updated(instrument_type)
1316 |
1317 | print("__Please_wait_for_sec__")
1318 | while True:
1319 | if I_want_money.get_top_assets_updated(instrument_type)!=None:
1320 | print(I_want_money.get_top_assets_updated(instrument_type))
1321 | print("\n\n")
1322 | time.sleep(1)
1323 | I_want_money.unsubscribe_top_assets_updated(instrument_type)
1324 | ```
1325 |
1326 | #### get popularity by top_assets_updated() api
1327 |
1328 | https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/131
1329 |
1330 | 
1331 |
1332 | ```python
1333 | from iqoptionapi.stable_api import IQ_Option
1334 | import logging
1335 | import time
1336 | import operator
1337 |
1338 | #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
1339 | def opcode_to_name(opcode_data,opcode):
1340 | return list(opcode_data.keys())[list(opcode_data.values()).index(opcode)]
1341 |
1342 | I_want_money=IQ_Option("email","password")
1343 | I_want_money.update_ACTIVES_OPCODE()
1344 | opcode_data=I_want_money.get_all_ACTIVES_OPCODE()
1345 |
1346 | instrument_type="digital-option"#"binary-option"/"digital-option"/"forex"/"cfd"/"crypto"
1347 | I_want_money.subscribe_top_assets_updated(instrument_type)
1348 |
1349 |
1350 | print("__Please_wait_for_sec__")
1351 | while True:
1352 | if I_want_money.get_top_assets_updated(instrument_type)!=None:
1353 | break
1354 |
1355 | top_assets=I_want_money.get_top_assets_updated(instrument_type)
1356 | popularity={}
1357 | for asset in top_assets:
1358 | opcode=asset["active_id"]
1359 | popularity_value=asset["popularity"]["value"]
1360 | try:
1361 | name=opcode_to_name(opcode_data,opcode)
1362 | popularity[name]=popularity_value
1363 | except:
1364 | pass
1365 |
1366 |
1367 | sorted_popularity = sorted(popularity.items(), key=operator.itemgetter(1))
1368 | print("__Popularity_min_to_max__")
1369 | for lis in sorted_popularity:
1370 | print(lis)
1371 |
1372 | I_want_money.unsubscribe_top_assets_updated(instrument_type)
1373 | ```
1374 |
1375 |
1376 | ---
1377 | ### Get mood
1378 |
1379 | for now... only support get binary option mood , i will implement beterr if need..
1380 |
1381 | Sample
1382 |
1383 | ```python
1384 | from iqoptionapi.stable_api import IQ_Option
1385 | I_want_money=IQ_Option("email","password")
1386 | goal="EURUSD"
1387 | I_want_money.start_mood_stream(goal)
1388 | print(I_want_money.get_traders_mood(goal))
1389 | I_want_money.stop_mood_stream(goal)
1390 | ```
1391 |
1392 | #### get_traders_mood
1393 |
1394 |
1395 | get percent of higher(call)
1396 |
1397 | if you want to know percent of lower(put) just 1-higher
1398 | ```python
1399 | I_want_money.get_traders_mood(goal)
1400 | #input:input "EURUSD" OR "EURGBP".... you can view by get_all_ACTIVES_OPCODE
1401 | #output:(float) the higher(call)%
1402 | #if you want to know lower(put)% try 1-I_want_money.get_traders_mood(goal)
1403 | ```
1404 | #### get_all_traders_mood
1405 | get all you start mood
1406 | ```python
1407 | I_want_money.get_all_traders_mood(goal)
1408 | #output:(dict) all mood you start
1409 | ```
1410 |
1411 | ### Account
1412 |
1413 | #### get balance
1414 | ```python
1415 | I_want_money.get_balance()
1416 | ```
1417 |
1418 |
1419 | #### reset practice balance
1420 |
1421 | reset practice balance to $10000
1422 |
1423 | ```python
1424 | from iqoptionapi.stable_api import IQ_Option
1425 | I_want_money=IQ_Option("email","password")
1426 | print(I_want_money.reset_practice_balance())
1427 | ```
1428 |
1429 | #### Change real/practice Account
1430 | ```python
1431 | I_want_money.change_balance(MODE)
1432 | #MODE: "PRACTICE"/"REAL"
1433 | ```
1434 |
1435 | ---
1436 |
1437 |
1438 |
1439 |
1440 |
1441 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import os
4 | import sys
5 |
6 | sys.path.insert(0, os.path.abspath(".."))
7 |
8 | extensions = ["sphinx.ext.todo",
9 | "sphinx.ext.viewcode",
10 | "sphinx.ext.autodoc"]
11 |
12 | master_doc = "index"
13 |
14 | autoclass_content = "both"
15 |
16 | html_static_path = ["_static"]
17 |
18 | templates_path = ["_templates"]
19 |
20 | project = "iqoptionapi"
21 |
22 | copyright = "2016, n1nj4z33"
23 |
24 | author = "n1nj4z33"
25 |
26 | version = "0.1"
27 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. iqoptionapi documentation master file, created by
2 | sphinx-quickstart on Sun Aug 28 16:48:39 2016.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to iqoptionapi's documentation!
7 | =======================================
8 |
9 | Contents:
10 |
11 | .. toctree::
12 | :maxdepth: 4
13 |
14 | modules
15 |
16 |
17 | Indices and tables
18 | ==================
19 |
20 | * :ref:`genindex`
21 | * :ref:`modindex`
22 | * :ref:`search`
23 |
24 |
--------------------------------------------------------------------------------
/docs/iqoptionapi.http.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi.http package
2 | ========================
3 |
4 | Submodules
5 | ----------
6 |
7 | iqoptionapi.http.appinit module
8 | -------------------------------
9 |
10 | .. automodule:: iqoptionapi.http.appinit
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | iqoptionapi.http.auth module
16 | ----------------------------
17 |
18 | .. automodule:: iqoptionapi.http.auth
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | iqoptionapi.http.billing module
24 | -------------------------------
25 |
26 | .. automodule:: iqoptionapi.http.billing
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
31 | iqoptionapi.http.buyback module
32 | -------------------------------
33 |
34 | .. automodule:: iqoptionapi.http.buyback
35 | :members:
36 | :undoc-members:
37 | :show-inheritance:
38 |
39 | iqoptionapi.http.changebalance module
40 | -------------------------------------
41 |
42 | .. automodule:: iqoptionapi.http.changebalance
43 | :members:
44 | :undoc-members:
45 | :show-inheritance:
46 |
47 | iqoptionapi.http.getprofile module
48 | ----------------------------------
49 |
50 | .. automodule:: iqoptionapi.http.getprofile
51 | :members:
52 | :undoc-members:
53 | :show-inheritance:
54 |
55 | iqoptionapi.http.getregdata module
56 | ----------------------------------
57 |
58 | .. automodule:: iqoptionapi.http.getregdata
59 | :members:
60 | :undoc-members:
61 | :show-inheritance:
62 |
63 | iqoptionapi.http.login module
64 | -----------------------------
65 |
66 | .. automodule:: iqoptionapi.http.login
67 | :members:
68 | :undoc-members:
69 | :show-inheritance:
70 |
71 | iqoptionapi.http.loginv2 module
72 | -------------------------------
73 |
74 | .. automodule:: iqoptionapi.http.loginv2
75 | :members:
76 | :undoc-members:
77 | :show-inheritance:
78 |
79 | iqoptionapi.http.profile module
80 | -------------------------------
81 |
82 | .. automodule:: iqoptionapi.http.profile
83 | :members:
84 | :undoc-members:
85 | :show-inheritance:
86 |
87 | iqoptionapi.http.register module
88 | --------------------------------
89 |
90 | .. automodule:: iqoptionapi.http.register
91 | :members:
92 | :undoc-members:
93 | :show-inheritance:
94 |
95 | iqoptionapi.http.resource module
96 | --------------------------------
97 |
98 | .. automodule:: iqoptionapi.http.resource
99 | :members:
100 | :undoc-members:
101 | :show-inheritance:
102 |
103 | iqoptionapi.http.token module
104 | -----------------------------
105 |
106 | .. automodule:: iqoptionapi.http.token
107 | :members:
108 | :undoc-members:
109 | :show-inheritance:
110 |
111 |
112 | Module contents
113 | ---------------
114 |
115 | .. automodule:: iqoptionapi.http
116 | :members:
117 | :undoc-members:
118 | :show-inheritance:
119 |
--------------------------------------------------------------------------------
/docs/iqoptionapi.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi package
2 | ===================
3 |
4 | Subpackages
5 | -----------
6 |
7 | .. toctree::
8 |
9 | iqoptionapi.http
10 | iqoptionapi.ws
11 |
12 | Submodules
13 | ----------
14 |
15 | iqoptionapi.api module
16 | ----------------------
17 |
18 | .. automodule:: iqoptionapi.api
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | iqoptionapi.constants module
24 | ----------------------------
25 |
26 | .. automodule:: iqoptionapi.constants
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
31 |
32 | Module contents
33 | ---------------
34 |
35 | .. automodule:: iqoptionapi
36 | :members:
37 | :undoc-members:
38 | :show-inheritance:
39 |
--------------------------------------------------------------------------------
/docs/iqoptionapi.ws.chanels.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi.ws.chanels package
2 | ==============================
3 |
4 | Submodules
5 | ----------
6 |
7 | iqoptionapi.ws.chanels.base module
8 | ----------------------------------
9 |
10 | .. automodule:: iqoptionapi.ws.chanels.base
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | iqoptionapi.ws.chanels.buyback module
16 | -------------------------------------
17 |
18 | .. automodule:: iqoptionapi.ws.chanels.buyback
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | iqoptionapi.ws.chanels.buyv2 module
24 | -----------------------------------
25 |
26 | .. automodule:: iqoptionapi.ws.chanels.buyv2
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
31 | iqoptionapi.ws.chanels.candles module
32 | -------------------------------------
33 |
34 | .. automodule:: iqoptionapi.ws.chanels.candles
35 | :members:
36 | :undoc-members:
37 | :show-inheritance:
38 |
39 | iqoptionapi.ws.chanels.setactives module
40 | ----------------------------------------
41 |
42 | .. automodule:: iqoptionapi.ws.chanels.setactives
43 | :members:
44 | :undoc-members:
45 | :show-inheritance:
46 |
47 | iqoptionapi.ws.chanels.ssid module
48 | ----------------------------------
49 |
50 | .. automodule:: iqoptionapi.ws.chanels.ssid
51 | :members:
52 | :undoc-members:
53 | :show-inheritance:
54 |
55 | iqoptionapi.ws.chanels.subscribe module
56 | ---------------------------------------
57 |
58 | .. automodule:: iqoptionapi.ws.chanels.subscribe
59 | :members:
60 | :undoc-members:
61 | :show-inheritance:
62 |
63 | iqoptionapi.ws.chanels.unsubscribe module
64 | -----------------------------------------
65 |
66 | .. automodule:: iqoptionapi.ws.chanels.unsubscribe
67 | :members:
68 | :undoc-members:
69 | :show-inheritance:
70 |
71 |
72 | Module contents
73 | ---------------
74 |
75 | .. automodule:: iqoptionapi.ws.chanels
76 | :members:
77 | :undoc-members:
78 | :show-inheritance:
79 |
--------------------------------------------------------------------------------
/docs/iqoptionapi.ws.objects.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi.ws.objects package
2 | ==============================
3 |
4 | Submodules
5 | ----------
6 |
7 | iqoptionapi.ws.objects.base module
8 | ----------------------------------
9 |
10 | .. automodule:: iqoptionapi.ws.objects.base
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 | iqoptionapi.ws.objects.candles module
16 | -------------------------------------
17 |
18 | .. automodule:: iqoptionapi.ws.objects.candles
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 | iqoptionapi.ws.objects.profile module
24 | -------------------------------------
25 |
26 | .. automodule:: iqoptionapi.ws.objects.profile
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
31 | iqoptionapi.ws.objects.timesync module
32 | --------------------------------------
33 |
34 | .. automodule:: iqoptionapi.ws.objects.timesync
35 | :members:
36 | :undoc-members:
37 | :show-inheritance:
38 |
39 |
40 | Module contents
41 | ---------------
42 |
43 | .. automodule:: iqoptionapi.ws.objects
44 | :members:
45 | :undoc-members:
46 | :show-inheritance:
47 |
--------------------------------------------------------------------------------
/docs/iqoptionapi.ws.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi.ws package
2 | ======================
3 |
4 | Subpackages
5 | -----------
6 |
7 | .. toctree::
8 |
9 | iqoptionapi.ws.chanels
10 | iqoptionapi.ws.objects
11 |
12 | Submodules
13 | ----------
14 |
15 | iqoptionapi.ws.client module
16 | ----------------------------
17 |
18 | .. automodule:: iqoptionapi.ws.client
19 | :members:
20 | :undoc-members:
21 | :show-inheritance:
22 |
23 |
24 | Module contents
25 | ---------------
26 |
27 | .. automodule:: iqoptionapi.ws
28 | :members:
29 | :undoc-members:
30 | :show-inheritance:
31 |
--------------------------------------------------------------------------------
/docs/modules.rst:
--------------------------------------------------------------------------------
1 | iqoptionapi
2 | ===========
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 |
7 | iqoptionapi
8 |
--------------------------------------------------------------------------------
/image/asset_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/asset_close.png
--------------------------------------------------------------------------------
/image/cancel_order.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/cancel_order.png
--------------------------------------------------------------------------------
/image/change_ID_Name_order_id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/change_ID_Name_order_id.png
--------------------------------------------------------------------------------
/image/change_ID_Name_position_id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/change_ID_Name_position_id.png
--------------------------------------------------------------------------------
/image/close_position.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/close_position.png
--------------------------------------------------------------------------------
/image/expiration_time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/expiration_time.png
--------------------------------------------------------------------------------
/image/get_pending.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/get_pending.png
--------------------------------------------------------------------------------
/image/get_position.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/get_position.png
--------------------------------------------------------------------------------
/image/get_position_history.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/get_position_history.png
--------------------------------------------------------------------------------
/image/get_positions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/get_positions.png
--------------------------------------------------------------------------------
/image/profit_after_sale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/image/profit_after_sale.png
--------------------------------------------------------------------------------
/image/time_interval.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/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"
--------------------------------------------------------------------------------
/iqoptionapi/__init__.py:
--------------------------------------------------------------------------------
1 | """A python wrapper for IQ Option API."""
2 |
3 | import logging
4 |
5 | def _prepare_logging():
6 | """Prepare logger for module IQ Option API."""
7 | logger = logging.getLogger(__name__)
8 | 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 |
--------------------------------------------------------------------------------
/iqoptionapi/api.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option API."""
2 |
3 | import time
4 | import json
5 | import logging
6 | import threading
7 | import requests
8 | import ssl
9 | from iqoptionapi.http.login import Login
10 | from iqoptionapi.http.loginv2 import Loginv2
11 | from iqoptionapi.http.getprofile import Getprofile
12 | from iqoptionapi.http.auth import Auth
13 | from iqoptionapi.http.token import Token
14 | from iqoptionapi.http.appinit import Appinit
15 | from iqoptionapi.http.billing import Billing
16 | from iqoptionapi.http.buyback import Buyback
17 | from iqoptionapi.http.changebalance import Changebalance
18 | from iqoptionapi.ws.client import WebsocketClient
19 |
20 | from iqoptionapi.ws.chanels.ssid import Ssid
21 | from iqoptionapi.ws.chanels.subscribe import *
22 | from iqoptionapi.ws.chanels.unsubscribe import *
23 | from iqoptionapi.ws.chanels.setactives import SetActives
24 | from iqoptionapi.ws.chanels.candles import GetCandles
25 | from iqoptionapi.ws.chanels.buyv2 import Buyv2
26 | from iqoptionapi.ws.chanels.buyv3 import Buyv3
27 |
28 | from iqoptionapi.ws.chanels.api_game_betinfo import Game_betinfo
29 | from iqoptionapi.ws.chanels.instruments import Get_instruments
30 | from iqoptionapi.ws.chanels.get_financial_information import GetFinancialInformation
31 | from iqoptionapi.ws.chanels.strike_list import Strike_list
32 |
33 |
34 | from iqoptionapi.ws.chanels.traders_mood import Traders_mood_subscribe
35 | from iqoptionapi.ws.chanels.traders_mood import Traders_mood_unsubscribe
36 | from iqoptionapi.ws.chanels.buy_place_order_temp import Buy_place_order_temp
37 | from iqoptionapi.ws.chanels.get_order import Get_order
38 | from iqoptionapi.ws.chanels.get_deferred_orders import GetDeferredOrders
39 | from iqoptionapi.ws.chanels.get_positions import *
40 |
41 | from iqoptionapi.ws.chanels.get_available_leverages import Get_available_leverages
42 | from iqoptionapi.ws.chanels.cancel_order import Cancel_order
43 | from iqoptionapi.ws.chanels.close_position import Close_position
44 | from iqoptionapi.ws.chanels.get_overnight_fee import Get_overnight_fee
45 | from iqoptionapi.ws.chanels.heartbeat import Heartbeat
46 |
47 |
48 | from iqoptionapi.ws.chanels.digital_option import *
49 | from iqoptionapi.ws.chanels.api_game_getoptions import *
50 | from iqoptionapi.ws.chanels.sell_option import Sell_Option
51 | from iqoptionapi.ws.chanels.sell_digital_option import Sell_Digital_Option
52 | from iqoptionapi.ws.chanels.change_tpsl import Change_Tpsl
53 | from iqoptionapi.ws.chanels.change_auto_margin_call import ChangeAutoMarginCall
54 |
55 | from iqoptionapi.ws.objects.timesync import TimeSync
56 | from iqoptionapi.ws.objects.profile import Profile
57 | from iqoptionapi.ws.objects.candles import Candles
58 | from iqoptionapi.ws.objects.listinfodata import ListInfoData
59 | from iqoptionapi.ws.objects.betinfo import Game_betinfo_data
60 | import iqoptionapi.global_value as global_value
61 | from collections import defaultdict
62 |
63 |
64 | def nested_dict(n, type):
65 | if n == 1:
66 | return defaultdict(type)
67 | else:
68 | return defaultdict(lambda: nested_dict(n-1, type))
69 |
70 |
71 | # InsecureRequestWarning: Unverified HTTPS request is being made.
72 | # Adding certificate verification is strongly advised.
73 | # See: https://urllib3.readthedocs.org/en/latest/security.html
74 | requests.packages.urllib3.disable_warnings() # pylint: disable=no-member
75 |
76 |
77 | class IQOptionAPI(object): # pylint: disable=too-many-instance-attributes
78 | """Class for communication with IQ Option API."""
79 | # pylint: disable=too-many-public-methods
80 | socket_option_opened={}
81 | timesync = TimeSync()
82 | profile = Profile()
83 | candles = Candles()
84 | listinfodata = ListInfoData()
85 | api_option_init_all_result = []
86 | api_option_init_all_result_v2 = []
87 | # for digital
88 | underlying_list_data = None
89 | position_changed = None
90 | instrument_quites_generated_data = nested_dict(2, dict)
91 | instrument_quotes_generated_raw_data=nested_dict(2, dict)
92 | instrument_quites_generated_timestamp = nested_dict(2, dict)
93 | strike_list = None
94 | position_changed_data = {}
95 | game_betinfo = Game_betinfo_data()
96 | instruments = None
97 | financial_information = None
98 | buy_id = None
99 | buy_order_id = None
100 | traders_mood = {} # get hight(put) %
101 | order_data = None
102 | positions = None
103 | position = None
104 | deferred_orders = None
105 | position_history = None
106 | position_history_v2 = None
107 | available_leverages = None
108 | order_canceled = None
109 | close_position_data = None
110 | overnight_fee = None
111 | # ---for real time
112 | digital_option_placed_id = None
113 |
114 | microserviceName_binary_options_name_option={}
115 |
116 | real_time_candles = nested_dict(3, dict)
117 | real_time_candles_maxdict_table = nested_dict(2, dict)
118 | candle_generated_check = nested_dict(2, dict)
119 | candle_generated_all_size_check = nested_dict(1, dict)
120 | # ---for api_game_getoptions_result
121 | api_game_getoptions_result = None
122 | sold_options_respond = None
123 | sold_digital_options_respond = None
124 | tpsl_changed_respond = None
125 | auto_margin_call_changed_respond = None
126 | top_assets_updated_data={}
127 | get_options_v2_data=None
128 | # --for binary option multi buy
129 | buy_multi_result = None
130 | buy_multi_option = {}
131 | #
132 | result = None
133 | training_balance_reset_request=None
134 | # ------------------
135 |
136 | def __init__(self, host, username, password, proxies=None):
137 | """
138 | :param str host: The hostname or ip address of a IQ Option server.
139 | :param str username: The username of a IQ Option server.
140 | :param str password: The password of a IQ Option server.
141 | :param dict proxies: (optional) The http request proxies.
142 | """
143 | self.https_url = "https://{host}/api".format(host=host)
144 | self.wss_url = "wss://{host}/echo/websocket".format(host=host)
145 | self.websocket_client = None
146 | self.session = requests.Session()
147 | self.session.verify = False
148 | self.session.trust_env = False
149 | self.username = username
150 | self.password = password
151 | self.proxies = proxies
152 | # is used to determine if a buyOrder was set or failed. If
153 | # it is None, there had been no buy order yet or just send.
154 | # If it is false, the last failed
155 | # If it is true, the last buy order was successful
156 | self.buy_successful = None
157 | self.__active_account_type=None
158 |
159 | def prepare_http_url(self, resource):
160 | """Construct http url from resource url.
161 |
162 | :param resource: The instance of
163 | :class:`Resource `.
164 |
165 | :returns: The full url to IQ Option http resource.
166 | """
167 | return "/".join((self.https_url, resource.url))
168 |
169 | def send_http_request(self, resource, method, data=None, params=None, headers=None): # pylint: disable=too-many-arguments
170 | """Send http request to IQ Option server.
171 |
172 | :param resource: The instance of
173 | :class:`Resource `.
174 | :param str method: The http request method.
175 | :param dict data: (optional) The http request data.
176 | :param dict params: (optional) The http request params.
177 | :param dict headers: (optional) The http request headers.
178 |
179 | :returns: The instance of :class:`Response `.
180 | """
181 | logger = logging.getLogger(__name__)
182 | url = self.prepare_http_url(resource)
183 |
184 | logger.debug(url)
185 |
186 | response = self.session.request(method=method,
187 | url=url,
188 | data=data,
189 | params=params,
190 | headers=headers,
191 | proxies=self.proxies)
192 | logger.debug(response)
193 | logger.debug(response.text)
194 | logger.debug(response.headers)
195 | logger.debug(response.cookies)
196 |
197 | response.raise_for_status()
198 | return response
199 |
200 | def send_http_request_v2(self, url, method, data=None, params=None, headers=None): # pylint: disable=too-many-arguments
201 | """Send http request to IQ Option server.
202 |
203 | :param resource: The instance of
204 | :class:`Resource `.
205 | :param str method: The http request method.
206 | :param dict data: (optional) The http request data.
207 | :param dict params: (optional) The http request params.
208 | :param dict headers: (optional) The http request headers.
209 |
210 | :returns: The instance of :class:`Response `.
211 | """
212 | logger = logging.getLogger(__name__)
213 |
214 | logger.debug(url)
215 |
216 | response = self.session.request(method=method,
217 | url=url,
218 | data=data,
219 | params=params,
220 | headers=headers,
221 | proxies=self.proxies)
222 | logger.debug(response)
223 | logger.debug(response.text)
224 | logger.debug(response.headers)
225 | logger.debug(response.cookies)
226 |
227 | response.raise_for_status()
228 | return response
229 |
230 | @property
231 | def websocket(self):
232 | """Property to get websocket.
233 |
234 | :returns: The instance of :class:`WebSocket `.
235 | """
236 | return self.websocket_client.wss
237 |
238 | def send_websocket_request(self, name, msg, request_id=""):
239 | """Send websocket request to IQ Option server.
240 |
241 | :param str name: The websocket request name.
242 | :param dict msg: The websocket request msg.
243 | """
244 | logger = logging.getLogger(__name__)
245 |
246 | data = json.dumps(dict(name=name,
247 | msg=msg, request_id=request_id))
248 | logger.debug(data)
249 | self.websocket.send(data)
250 |
251 | @property
252 | def login(self):
253 | """Property for get IQ Option http login resource.
254 |
255 | :returns: The instance of :class:`Login
256 | `.
257 | """
258 | return Login(self)
259 |
260 | @property
261 | def loginv2(self):
262 | """Property for get IQ Option http loginv2 resource.
263 |
264 | :returns: The instance of :class:`Loginv2
265 | `.
266 | """
267 | return Loginv2(self)
268 |
269 | @property
270 | def auth(self):
271 | """Property for get IQ Option http auth resource.
272 |
273 | :returns: The instance of :class:`Auth
274 | `.
275 | """
276 | return Auth(self)
277 |
278 | @property
279 | def appinit(self):
280 | """Property for get IQ Option http appinit resource.
281 |
282 | :returns: The instance of :class:`Appinit
283 | `.
284 | """
285 | return Appinit(self)
286 |
287 | @property
288 | def token(self):
289 | """Property for get IQ Option http token resource.
290 |
291 | :returns: The instance of :class:`Token
292 | `.
293 | """
294 | return Token(self)
295 |
296 | # @property
297 | # def profile(self):
298 | # """Property for get IQ Option http profile resource.
299 |
300 | # :returns: The instance of :class:`Profile
301 | # `.
302 | # """
303 | # return Profile(self)
304 | def reset_training_balance(self):
305 | # sendResults True/False
306 | # {"name":"sendMessage","request_id":"142","msg":{"name":"reset-training-balance","version":"2.0"}}
307 | logger = logging.getLogger(__name__)
308 | data = json.dumps(dict(name="sendMessage",
309 | msg={"name": "reset-training-balance",
310 | "version": "2.0"}
311 | )
312 | )
313 |
314 | logger.debug(data)
315 | self.websocket.send(data)
316 |
317 | @property
318 | def changebalance(self):
319 | """Property for get IQ Option http changebalance resource.
320 |
321 | :returns: The instance of :class:`Changebalance
322 | `.
323 | """
324 | return Changebalance(self)
325 |
326 | @property
327 | def billing(self):
328 | """Property for get IQ Option http billing resource.
329 |
330 | :returns: The instance of :class:`Billing
331 | `.
332 | """
333 | return Billing(self)
334 |
335 | @property
336 | def buyback(self):
337 | """Property for get IQ Option http buyback resource.
338 |
339 | :returns: The instance of :class:`Buyback
340 | `.
341 | """
342 | return Buyback(self)
343 | # ------------------------------------------------------------------------
344 |
345 | @property
346 | def getprofile(self):
347 | """Property for get IQ Option http getprofile resource.
348 |
349 | :returns: The instance of :class:`Login
350 | `.
351 | """
352 | return Getprofile(self)
353 | # for active code ...
354 |
355 | @property
356 | def get_instruments(self):
357 | return Get_instruments(self)
358 |
359 | @property
360 | def get_financial_information(self):
361 | return GetFinancialInformation(self)
362 | # ----------------------------------------------------------------------------
363 |
364 | @property
365 | def ssid(self):
366 | """Property for get IQ Option websocket ssid chanel.
367 |
368 | :returns: The instance of :class:`Ssid
369 | `.
370 | """
371 | return Ssid(self)
372 | # --------------------------------------------------------------------------------
373 | # trader mood
374 |
375 | @property
376 | def subscribe_Traders_mood(self):
377 | return Traders_mood_subscribe(self)
378 |
379 | @property
380 | def unsubscribe_Traders_mood(self):
381 | return Traders_mood_unsubscribe(self)
382 |
383 | # --------------------------------------------------------------------------------
384 | # --------------------------subscribe&unsubscribe---------------------------------
385 | # --------------------------------------------------------------------------------
386 | @property
387 | def subscribe(self):
388 | "candle-generated"
389 | """Property for get IQ Option websocket subscribe chanel.
390 |
391 | :returns: The instance of :class:`Subscribe
392 | `.
393 | """
394 | return Subscribe(self)
395 |
396 | @property
397 | def subscribe_all_size(self):
398 | return Subscribe_candles(self)
399 |
400 | @property
401 | def unsubscribe(self):
402 | """Property for get IQ Option websocket unsubscribe chanel.
403 |
404 | :returns: The instance of :class:`Unsubscribe
405 | `.
406 | """
407 | return Unsubscribe(self)
408 |
409 | @property
410 | def unsubscribe_all_size(self):
411 | return Unsubscribe_candles(self)
412 |
413 | def subscribe_position_changed(self, name, instrument_type, request_id):
414 | # instrument_type="multi-option","crypto","forex","cfd"
415 | # name="position-changed","trading-fx-option.position-changed",digital-options.position-changed
416 | logger = logging.getLogger(__name__)
417 | data = json.dumps(dict(name="subscribeMessage",
418 | request_id=str(request_id),
419 | msg={"name": name,
420 | "version": "1.0",
421 | "params": {
422 | "routingFilters": {"instrument_type": str(instrument_type)}
423 |
424 | }
425 | }
426 | )
427 | )
428 |
429 | logger.debug(data)
430 | self.websocket.send(data)
431 |
432 | def setOptions(self, request_id, sendResults):
433 | # sendResults True/False
434 | logger = logging.getLogger(__name__)
435 | data = json.dumps(dict(name="setOptions",
436 | request_id=str(request_id),
437 | msg={"sendResults": sendResults}
438 | )
439 | )
440 |
441 | logger.debug(data)
442 | self.websocket.send(data)
443 |
444 | @property
445 | def Subscribe_Top_Assets_Updated(self):
446 | return Subscribe_top_assets_updated(self)
447 |
448 | @property
449 | def Unsubscribe_Top_Assets_Updated(self):
450 | return Unsubscribe_top_assets_updated(self)
451 |
452 | # --------------------------------------------------------------------------------
453 | # -----------------------------------------------------------------------------------
454 |
455 | @property
456 | def setactives(self):
457 | """Property for get IQ Option websocket setactives chanel.
458 |
459 | :returns: The instance of :class:`SetActives
460 | `.
461 | """
462 | return SetActives(self)
463 |
464 | @property
465 | def getcandles(self):
466 | """Property for get IQ Option websocket candles chanel.
467 |
468 | :returns: The instance of :class:`GetCandles
469 | `.
470 | """
471 | return GetCandles(self)
472 |
473 | def get_api_option_init_all(self):
474 | logger = logging.getLogger(__name__)
475 |
476 | data = json.dumps(dict(name="api_option_init_all",
477 | msg=""))
478 | logger.debug(data)
479 | self.websocket.send(data)
480 |
481 | def get_api_option_init_all_v2(self):
482 | logger = logging.getLogger(__name__)
483 | data = json.dumps(dict(name="sendMessage",
484 | msg={"name": "get-initialization-data",
485 | "version": "3.0",
486 | "body": {}
487 | }
488 | )
489 | )
490 | logger.debug(data)
491 | self.websocket.send(data)
492 | # -------------get information-------------
493 |
494 | @property
495 | def get_betinfo(self):
496 | return Game_betinfo(self)
497 |
498 | @property
499 | def get_options(self):
500 | return Get_options(self)
501 | @property
502 | def get_options_v2(self):
503 | return Get_options_v2(self)
504 |
505 | # ____________for_______binary_______option_____________
506 |
507 | @property
508 | def buyv3(self):
509 | return Buyv3(self)
510 |
511 | @property
512 | def buy(self):
513 | """Property for get IQ Option websocket buyv2 request.
514 |
515 | :returns: The instance of :class:`Buyv2
516 | `.
517 | """
518 | self.buy_successful = None
519 | return Buyv2(self)
520 |
521 | @property
522 | def sell_option(self):
523 | return Sell_Option(self)
524 |
525 | @property
526 | def sell_digital_option(self):
527 | return Sell_Digital_Option(self)
528 | # ____________________for_______digital____________________
529 |
530 | def get_digital_underlying(self):
531 | logger = logging.getLogger(__name__)
532 | data = json.dumps(dict(name="sendMessage",
533 | msg={"name": "get-underlying-list",
534 | "version": "2.0",
535 | "body": {"type": "digital-option"}
536 | }
537 | )
538 | )
539 | logger.debug(data)
540 | self.websocket.send(data)
541 |
542 | @property
543 | def get_strike_list(self):
544 | return Strike_list(self)
545 |
546 | @property
547 | def subscribe_instrument_quites_generated(self):
548 | return Subscribe_Instrument_Quites_Generated(self)
549 |
550 | @property
551 | def unsubscribe_instrument_quites_generated(self):
552 | return Unsubscribe_Instrument_Quites_Generated(self)
553 |
554 | @property
555 | def place_digital_option(self):
556 | return Digital_options_place_digital_option(self)
557 |
558 | @property
559 | def close_digital_option(self):
560 | return Digital_options_close_position(self)
561 |
562 | # ____BUY_for__Forex__&&__stock(cfd)__&&__ctrpto_____
563 | @property
564 | def buy_order(self):
565 | return Buy_place_order_temp(self)
566 |
567 | @property
568 | def change_order(self):
569 | return Change_Tpsl(self)
570 |
571 | @property
572 | def change_auto_margin_call(self):
573 | return ChangeAutoMarginCall(self)
574 |
575 | @property
576 | def get_order(self):
577 | return Get_order(self)
578 |
579 | @property
580 | def get_pending(self):
581 | return GetDeferredOrders(self)
582 |
583 | @property
584 | def get_positions(self):
585 | return Get_positions(self)
586 |
587 | @property
588 | def get_position(self):
589 | return Get_position(self)
590 | @property
591 | def get_digital_position(self):
592 | return Get_digital_position(self)
593 | @property
594 | def get_position_history(self):
595 | return Get_position_history(self)
596 |
597 | @property
598 | def get_position_history_v2(self):
599 | return Get_position_history_v2(self)
600 |
601 | @property
602 | def get_available_leverages(self):
603 | return Get_available_leverages(self)
604 |
605 | @property
606 | def cancel_order(self):
607 | return Cancel_order(self)
608 |
609 | @property
610 | def close_position(self):
611 | return Close_position(self)
612 |
613 | @property
614 | def get_overnight_fee(self):
615 | return Get_overnight_fee(self)
616 | # -------------------------------------------------------
617 |
618 | @property
619 | def heartbeat(self):
620 | return Heartbeat(self)
621 | # -------------------------------------------------------
622 |
623 | def set_session_cookies(self):
624 | """Method to set session cookies."""
625 | cookies = dict(platform="15")
626 | self.session.headers["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
627 | requests.utils.add_dict_to_cookiejar(self.session.cookies, cookies)
628 |
629 | def connect(self):
630 | global_value.check_websocket_if_connect = None
631 | """Method for connection to IQ Option API."""
632 | try:
633 | response = self.login(self.username, self.password) # pylint: disable=not-callable
634 | except Exception as e:
635 | logger = logging.getLogger(__name__)
636 | logger.error(e)
637 | return False
638 |
639 | ssid = response.cookies["ssid"]
640 | self.set_session_cookies()
641 | self.websocket_client = WebsocketClient(self)
642 |
643 | self.websocket_thread = threading.Thread(target=self.websocket.run_forever, kwargs={'sslopt': {
644 | "check_hostname": False, "cert_reqs": ssl.CERT_NONE, "ca_certs": "cacert.pem"}}) # for fix pyinstall error: cafile, capath and cadata cannot be all omitted
645 | self.websocket_thread.daemon = True
646 | self.websocket_thread.start()
647 |
648 | while True:
649 | try:
650 | if global_value.check_websocket_if_connect == 0 or global_value.check_websocket_if_connect == -1:
651 | return False
652 | elif global_value.check_websocket_if_connect == 1:
653 | break
654 | except:
655 | pass
656 |
657 | pass
658 |
659 | self.ssid(ssid) # pylint: disable=not-callable
660 | self.timesync.server_timestamp = None
661 | while True:
662 | try:
663 | if self.timesync.server_timestamp != None:
664 | break
665 | except:
666 | pass
667 | return True
668 |
669 | def close(self):
670 | self.websocket.close()
671 | self.websocket_thread.join()
672 |
673 | def websocket_alive(self):
674 | return self.websocket_thread.is_alive()
675 |
676 | def get_active_account_type(self):
677 | return self.__active_account_type
678 |
679 | def set_active_account_type(self, active_account_type):
680 | self.__active_account_type = 1
681 | if active_account_type.upper() != "REAL":
682 | self.__active_account_type = 4
--------------------------------------------------------------------------------
/iqoptionapi/constants.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option API constants."""
2 | #~~~need to update~~~
3 | ACTIVES ={'EURUSD': 1, 'EURGBP': 2, 'GBPJPY': 3, 'EURJPY': 4, 'GBPUSD': 5, 'USDJPY': 6, 'AUDCAD': 7, 'NZDUSD': 8, 'USDRUB': 10, 'AMAZON': 31, 'APPLE': 32, 'BAIDU': 33, 'CISCO': 34, 'FACEBOOK': 35, 'GOOGLE': 36, 'INTEL': 37, 'MSFT': 38, 'YAHOO': 40, 'AIG': 41, 'CITI': 45, 'COKE': 46, 'GE': 48, 'GM': 49, 'GS': 50, 'JPM': 51, 'MCDON': 52, 'MORSTAN': 53, 'NIKE': 54, 'USDCHF': 72, 'XAUUSD': 74, 'XAGUSD': 75, 'EURUSD-OTC': 76, 'EURGBP-OTC': 77, 'USDCHF-OTC': 78, 'EURJPY-OTC': 79, 'NZDUSD-OTC': 80, 'GBPUSD-OTC': 81, 'USDJPY-OTC': 85, 'AUDCAD-OTC': 86, 'ALIBABA': 87, 'YANDEX': 95, 'AUDUSD': 99, 'USDCAD': 100, 'AUDJPY': 101, 'GBPCAD': 102, 'GBPCHF': 103, 'GBPAUD': 104, 'EURCAD': 105, 'CHFJPY': 106, 'CADCHF': 107, 'EURAUD': 108, 'TWITTER': 113, 'FERRARI': 133, 'TESLA': 167, 'USDNOK': 168, 'EURNZD': 212, 'USDSEK': 219, 'USDTRY': 220, 'MMM:US': 252, 'ABT:US': 253, 'ABBV:US': 254, 'ACN:US': 255, 'ATVI:US': 256, 'ADBE:US': 258, 'AAP:US': 259, 'AA:US': 269, 'MO:US': 278, 'AMGN:US': 290, 'T:US': 303, 'ADSK:US': 304, 'BAC:US': 313, 'BBY:US': 320, 'BA:US': 324, 'BMY:US': 328, 'CAT:US': 338, 'CTL:US': 344, 'CVX:US': 349, 'CTAS:US': 356, 'CTXS:US': 360, 'CL:US': 365, 'CMCSA:US': 366, 'CXO:US': 369, 'COP:US': 370, 'ED:US': 371, 'COST:US': 374, 'CVS:US': 379, 'DHI:US': 380, 'DHR:US': 381, 'DRI:US': 382, 'DVA:US': 383, 'DAL:US': 386, 'DVN:US': 388, 'DO:US': 389, 'DLR:US': 390, 'DFS:US': 391, 'DISCA:US': 392, 'DOV:US': 397, 'DTE:US': 400, 'DNB:US': 403, 'ETFC:US': 404, 'EMN:US': 405, 'EBAY:US': 407, 'ECL:US': 408, 'EIX:US': 409, 'EMR:US': 413, 'ETR:US': 415, 'EQT:US': 417, 'EFX:US': 418, 'EQR:US': 420, 'ESS:US': 421, 'EXPD:US': 426, 'EXR:US': 428, 'XOM:US': 429, 'FFIV:US': 430, 'FAST:US': 432, 'FRT:US': 433, 'FDX:US': 434, 'FIS:US': 435, 'FITB:US': 436, 'FSLR:US': 437, 'FE:US': 438, 'FISV:US': 439, 'FLS:US': 441, 'FMC:US': 443, 'FBHS:US': 448, 'FCX:US': 450, 'FTR:US': 451, 'GILD:US': 460, 'HAS:US': 471, 'HON:US': 480, 'IBM:US': 491, 'KHC:US': 513, 'LMT:US': 528, 'MA:US': 542, 'MDT:US': 548, 'MU:US': 553, 'NFLX:US': 569, 'NEE:US': 575, 'NVDA:US': 586, 'PYPL:US': 597, 'PFE:US': 603, 'PM:US': 605, 'PG:US': 617, 'QCOM:US': 626, 'DGX:US': 628, 'RTN:US': 630, 'CRM:US': 645, 'SLB:US': 647, 'SBUX:US': 666, 'SYK:US': 670, 'DIS:US': 689, 'TWX:US': 692, 'VZ:US': 723, 'V:US': 726, 'WMT:US': 729, 'WBA:US': 730, 'WFC:US': 733, 'SNAP': 756, 'DUBAI': 757, 'TA25': 758, 'AMD': 760, 'ALGN': 761, 'ANSS': 762, 'DRE': 772, 'IDXX': 775, 'RMD': 781, 'SU': 783, 'TFX': 784, 'TMUS': 785, 'QQQ': 796, 'SPY': 808, 'BTCUSD': 816, 'XRPUSD': 817, 'ETHUSD': 818, 'LTCUSD': 819, 'DSHUSD': 821, 'BCHUSD': 824, 'OMGUSD': 825, 'ZECUSD': 826, 'ETCUSD': 829, 'BTCUSD-L': 830, 'ETHUSD-L': 831, 'LTCUSD-L': 834, 'BCHUSD-L': 836, 'BTGUSD': 837, 'QTMUSD': 845, 'TRXUSD': 858, 'EOSUSD': 864, 'USDINR': 865, 'USDPLN': 866, 'USDBRL': 867, 'USDZAR': 868, 'DBX': 889, 'SPOT': 891, 'USDSGD': 892, 'USDHKD': 893, 'LLOYL-CHIX': 894, 'VODL-CHIX': 895, 'BARCL-CHIX': 896, 'TSCOL-CHIX': 897, 'BPL-CHIX': 898, 'HSBAL-CHIX': 899, 'RBSL-CHIX': 900, 'BLTL-CHIX': 901, 'MRWL-CHIX': 902, 'STANL-CHIX': 903, 'RRL-CHIX': 904, 'MKSL-CHIX': 905, 'BATSL-CHIX': 906, 'ULVRL-CHIX': 908, 'EZJL-CHIX': 909, 'ADSD-CHIX': 910, 'ALVD-CHIX': 911, 'BAYND-CHIX': 912, 'BMWD-CHIX': 913, 'CBKD-CHIX': 914, 'COND-CHIX': 915, 'DAID-CHIX': 916, 'DBKD-CHIX': 917, 'DPWD-CHIX': 919, 'DTED-CHIX': 920, 'EOAND-CHIX': 921, 'MRKD-CHIX': 922, 'SIED-CHIX': 923, 'TKAD-CHIX': 924, 'VOW3D-CHIX': 925, 'PIRCM-CHIX': 929, 'PSTM-CHIX': 930, 'TITM-CHIX': 931, 'CSGNZ-CHIX': 933, 'NESNZ-CHIX': 934, 'ROGZ-CHIX': 935, 'UBSGZ-CHIX': 936, 'SANE-CHIX': 937, 'BBVAE-CHIX': 938, 'TEFE-CHIX': 939, 'AIRP-CHIX': 940, 'HEIOA-CHIX': 941, 'ORP-CHIX': 942, 'AUDCHF': 943, 'AUDNZD': 944, 'CADJPY': 945, 'EURCHF': 946, 'GBPNZD': 947, 'NZDCAD': 948, 'NZDJPY': 949, 'EURNOK': 951, 'CHFSGD': 952, 'EURSGD': 955, 'USDMXN': 957, 'JUVEM': 958, 'ASRM': 959, 'MANU': 966, 'UKOUSD': 969, 'XPTUSD': 970, 'USOUSD': 971, 'W1': 977, 'AUDDKK': 983, 'AUDMXN': 985, 'AUDNOK': 986, 'AUDSEK': 988, 'AUDSGD': 989, 'AUDTRY': 990, 'CADMXN': 992, 'CADNOK': 993, 'CADPLN': 994, 'CADTRY': 995, 'CHFDKK': 996, 'CHFNOK': 998, 'CHFSEK': 1000, 'CHFTRY': 1001, 'DKKPLN': 1004, 'DKKSGD': 1005, 'EURDKK': 1007, 'EURMXN': 1008, 'EURTRY': 1010, 'GBPILS': 1013, 'GBPMXN': 1014, 'GBPNOK': 1015, 'GBPPLN': 1016, 'GBPSEK': 1017, 'GBPSGD': 1018, 'GBPTRY': 1019, 'NOKDKK': 1023, 'NOKJPY': 1024, 'NOKSEK': 1025, 'NZDDKK': 1026, 'NZDMXN': 1027, 'NZDNOK': 1028, 'NZDSEK': 1030, 'NZDSGD': 1031, 'NZDTRY': 1032, 'NZDZAR': 1033, 'PLNSEK': 1036, 'SEKDKK': 1037, 'SEKJPY': 1038, 'SGDJPY': 1041, 'USDDKK': 1045, 'NZDCHF': 1048, 'GBPHUF': 1049, 'USDCZK': 1050, 'USDHUF': 1051, 'CADSGD': 1054, 'EURCZK': 1056, 'EURHUF': 1057, 'USDTHB': 1062, 'IOTUSD-L': 1116, 'XLMUSD-L': 1117, 'NEOUSD-L': 1118, 'ADAUSD-L': 1119, 'XEMUSD-L': 1120, 'XRPUSD-L': 1122, 'EEM': 1203, 'FXI': 1204, 'IWM': 1205, 'GDX': 1206, 'XOP': 1209, 'XLK': 1210, 'XLE': 1211, 'XLU': 1212, 'IEMG': 1213, 'XLY': 1214, 'IYR': 1215, 'SQQQ': 1216, 'OIH': 1217, 'SMH': 1218, 'EWJ': 1219, 'XLB': 1221, 'DIA': 1222, 'TLT': 1223, 'SDS': 1224, 'EWW': 1225, 'XME': 1227, 'QID': 1229, 'AUS200': 1230, 'FRANCE40': 1231, 'GERMANY30': 1232, 'HONGKONG50': 1233, 'SPAIN35': 1234, 'US30': 1235, 'USNDAQ100': 1236, 'JAPAN225': 1237, 'USSPX500': 1239, 'UK100': 1241, 'TRXUSD-L': 1242, 'EOSUSD-L': 1244, 'BNBUSD-L': 1279, 'ACB': 1288, 'CGC': 1289, 'CRON': 1290, 'GWPH': 1291, 'MJ': 1292, 'TLRY': 1293, 'BUD': 1294, 'LYFT': 1313, 'PINS': 1315, 'ZM': 1316, 'UBER': 1334, 'MELI': 1335, 'BYND': 1336, 'BSVUSD-L': 1338, 'ONTUSD-L': 1339, 'ATOMUSD-L': 1340, 'WORK': 1343}
4 |
--------------------------------------------------------------------------------
/iqoptionapi/expiration.py:
--------------------------------------------------------------------------------
1 | # python
2 | import time
3 | from datetime import datetime, timedelta
4 |
5 | # https://docs.python.org/3/library/datetime.html
6 | # If optional argument tz is None or not specified, the timestamp is converted to the platform's local date and time, and the returned datetime object is naive.
7 | # time.mktime(dt.timetuple())
8 |
9 |
10 | def date_to_timestamp(dt):
11 | # local timezone to timestamp support python2 pytohn3
12 | return time.mktime(dt.timetuple())
13 |
14 |
15 | def get_expiration_time(timestamp, duration):
16 | #
17 | now_date = datetime.fromtimestamp(timestamp)
18 | exp_date = now_date.replace(second=0, microsecond=0)
19 | if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30:
20 | exp_date = exp_date+timedelta(minutes=1)
21 |
22 | else:
23 | exp_date = exp_date+timedelta(minutes=2)
24 | exp = []
25 | for _ in range(5):
26 | exp.append(date_to_timestamp(exp_date))
27 | exp_date = exp_date+timedelta(minutes=1)
28 |
29 | idx = 50
30 | index = 0
31 | now_date = datetime.fromtimestamp(timestamp)
32 | exp_date = now_date.replace(second=0, microsecond=0)
33 | while index < idx:
34 | if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5:
35 | exp.append(date_to_timestamp(exp_date))
36 | index = index+1
37 | exp_date = exp_date+timedelta(minutes=1)
38 |
39 | remaning = []
40 |
41 | for t in exp:
42 | remaning.append(int(t)-int(time.time()))
43 |
44 | close = [abs(x-60*duration) for x in remaning]
45 |
46 | return int(exp[close.index(min(close))]), int(close.index(min(close)))
47 |
48 |
49 | def get_remaning_time(timestamp):
50 | now_date = datetime.fromtimestamp(timestamp)
51 | exp_date = now_date.replace(second=0, microsecond=0)
52 | if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30:
53 | exp_date = exp_date+timedelta(minutes=1)
54 |
55 | else:
56 | exp_date = exp_date+timedelta(minutes=2)
57 | exp = []
58 | for _ in range(5):
59 | exp.append(date_to_timestamp(exp_date))
60 | exp_date = exp_date+timedelta(minutes=1)
61 | idx = 11
62 | index = 0
63 | now_date = datetime.fromtimestamp(timestamp)
64 | exp_date = now_date.replace(second=0, microsecond=0)
65 | while index < idx:
66 | if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5:
67 | exp.append(date_to_timestamp(exp_date))
68 | index = index+1
69 | exp_date = exp_date+timedelta(minutes=1)
70 |
71 | remaning = []
72 |
73 | for idx, t in enumerate(exp):
74 | if idx >= 5:
75 | dr = 15*(idx-4)
76 | else:
77 | dr = idx+1
78 | remaning.append((dr, int(t)-int(time.time())))
79 |
80 | return remaning
81 |
--------------------------------------------------------------------------------
/iqoptionapi/global_value.py:
--------------------------------------------------------------------------------
1 | #python
2 | check_websocket_if_connect=None
--------------------------------------------------------------------------------
/iqoptionapi/http/__init__.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option API http resources."""
2 |
--------------------------------------------------------------------------------
/iqoptionapi/http/appinit.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option appinit http resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Appinit(Resource):
7 | """Class for IQ option login resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "appinit"
11 |
12 | def _get(self, data=None, headers=None):
13 | """Send get request for IQ Option API appinit http resource.
14 |
15 | :returns: The instance of :class:`requests.Response`.
16 | """
17 | return self.send_http_request("GET", data=data, headers=headers)
18 |
19 | def __call__(self):
20 | """Method to get IQ Option API appinit http request.
21 |
22 | :returns: The instance of :class:`requests.Response`.
23 | """
24 | return self._get()
25 |
--------------------------------------------------------------------------------
/iqoptionapi/http/auth.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http auth resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Auth(Resource):
7 | """Class for IQ Option http auth resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "auth"
11 |
--------------------------------------------------------------------------------
/iqoptionapi/http/billing.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option billing resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Billing(Resource):
7 | """Class for IQ option billing resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "billing"
11 |
--------------------------------------------------------------------------------
/iqoptionapi/http/buyback.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option buyback resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 | from iqoptionapi.http.billing import Billing
5 |
6 |
7 | class Buyback(Resource):
8 | """Class for IQ option buyback resource."""
9 | # pylint: disable=too-few-public-methods
10 |
11 | url = "/".join((Billing.url, "buyback"))
12 |
13 | def _post(self, data=None, headers=None):
14 | """Send get request for IQ Option API buyback http resource.
15 |
16 | :returns: The instance of :class:`requests.Response`.
17 | """
18 | return self.send_http_request("POST", data=data, headers=headers)
19 |
20 | def __call__(self, option_id):
21 | """Method to get IQ Option API buyback http request.
22 |
23 | :param str option_id: The option identifier.
24 |
25 | :returns: The instance of :class:`requests.Response`.
26 | """
27 | data = {"option_id": [option_id]}
28 | return self._post(data=data)
29 |
--------------------------------------------------------------------------------
/iqoptionapi/http/changebalance.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option changebalance resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 | from iqoptionapi.http.profile import Profile
5 |
6 |
7 | class Changebalance(Resource):
8 | """Class for IQ option changebalance resource."""
9 | # pylint: disable=too-few-public-methods
10 |
11 | url = "/".join((Profile.url, "changebalance"))
12 |
13 | def _post(self, data=None, headers=None):
14 | """Send get request for IQ Option API changebalance http resource.
15 |
16 | :returns: The instance of :class:`requests.Response`.
17 | """
18 | return self.send_http_request("POST", data=data, headers=headers)
19 |
20 | def __call__(self,balance_id):
21 | """Method to get IQ Option API changebalance http request.
22 |
23 | :param str balance_id: The balance identifier.
24 |
25 | :returns: The instance of :class:`requests.Response`.
26 | """
27 | data = {"balance_id": balance_id}
28 | return self._post(data)
29 |
--------------------------------------------------------------------------------
/iqoptionapi/http/getprofile.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http getprofile resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Getprofile(Resource):
7 | """Class for IQ option getprofile resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "getprofile"
11 |
12 | def _get(self):
13 | """Send get request for IQ Option API getprofile http resource.
14 |
15 | :returns: The instance of :class:`requests.Response`.
16 | """
17 | return self.send_http_request("GET")
18 |
19 | def __call__(self):
20 | """Method to get IQ Option API getprofile http request.
21 |
22 | :returns: The instance of :class:`requests.Response`.
23 | """
24 | return self._get()
25 |
--------------------------------------------------------------------------------
/iqoptionapi/http/getregdata.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http getregdata resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 | from iqoptionapi.http.register import Register
5 |
6 |
7 | class Getprofile(Resource):
8 | """Class for IQ option getregdata resource."""
9 | # pylint: disable=too-few-public-methods
10 |
11 | url = "/".join((Register.url, "getregdata"))
12 |
13 | def _get(self):
14 | """Send get request for IQ Option API getregdata http resource.
15 |
16 | :returns: The instance of :class:`requests.Response`.
17 | """
18 | return self.send_http_request("GET")
19 |
20 | def __call__(self):
21 | """Method to get IQ Option API getregdata http request.
22 |
23 | :returns: The instance of :class:`requests.Response`.
24 | """
25 | return self._get()
26 |
--------------------------------------------------------------------------------
/iqoptionapi/http/login.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http login resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Login(Resource):
7 | """Class for IQ option login resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = ""
11 |
12 | def _post(self, data=None, headers=None):
13 | """Send get request for IQ Option API login http resource.
14 |
15 | :returns: The instance of :class:`requests.Response`.
16 | """
17 | return self.api.send_http_request_v2(method="POST", url="https://auth.iqoption.com/api/v1.0/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 = {"email": username,
28 | "password": password}
29 |
30 | return self._post(data=data)
31 |
--------------------------------------------------------------------------------
/iqoptionapi/http/loginv2.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http loginv2 resource."""
2 |
3 | from iqoptionapi.http.login import Login
4 |
5 |
6 | class Loginv2(Login):
7 | """Class for IQ option loginv2 resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "/".join((Login.url, "v2"))
11 |
12 | def __init__(self, api):
13 | super(Loginv2, self).__init__(api)
14 |
--------------------------------------------------------------------------------
/iqoptionapi/http/profile.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option profile resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Profile(Resource):
7 | """Class for IQ option profile resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "profile"
11 |
--------------------------------------------------------------------------------
/iqoptionapi/http/register.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option register resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 |
5 |
6 | class Register(Resource):
7 | """Class for IQ option register resource."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | url = "register"
11 |
--------------------------------------------------------------------------------
/iqoptionapi/http/resource.py:
--------------------------------------------------------------------------------
1 | """Module for base IQ Option http base resource."""
2 |
3 |
4 | class Resource(object):
5 | """Class for base IQ Option API http resource."""
6 | # pylint: disable=too-few-public-methods
7 |
8 | def __init__(self, api):
9 | """
10 | :param api: The instance of :class:`IQOptionAPI
11 | `.
12 | """
13 | self.api = api
14 |
15 | def send_http_request(self, method, data=None, params=None, headers=None):
16 | """Send http request to IQ Option API.
17 |
18 | :param str method: The http request method.
19 | :param dict data: (optional) The http request data.
20 | :param dict params: (optional) The http request params.
21 | :param dict headers: (optional) The http request headers.
22 |
23 | :returns: The instance of :class:`requests.Response`.
24 | """
25 | return self.api.send_http_request(self, method, data=data, params=params, headers=headers)
26 |
--------------------------------------------------------------------------------
/iqoptionapi/http/token.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option http token resource."""
2 |
3 | from iqoptionapi.http.resource import Resource
4 | from iqoptionapi.http.auth import Auth
5 |
6 |
7 | class Token(Resource):
8 | """Class for IQ Option http token resource."""
9 | # pylint: disable=too-few-public-methods
10 |
11 | url = "/".join((Auth.url, "token"))
12 |
13 | def __init__(self, api):
14 | super(Token, self).__init__(api)
15 |
16 | def _get(self):
17 | """Send get request for IQ Option API token http resource.
18 |
19 | :returns: The instance of :class:`requests.Response`.
20 | """
21 | return self.send_http_request("GET")
22 |
23 | def __call__(self):
24 | """Method to get IQ Option API token http request.
25 |
26 | :returns: The instance of :class:`requests.Response`.
27 | """
28 | return self._get()
29 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/__init__.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option API websocket."""
2 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/__init__.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option API websocket chanels."""
2 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/api_game_betinfo.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 | import logging
5 | class Game_betinfo(Base):
6 | name = "api_game_betinfo"
7 | def __call__(self, id_number_list):
8 | data = {"currency": "USD"}
9 | if type(id_number_list) is list:
10 | for idx, val in enumerate(id_number_list):
11 | data["id["+str(idx)+"]"]=int(val)
12 | elif id_number_list is None:
13 | logging.error('**error** Game_betinfo can not input None type,please input buy id')
14 | else :
15 | data["id[0]"]=int(id_number_list)
16 | self.send_websocket_request(self.name, data)
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/api_game_getoptions.py:
--------------------------------------------------------------------------------
1 | #python
2 | """Module for IQ option candles websocket chanel."""
3 |
4 | from iqoptionapi.ws.chanels.base import Base
5 | import time
6 |
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(self.api.profile.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(self.api.profile.balance_id)
28 | }
29 | }
30 | self.send_websocket_request(self.name, data)
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/base.py:
--------------------------------------------------------------------------------
1 | """Module for base IQ Option base websocket chanel."""
2 | import time
3 |
4 | class Base(object):
5 | """Class for base IQ Option websocket chanel."""
6 | # pylint: disable=too-few-public-methods
7 |
8 | def __init__(self, api):
9 | """
10 | :param api: The instance of :class:`IQOptionAPI
11 | `.
12 | """
13 | self.api = api
14 |
15 | def send_websocket_request(self, name, msg,request_id=""):
16 | """Send request to IQ Option server websocket.
17 |
18 | :param str name: The websocket chanel name.
19 | :param dict msg: The websocket chanel msg.
20 |
21 | :returns: The instance of :class:`requests.Response`.
22 | """
23 | if request_id == '':
24 | request_id = int(str(time.time()).split('.')[1])
25 | return self.api.send_websocket_request(name, msg,request_id)
26 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/buy_place_order_temp.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
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(self.api.profile.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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/buyback.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option buyback websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Buyback(Base):
7 | """Class for IQ option subscribe to buyback websocket chanel."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | name = "buyback"
11 |
12 | def __call__(self):
13 | """Method to send message to buyback websocket chanel."""
14 | pass
15 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/buyv2.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option buyV2 websocket chanel."""
2 | import datetime
3 | import time
4 | from iqoptionapi.ws.chanels.base import Base
5 | import logging
6 | from iqoptionapi.expiration import get_expiration_time
7 | from datetime import datetime,timedelta
8 |
9 | class Buyv2(Base):
10 | """Class for IQ option buy websocket chanel."""
11 | # pylint: disable=too-few-public-methods
12 |
13 | name = "buyV2"
14 |
15 | def __call__(self, price, active, direction,duration):
16 | """Method to send message to buyv2 websocket chanel.
17 |
18 | :param price: The buying price.
19 | :param active: The buying active.
20 | :param direction: The buying direction.
21 | """
22 | # thank Darth-Carrotpie's code
23 | #https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6
24 |
25 | exp,idx=get_expiration_time(int(self.api.timesync.server_timestamp),duration)
26 |
27 | if idx<5:
28 | option="turbo"
29 | else:
30 | option="binary"
31 |
32 |
33 |
34 | data = {
35 | "price": price,
36 | "act": active,
37 | "exp":int(exp),
38 | "type": option,
39 | "direction": direction.lower(),
40 | "user_balance_id":int(self.api.profile.balance_id),
41 | "time": self.api.timesync.server_timestamp
42 | }
43 |
44 | self.send_websocket_request(self.name, data)
45 |
46 | # thank Darth-Carrotpie's code
47 | #https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6
48 | """ def get_expiration_time(self, duration):
49 | exp=int(self.api.timesync.server_timestamp)
50 | if duration>=1 and duration<=5:
51 | option="turbo"
52 | #Round to next full minute
53 | #datetime.datetime.now().second>30
54 | if (exp % 60) > 30:
55 | exp = exp - (exp % 60) + 60*(duration+1)
56 | else:
57 | exp = exp - (exp % 60)+60*(duration)
58 | elif duration > 5:
59 | option = "binary"
60 | period = int(round(duration / 15))
61 | tmp_exp = exp - (exp % 60)#nuima sekundes
62 | tmp_exp = tmp_exp - (tmp_exp%3600)#nuimam minutes
63 | j=0
64 | while exp > tmp_exp + (j)*15*60:#find quarter
65 | j = j+1
66 | if exp - tmp_exp > 5 * 60:
67 | quarter = tmp_exp + (j)*15*60
68 | exp = quarter + period*15*60
69 | else:
70 | quarter = tmp_exp + (j+1)*15*60
71 | exp = quarter + period*15*60
72 | else:
73 | logging.error("ERROR get_expiration_time DO NOT LESS 1")
74 | exit(1)
75 | return exp, option"""
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/buyv3.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 | import logging
5 |
6 | from iqoptionapi.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/iqoptionapi/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 | },
27 | "name": "binary-options.open-option",
28 | "version": "1.0"
29 | }
30 | self.send_websocket_request(self.name, data,str(request_id))
31 | """
32 | # thank Darth-Carrotpie's code
33 | # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6
34 | def get_expiration_time(self, duration):
35 | exp = time.time()
36 | if duration >= 1 and duration <= 5:
37 | option = 3#"turbo"
38 | # Round to next full minute
39 | # datetime.datetime.now().second>30
40 | if (exp % 60) > 30:
41 | exp = exp - (exp % 60) + 60*(duration+1)
42 | else:
43 | exp = exp - (exp % 60)+60*(duration)
44 | elif duration > 5:
45 | option = 1#"binary"
46 | period = int(round(duration / 15))
47 | tmp_exp = exp - (exp % 60) # nuima sekundes
48 | tmp_exp = tmp_exp - (tmp_exp % 3600) # nuimam minutes
49 | j = 0
50 | while exp > tmp_exp + (j)*15*60: # find quarter
51 | j = j+1
52 | if exp - tmp_exp > 5 * 60:
53 | quarter = tmp_exp + (j)*15*60
54 | exp = quarter + period*15*60
55 | else:
56 | quarter = tmp_exp + (j+1)*15*60
57 | exp = quarter + period*15*60
58 | else:
59 | logging.error("ERROR get_expiration_time DO NOT LESS 1")
60 | exit(1)
61 | return exp, option
62 | """
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/cancel_order.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Cancel_order(Base):
7 | name = "sendMessage"
8 | def __call__(self,order_id):
9 | data = {
10 | "name":"cancel-order",
11 | "version":"1.0",
12 | "body":{
13 | "order_id":order_id
14 | }
15 | }
16 | self.send_websocket_request(self.name, data)
17 |
18 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/candles.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option candles websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 | import time
5 |
6 | class GetCandles(Base):
7 | """Class for IQ option candles websocket chanel."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | name = "sendMessage"
11 |
12 | def __call__(self, active_id, interval, count,endtime):
13 | """Method to send message to candles websocket chanel.
14 |
15 | :param active_id: The active/asset identifier.
16 | :param duration: The candle duration (timeframe for the candles).
17 | :param amount: The number of candles you want to have
18 | """
19 | #thank SeanStayn share new request
20 | #https://github.com/n1nj4z33/iqoptionapi/issues/88
21 | data = {"name":"get-candles",
22 | "version":"2.0",
23 | "body":{
24 | "active_id":int(active_id),
25 | "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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/change_auto_margin_call.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 | class ChangeAutoMarginCall(Base):
5 | name = "sendMessage"
6 | def __call__(self,ID_Name,ID,auto_margin_call):
7 | data = {
8 | "name":"change-auto-margin-call",
9 | "version":"2.0",
10 | "body":{
11 | ID_Name: ID,
12 | "auto_margin_call": bool(auto_margin_call)
13 | }
14 | }
15 | self.send_websocket_request(self.name, data)
16 |
17 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/change_tpsl.py:
--------------------------------------------------------------------------------
1 | #python
2 |
3 | import datetime
4 | import time
5 | from iqoptionapi.ws.chanels.base import Base
6 | class Change_Tpsl(Base):
7 | name = "sendMessage"
8 | def __call__(self,ID_Name,ID,
9 | stop_lose_kind,stop_lose_value,
10 | take_profit_kind,take_profit_value,
11 | use_trail_stop):
12 | data = {
13 | "name":"change-tpsl",
14 | "version":"2.0",
15 | "body":{
16 | ID_Name: ID,
17 | "stop_lose_kind": stop_lose_kind,
18 | "stop_lose_value": stop_lose_value,
19 | "take_profit_kind": take_profit_kind,
20 | "take_profit_value": take_profit_value,
21 | "use_trail_stop": use_trail_stop,
22 | "extra":{
23 | "stop_lose_kind":stop_lose_kind,
24 | "take_profit_kind":take_profit_kind
25 | }
26 | }
27 | }
28 | self.send_websocket_request(self.name, data)
29 |
30 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/changebalance.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option buyV2 websocket chanel."""
2 | import datetime
3 |
4 | from iqoptionapi.ws.chanels.base import Base
5 | class Changebalance(Base):
6 | """Class for IQ option buy websocket chanel."""
7 | # pylint: disable=too-few-public-methods
8 |
9 | name = "api_profile_changebalance"
10 |
11 | def __call__(self, balance_id):
12 | """Method to send message to buyv2 websocket chanel.
13 |
14 | :param price: The buying price.
15 | :param active: The buying active.
16 | :param option: The buying option.
17 | :param direction: The buying direction.
18 | """
19 |
20 |
21 | data = {
22 | "balance_id":balance_id
23 | }
24 |
25 | self.send_websocket_request(self.name, data)
26 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/close_position.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Close_position(Base):
7 | name = "sendMessage"
8 | def __call__(self,position_id):
9 | data = {
10 | "name":"close-position",
11 | "version":"1.0",
12 | "body":{
13 | "position_id":position_id
14 | }
15 | }
16 | self.send_websocket_request(self.name, data)
17 |
18 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/digital_option.py:
--------------------------------------------------------------------------------
1 | #python
2 |
3 | import datetime
4 | import time
5 | from iqoptionapi.ws.chanels.base import Base
6 |
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, user_balance_id=None):
12 | if user_balance_id==None:
13 | user_balance_id = int(self.api.profile.balance_id)
14 |
15 | data = {
16 | "name": "digital-options.place-digital-option",
17 | "version":"1.0",
18 | "body":{
19 | "user_balance_id": user_balance_id,
20 | "instrument_id":str(instrument_id),
21 | "amount":str(amount)
22 | }
23 | }
24 | self.send_websocket_request(self.name, data)
25 |
26 | class Digital_options_close_position(Base):
27 | name = "sendMessage"
28 | def __call__(self,position_id):
29 | data = {
30 | "name": "digital-options.close-position",
31 | "version":"1.0",
32 | "body":{
33 | "position_id":int(position_id)
34 | }
35 | }
36 | self.send_websocket_request(self.name, data)
37 |
38 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_available_leverages.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Get_available_leverages(Base):
7 | name = "sendMessage"
8 | def __call__(self,instrument_type,actives):
9 | data = {
10 | "name":"get-available-leverages",
11 | "version":"2.0",
12 | "body":{
13 | "instrument_type":instrument_type,
14 | "actives":[actives]
15 | }
16 | }
17 | self.send_websocket_request(self.name, data)
18 |
19 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_deferred_orders.py:
--------------------------------------------------------------------------------
1 | from iqoptionapi.ws.chanels.base import Base
2 | import time
3 |
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(self.api.profile.balance_id),
14 | "instrument_type":instrument_type
15 |
16 | }
17 | }
18 |
19 | self.send_websocket_request(self.name, data)
20 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_financial_information.py:
--------------------------------------------------------------------------------
1 | from iqoptionapi.ws.chanels.base import Base
2 | class GetFinancialInformation(Base):
3 | name = "sendMessage"
4 | def __call__(self,activeId):
5 | data = {
6 | "name":"get-financial-information",
7 | "version":"1.0",
8 | "body":{
9 | "query":"query GetAssetProfileInfo($activeId:ActiveID!, $locale: LocaleName){\n active(id: $activeId) {\n id\n name(source: TradeRoom, locale: $locale)\n ticker\n media {\n siteBackground\n }\n charts {\n dtd {\n change\n }\n m1 {\n change\n }\n y1 {\n change\n }\n ytd {\n change\n }\n }\n index_fininfo: fininfo {\n ... on Index {\n description(locale: $locale)\n }\n }\n fininfo {\n ... on Pair {\n type\n description(locale: $locale)\n currency {\n name(locale: $locale)\n }\n base {\n name(locale: $locale)\n ... on Stock {\n company {\n country {\n nameShort\n }\n gics {\n sector\n industry\n }\n site\n domain\n }\n keyStat {\n marketCap\n peRatioHigh\n }\n }\n ... on CryptoCurrency {\n site\n domain\n coinsInCirculation\n maxCoinsQuantity\n volume24h\n marketCap\n }\n }\n }\n }\n }\n }",
10 | "operationName": "GetAssetProfileInfo",
11 | "variables":{
12 | "activeId":activeId
13 | }
14 | }
15 | }
16 | self.send_websocket_request(self.name, data)
17 |
18 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_order.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Get_order(Base):
7 | name = "sendMessage"
8 | def __call__(self,order_id):
9 | data = {
10 | "name":"get-order",
11 | "body":{
12 | "order_id":int(order_id)
13 | }
14 | }
15 | self.send_websocket_request(self.name, data)
16 |
17 |
18 |
19 | #{"name":"sendMessage","request_id":"140","msg":{"name":"get-order","version":"1.0","body":{"order_id":664130181}}}
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_overnight_fee.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Get_overnight_fee(Base):
7 | name = "sendMessage"
8 | def __call__(self,instrument_type,active_id):
9 | data = {
10 | "name":"get-overnight-fee",
11 | "version":"1.0",
12 | "body":{
13 | "user_group_id":1,
14 | "instrument_type":instrument_type,
15 | "active_id":active_id
16 | }
17 | }
18 | self.send_websocket_request(self.name, data)
19 |
20 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/get_positions.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
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(self.api.profile.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(self.api.profile.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(self.api.profile.balance_id)
58 | }
59 | }
60 | self.send_websocket_request(self.name, data)
61 |
62 | class Get_digital_position(Base):
63 | name = "sendMessage"
64 | def __call__(self,position_id):
65 | data = {
66 | "name":"digital-options.get-position",
67 | "body":{
68 | "position_id":position_id,
69 | }
70 | }
71 | self.send_websocket_request(self.name, data)
72 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/heartbeat.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | from iqoptionapi.ws.chanels.base import Base
3 | class Heartbeat(Base):
4 | name = "heartbeat"
5 |
6 | def __call__(self,heartbeatTime):
7 |
8 | data = {
9 | "msg": {
10 | "heartbeatTime":int(heartbeatTime),
11 | "userTime":int(self.api.timesync.server_timestamp*1000)
12 | }
13 |
14 | }
15 | self.send_websocket_request(self.name, data)
16 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/instruments.py:
--------------------------------------------------------------------------------
1 | import datetime
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Get_instruments(Base):
7 | """Class for IQ option buy websocket chanel."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | name = "sendMessage"
11 |
12 | def __call__(self,types):
13 |
14 |
15 | data = {
16 | "name":"get-instruments",
17 | "version":"4.0",
18 | "body":{"type":types}
19 | }
20 |
21 | self.send_websocket_request(self.name, data)
22 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/sell_digital_option.py:
--------------------------------------------------------------------------------
1 |
2 | from iqoptionapi.ws.chanels.base import Base
3 | import time
4 |
5 | class Sell_Digital_Option(Base):
6 | name = "sendMessage"
7 | def __call__(self, position_ids):
8 | """
9 | :param options_ids: list or int
10 | """
11 | if type(position_ids) == list:
12 | id_list=[]
13 | id_list.append(position_ids)
14 | position_ids=id_list
15 |
16 | data = {"name":"digital-options.close-position-batch",
17 | "version":"1.0",
18 | "body":{
19 | "position_ids":(position_ids)
20 | }
21 | }
22 | else:
23 | data = {"name":"digital-options.close-position",
24 | "version":"1.0",
25 | "body":{
26 | "position_id":position_ids
27 | }
28 | }
29 | request_id = int(str(time.time()).split('.')[1])
30 | self.send_websocket_request(self.name, data, request_id)
31 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/sell_option.py:
--------------------------------------------------------------------------------
1 |
2 | from iqoptionapi.ws.chanels.base import Base
3 | import time
4 |
5 | class Sell_Option(Base):
6 | name = "sendMessage"
7 | def __call__(self, options_ids):
8 | """
9 | :param options_ids: list or int
10 | """
11 | if type(options_ids) != list:
12 | id_list=[]
13 | id_list.append(options_ids)
14 | options_ids=id_list
15 |
16 | data = {"name":"sell-options",
17 | "version":"2.0",
18 | "body":{
19 | "options_ids":(options_ids)
20 | }
21 | }
22 |
23 | self.send_websocket_request(self.name, data)
24 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/setactives.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option setactives websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class SetActives(Base):
7 | """Class for IQ option setactives websocket chanel."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | name = "setActives"
11 |
12 | def __call__(self, actives):
13 | """Method to send message to setactives websocket chanel.
14 |
15 | :param actives: The list of actives identifiers.
16 | """
17 | data = {"actives": actives}
18 | self.send_websocket_request(self.name, data)
19 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/ssid.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option API ssid websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Ssid(Base):
7 | """Class for IQ option API ssid websocket chanel."""
8 | # pylint: disable=too-few-public-methods
9 |
10 | name = "ssid"
11 |
12 | def __call__(self, ssid):
13 | """Method to send message to ssid websocket chanel.
14 |
15 | :param ssid: The session identifier.
16 | """
17 | self.send_websocket_request(self.name, ssid)
18 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/strike_list.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | from iqoptionapi.ws.chanels.base import Base
3 | import logging
4 | class Strike_list(Base):
5 | name = "sendMessage"
6 |
7 | def __call__(self,name,duration):
8 | """
9 | duration:minute
10 | """
11 | exp=self.get_digital_expiration_time(duration)
12 | data = {
13 | "name": "get-strike-list",
14 | "body":{"type":"digital-option",
15 | "underlying":name,
16 | "expiration":int(exp)*1000,
17 | "period": duration*60
18 | },
19 | "version": "4.0"
20 | }
21 | self.send_websocket_request(self.name, data)
22 |
23 | def get_digital_expiration_time(self, duration):
24 | exp=int(self.api.timesync.server_timestamp)
25 | value = datetime.datetime.fromtimestamp(exp)
26 | minute = int(value.strftime('%M'))
27 | second=int(value.strftime('%S'))
28 | ans=exp-exp%60#delete second
29 | ans=ans+(duration-minute%duration)*60
30 | if exp>ans-10:
31 | ans=ans+(duration)*60
32 |
33 | return ans
34 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/subscribe.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option subscribe websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 | import datetime
5 | import iqoptionapi.constants as OP_code
6 | 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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/traders_mood.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 | from iqoptionapi.ws.chanels.base import Base
4 |
5 |
6 | class Traders_mood_subscribe(Base):
7 |
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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/chanels/unsubscribe.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option unsubscribe websocket chanel."""
2 |
3 | from iqoptionapi.ws.chanels.base import Base
4 | import datetime
5 | import iqoptionapi.constants as OP_code
6 | 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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/client.py:
--------------------------------------------------------------------------------
1 | """Module for IQ option websocket."""
2 |
3 | import json
4 | import logging
5 | import websocket
6 | import iqoptionapi.constants as OP_code
7 | import iqoptionapi.global_value as global_value
8 |
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 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/objects/listinfodata.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option Candles websocket object."""
2 | from collections import OrderedDict
3 |
4 | from iqoptionapi.ws.objects.base import Base
5 |
6 | class ListInfoData(Base):
7 | """Class for IQ Option Candles websocket object."""
8 |
9 | def __init__(self):
10 | super(ListInfoData, self).__init__()
11 | self.__name = "listInfoData"
12 | self.listinfodata_dict = {}
13 | #--------------------
14 | def set(self,win,game_state,id_number):
15 | self.listinfodata_dict[id_number]={"win":win,"game_state":game_state}
16 | def delete(self,id_number):
17 | del self.listinfodata_dict[id_number]
18 | def get(self, id_number):
19 | return self.listinfodata_dict[id_number]
20 |
21 |
--------------------------------------------------------------------------------
/iqoptionapi/ws/objects/profile.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option Profile websocket object."""
2 | from iqoptionapi.ws.objects.base import Base
3 |
4 |
5 | class Profile(Base):
6 | """Class for IQ Option Profile websocket object."""
7 |
8 | def __init__(self):
9 | super(Profile, self).__init__()
10 | self.__name = "profile"
11 | self.__skey = None
12 | self.__balance = None
13 | self.__balance_id=None
14 | self.__balances=None
15 | self.__msg=None
16 | self.__currency=None
17 | self.__minimum_amount=1
18 | self.__balance_type=None
19 | self.__currency_char=None
20 | self.__time_zone=-3
21 |
22 | @property
23 | def skey(self):
24 | """Property to get skey value.
25 |
26 | :returns: The skey value.
27 | """
28 | return self.__skey
29 |
30 | @skey.setter
31 | def skey(self, skey):
32 | """Method to set skey value."""
33 | self.__skey = skey
34 | #----------------------------------------------------------------
35 | @property
36 | def balance(self):
37 | """Property to get balance value.
38 |
39 | :returns: The balance value.
40 | """
41 | return self.__balance
42 |
43 | @balance.setter
44 | def balance(self, balance):
45 | """Method to set balance value."""
46 | self.__balance = balance
47 |
48 | #---------------------------------------------------------------------
49 | @property
50 | def balance_id(self):
51 | """Property to get balance value.
52 |
53 | :returns: The balance value.
54 | """
55 | return self.__balance_id
56 | @balance_id.setter
57 | def balance_id(self, balance_id):
58 | """Method to set balance value."""
59 | self.__balance_id = balance_id
60 |
61 |
62 | #------------------------------------------------------------------------
63 | @property
64 | def balance_type(self):
65 | """Property to get balance value.
66 |
67 | :returns: The balance value.
68 | """
69 | return self.__balance_type
70 | @balance_type.setter
71 | def balance_type(self, balance_type):
72 | """Method to set balance value."""
73 | self.__balance_type = balance_type
74 |
75 |
76 |
77 |
78 | #----------------------------------------
79 | @property
80 | def balances(self):
81 | """Property to get balance value.
82 |
83 | :returns: The balance value.
84 | """
85 | return self.__balances
86 | @balances.setter
87 | def balances(self, balances):
88 | """Method to set balance value."""
89 | self.__balances = balances
90 |
91 | #------------
92 | @property
93 | def msg(self):
94 | return self.__msg
95 | @msg.setter
96 | def msg(self, msg):
97 | self.__msg = msg
98 |
99 | #------------
100 | @property
101 | def currency(self):
102 | return self.__currency
103 |
104 | @currency.setter
105 | def currency(self, currency):
106 | self.__currency = currency
107 | if self.__currency.upper() == "BRL":
108 | self.__minimum_amount = 2
109 |
110 | @property
111 | def minimum_amount(self):
112 | return self.__minimum_amount
113 | #------------
114 | @property
115 | def currency_char(self):
116 | return self.__currency_char
117 |
118 | @currency_char.setter
119 | def currency_char(self, currency_char):
120 | self.__currency_char = currency_char
121 | #------------
122 | @property
123 | def time_zone(self):
124 | return self.__time_zone
125 |
126 | @time_zone.setter
127 | def time_zone(self, time_zone):
128 | self.__time_zone = int(time_zone/60)
--------------------------------------------------------------------------------
/iqoptionapi/ws/objects/timesync.py:
--------------------------------------------------------------------------------
1 | """Module for IQ Option TimeSync websocket object."""
2 |
3 | import time
4 | import datetime
5 |
6 | from iqoptionapi.ws.objects.base import Base
7 |
8 |
9 | class TimeSync(Base):
10 | """Class for IQ Option TimeSync websocket object."""
11 |
12 | def __init__(self):
13 | super(TimeSync, self).__init__()
14 | self.__name = "timeSync"
15 | self.__server_timestamp = time.time()
16 | self.__expiration_time = 1
17 |
18 | @property
19 | def server_timestamp(self):
20 | """Property to get server timestamp.
21 |
22 | :returns: The server timestamp.
23 | """
24 | while self.__server_timestamp==None:
25 | time.sleep(0.2)
26 | pass
27 |
28 | return self.__server_timestamp / 1000
29 |
30 | @server_timestamp.setter
31 | def server_timestamp(self, timestamp):
32 | """Method to set server timestamp."""
33 | self.__server_timestamp = timestamp
34 |
35 | @property
36 | def server_datetime(self):
37 | """Property to get server datetime.
38 |
39 | :returns: The server datetime.
40 | """
41 | return datetime.datetime.fromtimestamp(self.server_timestamp)
42 |
43 | @property
44 | def expiration_time(self):
45 | """Property to get expiration time.
46 |
47 | :returns: The expiration time.
48 | """
49 | return self.__expiration_time
50 |
51 | @expiration_time.setter
52 | def expiration_time(self, minutes):
53 | """Method to set expiration time
54 |
55 | :param int minutes: The expiration time in minutes.
56 | """
57 | self.__expiration_time = minutes
58 |
59 | @property
60 | def expiration_datetime(self):
61 | """Property to get expiration datetime.
62 |
63 | :returns: The expiration datetime.
64 | """
65 | return self.server_datetime + datetime.timedelta(minutes=self.expiration_time)
66 |
67 | @property
68 | def expiration_timestamp(self):
69 | """Property to get expiration timestamp.
70 |
71 | :returns: The expiration timestamp.
72 | """
73 | return time.mktime(self.expiration_datetime.timetuple())
74 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """The python wrapper for IQ Option API package setup."""
2 | from setuptools import (setup, find_packages)
3 |
4 | setup(
5 | name="iqoptionapi",
6 | version="5.2.2",
7 | packages=find_packages(),
8 | install_requires=["pylint","requests","websocket-client==0.56"],
9 | include_package_data = True,
10 | description="Best IQ Option API for python",
11 | long_description="Best IQ Option API for python",
12 | url="https://github.com/evecimar/iqoptionapi",
13 | author="Evecimar",
14 | author_email="silva.evecimar@gmail.com",
15 | zip_safe=False
16 | )
17 |
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evecimar/iqoptionapi/7e3b18a427129742fd6cf6c2fdd064df1097febd/tests/__init__.py
--------------------------------------------------------------------------------
/tests/test_Binary_Option.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 | from iqoptionapi.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 | I_want_money=IQ_Option(email,password)
14 | I_want_money.change_balance("PRACTICE")
15 | I_want_money.reset_practice_balance()
16 | self.assertEqual(I_want_money.check_connect(), True)
17 | #start test binary option
18 | ALL_Asset=I_want_money.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=I_want_money.buy(Money,ACTIVES,ACTION_call,expirations_mode)
27 | self.assertTrue(check_call)
28 | self.assertTrue(type(id_call) is int)
29 | I_want_money.sell_option(id_call)
30 |
31 | ACTION_call="put"
32 | check_put,id_put=I_want_money.buy(Money,ACTIVES,ACTION_call,expirations_mode)
33 | self.assertTrue(check_put)
34 | self.assertTrue(type(id_put) is int)
35 | I_want_money.sell_option(id_put)
36 | I_want_money.check_win_v2(id_put)
37 |
38 |
39 | I_want_money.get_binary_option_detail()
40 |
41 | I_want_money.get_all_profit()
42 |
43 | isSuccessful,dict=I_want_money.get_betinfo(id_put)
44 | self.assertTrue(isSuccessful)
45 | I_want_money.get_optioninfo(10)
46 |
--------------------------------------------------------------------------------
/tests/test_Candle.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 | from iqoptionapi.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 | I_want_money=IQ_Option(email,password)
15 | I_want_money.change_balance("PRACTICE")
16 | I_want_money.reset_practice_balance()
17 | self.assertEqual(I_want_money.check_connect(), True)
18 | #start test binary option
19 | ALL_Asset=I_want_money.get_all_open_time()
20 | if ALL_Asset["turbo"]["EURUSD"]["open"]:
21 | ACTIVES="EURUSD"
22 | else:
23 | ACTIVES="EURUSD-OTC"
24 |
25 | I_want_money.get_candles(ACTIVES, 60, 1000, time.time())
26 | #realtime candle
27 | size="all"
28 | I_want_money.start_candles_stream(ACTIVES,size,10)
29 | I_want_money.get_realtime_candles(ACTIVES,size)
30 | I_want_money.stop_candles_stream(ACTIVES,size)
31 |
32 |
--------------------------------------------------------------------------------
/tests/test_Login.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 | from iqoptionapi.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 | I_want_money=IQ_Option(email,password)
11 | I_want_money.change_balance("PRACTICE")
12 | I_want_money.reset_practice_balance()
13 | self.assertEqual(I_want_money.check_connect(), True)
14 |
15 |
--------------------------------------------------------------------------------