diff --git a/README.md b/README.md index eaab72b..9817d5c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# talk with us -https://discord.gg/du4GaQGHMT - - - # Pocket Option API In development! for a better understanding, check this [link](https://github.com/theshadow76/PocketOptionAPI/issues/4) -there is a pocketoption api being sold for 1000 usd, and here we want to make it for free! +# help me + +you can donate here: [paypal](https://paypal.me/shadowtechsc?country.x=CL&locale.x=es_XC) + +or my BTC adress: bc1qmvpmpdt96vmgq3s3rh3gzxf75eml52r2d7sclw + +By donating you are helping me make this project better! diff --git a/docs/todo.md b/docs/todo.md index 7b41d26..67b5a55 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -1,4 +1,6 @@ # todo ### Add login system -- Not Done \ No newline at end of file +- Not Done + +-- updated \ No newline at end of file diff --git a/pocketoptionapi/__pycache__/__init__.cpython-311.pyc b/pocketoptionapi/__pycache__/__init__.cpython-311.pyc index 67ac79d..d6f4f31 100644 Binary files a/pocketoptionapi/__pycache__/__init__.cpython-311.pyc and b/pocketoptionapi/__pycache__/__init__.cpython-311.pyc differ diff --git a/pocketoptionapi/__pycache__/api.cpython-310.pyc b/pocketoptionapi/__pycache__/api.cpython-310.pyc index 40e9064..52860c5 100644 Binary files a/pocketoptionapi/__pycache__/api.cpython-310.pyc and b/pocketoptionapi/__pycache__/api.cpython-310.pyc differ diff --git a/pocketoptionapi/__pycache__/api.cpython-311.pyc b/pocketoptionapi/__pycache__/api.cpython-311.pyc deleted file mode 100644 index c65716c..0000000 Binary files a/pocketoptionapi/__pycache__/api.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/__pycache__/api.cpython-39.pyc b/pocketoptionapi/__pycache__/api.cpython-39.pyc new file mode 100644 index 0000000..68af619 Binary files /dev/null and b/pocketoptionapi/__pycache__/api.cpython-39.pyc differ diff --git a/pocketoptionapi/__pycache__/constants.cpython-310.pyc b/pocketoptionapi/__pycache__/constants.cpython-310.pyc index 7f59a58..8f08772 100644 Binary files a/pocketoptionapi/__pycache__/constants.cpython-310.pyc and b/pocketoptionapi/__pycache__/constants.cpython-310.pyc differ diff --git a/pocketoptionapi/__pycache__/constants.cpython-311.pyc b/pocketoptionapi/__pycache__/constants.cpython-311.pyc index 1a5aec4..83015a0 100644 Binary files a/pocketoptionapi/__pycache__/constants.cpython-311.pyc and b/pocketoptionapi/__pycache__/constants.cpython-311.pyc differ diff --git a/pocketoptionapi/__pycache__/constants.cpython-39.pyc b/pocketoptionapi/__pycache__/constants.cpython-39.pyc new file mode 100644 index 0000000..619aef0 Binary files /dev/null and b/pocketoptionapi/__pycache__/constants.cpython-39.pyc differ diff --git a/pocketoptionapi/__pycache__/expiration.cpython-310.pyc b/pocketoptionapi/__pycache__/expiration.cpython-310.pyc index 1c2c89c..70f0d08 100644 Binary files a/pocketoptionapi/__pycache__/expiration.cpython-310.pyc and b/pocketoptionapi/__pycache__/expiration.cpython-310.pyc differ diff --git a/pocketoptionapi/__pycache__/expiration.cpython-311.pyc b/pocketoptionapi/__pycache__/expiration.cpython-311.pyc deleted file mode 100644 index c565617..0000000 Binary files a/pocketoptionapi/__pycache__/expiration.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/__pycache__/expiration.cpython-39.pyc b/pocketoptionapi/__pycache__/expiration.cpython-39.pyc new file mode 100644 index 0000000..0d18314 Binary files /dev/null and b/pocketoptionapi/__pycache__/expiration.cpython-39.pyc differ diff --git a/pocketoptionapi/__pycache__/global_value.cpython-310.pyc b/pocketoptionapi/__pycache__/global_value.cpython-310.pyc index dd1f375..f096c95 100644 Binary files a/pocketoptionapi/__pycache__/global_value.cpython-310.pyc and b/pocketoptionapi/__pycache__/global_value.cpython-310.pyc differ diff --git a/pocketoptionapi/__pycache__/global_value.cpython-311.pyc b/pocketoptionapi/__pycache__/global_value.cpython-311.pyc deleted file mode 100644 index 2060890..0000000 Binary files a/pocketoptionapi/__pycache__/global_value.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/__pycache__/global_value.cpython-39.pyc b/pocketoptionapi/__pycache__/global_value.cpython-39.pyc new file mode 100644 index 0000000..7e529a8 Binary files /dev/null and b/pocketoptionapi/__pycache__/global_value.cpython-39.pyc differ diff --git a/pocketoptionapi/__pycache__/stable_api.cpython-310.pyc b/pocketoptionapi/__pycache__/stable_api.cpython-310.pyc index 3aa15a9..1983d9a 100644 Binary files a/pocketoptionapi/__pycache__/stable_api.cpython-310.pyc and b/pocketoptionapi/__pycache__/stable_api.cpython-310.pyc differ diff --git a/pocketoptionapi/__pycache__/stable_api.cpython-311.pyc b/pocketoptionapi/__pycache__/stable_api.cpython-311.pyc deleted file mode 100644 index 6fb2ef3..0000000 Binary files a/pocketoptionapi/__pycache__/stable_api.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/__pycache__/stable_api.cpython-39.pyc b/pocketoptionapi/__pycache__/stable_api.cpython-39.pyc new file mode 100644 index 0000000..9e457df Binary files /dev/null and b/pocketoptionapi/__pycache__/stable_api.cpython-39.pyc differ diff --git a/pocketoptionapi/api.py b/pocketoptionapi/api.py index cb0d725..f925d78 100644 --- a/pocketoptionapi/api.py +++ b/pocketoptionapi/api.py @@ -10,40 +10,40 @@ import atexit from collections import deque from pocketoptionapi.ws.client import WebsocketClient -from pocketoptionapi.ws.chanels.get_balances import * - -from pocketoptionapi.ws.chanels.ssid import Ssid -# from pocketoptionapi.ws.chanels.subscribe import * -# from pocketoptionapi.ws.chanels.unsubscribe import * -# from pocketoptionapi.ws.chanels.setactives import SetActives -from pocketoptionapi.ws.chanels.candles import GetCandles -# from pocketoptionapi.ws.chanels.buyv2 import Buyv2 -from pocketoptionapi.ws.chanels.buyv3 import * -# from pocketoptionapi.ws.chanels.user import * -# from pocketoptionapi.ws.chanels.api_game_betinfo import Game_betinfo -# from pocketoptionapi.ws.chanels.instruments import Get_instruments -# from pocketoptionapi.ws.chanels.get_financial_information import GetFinancialInformation -# from pocketoptionapi.ws.chanels.strike_list import Strike_list -# from pocketoptionapi.ws.chanels.leaderboard import Leader_Board - -# from pocketoptionapi.ws.chanels.traders_mood import Traders_mood_subscribe -# from pocketoptionapi.ws.chanels.traders_mood import Traders_mood_unsubscribe -# from pocketoptionapi.ws.chanels.buy_place_order_temp import Buy_place_order_temp -# from pocketoptionapi.ws.chanels.get_order import Get_order -# from pocketoptionapi.ws.chanels.get_deferred_orders import GetDeferredOrders -# from pocketoptionapi.ws.chanels.get_positions import * - -# from pocketoptionapi.ws.chanels.get_available_leverages import Get_available_leverages -# from pocketoptionapi.ws.chanels.cancel_order import Cancel_order -# from pocketoptionapi.ws.chanels.close_position import Close_position -# from pocketoptionapi.ws.chanels.get_overnight_fee import Get_overnight_fee -# from pocketoptionapi.ws.chanels.heartbeat import Heartbeat - -# from pocketoptionapi.ws.chanels.digital_option import * -# from pocketoptionapi.ws.chanels.api_game_getoptions import * -# from pocketoptionapi.ws.chanels.sell_option import Sell_Option -# from pocketoptionapi.ws.chanels.change_tpsl import Change_Tpsl -# from pocketoptionapi.ws.chanels.change_auto_margin_call import ChangeAutoMarginCall +from pocketoptionapi.ws.channels.get_balances import * + +from pocketoptionapi.ws.channels.ssid import Ssid +# from pocketoptionapi.ws.channels.subscribe import * +# from pocketoptionapi.ws.channels.unsubscribe import * +# from pocketoptionapi.ws.channels.setactives import SetActives +from pocketoptionapi.ws.channels.candles import GetCandles +# from pocketoptionapi.ws.channels.buyv2 import Buyv2 +from pocketoptionapi.ws.channels.buyv3 import * +# from pocketoptionapi.ws.channels.user import * +# from pocketoptionapi.ws.channels.api_game_betinfo import Game_betinfo +# from pocketoptionapi.ws.channels.instruments import Get_instruments +# from pocketoptionapi.ws.channels.get_financial_information import GetFinancialInformation +# from pocketoptionapi.ws.channels.strike_list import Strike_list +# from pocketoptionapi.ws.channels.leaderboard import Leader_Board + +# from pocketoptionapi.ws.channels.traders_mood import Traders_mood_subscribe +# from pocketoptionapi.ws.channels.traders_mood import Traders_mood_unsubscribe +# from pocketoptionapi.ws.channels.buy_place_order_temp import Buy_place_order_temp +# from pocketoptionapi.ws.channels.get_order import Get_order +# from pocketoptionapi.ws.channels.get_deferred_orders import GetDeferredOrders +# from pocketoptionapi.ws.channels.get_positions import * + +# from pocketoptionapi.ws.channels.get_available_leverages import Get_available_leverages +# from pocketoptionapi.ws.channels.cancel_order import Cancel_order +# from pocketoptionapi.ws.channels.close_position import Close_position +# from pocketoptionapi.ws.channels.get_overnight_fee import Get_overnight_fee +# from pocketoptionapi.ws.channels.heartbeat import Heartbeat + +# from pocketoptionapi.ws.channels.digital_option import * +# from pocketoptionapi.ws.channels.api_game_getoptions import * +# from pocketoptionapi.ws.channels.sell_option import Sell_Option +# from pocketoptionapi.ws.channels.change_tpsl import Change_Tpsl +# from pocketoptionapi.ws.channels.change_auto_margin_call import ChangeAutoMarginCall from pocketoptionapi.ws.objects.timesync import TimeSync # from pocketoptionapi.ws.objects.profile import Profile @@ -51,7 +51,9 @@ # from pocketoptionapi.ws.objects.listinfodata import ListInfoData # from pocketoptionapi.ws.objects.betinfo import Game_betinfo_data import pocketoptionapi.global_value as global_value +from pocketoptionapi.ws.channels.change_symbol import ChangeSymbol from collections import defaultdict +from pocketoptionapi.ws.objects.time_sync import TimeSynchronizer def nested_dict(n, type): @@ -71,7 +73,10 @@ class PocketOptionAPI(object): # pylint: disable=too-many-instance-attributes # pylint: disable=too-many-public-methods socket_option_opened = {} - timesync = TimeSync() + time_sync = TimeSync() + sync = TimeSynchronizer() + timesync = None + # pylint: disable=too-many-arguments # profile = Profile() candles = Candles() # listinfodata = ListInfoData() @@ -132,6 +137,8 @@ class PocketOptionAPI(object): # pylint: disable=too-many-instance-attributes users_availability = None history_data = None historyNew = None + server_timestamp = None + sync_datetime = None # ------------------ @@ -177,11 +184,9 @@ def send_websocket_request(self, name, msg, request_id="", no_force_send=True): data = f'42{json.dumps(msg)}' while (global_value.ssl_Mutual_exclusion or global_value.ssl_Mutual_exclusion_write) and no_force_send: - pass global_value.ssl_Mutual_exclusion_write = True - # self.websocket_client.send_message(data) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) @@ -223,27 +228,22 @@ def connect(self): global_value.ssl_Mutual_exclusion = False global_value.ssl_Mutual_exclusion_write = False - try: - self.close() - except: - pass - check_websocket, websocket_reason = self.start_websocket() if not check_websocket: return check_websocket, websocket_reason - self.timesync.server_timestamps = None + self.time_sync.server_timestamps = None while True: try: - if self.timesync.server_timestamps is not None: + if self.time_sync.server_timestamps is not None: break except: pass return True, None - def close(self): - self.websocket.close() + async def close(self, error=None): + await self.websocket.on_close(error) self.websocket_thread.join() def websocket_alive(self): @@ -269,6 +269,30 @@ def getcandles(self): """Property for get IQ Option websocket candles chanel. :returns: The instance of :class:`GetCandles - `. + `. """ return GetCandles(self) + + @property + def change_symbol(self): + """Property for get Pocket Option websocket change_symbol chanel. + + :returns: The instance of :class:`ChangeSymbol + `. + """ + return ChangeSymbol(self) + + @property + def synced_datetime(self): + try: + if self.time_sync is not None: + self.sync.synchronize(self.time_sync.server_timestamp) + self.sync_datetime = self.sync.get_synced_datetime() + else: + logging.error("timesync no está establecido") + self.sync_datetime = None + except Exception as e: + logging.error(e) + self.sync_datetime = None + + return self.sync_datetime diff --git a/pocketoptionapi/constants.py b/pocketoptionapi/constants.py index 46ae868..cba6738 100644 --- a/pocketoptionapi/constants.py +++ b/pocketoptionapi/constants.py @@ -137,23 +137,25 @@ class REGION: REGIONS = { - "EUROPA": "wss://api-eu.po.market/socket.io/?EIO=4&transport=websocket", - "SEYCHELLES": "wss://api-sc.po.market/socket.io/?EIO=4&transport=websocket", - "HONGKONG": "wss://api-hk.po.market/socket.io/?EIO=4&transport=websocket", - "SERVER1": "wss://api-spb.po.market/socket.io/?EIO=4&transport=websocket", - "FRANCE2": "wss://api-fr2.po.market/socket.io/?EIO=4&transport=websocket", - "UNITED_STATES4": "wss://api-us4.po.market/socket.io/?EIO=4&transport=websocket", - "UNITED_STATES3": "wss://api-us3.po.market/socket.io/?EIO=4&transport=websocket", - "UNITED_STATES2": "wss://api-us2.po.market/socket.io/?EIO=4&transport=websocket", - "UNITED_STATES": "wss://api-us-north.po.market/socket.io/?EIO=4&transport=websocket", - "RUSSIA": "wss://api-msk.po.market/socket.io/?EIO=4&transport=websocket", - "SERVER2": "wss://api-l.po.market/socket.io/?EIO=4&transport=websocket", - "INDIA": "wss://api-in.po.market/socket.io/?EIO=4&transport=websocket", - "FRANCE": "wss://api-fr.po.market/socket.io/?EIO=4&transport=websocket", - "FINLAND": "wss://api-fin.po.market/socket.io/?EIO=4&transport=websocket", - "SERVER3": "wss://api-c.po.market/socket.io/?EIO=4&transport=websocket", - "ASIA": "wss://api-asia.po.market/socket.io/?EIO=4&transport=websocket", - "SERVER4": "wss://api-us-south.po.market/socket.io/?EIO=4&transport=websocket" + # "EUROPA": "wss://api-eu.po.market/socket.io/?EIO=4&transport=websocket", + # "SEYCHELLES": "wss://api-sc.po.market/socket.io/?EIO=4&transport=websocket", + # "HONGKONG": "wss://api-hk.po.market/socket.io/?EIO=4&transport=websocket", + # "SERVER1": "wss://api-spb.po.market/socket.io/?EIO=4&transport=websocket", + # "FRANCE2": "wss://api-fr2.po.market/socket.io/?EIO=4&transport=websocket", + # "UNITED_STATES4": "wss://api-us4.po.market/socket.io/?EIO=4&transport=websocket", + # "UNITED_STATES3": "wss://api-us3.po.market/socket.io/?EIO=4&transport=websocket", + # "UNITED_STATES2": "wss://api-us2.po.market/socket.io/?EIO=4&transport=websocket", + "DEMO": "wss://demo-api-eu.po.market/socket.io/?EIO=4&transport=websocket", + # "DEMO_2": "wss://try-demo-eu.po.market/socket.io/?EIO=4&transport=websocket", + # "UNITED_STATES": "wss://api-us-north.po.market/socket.io/?EIO=4&transport=websocket", + # "RUSSIA": "wss://api-msk.po.market/socket.io/?EIO=4&transport=websocket", + # "SERVER2": "wss://api-l.po.market/socket.io/?EIO=4&transport=websocket", + # "INDIA": "wss://api-in.po.market/socket.io/?EIO=4&transport=websocket", + # "FRANCE": "wss://api-fr.po.market/socket.io/?EIO=4&transport=websocket", + # "FINLAND": "wss://api-fin.po.market/socket.io/?EIO=4&transport=websocket", + # "SERVER3": "wss://api-c.po.market/socket.io/?EIO=4&transport=websocket", + # "ASIA": "wss://api-asia.po.market/socket.io/?EIO=4&transport=websocket", + # "SERVER4": "wss://api-us-south.po.market/socket.io/?EIO=4&transport=websocket" } def __getattr__(self, key): diff --git a/pocketoptionapi/prueba_temp.py b/pocketoptionapi/prueba_temp.py new file mode 100644 index 0000000..1141261 --- /dev/null +++ b/pocketoptionapi/prueba_temp.py @@ -0,0 +1,9 @@ +import pandas as pd + + +df_1 = pd.read_csv('datos_completos_AUDNZD_otc.csv') +df_2 = pd.read_csv('datos_completos_AUDNZD_otc_2.csv') + +df_full = pd.concat([df_1, df_2], axis=0) +print(df_full.shape) +df_full.to_csv('datos_full_AUDNZD_otc.csv', index=False) diff --git a/pocketoptionapi/stable_api.py b/pocketoptionapi/stable_api.py index 27fb47d..9801c86 100644 --- a/pocketoptionapi/stable_api.py +++ b/pocketoptionapi/stable_api.py @@ -16,8 +16,6 @@ from collections import deque # from pocketoptionapi.expiration import get_expiration_time, get_remaning_time import pandas as pd -from pocketoptionapi.ws.chanels.get_balances import * -from pocketoptionapi.ws.client import WebsocketClient # Obtener la zona horaria local del sistema como una cadena en el formato IANA local_zone_name = get_localzone() @@ -36,7 +34,7 @@ def get_balance(): class PocketOption: - __version__ = "6.8.9.1" + __version__ = "1.0.0" def __init__(self, ssid): self.size = [1, 5, 10, 15, 30, 60, 120, 300, 600, 900, 1800, @@ -67,10 +65,10 @@ def __init__(self, ssid): # -------------------------------------------------------------------------- def get_server_timestamp(self): - return self.api.timesync.server_timestamp + return self.api.time_sync.server_timestamp def get_server_datetime(self): - return self.api.timesync.server_datetime + return self.api.time_sync.server_datetime def set_session(self, header, cookie): self.SESSION_HEADER = header @@ -104,8 +102,6 @@ def connect(self): return False return True - async def reconect(self): - await WebsocketClient(self).reconnect() @staticmethod def check_connect(): # True/False @@ -119,46 +115,74 @@ def check_connect(): # wait for timestamp getting # self.update_ACTIVES_OPCODE() - def get_balance(self): + @staticmethod + def get_balance(): if global_value.balance_updated: return global_value.balance else: return None - def buy(self, amount, ACTIVES, ACTION, expirations): + def buy(self, amount, active, action, expirations): self.api.buy_multi_option = {} self.api.buy_successful = None req_id = "buy" + try: - self.api.buy_multi_option[req_id]["id"] = None - except: - pass + if req_id not in self.api.buy_multi_option: + self.api.buy_multi_option[req_id] = {"id": None} + else: + self.api.buy_multi_option[req_id]["id"] = None + except Exception as e: + logging.error(f"Error initializing buy_multi_option: {e}") + return False, None + global_value.order_data = None global_value.result = None - self.api.buyv3( - amount, ACTIVES, ACTION, expirations, req_id) + + self.api.buyv3(amount, active, action, expirations, req_id) + start_t = time.time() - while global_value.result is None or global_value.order_data is None: + while True: + if global_value.result is not None and global_value.order_data is not None: + break if time.time() - start_t >= 5: - logging.error(global_value.order_data["error"]) + if isinstance(global_value.order_data, dict) and "error" in global_value.order_data: + logging.error(global_value.order_data["error"]) + else: + logging.error("Unknown error occurred during buy operation") return False, None + time.sleep(0.1) # Sleep for a short period to prevent busy-waiting - return global_value.result, global_value.order_data["id"] + return global_value.result, global_value.order_data.get("id", None) def check_win(self, id_number): """Return amount of deals and win/lose status.""" + start_t = time.time() + order_info = None + while True: try: order_info = self.get_async_order(id_number) - if order_info["id"] is not None: + if order_info and "id" in order_info and order_info["id"] is not None: break except: pass + # except Exception as e: + # logging.error(f"Error retrieving order info: {e}") + + if time.time() - start_t >= 120: + logging.error("Timeout: Could not retrieve order info in time.") + return None, "unknown" - # Determina el estado de win/lose basado en el profit. - status = "win" if order_info["profit"] > 0 else "lose" - return order_info["profit"], status + time.sleep(0.1) # Sleep for a short period to prevent busy-waiting + + if order_info and "profit" in order_info: + status = "win" if order_info["profit"] > 0 else "lose" + return order_info["profit"], status + else: + logging.error("Invalid order info retrieved.") + return None, "unknown" @staticmethod def last_time(timestamp, period): @@ -167,48 +191,73 @@ def last_time(timestamp, period): timestamp_redondeado = (timestamp // period) * period return int(timestamp_redondeado) - def get_candles(self, ACTIVES, period, end_time, count=9000, count_request=1): + def get_candles(self, active, period, start_time=None, count=6000, count_request=1): """ Realiza múltiples peticiones para obtener datos históricos de velas y los procesa. Devuelve un Dataframe ordenado de menor a mayor por la columna 'time'. - :param ACTIVES: El activo para el cual obtener las velas. + :param active: El activo para el cual obtener las velas. :param period: El intervalo de tiempo de cada vela en segundos. - :param count: El número de segundos a obtener en cada petición, max: 9000 = 150 datos. - :param end_time: El tiempo final para la última vela. + :param count: El número de segundos a obtener en cada petición, max: 9000 = 150 datos de 1 min. + :param start_time: El tiempo final para la última vela. :param count_request: El número de peticiones para obtener más datos históricos. """ + if start_time is None: + time_sync = self.get_server_timestamp() + time_red = self.last_time(time_sync, period) + else: + time_red = start_time + time_sync = self.get_server_timestamp() - time_sync = self.get_server_timestamp() - period - time_red = self.last_time(time_sync, period) - print(time_red) - data_temp = [] - self.api.candles = data_temp - - if self.api.historyNew is not None: - data_temp.extend(self.process_data_history(self.api.historyNew, period)) + all_candles = [] - for i in range(count_request): + for _ in range(count_request): self.api.history_data = None + while True: try: - self.api.getcandles(ACTIVES, period, count, time_red) + # Enviar la petición de velas + self.api.getcandles(active, 30, count, time_red) + + # Esperar hasta que history_data no sea None while self.check_connect and self.api.history_data is None: - pass + time.sleep(0.1) + if self.api.history_data is not None: - data_temp.extend(self.api.history_data) + all_candles.extend(self.api.history_data) break - except: - logging.error('**error** get_candles need reconnect') - # self.connect() + except Exception as e: + logging.error(e) + # Puedes agregar lógica de reconexión aquí si es necesario + + # Ordenar all_candles por 'index' para asegurar que estén en el orden correcto + all_candles = sorted(all_candles, key=lambda x: x["time"]) + + # Asegurarse de que se han recibido velas antes de actualizar time_red + if all_candles: + # Usar el tiempo de la última vela recibida para la próxima petición + time_red = all_candles[0]["time"] - # Ajusta el tiempo de inicio para la próxima petición - time_red -= count + # Crear un DataFrame con todas las velas obtenidas + df_candles = pd.DataFrame(all_candles) - return self.api.candles + # Ordenar por la columna 'time' de menor a mayor + df_candles = df_candles.sort_values(by='time').reset_index(drop=True) + df_candles['time'] = pd.to_datetime(df_candles['time'], unit='s') + df_candles.set_index('time', inplace=True) + df_candles.index = df_candles.index.floor('1s') - def process_data_history(self, data, period): + # Resamplear los datos en intervalos de 30 segundos y calcular open, high, low, close + df_resampled = df_candles['price'].resample(f'{period}s').ohlc() + + # Resetear el índice para que 'time' vuelva a ser una columna + df_resampled.reset_index(inplace=True) + + return df_resampled + + @staticmethod + def process_data_history(data, period): """ Este método toma datos históricos, los convierte en un DataFrame de pandas, redondea los tiempos al minuto más cercano, y calcula los valores OHLC (Open, High, Low, Close) para cada minuto. Luego, convierte el resultado en un diccionario @@ -222,8 +271,8 @@ def process_data_history(self, data, period): df = pd.DataFrame(data['history'], columns=['timestamp', 'price']) # Convertir a datetime y redondear al minuto df['datetime'] = pd.to_datetime(df['timestamp'], unit='s', utc=True) - df['datetime'] = df['datetime'].dt.tz_convert(str(local_zone_name)) - df['minute_rounded'] = df['datetime'].dt.floor(f'{period/60}T') + # df['datetime'] = df['datetime'].dt.tz_convert(str(local_zone_name)) + df['minute_rounded'] = df['datetime'].dt.floor(f'{period / 60}min') # Calcular OHLC ohlcv = df.groupby('minute_rounded').agg( @@ -236,6 +285,8 @@ def process_data_history(self, data, period): ohlcv['time'] = ohlcv['minute_rounded'].apply(lambda x: int(x.timestamp())) ohlcv = ohlcv.drop(columns='minute_rounded') + ohlcv = ohlcv.iloc[:-1] + ohlcv_dict = ohlcv.to_dict(orient='records') return ohlcv_dict @@ -265,10 +316,15 @@ def process_candle(candle_data, period): data_df.sort_values(by='time', ascending=True, inplace=True) data_df.drop_duplicates(subset='time', keep="first", inplace=True) data_df.reset_index(drop=True, inplace=True) - data_df.fillna(method='ffill', inplace=True) + data_df.ffill(inplace=True) data_df.drop(columns='symbol_id', inplace=True) # Verificación opcional: Comprueba si las diferencias son todas de 60 segundos (excepto el primer valor NaN) diferencias = data_df['time'].diff() diff = (diferencias[1:] == period).all() return data_df, diff + def change_symbol(self, active, period): + return self.api.change_symbol(active, period) + + def sync_datetime(self): + return self.api.synced_datetime diff --git a/pocketoptionapi/ws/__pycache__/client.cpython-310.pyc b/pocketoptionapi/ws/__pycache__/client.cpython-310.pyc index 3228589..38cc8ac 100644 Binary files a/pocketoptionapi/ws/__pycache__/client.cpython-310.pyc and b/pocketoptionapi/ws/__pycache__/client.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/__pycache__/client.cpython-311.pyc b/pocketoptionapi/ws/__pycache__/client.cpython-311.pyc deleted file mode 100644 index 6879654..0000000 Binary files a/pocketoptionapi/ws/__pycache__/client.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/__pycache__/client.cpython-39.pyc b/pocketoptionapi/ws/__pycache__/client.cpython-39.pyc index 42a9c1a..448012b 100644 Binary files a/pocketoptionapi/ws/__pycache__/client.cpython-39.pyc and b/pocketoptionapi/ws/__pycache__/client.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/base.cpython-311.pyc b/pocketoptionapi/ws/chanels/__pycache__/base.cpython-311.pyc deleted file mode 100644 index a888d70..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/base.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-310.pyc b/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-310.pyc deleted file mode 100644 index ad63c18..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-310.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-311.pyc b/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-311.pyc deleted file mode 100644 index 0c1afac..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/buyv3.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/candles.cpython-311.pyc b/pocketoptionapi/ws/chanels/__pycache__/candles.cpython-311.pyc deleted file mode 100644 index 45610cb..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/candles.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-310.pyc b/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-310.pyc deleted file mode 100644 index 75e0094..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-310.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-311.pyc b/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-311.pyc deleted file mode 100644 index 0116114..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/get_balances.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-311.pyc b/pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-311.pyc deleted file mode 100644 index 6cbbae7..0000000 Binary files a/pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/chanels/buyv3.py b/pocketoptionapi/ws/chanels/buyv3.py index 07179f8..f39fa99 100644 --- a/pocketoptionapi/ws/chanels/buyv3.py +++ b/pocketoptionapi/ws/chanels/buyv3.py @@ -14,7 +14,7 @@ def __call__(self, amount, active, direction, duration, request_id): # thank Darth-Carrotpie's code # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 - exp = get_expiration_time(int(self.api.timesync.server_timestamp), duration) + exp = get_expiration_time(int(self.api.timesync.server_timestamps), duration) """if idx < 5: option = 3 # "turbo" else: diff --git a/pocketoptionapi/ws/chanels/get_balances.py b/pocketoptionapi/ws/chanels/get_balances.py index 627ad38..97659bb 100644 --- a/pocketoptionapi/ws/chanels/get_balances.py +++ b/pocketoptionapi/ws/chanels/get_balances.py @@ -13,6 +13,6 @@ def __call__(self): data = {"name": "get-balances", "version": "1.0" } - print(f"sent balance requests | data: {data}") + print("get_balances in get_balances.py") self.send_websocket_request(self.name, data) diff --git a/pocketoptionapi/ws/chanels/__pycache__/base.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/base.cpython-310.pyc similarity index 71% rename from pocketoptionapi/ws/chanels/__pycache__/base.cpython-310.pyc rename to pocketoptionapi/ws/channels/__pycache__/base.cpython-310.pyc index 6a48b8e..f254efb 100644 Binary files a/pocketoptionapi/ws/chanels/__pycache__/base.cpython-310.pyc and b/pocketoptionapi/ws/channels/__pycache__/base.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/base.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/base.cpython-39.pyc new file mode 100644 index 0000000..6e0aec9 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/base.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-310.pyc new file mode 100644 index 0000000..c5ff517 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-39.pyc new file mode 100644 index 0000000..24ec963 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/buyv3.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/candles.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/candles.cpython-310.pyc similarity index 65% rename from pocketoptionapi/ws/chanels/__pycache__/candles.cpython-310.pyc rename to pocketoptionapi/ws/channels/__pycache__/candles.cpython-310.pyc index 1798515..777acb4 100644 Binary files a/pocketoptionapi/ws/chanels/__pycache__/candles.cpython-310.pyc and b/pocketoptionapi/ws/channels/__pycache__/candles.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/candles.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/candles.cpython-39.pyc new file mode 100644 index 0000000..3e01754 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/candles.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-310.pyc new file mode 100644 index 0000000..34a0144 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-39.pyc new file mode 100644 index 0000000..395b0e1 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/change_symbol.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-310.pyc new file mode 100644 index 0000000..66e1c60 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-39.pyc new file mode 100644 index 0000000..47bd32f Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/get_balances.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-310.pyc b/pocketoptionapi/ws/channels/__pycache__/ssid.cpython-310.pyc similarity index 57% rename from pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-310.pyc rename to pocketoptionapi/ws/channels/__pycache__/ssid.cpython-310.pyc index 7146c46..0b94b8c 100644 Binary files a/pocketoptionapi/ws/chanels/__pycache__/ssid.cpython-310.pyc and b/pocketoptionapi/ws/channels/__pycache__/ssid.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/channels/__pycache__/ssid.cpython-39.pyc b/pocketoptionapi/ws/channels/__pycache__/ssid.cpython-39.pyc new file mode 100644 index 0000000..33542f7 Binary files /dev/null and b/pocketoptionapi/ws/channels/__pycache__/ssid.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/channels/base.py b/pocketoptionapi/ws/channels/base.py new file mode 100644 index 0000000..5a93fb1 --- /dev/null +++ b/pocketoptionapi/ws/channels/base.py @@ -0,0 +1,26 @@ +"""Module for base Pocket Option base websocket chanel.""" + + +class Base(object): + """Class for base Pocket Option websocket chanel.""" + + # pylint: disable=too-few-public-methods + + def __init__(self, api): + """ + :param api: The instance of :class:`PocketOptionAPI + `. + """ + self.api = api + + def send_websocket_request(self, name, msg, request_id=""): + """Send request to Pocket Option server websocket. + + :param request_id: + :param str name: The websocket chanel name. + :param list msg: The websocket chanel msg. + + :returns: The instance of :class:`requests.Response`. + """ + + return self.api.send_websocket_request(name, msg, request_id) diff --git a/pocketoptionapi/ws/channels/buyv3.py b/pocketoptionapi/ws/channels/buyv3.py new file mode 100644 index 0000000..406ecf4 --- /dev/null +++ b/pocketoptionapi/ws/channels/buyv3.py @@ -0,0 +1,61 @@ +import datetime +import json +import time +from pocketoptionapi.ws.channels.base import Base +import logging +import pocketoptionapi.global_value as global_value +from pocketoptionapi.expiration import get_expiration_time + + +class Buyv3(Base): + name = "sendMessage" + + def __call__(self, amount, active, direction, duration, request_id): + + # thank Darth-Carrotpie's code + # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 + # exp = get_expiration_time(int(self.api.timesync.server_timestamps), duration) + """if idx < 5: + option = 3 # "turbo" + else: + option = 1 # "binary""" + # Construir el diccionario + data_dict = { + "asset": active, + "amount": amount, + "action": direction, + "isDemo": 1, + "requestId": request_id, + "optionType": 100, + "time": duration + } + + message = ["openOrder", data_dict] + + self.send_websocket_request(self.name, message, str(request_id)) + + +class Buyv3_by_raw_expired(Base): + name = "sendMessage" + + def __call__(self, price, active, direction, option, expired, request_id): + + # thank Darth-Carrotpie's code + # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 + + if option == "turbo": + option_id = 3 # "turbo" + elif option == "binary": + option_id = 1 # "binary" + data = { + "body": {"price": price, + "active_id": active, + "expired": int(expired), + "direction": direction.lower(), + "option_type_id": option_id, + "user_balance_id": int(global_value.balance_id) + }, + "name": "binary-options.open-option", + "version": "1.0" + } + self.send_websocket_request(self.name, data, str(request_id)) diff --git a/pocketoptionapi/ws/channels/candles.py b/pocketoptionapi/ws/channels/candles.py new file mode 100644 index 0000000..806ca4f --- /dev/null +++ b/pocketoptionapi/ws/channels/candles.py @@ -0,0 +1,42 @@ +"""Module for Pocket option candles websocket chanel.""" + +from pocketoptionapi.ws.channels.base import Base +import time +import random + + +def index_num(): + # El número mínimo sería 100000000000 (12 dígitos) + minimo = 5000 + # El número máximo sería 999999999999 (12 dígitos) + maximo = 10000 - 1 + # Generar y retornar un número aleatorio dentro del rango + return random.randint(minimo, maximo) + + +class GetCandles(Base): + """Class for Pocket option candles websocket chanel.""" + # pylint: disable=too-few-public-methods + + name = "sendMessage" + + def __call__(self, active_id, interval, count, end_time): + """Method to send message to candles websocket chanel. + + :param active_id: The active/asset identifier. + :param interval: The candle duration (timeframe for the candles). + :param count: The number of candles you want to have + """ + + # {"asset": "AUDNZD_otc", "index": 171201484810, "time": 1712002800, "offset": 9000, "period": 60}] + data = { + "asset": str(active_id), + "index": end_time, + "offset": count, # number of candles + "period": interval, + "time": end_time, # time size sample:if interval set 1 mean get time 0~1 candle + } + + data = ["loadHistoryPeriod", data] + + self.send_websocket_request(self.name, data) diff --git a/pocketoptionapi/ws/channels/change_symbol.py b/pocketoptionapi/ws/channels/change_symbol.py new file mode 100644 index 0000000..9f6ff97 --- /dev/null +++ b/pocketoptionapi/ws/channels/change_symbol.py @@ -0,0 +1,25 @@ +"""Module for PocketOption change symbol websocket chanel.""" + +from pocketoptionapi.ws.channels.base import Base +import time +import random + + +class ChangeSymbol(Base): + """Class for Pocket option change symbol websocket chanel.""" + # pylint: disable=too-few-public-methods + + name = "sendMessage" + + def __call__(self, active_id, interval): + """Method to send message to candles websocket chanel. + + :param active_id: The active/asset identifier. + :param interval: The candle duration (timeframe for the candles). + """ + + data_stream = ["changeSymbol", { + "asset": active_id, + "period": interval}] + + self.send_websocket_request(self.name, data_stream) diff --git a/pocketoptionapi/ws/channels/get_balances.py b/pocketoptionapi/ws/channels/get_balances.py new file mode 100644 index 0000000..377b90c --- /dev/null +++ b/pocketoptionapi/ws/channels/get_balances.py @@ -0,0 +1,18 @@ +from pocketoptionapi.ws.channels.base import Base +import time + + +class Get_Balances(Base): + name = "sendMessage" + + def __call__(self): + """ + :param options_ids: list or int + """ + + data = {"name": "get-balances", + "version": "1.0" + } + print("get_balances in get_balances.py") + + self.send_websocket_request(self.name, data) diff --git a/pocketoptionapi/ws/channels/ssid.py b/pocketoptionapi/ws/channels/ssid.py new file mode 100644 index 0000000..777d934 --- /dev/null +++ b/pocketoptionapi/ws/channels/ssid.py @@ -0,0 +1,17 @@ +"""Module for Pocket Option API ssid websocket chanel.""" + +from pocketoptionapi.ws.channels.base import Base + + +class Ssid(Base): + """Class for Pocket Option API ssid websocket chanel.""" + # pylint: disable=too-few-public-methods + + name = "ssid" + + def __call__(self, ssid): + """Method to send message to ssid websocket chanel. + + :param ssid: The session identifier. + """ + self.send_websocket_request(self.name, ssid) diff --git a/pocketoptionapi/ws/client.py b/pocketoptionapi/ws/client.py index bf85e7f..a570c56 100644 --- a/pocketoptionapi/ws/client.py +++ b/pocketoptionapi/ws/client.py @@ -1,56 +1,75 @@ import asyncio from datetime import datetime, timedelta, timezone -import websocket import websockets import json import logging import ssl -import time + # Suponiendo la existencia de estos módulos basados en tu código original import pocketoptionapi.constants as OP_code import pocketoptionapi.global_value as global_value from pocketoptionapi.constants import REGION from pocketoptionapi.ws.objects.timesync import TimeSync +from pocketoptionapi.ws.objects.time_sync import TimeSynchronizer logger = logging.getLogger(__name__) timesync = TimeSync() +sync = TimeSynchronizer() + async def on_open(): # pylint: disable=unused-argument """Method to process websocket open.""" - print("CONECTADO CON EXITO") - logger = logging.getLogger(__name__) + print("CONNECTED SUCCESSFUL") logger.debug("Websocket client connected.") global_value.websocket_is_connected = True -async def send_pin(ws): - while not global_value.websocket_is_connected: +async def send_ping(ws): + while global_value.websocket_is_connected is False: await asyncio.sleep(0.1) - print("before pass") - # pass - print("after pass") + pass while True: - await asyncio.sleep(5) - print("sent ping request") + await asyncio.sleep(20) await ws.send('42["ps"]') +async def process_message(message): + try: + data = json.loads(message) + print(f"Received message: {data}") + + # Procesa el mensaje dependiendo del tipo + if isinstance(data, dict) and 'uid' in data: + uid = data['uid'] + print(f"UID: {uid}") + elif isinstance(data, list) and len(data) > 0: + event_type = data[0] + event_data = data[1] + print(f"Event type: {event_type}, Event data: {event_data}") + # Aquí puedes añadir más lógica para manejar diferentes tipos de eventos + + except json.JSONDecodeError as e: + print(f"JSON decode error: {e}") + except KeyError as e: + print(f"Key error: {e}") + except Exception as e: + print(f"Error processing message: {e}") + + class WebsocketClient(object): def __init__(self, api) -> None: """ Inicializa el cliente WebSocket. - - :param ssid: El ID de sesión para la autenticación. - :param url: La URL del WebSocket a la que conectarse. + :param api: Instancia de la clase PocketOptionApi """ self.updateHistoryNew = None self.updateStream = None self.history_data_ready = None - self.successcloseOrder = False + self.successCloseOrder = False self.api = api self.message = None self.url = None @@ -58,66 +77,77 @@ def __init__(self, api) -> None: self.websocket = None self.region = REGION() self.loop = asyncio.get_event_loop() - self.esperar_segundo_mensaje = False - self.recibido_updateClosedDeals = False - - async def reconnect(self): - regs = self.region.get_regions() - for i in regs: - print(f"Reconnecting to {i}...") - async with websockets.connect(i, extra_headers={"Origin": "https://pocketoption.com/ "}) as ws: - print("Conectado a: ", i) - self.websocket = ws - self.url = i - on_message_task = asyncio.create_task(self.websocket_listener(ws)) - sender_task = asyncio.create_task(send_pin(ws)) - message_task = asyncio.create_task(self.send_message(self.message)) - await asyncio.gather(on_message_task, sender_task, message_task) - + self.wait_second_message = False + self._updateClosedDeals = False async def websocket_listener(self, ws): - async for message in ws: - await self.on_message(message) + try: + async for message in ws: + await self.on_message(message) + except Exception as e: + logging.warning(f"Error occurred: {e}") async def connect(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE - while global_value.websocket_is_connected is False: + try: + await self.api.close() + except: + pass + + while not global_value.websocket_is_connected: for url in self.region.get_regions(True): print(url) try: - async with websockets.connect(url, extra_headers={"Origin": "https://pocketoption.com/ "}) as ws: - - print("Conectado a: ", url) + async with websockets.connect( + url, + ssl=ssl_context, + extra_headers={"Origin": "https://pocketoption.com", "Cache-Control": "no-cache"}, + user_agent_header="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, " + "like Gecko) Chrome/124.0.0.0 Safari/537.36" + ) as ws: + + # print("Connected a: ", url) self.websocket = ws self.url = url + global_value.websocket_is_connected = True + + # Crear y ejecutar tareas + # process_message_task = asyncio.create_task(process_message(self.message)) on_message_task = asyncio.create_task(self.websocket_listener(ws)) - sender_task = asyncio.create_task(send_pin(ws)) - message_task = asyncio.create_task(self.send_message(self.message)) - await asyncio.gather(on_message_task, sender_task, message_task) + sender_task = asyncio.create_task(self.send_message(self.message)) + ping_task = asyncio.create_task(send_ping(ws)) + + await asyncio.gather(on_message_task, sender_task, ping_task) + except websockets.ConnectionClosed as e: + global_value.websocket_is_connected = False await self.on_close(e) + logger.warning("Trying another server") + except Exception as e: + global_value.websocket_is_connected = False await self.on_error(e) - return True + await asyncio.sleep(1) # Esperar antes de intentar reconectar + + return True async def send_message(self, message): while global_value.websocket_is_connected is False: await asyncio.sleep(0.1) - pass self.message = message - if global_value.websocket_is_connected: - - if message is not None: + if global_value.websocket_is_connected and message is not None: + try: await self.websocket.send(message) - - else: - logging.warning("WebSocked not connected") + except Exception as e: + logger.warning(f"Error sending message: {e}") + elif message is not None: + logger.warning("WebSocket not connected") @staticmethod def dict_queue_add(self, dict, maxdict, key1, key2, key3, value): @@ -139,44 +169,29 @@ def dict_queue_add(self, dict, maxdict, key1, key2, key3, value): async def on_message(self, message): # pylint: disable=unused-argument """Method to process websocket messages.""" # global_value.ssl_Mutual_exclusion = True - logger = logging.getLogger(__name__) logger.debug(message) - print(message) - - # message = json.loads(str(message)) if type(message) is bytes: - # Paso 1: Decodificar los bytes a una cadena de texto (string) message = message.decode('utf-8') message = json.loads(message) - # print(message, type(message)) # [:1000000]) + # print(message, type(message)) if "balance" in message: - global_value.balance_id = message["uid"] + if "uid" in message: + global_value.balance_id = message["uid"] global_value.balance = message["balance"] global_value.balance_type = message["isDemo"] - data = { - "balance_id" : message["uid"], - "balance" : message["balance"], - "balance_type" : message["isDemo"] - } - - with open("balance.json", "w") as f: - json.dump(data, f) - elif "requestId" in message and message["requestId"] == 'buy': global_value.order_data = message - # Supongamos que este es el segundo mensaje de interés basado en tu lógica - elif self.esperar_segundo_mensaje and isinstance(message, list): - self.esperar_segundo_mensaje = False # Restablecer para futuros mensajes - self.recibido_updateClosedDeals = False # Restablecer el estado + elif self.wait_second_message and isinstance(message, list): + self.wait_second_message = False # Restablecer para futuros mensajes + self._updateClosedDeals = False # Restablecer el estado - elif self.esperar_segundo_mensaje and isinstance(message, dict) and self.successcloseOrder: + elif isinstance(message, dict) and self.successCloseOrder: self.api.order_async = message - self.successcloseOrder = False # Restablecer para futuros mensajes - self.esperar_segundo_mensaje = False # Restablecer el estado + self.successCloseOrder = False # Restablecer para futuros mensajes elif self.history_data_ready and isinstance(message, dict): self.history_data_ready = False @@ -184,8 +199,7 @@ async def on_message(self, message): # pylint: disable=unused-argument elif self.updateStream and isinstance(message, list): self.updateStream = False - self.api.timesync.server_timestamp = message[0][1] - # print("server_timestamp asignado:", timesync.server_timestamp) + self.api.time_sync.server_timestamp = message[0][1] elif self.updateHistoryNew and isinstance(message, dict): self.updateHistoryNew = False @@ -197,27 +211,24 @@ async def on_message(self, message): # pylint: disable=unused-argument pass # print(message) - if message.startswith('0{"sid":"'): - # print(f"{self.url.split('/')[2]} got 0 sid send 40") + if message.startswith('0') and "sid" in message: await self.websocket.send("40") + elif message == "2": - # print(f"{self.url.split('/')[2]} got 2 send 3") await self.websocket.send("3") - elif message.startswith('40{"sid":"'): - print(f"{self.url.split('/')[2]} got 40 sid send session") - print(f"send: {self.ssid}") + elif "40" and "sid" in message: await self.websocket.send(self.ssid) elif message.startswith('451-['): - # Eliminar el prefijo numérico y el guion para obtener el JSON válido - json_part = message.split("-", 1)[1] + json_part = message.split("-", 1)[1] # Eliminar el prefijo numérico y el guion para obtener el JSON válido # Convertir la parte JSON a un objeto Python message = json.loads(json_part) if message[0] == "successauth": await on_open() + elif message[0] == "successupdateBalance": global_value.balance_updated = True elif message[0] == "successopenOrder": @@ -226,13 +237,13 @@ async def on_message(self, message): # pylint: disable=unused-argument # Si es el primer mensaje de interés elif message[0] == "updateClosedDeals": # Establecemos que hemos recibido el primer mensaje de interés - self.recibido_updateClosedDeals = True - self.esperar_segundo_mensaje = True # Establecemos que esperamos el segundo mensaje de interés + self._updateClosedDeals = True + self.wait_second_message = True # Establecemos que esperamos el segundo mensaje de interés await self.websocket.send('42["changeSymbol",{"asset":"AUDNZD_otc","period":60}]') elif message[0] == "successcloseOrder": - self.successcloseOrder = True - self.esperar_segundo_mensaje = True # Establecemos que esperamos el segundo mensaje de interés + self.successCloseOrder = True + self.wait_second_message = True # Establecemos que esperamos el segundo mensaje de interés elif message[0] == "loadHistoryPeriod": self.history_data_ready = True @@ -242,22 +253,19 @@ async def on_message(self, message): # pylint: disable=unused-argument elif message[0] == "updateHistoryNew": self.updateHistoryNew = True + # self.api.historyNew = None + + elif message.startswith("42") and "NotAuthorized" in message: + logging.error("User not Authorized: Please Change SSID for one valid") + global_value.ssl_Mutual_exclusion = False + await self.websocket.close() async def on_error(self, error): # pylint: disable=unused-argument - """Method to process websocket errors.""" - logger = logging.getLogger(__name__) logger.error(error) - try: - await self.reconnect() - except: - global_value.websocket_error_reason = str(error) - global_value.check_websocket_if_error = True + global_value.websocket_error_reason = str(error) + global_value.check_websocket_if_error = True async def on_close(self, error): # pylint: disable=unused-argument - """Method to process websocket close.""" - logger = logging.getLogger(__name__) - logger.debug("Websocket connection closed.") - try: - await self.reconnect() - except: - global_value.websocket_is_connected = False + # logger.debug("Websocket connection closed.") + # logger.warning(f"Websocket connection closed. Reason: {error}") + global_value.websocket_is_connected = False diff --git a/pocketoptionapi/ws/objects/__pycache__/base.cpython-310.pyc b/pocketoptionapi/ws/objects/__pycache__/base.cpython-310.pyc index 7aed546..277920a 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/base.cpython-310.pyc and b/pocketoptionapi/ws/objects/__pycache__/base.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/base.cpython-311.pyc b/pocketoptionapi/ws/objects/__pycache__/base.cpython-311.pyc deleted file mode 100644 index 828677c..0000000 Binary files a/pocketoptionapi/ws/objects/__pycache__/base.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/objects/__pycache__/base.cpython-39.pyc b/pocketoptionapi/ws/objects/__pycache__/base.cpython-39.pyc index 3b7ca3e..cd49bfb 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/base.cpython-39.pyc and b/pocketoptionapi/ws/objects/__pycache__/base.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc b/pocketoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc index 97cb2be..ed21b27 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc and b/pocketoptionapi/ws/objects/__pycache__/candles.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-311.pyc b/pocketoptionapi/ws/objects/__pycache__/candles.cpython-311.pyc deleted file mode 100644 index 6b7e9fc..0000000 Binary files a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-39.pyc b/pocketoptionapi/ws/objects/__pycache__/candles.cpython-39.pyc index 063c346..44d0c72 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/candles.cpython-39.pyc and b/pocketoptionapi/ws/objects/__pycache__/candles.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/time_sync.cpython-310.pyc b/pocketoptionapi/ws/objects/__pycache__/time_sync.cpython-310.pyc new file mode 100644 index 0000000..c7b67a4 Binary files /dev/null and b/pocketoptionapi/ws/objects/__pycache__/time_sync.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc b/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc index a05aa18..1d5ad67 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc and b/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-310.pyc differ diff --git a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-311.pyc b/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-311.pyc deleted file mode 100644 index e7553ac..0000000 Binary files a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-311.pyc and /dev/null differ diff --git a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-39.pyc b/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-39.pyc index 38798ce..c89d48d 100644 Binary files a/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-39.pyc and b/pocketoptionapi/ws/objects/__pycache__/timesync.cpython-39.pyc differ diff --git a/pocketoptionapi/ws/objects/time_sync.py b/pocketoptionapi/ws/objects/time_sync.py new file mode 100644 index 0000000..e5d7995 --- /dev/null +++ b/pocketoptionapi/ws/objects/time_sync.py @@ -0,0 +1,70 @@ +import logging +import time +from datetime import datetime, timedelta, timezone + + +class TimeSynchronizer: + def __init__(self): + self.server_time_reference = None + self.local_time_reference = None + self.timezone_offset = timedelta(seconds=self._get_local_timezone_offset()) + + @staticmethod + def _get_local_timezone_offset(): + """ + Obtiene el desplazamiento de la zona horaria local en segundos. + + :return: Desplazamiento de la zona horaria local en segundos. + """ + local_time = datetime.now() + utc_time = datetime.utcnow() + offset = (local_time - utc_time).total_seconds() + return offset + + def synchronize(self, server_time): + """ + Sincroniza el tiempo local con el tiempo del servidor. + + :param server_time: Tiempo del servidor en segundos (puede ser un timestamp). + """ + + self.server_time_reference = server_time + self.local_time_reference = time.time() + + def get_synced_time(self): + """ + Obtiene el tiempo sincronizado basado en el tiempo actual del sistema. + + :return: Tiempo sincronizado en segundos. + """ + if self.server_time_reference is None or self.local_time_reference is None: + raise ValueError("El tiempo no ha sido sincronizado aún.") + + # Calcula la diferencia de tiempo desde la última sincronización + elapsed_time = time.time() - self.local_time_reference + # Calcula el tiempo sincronizado + synced_time = self.server_time_reference + elapsed_time + return synced_time + + def get_synced_datetime(self): + """ + Convierte el tiempo sincronizado a un objeto datetime ajustado a la zona horaria local. + + :return: Tiempo sincronizado como un objeto datetime. + """ + synced_time_seconds = self.get_synced_time() + # Redondear los segundos + rounded_time_seconds = round(synced_time_seconds) + # Convertir a datetime en UTC + synced_datetime_utc = datetime.fromtimestamp(rounded_time_seconds, tz=timezone.utc) + # Ajustar el tiempo sincronizado a la zona horaria local + synced_datetime_local = synced_datetime_utc + self.timezone_offset + return synced_datetime_local + + def update_sync(self, new_server_time): + """ + Actualiza la sincronización con un nuevo tiempo del servidor. + + :param new_server_time: Nuevo tiempo del servidor en segundos. + """ + self.synchronize(new_server_time) diff --git a/test.py b/test.py index 0e9ba17..b71d8d3 100644 --- a/test.py +++ b/test.py @@ -1,38 +1,31 @@ import random import time -import dotenv -import asyncio + from pocketoptionapi.stable_api import PocketOption -import os -import time -# dotenv.load_dotenv() -SSID=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"0641660deb66bacfe493ee595ad5bcd6\";s:10:\"ip_address\";s:12:\"190.162.4.33\";s:10:\"user_agent\";s:120:\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.\";s:13:\"last_activity\";i:1715088712;}bf42446033b557288d0399ac1527842c","isDemo":0,"uid":27658142,"platform":2}]""" -api = PocketOption(SSID) -print(SSID) + +ssid = (r'') +api = PocketOption(ssid) + def direction(): # Selecciona aleatoriamente entre 'call' y 'put' return random.choice(['call', 'put']) -def main(): + +if __name__ == "__main__": api.connect() + time.sleep(2) + + print(api.check_connect(), "check connect") + + data_candles = api.get_candles("AUDNZD_otc", 60, time.time(), count_request=1) + + data, diff = api.process_candle(data_candles, 60) + print(data) + print(diff) + data.to_csv('datos_AUDNZD_otc_test.csv', index=False) + while api.check_connect(): + print(api.get_server_timestamp(), "server datetime") + time.sleep(1) - max_retries = 5 - for _ in range(max_retries): - print(api.get_balance()) - exp_time = int(time.time()) + 5000 - api.buy(amount=12, ACTIVES="EURUSD", ACTION="call", expirations=exp_time) - time.sleep(5) - try: - asyncio.run(api.reconect()) - except: - pass - if api.check_connect(): - print(api.get_balance()) - api.buy(amount=12, ACTIVES="EURUSD", ACTION="call", expirations=exp_time) - break # Exit loop if connected - else: - print("Failed to connect after max retries") - -if __name__ == '__main__': - main() \ No newline at end of file + # Cierra la conexión con la API diff --git a/v2/pocketoptionapi-v2/.gitignore b/v2/pocketoptionapi-v2/.gitignore deleted file mode 100644 index a3b9b4f..0000000 --- a/v2/pocketoptionapi-v2/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.py[cod] -build/ -dist/ -*.egg-info/ -.vscode/ -/.vs \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/ACTIVE_CODE.txt b/v2/pocketoptionapi-v2/ACTIVE_CODE.txt deleted file mode 100644 index aaa55ad..0000000 --- a/v2/pocketoptionapi-v2/ACTIVE_CODE.txt +++ /dev/null @@ -1,146 +0,0 @@ -2018/5/7 -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 -EURUSD-OTC 76 -EURGBP-OTC 77 -USDCHF-OTC 78 -NZDUSD-OTC 80 -GBPUSD-OTC 81 -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 -BAC:US 313 -BBY:US 320 -BA:US 324 -BMY:US 328 -CAT:US 338 -CVX:US 349 -CL:US 365 -CMCSA:US 366 -COP:US 370 -COST:US 374 -CVS:US 379 -DHR:US 381 -DAL:US 386 -EBAY:US 407 -XOM:US 429 -FDX:US 434 -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 -RTN:US 630 -CRM:US 645 -SLB:US 647 -SBUX:US 666 -SYK:US 670 -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 -BTGUSD 837 -QTMUSD 845 -TRXUSD 858 -EOSUSD 864 -USDINR 865 -USDPLN 866 -USDBRL 867 -USDZAR 868 -DBX 889 -SPOT 891 -USDSGD 892 -USDHKD 893 \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/docs/image/icon/favicon.ico b/v2/pocketoptionapi-v2/docs/image/icon/favicon.ico deleted file mode 100644 index 43ce842..0000000 Binary files a/v2/pocketoptionapi-v2/docs/image/icon/favicon.ico and /dev/null differ diff --git a/v2/pocketoptionapi-v2/docs/index.md b/v2/pocketoptionapi-v2/docs/index.md deleted file mode 100644 index 47d5117..0000000 --- a/v2/pocketoptionapi-v2/docs/index.md +++ /dev/null @@ -1,201 +0,0 @@ -# Get start - -## document version - -7/5 - -2.2 fix connect stable - -6/13 -fix auth - - -12/5 - -1.6 -fix websocket connect - - -10/29 -1.5 -fix updateAssets - -7/17 -1.1 add get_payment - -7/3 - -add more function - -6/23 -v0.1 -!!!Start New!! - -## Debug Mode ON -```python -import logging -logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') -``` -## check_win & buy sample - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123123\";s:10:\"ip_address\";s:12:\"2.111.11.5\";s:10:\"user_agent\";s:104:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123232;}1232321213","isDemo":0,"uid":"123232132"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -if check_connect: - account.change_balance("PRACTICE")#"REAL" - asset="EURUSD" - amount=1 - dir="call"#"call"/"put" - duration=30#sec - print("Balance: ",account.get_balance()) - buy_info=account.buy(asset,amount,dir,duration) - #need this to close the connect - print("----Trade----") - print("Get: ",account.check_win(buy_info["id"])) - print("----Trade----") - print("Balance: ",account.get_balance()) - #need close ping server thread - account.close() -``` - -## Login - -PockOption only support ssid login, because GOOGLE reCAPTCHA - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check,message=account.connect() -account.close() -``` - -## Get Balance - - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check,message=account.connect() -account.change_balance("PRACTICE") -balance=account.get_balance() -print(balance) -account.close() -``` - - - -## Buy - -```python -from pocketoptionapi.stable_api import PocketOption - -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check,message=account.connect() -if check: - account.change_balance("PRACTICE") - asset="EURUSD" - amount=1 - dir="call"#"call"/"put" - duration=60#sec - print(account.buy(asset,amount,dir,duration)) - account.close() -``` - -## sell_option - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -if check_connect: - account.change_balance("PRACTICE")#"REAL" - asset="EURUSD" - amount=1 - dir="call"#"call"/"put" - duration=120#sec - print("Balance: ",account.get_balance()) - buy_info=account.buy(asset,amount,dir,duration) - #need this to close the connect - account.sell_option(buy_info["id"]) - account.close() -``` - - -## get candle - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -import time -if check_connect: - asset="EURUSD" - _time=int(time.time())#the candle end of time - offset=120#how much sec want to get _time-offset --->your candle <---_time - period=60#candle size in sec - print("You will get the candle from: "+str(_time-offset)+" to: "+str(_time)) - print("------\n") - candle=account.get_candle(asset,_time,offset,period) - for c in candle["data"]: - print(c) - account.close() -``` - -## check_asset_open - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -import time -if check_connect: - print("Check Asset Open") - for i in account.get_all_asset_name(): - print(i,account.check_asset_open(i)) - account.close() -``` - -## GET realtime candle - - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -import time -if check_connect: - asset="NZDUSD_otc" - list_size=10#this is setting how much Quote you want to save - account.start_candles_stream("NZDUSD_otc",list_size) - while True: - if len(account.get_realtime_candles("NZDUSD_otc"))==list_size: - break - print(account.get_realtime_candles("NZDUSD_otc")) - account.close() -``` - -## get_payment - -```python -from pocketoptionapi.stable_api import PocketOption -ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123\";s:10:\"ip_address\";s:12:\"1.2.3.4\";s:10:\"user_agent\";s:123:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123;}123","isDemo":1,"uid":"123"}]""" -account=PocketOption(ssid) -check_connect,message=account.connect() -if check_connect: - - all_data=account.get_payment() - for asset_name in all_data: - asset_data=all_data[asset_name] - print(asset_name,asset_data["payment"],asset_data["open"]) - -account.close() -``` \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/docs/javascripts/.Rhistory b/v2/pocketoptionapi-v2/docs/javascripts/.Rhistory deleted file mode 100644 index e69de29..0000000 diff --git a/v2/pocketoptionapi-v2/docs/javascripts/extra.js b/v2/pocketoptionapi-v2/docs/javascripts/extra.js deleted file mode 100644 index b1f4222..0000000 --- a/v2/pocketoptionapi-v2/docs/javascripts/extra.js +++ /dev/null @@ -1,27 +0,0 @@ -window.MathJax = { - jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"], - extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "a11y/accessibility-menu.js"], - TeX: { - extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] - }, - tex2jax: { - inlineMath: [ ["\\(","\\)"] ], - displayMath: [ ["\\[","\\]"] ] - }, - TeX: { - TagSide: "right", - TagIndent: ".8em", - MultLineWidth: "85%", - equationNumbers: { - autoNumber: "AMS", - }, - unicode: { - fonts: "STIXGeneral,'Arial Unicode MS'" - } - }, - displayAlign: "left", - showProcessingMessages: false, - messageStyle: "none" -}; - - diff --git a/v2/pocketoptionapi-v2/instrument.txt b/v2/pocketoptionapi-v2/instrument.txt deleted file mode 100644 index 920723d..0000000 --- a/v2/pocketoptionapi-v2/instrument.txt +++ /dev/null @@ -1,318 +0,0 @@ -Name: NZD/SEK instrument_id: "NZDSEK" instrument_type: "forex" -Name: NZD/USD instrument_id: "NZDUSD" instrument_type: "forex" -Name: CAD/TRY instrument_id: "CADTRY" instrument_type: "forex" -Name: EUR/CHF instrument_id: "EURCHF" instrument_type: "forex" -Name: USD/THB instrument_id: "USDTHB" instrument_type: "forex" -Name: EUR/TRY instrument_id: "EURTRY" instrument_type: "forex" -Name: GBP/AUD instrument_id: "GBPAUD" instrument_type: "forex" -Name: AUD/USD instrument_id: "AUDUSD" instrument_type: "forex" -Name: EUR/MXN instrument_id: "EURMXN" instrument_type: "forex" -Name: USD/CHF instrument_id: "USDCHF" instrument_type: "forex" -Name: NOK/DKK instrument_id: "NOKDKK" instrument_type: "forex" -Name: EUR/NOK instrument_id: "EURNOK" instrument_type: "forex" -Name: SEK/JPY instrument_id: "SEKJPY" instrument_type: "forex" -Name: CAD/NOK instrument_id: "CADNOK" instrument_type: "forex" -Name: NOK/SEK instrument_id: "NOKSEK" instrument_type: "forex" -Name: GBP/HUF instrument_id: "GBPHUF" instrument_type: "forex" -Name: GBP/SGD instrument_id: "GBPSGD" instrument_type: "forex" -Name: AUD/NZD instrument_id: "AUDNZD" instrument_type: "forex" -Name: GBP/JPY instrument_id: "GBPJPY" instrument_type: "forex" -Name: CHF/SEK instrument_id: "CHFSEK" instrument_type: "forex" -Name: AUD/NOK instrument_id: "AUDNOK" instrument_type: "forex" -Name: GBP/NOK instrument_id: "GBPNOK" instrument_type: "forex" -Name: AUD/DKK instrument_id: "AUDDKK" instrument_type: "forex" -Name: EUR/AUD instrument_id: "EURAUD" instrument_type: "forex" -Name: AUD/CHF instrument_id: "AUDCHF" instrument_type: "forex" -Name: GBP/CHF instrument_id: "GBPCHF" instrument_type: "forex" -Name: AUD/CAD instrument_id: "AUDCAD" instrument_type: "forex" -Name: CHF/DKK instrument_id: "CHFDKK" instrument_type: "forex" -Name: AUD/TRY instrument_id: "AUDTRY" instrument_type: "forex" -Name: NZD/CHF instrument_id: "NZDCHF" instrument_type: "forex" -Name: USD/SEK instrument_id: "USDSEK" instrument_type: "forex" -Name: GBP/NZD instrument_id: "GBPNZD" instrument_type: "forex" -Name: EUR/DKK instrument_id: "EURDKK" instrument_type: "forex" -Name: NZD/DKK instrument_id: "NZDDKK" instrument_type: "forex" -Name: CAD/SGD instrument_id: "CADSGD" instrument_type: "forex" -Name: EUR/GBP instrument_id: "EURGBP" instrument_type: "forex" -Name: EUR/CAD instrument_id: "EURCAD" instrument_type: "forex" -Name: USD/CZK instrument_id: "USDCZK" instrument_type: "forex" -Name: AUD/MXN instrument_id: "AUDMXN" instrument_type: "forex" -Name: EUR/NZD instrument_id: "EURNZD" instrument_type: "forex" -Name: GBP/PLN instrument_id: "GBPPLN" instrument_type: "forex" -Name: NZD/NOK instrument_id: "NZDNOK" instrument_type: "forex" -Name: AUD/SGD instrument_id: "AUDSGD" instrument_type: "forex" -Name: GBP/SEK instrument_id: "GBPSEK" instrument_type: "forex" -Name: NZD/CAD instrument_id: "NZDCAD" instrument_type: "forex" -Name: NZD/MXN instrument_id: "NZDMXN" instrument_type: "forex" -Name: NZD/TRY instrument_id: "NZDTRY" instrument_type: "forex" -Name: CHF/SGD instrument_id: "CHFSGD" instrument_type: "forex" -Name: USD/MXN instrument_id: "USDMXN" instrument_type: "forex" -Name: EUR/HUF instrument_id: "EURHUF" instrument_type: "forex" -Name: GBP/CAD instrument_id: "GBPCAD" instrument_type: "forex" -Name: USD/TRY instrument_id: "USDTRY" instrument_type: "forex" -Name: USD/JPY instrument_id: "USDJPY" instrument_type: "forex" -Name: EUR/USD instrument_id: "EURUSD" instrument_type: "forex" -Name: AUD/SEK instrument_id: "AUDSEK" instrument_type: "forex" -Name: CHF/NOK instrument_id: "CHFNOK" instrument_type: "forex" -Name: USD/PLN instrument_id: "USDPLN" instrument_type: "forex" -Name: USD/HUF instrument_id: "USDHUF" instrument_type: "forex" -Name: CHF/JPY instrument_id: "CHFJPY" instrument_type: "forex" -Name: GBP/ILS instrument_id: "GBPILS" instrument_type: "forex" -Name: NZD/JPY instrument_id: "NZDJPY" instrument_type: "forex" -Name: CHF/TRY instrument_id: "CHFTRY" instrument_type: "forex" -Name: CAD/JPY instrument_id: "CADJPY" instrument_type: "forex" -Name: USD/RUB instrument_id: "USDRUB" instrument_type: "forex" -Name: SGD/JPY instrument_id: "SGDJPY" instrument_type: "forex" -Name: GBP/USD instrument_id: "GBPUSD" instrument_type: "forex" -Name: CAD/PLN instrument_id: "CADPLN" instrument_type: "forex" -Name: DKK/SGD instrument_id: "DKKSGD" instrument_type: "forex" -Name: NZD/SGD instrument_id: "NZDSGD" instrument_type: "forex" -Name: AUD/JPY instrument_id: "AUDJPY" instrument_type: "forex" -Name: NOK/JPY instrument_id: "NOKJPY" instrument_type: "forex" -Name: PLN/SEK instrument_id: "PLNSEK" instrument_type: "forex" -Name: USD/SGD instrument_id: "USDSGD" instrument_type: "forex" -Name: GBP/MXN instrument_id: "GBPMXN" instrument_type: "forex" -Name: USD/CAD instrument_id: "USDCAD" instrument_type: "forex" -Name: SEK/DKK instrument_id: "SEKDKK" instrument_type: "forex" -Name: DKK/PLN instrument_id: "DKKPLN" instrument_type: "forex" -Name: CAD/MXN instrument_id: "CADMXN" instrument_type: "forex" -Name: GBP/TRY instrument_id: "GBPTRY" instrument_type: "forex" -Name: EUR/SGD instrument_id: "EURSGD" instrument_type: "forex" -Name: NZD/ZAR instrument_id: "NZDZAR" instrument_type: "forex" -Name: EUR/CZK instrument_id: "EURCZK" instrument_type: "forex" -Name: EUR/JPY instrument_id: "EURJPY" instrument_type: "forex" -Name: CAD/CHF instrument_id: "CADCHF" instrument_type: "forex" -Name: USD/INR instrument_id: "USDINR" instrument_type: "forex" -Name: USD/BRL instrument_id: "USDBRL" instrument_type: "forex" -Name: USD/NOK instrument_id: "USDNOK" instrument_type: "forex" -Name: USD/DKK instrument_id: "USDDKK" instrument_type: "forex" -Name: China Large-Cap ETF instrument_id: "FXI" instrument_type: "cfd" -Name: IBM Corporation instrument_id: "IBM:US" instrument_type: "cfd" -Name: IDEXX Laboratories instrument_id: "IDXX" instrument_type: "cfd" -Name: Siemens instrument_id: "SIED-CHIX" instrument_type: "cfd" -Name: Roche instrument_id: "ROGZ-CHIX" instrument_type: "cfd" -Name: Airbus SE instrument_id: "AIRP-CHIX" instrument_type: "cfd" -Name: AbbVie instrument_id: "ABBV:US" instrument_type: "cfd" -Name: Concho Resources instrument_id: "CXO:US" instrument_type: "cfd" -Name: Verizon instrument_id: "VZ:US" instrument_type: "cfd" -Name: Unilever instrument_id: "ULVRL-CHIX" instrument_type: "cfd" -Name: Lockheed Martin instrument_id: "LMT:US" instrument_type: "cfd" -Name: NextEra Energy instrument_id: "NEE:US" instrument_type: "cfd" -Name: US 100 instrument_id: "USNDAQ100" instrument_type: "cfd" -Name: Entergy instrument_id: "ETR:US" instrument_type: "cfd" -Name: QQQ Trust, Series 1 instrument_id: "QQQ" instrument_type: "cfd" -Name: DTE Energy instrument_id: "DTE:US" instrument_type: "cfd" -Name: Tesco instrument_id: "TSCOL-CHIX" instrument_type: "cfd" -Name: First Solar instrument_id: "FSLR:US" instrument_type: "cfd" -Name: Pfizer instrument_id: "PFE:US" instrument_type: "cfd" -Name: Eastman Chemical instrument_id: "EMN:US" instrument_type: "cfd" -Name: JP Morgan Chase instrument_id: "JPM" instrument_type: "cfd" -Name: Google instrument_id: "GOOGLE" instrument_type: "cfd" -Name: Fastenal instrument_id: "FAST:US" instrument_type: "cfd" -Name: HSBC Holdings PLC instrument_id: "HSBAL-CHIX" instrument_type: "cfd" -Name: DaVita instrument_id: "DVA:US" instrument_type: "cfd" -Name: Utilities SPDR instrument_id: "XLU" instrument_type: "cfd" -Name: Federal Realty instrument_id: "FRT:US" instrument_type: "cfd" -Name: Commerzbank instrument_id: "CBKD-CHIX" instrument_type: "cfd" -Name: Amgen instrument_id: "AMGN:US" instrument_type: "cfd" -Name: Silver instrument_id: "XAGUSD" instrument_type: "cfd" -Name: Resmed Inc instrument_id: "RMD" instrument_type: "cfd" -Name: Equifax instrument_id: "EFX:US" instrument_type: "cfd" -Name: Digital Realty Trust instrument_id: "DLR:US" instrument_type: "cfd" -Name: Adobe Systems instrument_id: "ADBE:US" instrument_type: "cfd" -Name: Autodesk instrument_id: "ADSK:US" instrument_type: "cfd" -Name: Barclays instrument_id: "BARCL-CHIX" instrument_type: "cfd" -Name: Spotify instrument_id: "SPOT" instrument_type: "cfd" -Name: Standard Chartered instrument_id: "STANL-CHIX" instrument_type: "cfd" -Name: Alibaba instrument_id: "ALIBABA" instrument_type: "cfd" -Name: Freeport-McMoRan instrument_id: "FCX:US" instrument_type: "cfd" -Name: Delta Air Lines instrument_id: "DAL:US" instrument_type: "cfd" -Name: Materials Select Sector SPDR instrument_id: "XLB" instrument_type: "cfd" -Name: Amazon instrument_id: "AMAZON" instrument_type: "cfd" -Name: Semiconductor ETF instrument_id: "SMH" instrument_type: "cfd" -Name: S&P 500 ETF instrument_id: "SPY" instrument_type: "cfd" -Name: Caterpillar instrument_id: "CAT:US" instrument_type: "cfd" -Name: US 30 instrument_id: "US30" instrument_type: "cfd" -Name: ConocoPhillips instrument_id: "COP:US" instrument_type: "cfd" -Name: Flowserve instrument_id: "FLS:US" instrument_type: "cfd" -Name: Goldman Sachs instrument_id: "GS" instrument_type: "cfd" -Name: AU 200 instrument_id: "AUS200" instrument_type: "cfd" -Name: Edison instrument_id: "EIX:US" instrument_type: "cfd" -Name: Crude Oil WTI instrument_id: "USOUSD" instrument_type: "cfd" -Name: MSCI Mexico ETF instrument_id: "EWW" instrument_type: "cfd" -Name: General Electric instrument_id: "GE" instrument_type: "cfd" -Name: Micron Technology instrument_id: "MU:US" instrument_type: "cfd" -Name: Telefónica instrument_id: "TEFE-CHIX" instrument_type: "cfd" -Name: Procter & Gamble instrument_id: "PG:US" instrument_type: "cfd" -Name: Accenture instrument_id: "ACN:US" instrument_type: "cfd" -Name: Costco instrument_id: "COST:US" instrument_type: "cfd" -Name: Medtronic instrument_id: "MDT:US" instrument_type: "cfd" -Name: MSCI Emerging Markets ETF instrument_id: "EEM" instrument_type: "cfd" -Name: Expeditors instrument_id: "EXPD:US" instrument_type: "cfd" -Name: Facebook instrument_id: "FACEBOOK" instrument_type: "cfd" -Name: Tesla instrument_id: "TESLA" instrument_type: "cfd" -Name: Merck instrument_id: "MRKD-CHIX" instrument_type: "cfd" -Name: FirstEnergy instrument_id: "FE:US" instrument_type: "cfd" -Name: Altria instrument_id: "MO:US" instrument_type: "cfd" -Name: Core MSCI Emerging Markets instrument_id: "IEMG" instrument_type: "cfd" -Name: AS Roma instrument_id: "ASRM" instrument_type: "cfd" -Name: Bayer instrument_id: "BAYND-CHIX" instrument_type: "cfd" -Name: Continental instrument_id: "COND-CHIX" instrument_type: "cfd" -Name: Qualcomm instrument_id: "QCOM:US" instrument_type: "cfd" -Name: Vodafone Group PLC instrument_id: "VODL-CHIX" instrument_type: "cfd" -Name: Visa instrument_id: "V:US" instrument_type: "cfd" -Name: AT&T instrument_id: "T:US" instrument_type: "cfd" -Name: FedEx instrument_id: "FDX:US" instrument_type: "cfd" -Name: Frontier Communications instrument_id: "FTR:US" instrument_type: "cfd" -Name: Teleflex Inc instrument_id: "TFX" instrument_type: "cfd" -Name: Twitter Inc instrument_id: "TWITTER" instrument_type: "cfd" -Name: Royal Bank of Scotland instrument_id: "RBSL-CHIX" instrument_type: "cfd" -Name: S&P Oil & Gas Explor & Product instrument_id: "XOP" instrument_type: "cfd" -Name: Deutsche Post instrument_id: "DPWD-CHIX" instrument_type: "cfd" -Name: General Motors instrument_id: "GM" instrument_type: "cfd" -Name: US 500 instrument_id: "USSPX500" instrument_type: "cfd" -Name: Bank of America instrument_id: "BAC:US" instrument_type: "cfd" -Name: Nike instrument_id: "NIKE" instrument_type: "cfd" -Name: Darden Restaurants instrument_id: "DRI:US" instrument_type: "cfd" -Name: UBS instrument_id: "UBSGZ-CHIX" instrument_type: "cfd" -Name: Discover Financial Services instrument_id: "DFS:US" instrument_type: "cfd" -Name: Emerson Electric instrument_id: "EMR:US" instrument_type: "cfd" -Name: Advance Auto Parts instrument_id: "AAP:US" instrument_type: "cfd" -Name: Duke Realty Corp instrument_id: "DRE" instrument_type: "cfd" -Name: Rolls-Royce instrument_id: "RRL-CHIX" instrument_type: "cfd" -Name: Wells Fargo instrument_id: "WFC:US" instrument_type: "cfd" -Name: CitiGroup instrument_id: "CITI" instrument_type: "cfd" -Name: Cisco Systems instrument_id: "CISCO" instrument_type: "cfd" -Name: Apple instrument_id: "APPLE" instrument_type: "cfd" -Name: MSCI Japan ETF instrument_id: "EWJ" instrument_type: "cfd" -Name: F5 Networks instrument_id: "FFIV:US" instrument_type: "cfd" -Name: Heinz instrument_id: "KHC:US" instrument_type: "cfd" -Name: British American Tobacco instrument_id: "BATSL-CHIX" instrument_type: "cfd" -Name: Nvidia instrument_id: "NVDA:US" instrument_type: "cfd" -Name: E.ON instrument_id: "EOAND-CHIX" instrument_type: "cfd" -Name: Citrix Systems instrument_id: "CTXS:US" instrument_type: "cfd" -Name: UK 100 instrument_id: "UK100" instrument_type: "cfd" -Name: BBVA instrument_id: "BBVAE-CHIX" instrument_type: "cfd" -Name: Philip Morris Int. instrument_id: "PM:US" instrument_type: "cfd" -Name: Consolidated Edison instrument_id: "ED:US" instrument_type: "cfd" -Name: Netflix instrument_id: "NFLX:US" instrument_type: "cfd" -Name: Allianz instrument_id: "ALVD-CHIX" instrument_type: "cfd" -Name: FR 40 instrument_id: "FRANCE40" instrument_type: "cfd" -Name: Schlumberger instrument_id: "SLB:US" instrument_type: "cfd" -Name: Platinum instrument_id: "XPTUSD" instrument_type: "cfd" -Name: Consumer Discretionary SPDR instrument_id: "XLY" instrument_type: "cfd" -Name: BHP Billiton instrument_id: "BLTL-CHIX" instrument_type: "cfd" -Name: Credit Suisse instrument_id: "CSGNZ-CHIX" instrument_type: "cfd" -Name: Activision Blizzard instrument_id: "ATVI:US" instrument_type: "cfd" -Name: Hasbro instrument_id: "HAS:US" instrument_type: "cfd" -Name: Bristol-Myers Squibb instrument_id: "BMY:US" instrument_type: "cfd" -Name: Equity Residential instrument_id: "EQR:US" instrument_type: "cfd" -Name: Suncor Energy Inc. instrument_id: "SU" instrument_type: "cfd" -Name: Cintas instrument_id: "CTAS:US" instrument_type: "cfd" -Name: Morgan Stanley instrument_id: "MORSTAN" instrument_type: "cfd" -Name: Devon Energy instrument_id: "DVN:US" instrument_type: "cfd" -Name: Dun & Bradstreet instrument_id: "DNB:US" instrument_type: "cfd" -Name: S&P Metals & Mining ETF instrument_id: "XME" instrument_type: "cfd" -Name: SP 35 instrument_id: "SPAIN35" instrument_type: "cfd" -Name: Boeing instrument_id: "BA:US" instrument_type: "cfd" -Name: Ferrari instrument_id: "FERRARI" instrument_type: "cfd" -Name: US Real Estate ETF instrument_id: "IYR" instrument_type: "cfd" -Name: Dover instrument_id: "DOV:US" instrument_type: "cfd" -Name: Honeywell instrument_id: "HON:US" instrument_type: "cfd" -Name: Marks & Spencer instrument_id: "MKSL-CHIX" instrument_type: "cfd" -Name: BMW instrument_id: "BMWD-CHIX" instrument_type: "cfd" -Name: HK 50 instrument_id: "HONGKONG50" instrument_type: "cfd" -Name: PayPal instrument_id: "PYPL:US" instrument_type: "cfd" -Name: Alcoa instrument_id: "AA:US" instrument_type: "cfd" -Name: CVS Health instrument_id: "CVS:US" instrument_type: "cfd" -Name: iShares Russell 2000 ETF instrument_id: "IWM" instrument_type: "cfd" -Name: Walgreens Boots All. instrument_id: "WBA:US" instrument_type: "cfd" -Name: ANSYS instrument_id: "ANSS" instrument_type: "cfd" -Name: Energy SPDR instrument_id: "XLE" instrument_type: "cfd" -Name: Wheat instrument_id: "W1" instrument_type: "cfd" -Name: Ecolab instrument_id: "ECL:US" instrument_type: "cfd" -Name: Starbucks instrument_id: "SBUX:US" instrument_type: "cfd" -Name: Heineken Holding NV instrument_id: "HEIOA-CHIX" instrument_type: "cfd" -Name: Quest Diagnostics instrument_id: "DGX:US" instrument_type: "cfd" -Name: easyJet instrument_id: "EZJL-CHIX" instrument_type: "cfd" -Name: JP 225 instrument_id: "JAPAN225" instrument_type: "cfd" -Name: AMD instrument_id: "AMD" instrument_type: "cfd" -Name: Colgate-Palmolive instrument_id: "CL:US" instrument_type: "cfd" -Name: Salesforce.com instrument_id: "CRM:US" instrument_type: "cfd" -Name: Technology SPDR instrument_id: "XLK" instrument_type: "cfd" -Name: Dropbox instrument_id: "DBX" instrument_type: "cfd" -Name: Fidelity National Information Services instrument_id: "FIS:US" instrument_type: "cfd" -Name: 3M Company instrument_id: "MMM:US" instrument_type: "cfd" -Name: Daimler instrument_id: "DAID-CHIX" instrument_type: "cfd" -Name: Baidu instrument_id: "BAIDU" instrument_type: "cfd" -Name: Wal-Mart Stores instrument_id: "WMT:US" instrument_type: "cfd" -Name: Exxon Mobil instrument_id: "XOM:US" instrument_type: "cfd" -Name: Raytheon instrument_id: "RTN:US" instrument_type: "cfd" -Name: eBay instrument_id: "EBAY:US" instrument_type: "cfd" -Name: Discovery – Class A instrument_id: "DISCA:US" instrument_type: "cfd" -Name: Oil Services ETF instrument_id: "OIH" instrument_type: "cfd" -Name: Microsoft instrument_id: "MSFT" instrument_type: "cfd" -Name: Chevron instrument_id: "CVX:US" instrument_type: "cfd" -Name: Lloyds Banking Group PLC instrument_id: "LLOYL-CHIX" instrument_type: "cfd" -Name: 20+ Year Treasury Bond ETF instrument_id: "TLT" instrument_type: "cfd" -Name: Adidas instrument_id: "ADSD-CHIX" instrument_type: "cfd" -Name: Comcast – Class A instrument_id: "CMCSA:US" instrument_type: "cfd" -Name: Danaher instrument_id: "DHR:US" instrument_type: "cfd" -Name: Align Technology instrument_id: "ALGN" instrument_type: "cfd" -Name: Volkswagen instrument_id: "VOW3D-CHIX" instrument_type: "cfd" -Name: Fiserv instrument_id: "FISV:US" instrument_type: "cfd" -Name: L'Oreal instrument_id: "ORP-CHIX" instrument_type: "cfd" -Name: D. R. Horton instrument_id: "DHI:US" instrument_type: "cfd" -Name: Deutsche Telekom instrument_id: "DTED-CHIX" instrument_type: "cfd" -Name: Gold Miners ETF instrument_id: "GDX" instrument_type: "cfd" -Name: Gold instrument_id: "XAUUSD" instrument_type: "cfd" -Name: Extra Space Storage instrument_id: "EXR:US" instrument_type: "cfd" -Name: Manchester United instrument_id: "MANU" instrument_type: "cfd" -Name: Banco Santander instrument_id: "SANE-CHIX" instrument_type: "cfd" -Name: Abbott Labs instrument_id: "ABT:US" instrument_type: "cfd" -Name: FMC Corporation instrument_id: "FMC:US" instrument_type: "cfd" -Name: Snapchat instrument_id: "SNAP" instrument_type: "cfd" -Name: ThyssenKrupp instrument_id: "TKAD-CHIX" instrument_type: "cfd" -Name: GER 30 instrument_id: "GERMANY30" instrument_type: "cfd" -Name: Fortune Brands Home & Security instrument_id: "FBHS:US" instrument_type: "cfd" -Name: Crude Oil Brent instrument_id: "UKOUSD" instrument_type: "cfd" -Name: Coca Cola instrument_id: "COKE" instrument_type: "cfd" -Name: Essex Property Trust instrument_id: "ESS:US" instrument_type: "cfd" -Name: Wm Morrison Supermarkets instrument_id: "MRWL-CHIX" instrument_type: "cfd" -Name: Gilead Sciences instrument_id: "GILD:US" instrument_type: "cfd" -Name: MasterCard instrument_id: "MA:US" instrument_type: "cfd" -Name: Nestlé instrument_id: "NESNZ-CHIX" instrument_type: "cfd" -Name: CenturyLink instrument_id: "CTL:US" instrument_type: "cfd" -Name: Deutsche Bank instrument_id: "DBKD-CHIX" instrument_type: "cfd" -Name: T-Mobile US, Inc. instrument_id: "TMUS" instrument_type: "cfd" -Name: McDonald's instrument_id: "MCDON" instrument_type: "cfd" -Name: Diamond Offshore Drilling instrument_id: "DO:US" instrument_type: "cfd" -Name: Intel instrument_id: "INTEL" instrument_type: "cfd" -Name: Fifth Third Bank instrument_id: "FITB:US" instrument_type: "cfd" -Name: Best Buy instrument_id: "BBY:US" instrument_type: "cfd" -Name: EQT Corporation instrument_id: "EQT:US" instrument_type: "cfd" -Name: BP PLC instrument_id: "BPL-CHIX" instrument_type: "cfd" -Name: E-Trade instrument_id: "ETFC:US" instrument_type: "cfd" -Name: Stryker instrument_id: "SYK:US" instrument_type: "cfd" -Name: Dow Jones Industrial Average ETF instrument_id: "DIA" instrument_type: "cfd" -Name: NEM ×20 instrument_id: "XEMUSD-L" instrument_type: "crypto" -Name: Ethereum instrument_id: "ETHUSD" instrument_type: "crypto" -Name: EOS ×20 instrument_id: "EOSUSD-L" instrument_type: "crypto" -Name: Qtum instrument_id: "QTMUSD" instrument_type: "crypto" -Name: EOS instrument_id: "EOSUSD" instrument_type: "crypto" -Name: Bitcoin Cash ×20 instrument_id: "BCHUSD-L" instrument_type: "crypto" -Name: Bitcoin instrument_id: "BTCUSD" instrument_type: "crypto" -Name: TRON instrument_id: "TRXUSD" instrument_type: "crypto" -Name: Ripple ×20 instrument_id: "XRPUSD-L" instrument_type: "crypto" -Name: Stellar ×20 instrument_id: "XLMUSD-L" instrument_type: "crypto" -Name: Ethereum ×50 instrument_id: "ETHUSD-L" instrument_type: "crypto" -Name: ZCash instrument_id: "ZECUSD" instrument_type: "crypto" -Name: Litecoin instrument_id: "LTCUSD" instrument_type: "crypto" -Name: Bitcoin Cash instrument_id: "BCHUSD" instrument_type: "crypto" -Name: Bitcoin ×100 instrument_id: "BTCUSD-L" instrument_type: "crypto" -Name: OmiseGo instrument_id: "OMGUSD" instrument_type: "crypto" -Name: TRON ×50 instrument_id: "TRXUSD-L" instrument_type: "crypto" -Name: Cardano ×20 instrument_id: "ADAUSD-L" instrument_type: "crypto" -Name: Dash instrument_id: "DSHUSD" instrument_type: "crypto" -Name: Litecoin ×20 instrument_id: "LTCUSD-L" instrument_type: "crypto" -Name: Ripple instrument_id: "XRPUSD" instrument_type: "crypto" \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/mkdocs.yml b/v2/pocketoptionapi-v2/mkdocs.yml deleted file mode 100644 index 6e7d409..0000000 --- a/v2/pocketoptionapi-v2/mkdocs.yml +++ /dev/null @@ -1,81 +0,0 @@ -site_name: pocketoptionapi document -#repo_name: 'THU-DBLAB/IRBRL' -#repo_url: 'https://github.com/THU-DBLAB/IRBRL' -#site_url: 'https://thu-dblab.github.io/IRBRL/' -edit_uri: "" # this code say do not view edit on page -extra: - # disqus: 'lu-yi-hsun' - search: - language: 'jp' - #-tokenizer: '[\a\-\.]+' - #social: - # - type: 'github' - # link: 'https://github.com/Lu-Yi-Hsun/' - # - type: 'facebook' - # link: 'https://www.facebook.com/profile.php?id=100001559307331' - #- type: 'twitter' - #link: 'https://twitter.com/squidfunk' - # - type: 'linkedin' - # link: 'https://linkedin.com/in/squidfunk' - social: - - icon: fontawesome/brands/github - link: https://github.com/Lu-Yi-Hsun/ - - icon: fontawesome/brands/facebook - link: https://www.facebook.com/profile.php?id=100001559307331 - - - -theme: - language: "en" - name: 'material' #readthedocs/readthedocs - palette: - primary: 'indigo' - accent: 'Blue Grey' - feature: - tabs: false - font: - text: 'Roboto' - code: 'Roboto Mono' - favicon: image/icon/favicon.ico - - -# Extensions -markdown_extensions: - - footnotes - - markdown.extensions.admonition -# - markdown.extensions.codehilite: - # guess_lang: false - # linenums: true - - markdown.extensions.def_list - - markdown.extensions.footnotes - - markdown.extensions.meta - - markdown.extensions.toc: - permalink: true - - pymdownx.superfences: - preserve_tabs: true - - pymdownx.arithmatex - - pymdownx.betterem: - smart_enable: all - - pymdownx.caret - - pymdownx.critic - - pymdownx.details - - - pymdownx.inlinehilite - - pymdownx.magiclink - - pymdownx.mark - - pymdownx.smartsymbols - - pymdownx.superfences - - pymdownx.tasklist: - custom_checkbox: true - - pymdownx.tilde - - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg - -extra_javascript: - - 'javascripts/extra.js' - - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js' - -nav: - - Get start: index.md - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/__init__.py b/v2/pocketoptionapi-v2/pocketoptionapi/__init__.py deleted file mode 100644 index bbe6873..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -import logging - -def _prepare_logging(): - - logger = logging.getLogger(__name__) - #https://github.com/Lu-Yi-Hsun/pocketoptionapi_private/issues/1 - #try to fix this problem - #logger.setLevel(logging.DEBUG) - logger.addHandler(logging.NullHandler()) - - websocket_logger = logging.getLogger("websocket") - websocket_logger.setLevel(logging.DEBUG) - websocket_logger.addHandler(logging.NullHandler()) - -_prepare_logging() diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/api.py b/v2/pocketoptionapi-v2/pocketoptionapi/api.py deleted file mode 100644 index 27ecd6e..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/api.py +++ /dev/null @@ -1,347 +0,0 @@ - -import time -import json -import logging -import threading -import requests -import ssl -import atexit -import tempfile -from des import DesKey -import base64 -from collections import deque -import sqlite3 -from pocketoptionapi.http.login import Login - -from pocketoptionapi.http.logout import Logout - -from pocketoptionapi.ws.client import WebsocketClient -from pocketoptionapi.ws.chanels.subscribe import * -from pocketoptionapi.ws.chanels.unsubscribe import * - -from pocketoptionapi.ws.chanels.auth import * -from pocketoptionapi.ws.chanels.ping_server import * -from pocketoptionapi.ws.chanels.buy import * -from pocketoptionapi.ws.chanels.candle import * -from pocketoptionapi.ws.chanels.get_balance import * -from pocketoptionapi.ws.chanels.get_asset_data import * - -import pocketoptionapi.global_value as global_value - -import collections -from collections import defaultdict - - - -# InsecureRequestWarning: Unverified HTTPS request is being made. -# Adding certificate verification is strongly advised. -# See: https://urllib3.readthedocs.org/en/latest/security.html -requests.packages.urllib3.disable_warnings() # pylint: disable=no-member - -def nested_dict(n, type): - if n == 1: - return defaultdict(type) - else: - return defaultdict(lambda: nested_dict(n-1, type)) - -class pocketoptionapi(object): - - def __init__(self, wss, header=None,proxies=None,set_ssid=None,auto_logout=True,_2FA_TOKEN=None): - - self.server_timestamp={} - self.real_time_canlde=nested_dict(2, dict) - self.real_time_quote={} - self.raw_e98={} - self.request_data={} - self.buy_data={} - self.check_win_end={} - self.check_win_refund_data={} - self.check_win_close_data={} - self.sub_uid={} - self.buy_info={} - self.header=header - self.wss_url = wss - self.websocket_client = None - self.session = requests.Session() - self.session.verify = False - self.session.trust_env = False - - self.getcandle_data={} - self.proxies = proxies - self._2FA_TOKEN=_2FA_TOKEN - # is used to determine if a buyOrder was set or failed. If - # it is None, there had been no buy order yet or just send. - # If it is false, the last failed - # If it is true, the last buy order was successful - self.buy_successful = None - self.object_id=None - self.set_ssid=set_ssid - self.auto_logout=auto_logout - self.realtime_price={} - self.updateAssets_data=None - - self.auto_tmp_session={} - self.async_name="" - - self.conn = sqlite3.connect(tempfile.gettempdir()+"/.pocketoptionapi") - - - self.c = self.conn.cursor() - self.c.execute('''create table if not exists session (email CHAR(100) PRIMARY KEY ,session CHAR(200));''') - self.conn.commit() - - #self._input_session("sdsss","twwt") - - - def _get_session(self,email): - cursor = self.c.execute("SELECT session from session Where email='"+email+"';") - data=cursor.fetchall() - if len(data)==0: - return None - else: - return data[0][0] - - - def _input_session(self,email,session): - try: - self.c.execute("INSERT INTO session (email,session) VALUES ('"+email+"','"+session+"' );") - except: - self.c.execute("UPDATE session set session = '"+session+"' where email='"+email+"' ") - self.conn.commit() - - def send_http_request(self, url, method, data=None, params=None, headers=None,cookies=None): # pylint: disable=too-many-arguments - - logger = logging.getLogger(__name__) - - logger.debug(method+": "+url+" headers: "+str(self.session.headers)+" cookies: "+str(self.session.cookies.get_dict())) - - - response = self.session.request(method=method, - url=url, - data=data, - params=params, - headers=headers, - proxies=self.proxies, - cookies=cookies) - logger.debug(response) - logger.debug(response.text) - logger.debug(response.headers) - logger.debug(response.cookies) - - - return response - - @property - def websocket(self): - - return self.websocket_client.wss - - def send_websocket_request(self,data,no_force_send=True): - if global_value.check_websocket_if_connect[self.object_id]==1: - logger = logging.getLogger(__name__) - data=data.replace("\\\\","\\") - data=data.replace("'","\"") - if no_force_send==False: - self.websocket.send(data) - else: - global_value.ssl_Mutex[self.object_id].acquire() - self.websocket.send(data) - global_value.ssl_Mutex[self.object_id].release() - logger.debug(data) - - def init_ansyc_data(self): - get=[{"t":2,"e":98,"uuid":"KDOJ6MMIERN26ZDIRV7","d":[22,20,21,26]}] - - self.send_websocket_request(get) - - def get_server_time(self,req_id:str=""): - get=[{"t":2,"e":90,"uuid":req_id}] - - self.send_websocket_request(get) - - - @property - def subscribe_realtime_candle(self): - - return changeSymbol(self) - - @property - def unsubscribe_realtime_candle(self): - return unsubfor(self) - - - @property - def logout(self): - - return Logout(self) - @property - def Auth_Mode(self): - return auth_mode(self) - @property - def login(self): - - return Login(self) - @property - def ping_to_server(self): - return Ping_To_Server(self) - @property - def TWO_FA(self): - return _2FA(self) - - @property - def Get_Balance(self): - - return get_balance(self) - @property - def Get_Asset_Data(self): - - return get_asset_data(self) - - @property - def ssid(self): - - return Ssid(self) - - - - @property - def getcandles(self): - - return loadHistoryPeriod(self) - - - - @property - def buy(self): - return buy_binary(self) - - @property - def sell_option(self): - return cancelOrder(self) - - - def set_session(self,cookies,headers): - - self.session.headers.update(headers) - - self.session.cookies.clear_session_cookies() - requests.utils.add_dict_to_cookiejar(self.session.cookies, cookies) - def init_global_value(self,object_id): - global_value.ssl_Mutex[object_id]=threading.Lock() - global_value.check_websocket_if_connect[object_id]=None - # try fix ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2361) - - #if false websocket can sent self.websocket.send(data) - #else can not sent self.websocket.send(data) - - if object_id not in global_value.SSID: - global_value.SSID[object_id]=self.set_ssid - - global_value.check_websocket_if_error[object_id]=False - global_value.websocket_error_reason[object_id]=None - #start account is demo - global_value.account_mode_isDemo[object_id]=1 - - global_value.balance_id[object_id]=0 - global_value.check_auth_finish[object_id]=False - global_value.balance[object_id]=nested_dict(2,dict) - global_value.req_mutex[object_id]=threading.Lock() - global_value.req_id[object_id]=1 - global_value.auth_send_count[object_id]=0 - global_value.real_balance[object_id]=None - global_value.practice_balance[object_id]=None - - - def del_init_global_value(self,object_id): - del global_value.check_websocket_if_connect[object_id] - del global_value.SSID[object_id] - del global_value.check_websocket_if_error[object_id] - del global_value.websocket_error_reason[object_id] - del global_value.balance_id[object_id] - del global_value.req_mutex[object_id] - del global_value.req_id[object_id] - del global_value.balance[object_id] - def start_websocket(self): - - self.websocket_client = WebsocketClient(self) - try: - self.del_init_global_value(self.object_id) - except: - pass - # update self.object_id - self.object_id=id(self.websocket_client.wss) - self.init_global_value(self.object_id) - - try: - import re - p = '(?:http.*://)?(?P[^:/ ]+).?(?P[0-9]*).*' - - m = re.search(p,self.proxies["http"]) - http_proxy_host=m.group('host') # 'www.abc.com' - http_proxy_port=m.group('port') # '123' - except: - http_proxy_host=None - http_proxy_port=None - - self.websocket_thread = threading.Thread(target=self.websocket.run_forever,kwargs={'sslopt': { - "check_hostname": False, "cert_reqs": ssl.CERT_NONE, "ca_certs": "cacert.pem"},"http_proxy_host":http_proxy_host,"http_proxy_port":http_proxy_port,"suppress_origin":True}) # for fix pyinstall error: cafile, capath and cadata cannot be all omitted - self.websocket_thread.daemon = True - self.websocket_thread.start() - - start_time=time.time() - while True: - - if global_value.check_websocket_if_error[self.object_id]: - return False,global_value.websocket_error_reason[self.object_id] - if global_value.check_websocket_if_connect[self.object_id] == 0 : - global_value.websocket_error_reason[self.object_id]="Websocket connection closed." - return False,global_value.websocket_error_reason[self.object_id] - elif global_value.check_websocket_if_connect[self.object_id] == 1: - return True,None - if time.time()-start_time>global_value.wait_connect_sec: - global_value.websocket_error_reason[self.object_id]="Connect Error" - return False,global_value.websocket_error_reason[self.object_id] - - - - pass - def get_ssid(self): - response=None - response = self.login(self.username, self.password,self._2FA_TOKEN) # - if "session" in response.cookies: - self._input_session(self.username,response.cookies["session"]) - return response - - def connect(self): - - try: - self.logout() - except: - pass - if self.auto_logout: - atexit.register(self.logout) - - check_websocket,websocket_reason=self.start_websocket() - if check_websocket==False: - return check_websocket,websocket_reason - #set ssis cookie - - - return True,None - - def close(self): - self.websocket.close() - self.websocket_thread.join() - - def websocket_alive(self): - return self.websocket_thread.is_alive() - - @property - def Get_User_Profile_Client(self): - return Get_user_profile_client(self) - @property - def Request_Leaderboard_Userinfo_Deals_Client(self): - return Request_leaderboard_userinfo_deals_client(self) - @property - def Get_Users_Availability(self): - return Get_users_availability(self) diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/constants.py b/v2/pocketoptionapi-v2/pocketoptionapi/constants.py deleted file mode 100644 index 92022af..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/constants.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Module for IQ Option API constants.""" -#~~~need to update~~~ -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, 'GBPJPY-OTC': 84, '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, 'AGN:US': 272, '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, 'XLMUSD': 847, '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, 'ENELM-CHIX': 926, 'ENIM-CHIX': 927, 'FCAM-CHIX': 928, '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, 'EURZAR': 1011, '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, 'FDJP': 1350, 'CAN': 1351, 'VIAC': 1352, 'TFC': 1353} - -""" - {'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, 'AGN:US': 272, '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, 'XLMUSD': 847, '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, 'EURZAR': 1011, '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, 'FDJP': 1350, 'CAN': 1351, 'VIAC': 1352, 'TFC': 1353} -""" \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/country_id.py b/v2/pocketoptionapi-v2/pocketoptionapi/country_id.py deleted file mode 100644 index 60bc5e4..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/country_id.py +++ /dev/null @@ -1,190 +0,0 @@ -ID = {"Worldwide":0, - "AF": 1, - "AL": 2, - "DZ": 3, - "AD": 5, - "AO": 6, - "AI": 7, - "AG": 9, - "AR": 10, - "AM": 11, - "AW": 12, - "AT": 14, - "AZ": 15, - "BS": 16, - "BH": 17, - "BD": 18, - "BB": 19, - "BY": 20, - "BZ": 22, - "BJ": 23, - "BM": 24, - "BO": 26, - "BA": 27, - "BW": 28, - "BV": 29, - "BR": 30, - "BN": 31, - "BG": 32, - "BF": 33, - "BI": 34, - "KH": 35, - "CM": 36, - "CV": 38, - "KY": 39, - "TD": 41, - "CL": 42, - "CN": 43, - "CC": 45, - "CO": 46, - "KM": 47, - "CG": 48, - "CK": 49, - "CR": 50, - "CI": 51, - "HR": 52, - "CU": 53, - "CY": 54, - "CZ": 55, - "DK": 56, - "DJ": 57, - "DM": 58, - "DO": 59, - "TL": 60, - "EC": 61, - "EG": 62, - "SV": 63, - "EE": 66, - "ET": 67, - "FO": 69, - "FJ": 70, - "FI": 71, - "FR": 72, - "GF": 73, - "PF": 74, - "GA": 75, - "GM": 76, - "GE": 77, - "DE": 78, - "GH": 79, - "GR": 81, - "GD": 83, - "GP": 84, - "GT": 86, - "GN": 87, - "GY": 88, - "HT": 89, - "HN": 90, - "HK": 91, - "HU": 92, - "IS": 93, - "ID": 94, - "IQ": 95, - "IE": 96, - "IT": 97, - "JM": 98, - "JO": 100, - "KZ": 101, - "KE": 102, - "KI": 103, - "KW": 104, - "KG": 105, - "LA": 106, - "LV": 107, - "LB": 108, - "LS": 109, - "LR": 110, - "LY": 111, - "LT": 113, - "LU": 114, - "MO": 115, - "MK": 116, - "MG": 117, - "MW": 118, - "MY": 119, - "MV": 120, - "ML": 121, - "MT": 122, - "MQ": 124, - "MR": 125, - "MU": 126, - "MX": 128, - "FM": 129, - "MD": 130, - "MC": 131, - "MN": 132, - "MA": 134, - "MZ": 135, - "MM": 136, - "NA": 137, - "NP": 139, - "NL": 140, - "AN": 141, - "NC": 142, - "NZ": 143, - "NI": 144, - "NE": 145, - "NG": 146, - "NO": 149, - "OM": 150, - "PK": 151, - "PW": 152, - "PA": 153, - "PG": 154, - "PY": 155, - "PE": 156, - "PH": 157, - "PL": 159, - "PT": 160, - "QA": 162, - "RE": 163, - "RO": 164, - "RW": 166, - "KN": 167, - "LC": 168, - "SA": 171, - "SN": 172, - "SC": 173, - "SG": 175, - "SK": 176, - "SI": 177, - "SO": 179, - "ZA": 180, - "KR": 181, - "ES": 182, - "LK": 183, - "SH": 184, - "SR": 186, - "SZ": 187, - "SE": 188, - "CH": 189, - "TW": 191, - "TJ": 192, - "TZ": 193, - "TH": 194, - "TG": 195, - "TT": 198, - "TN": 199, - "TR": 200, - "TM": 201, - "UG": 203, - "UA": 204, - "AE": 205, - "GB": 206, - "UY": 207, - "UZ": 208, - "VE": 211, - "VN": 212, - "VG": 213, - "YE": 216, - "ZM": 218, - "ZW": 219, - "RS": 220, - "ME": 221, - "IN": 225, - "TC": 234, - "CD": 235, - "GG": 236, - "IM": 237, - "JE": 239, - "CW": 246, } diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/expiration.py b/v2/pocketoptionapi-v2/pocketoptionapi/expiration.py deleted file mode 100644 index 8a5dae6..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/expiration.py +++ /dev/null @@ -1,80 +0,0 @@ -# python -import time -from datetime import datetime, timedelta - -# https://docs.python.org/3/library/datetime.html -# 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. -# time.mktime(dt.timetuple()) - - -def date_to_timestamp(dt): - # local timezone to timestamp support python2 pytohn3 - return time.mktime(dt.timetuple()) - - -def get_expiration_time(timestamp, duration): - # - now_date = datetime.fromtimestamp(timestamp) - exp_date = now_date.replace(second=0, microsecond=0) - if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30: - exp_date = exp_date+timedelta(minutes=1) - - else: - exp_date = exp_date+timedelta(minutes=2) - exp = [] - for _ in range(5): - exp.append(date_to_timestamp(exp_date)) - exp_date = exp_date+timedelta(minutes=1) - - idx = 50 - index = 0 - now_date = datetime.fromtimestamp(timestamp) - exp_date = now_date.replace(second=0, microsecond=0) - while index < idx: - if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5: - exp.append(date_to_timestamp(exp_date)) - index = index+1 - exp_date = exp_date+timedelta(minutes=1) - - remaning = [] - - for t in exp: - remaning.append(int(t)-int(time.time())) - - close = [abs(x-60*duration) for x in remaning] - - return int(exp[close.index(min(close))]), int(close.index(min(close))) - - -def get_remaning_time(timestamp): - now_date = datetime.fromtimestamp(timestamp) - exp_date = now_date.replace(second=0, microsecond=0) - if (int(date_to_timestamp(exp_date+timedelta(minutes=1)))-timestamp) > 30: - exp_date = exp_date+timedelta(minutes=1) - - else: - exp_date = exp_date+timedelta(minutes=2) - exp = [] - for _ in range(5): - exp.append(date_to_timestamp(exp_date)) - exp_date = exp_date+timedelta(minutes=1) - idx = 11 - index = 0 - now_date = datetime.fromtimestamp(timestamp) - exp_date = now_date.replace(second=0, microsecond=0) - while index < idx: - if int(exp_date.strftime("%M")) % 15 == 0 and (int(date_to_timestamp(exp_date))-int(timestamp)) > 60*5: - exp.append(date_to_timestamp(exp_date)) - index = index+1 - exp_date = exp_date+timedelta(minutes=1) - - remaning = [] - - for idx, t in enumerate(exp): - if idx >= 5: - dr = 15*(idx-4) - else: - dr = idx+1 - remaning.append((dr, int(t)-int(time.time()))) - - return remaning diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/global_value.py b/v2/pocketoptionapi-v2/pocketoptionapi/global_value.py deleted file mode 100644 index e7d5a8d..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/global_value.py +++ /dev/null @@ -1,58 +0,0 @@ - -check_websocket_if_connect={}#None -# try fix ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2361) -ssl_Mutex={} - -# - -#if false websocket can sent self.websocket.send(data) -#else can not sent self.websocket.send(data) - - - -SSID={}#None - -check_websocket_if_error={}#False -websocket_error_reason={}#None - -balance_id={}#None -account_mode_isDemo={}#practice is 1, real is 0 (int) -check_auth_finish={} -balance={} - -real_balance={} -practice_balance={} - -client_callback=None -auth_send_count={} -req_mutex={}#True or object_id -req_id={} -wait_connect_sec=2 -def get_req_id(object_id): - req_mutex[object_id].acquire() - get_req_id=req_id[object_id] - req_id[object_id]=req_id[object_id]+1 - req_mutex[object_id].release() - - return str(get_req_id) - -websocket_url=[ - - "wss://api-hk.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-fr.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-sg2.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-in.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-in2.po.market/socket.io/?EIO=4&transport=websocket", - - "wss://api-msk.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-fin.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-l.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-c.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-sc.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-asia2.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-us2.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-us3.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-us4.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-latina2.po.market/socket.io/?EIO=4&transport=websocket", - "wss://api-asia.po.market/socket.io/?EIO=4&transport=websocket" - ] \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/http/__init__.py b/v2/pocketoptionapi-v2/pocketoptionapi/http/__init__.py deleted file mode 100644 index 0519ecb..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/http/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/http/login.py b/v2/pocketoptionapi-v2/pocketoptionapi/http/login.py deleted file mode 100644 index f9a88cf..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/http/login.py +++ /dev/null @@ -1,22 +0,0 @@ -from pocketoptionapi.http.resource import Resource -import json -class Login(Resource): - - def _post(self, data=None, headers=None): - headers={} - - headers = { - 'X-App-Name': 'app_ios', - 'X-Request-Type': 'Api-Request', - 'X-Request-Project': 'bo', - 'Cookie': 'guest_id=1000290216601684147969408361021491595862009238107429568028672977' - } - - - return self.api.send_http_request(method="POST", url="https://api.olymptrade.com/v3/user/login-by-password",data=data, headers=headers) - def __call__(self, username, password,token=None): - - - data= "{\"data\":{\"email\":\""+username+"\",\"password\":\""+password+"\"}}" - return self._post(data=str(data)) - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/http/logout.py b/v2/pocketoptionapi-v2/pocketoptionapi/http/logout.py deleted file mode 100644 index 3bbb405..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/http/logout.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Module for IQ Option http login resource.""" - -from pocketoptionapi.http.resource import Resource - - -class Logout(Resource): - """Class for IQ option login resource.""" - # pylint: disable=too-few-public-methods - - url = "" - - def _post(self, data=None, headers=None): - """Send get request for IQ Option API login http resource. - - :returns: The instance of :class:`requests.Response`. - """ - #return self.api.send_http_request(method="POST", url="https://auth.iqoption.com/api/v1.0/logout",data=data, headers=headers) - pass - def __call__(self): - - return self._post() - diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/http/resource.py b/v2/pocketoptionapi-v2/pocketoptionapi/http/resource.py deleted file mode 100644 index e8adc5b..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/http/resource.py +++ /dev/null @@ -1,10 +0,0 @@ - -class Resource(object): - - def __init__(self, api): - - self.api = api - - def send_http_request(self, method, data=None, params=None, headers=None): - - return self.api.send_http_request(self, method, data=data, params=params, headers=headers) diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/stable_api.py b/v2/pocketoptionapi-v2/pocketoptionapi/stable_api.py deleted file mode 100644 index 24322f6..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/stable_api.py +++ /dev/null @@ -1,294 +0,0 @@ -# dev @vigo_walker, github: https://github.com/theshadow76 - -# python -from pocketoptionapi.api import pocketoptionapi -import pocketoptionapi.constants as OP_code -import pocketoptionapi.country_id as Country -import threading -import time -import logging -import operator -import pocketoptionapi.global_value as global_value -from pocketoptionapi.expiration import get_expiration_time, get_remaning_time -from datetime import datetime, timedelta,timezone -from collections import defaultdict -from collections import deque -import collections -import json -import threading -def nested_dict(n, type): - if n == 1: - return defaultdict(type) - else: - return defaultdict(lambda: nested_dict(n-1, type)) -def ping_server(self): - - t = threading.currentThread() - while getattr(t, "do_run", True): - if global_value.check_websocket_if_connect[self.api.object_id]==0: - break - time.sleep(10) - self.ping_server_go() - - - - -class PocketOption: - __version__ = "2.2" - - def __init__(self,set_ssid,proxies=None,auto_logout=True,websocket_url=None,wait_connect_sec=2): - - self.SESSION_HEADER={"Origin": "https://pocketoption.com","Sec-WebSocket-Version":"13","Connection":"Upgrade","Accept-Encoding:":"gzip, deflate, br","Sec-WebSocket-Extensions":"permessage-deflate; client_max_window_bits","User-Agent":r"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36"} - self.SESSION_COOKIE={} - self.proxies=proxies - self.set_ssid=set_ssid - self.auto_logout=auto_logout - self._2FA_TOKEN=None - self.websocket_url=websocket_url - global_value.wait_connect_sec=wait_connect_sec - # -------------------------------------------------------------------------- - def logout(self): - self.api.logout() - def ping_server_go(self): - self.api.ping_to_server() - - def set_call_back_for_client(self,function): - global_value.client_callback=function - def set_session(self,header,cookie): - self.SESSION_HEADER=header - self.SESSION_COOKIE=cookie - - def get_ssid(self): - return global_value.SSID[self.api.object_id] - - def setting_2FA_TOKEN(self,code): - self._2FA_TOKEN=code - def TWO_FA(self, token,method=None,code=None): - r=self.api.TWO_FA(token,method,code) - return json.loads(r.text) - def close(self): - - self._thread_ping_server.do_run = False - def connect(self): - - try: - self.api.close() - except: - pass - #logging.error('**warning** self.api.close() fail') - - #id-iqoption.com some country only can using this url - #Iqoption.com - try: - self.set_ssid=global_value.SSID[self.api.object_id] - except: - pass - - - if self.websocket_url==None: - for url in global_value.websocket_url: - self.api = pocketoptionapi(url,header=self.SESSION_HEADER,proxies=self.proxies,set_ssid=self.set_ssid,auto_logout=self.auto_logout,_2FA_TOKEN=self._2FA_TOKEN) - c,m=self.api.connect() - if c: - break - elif m=="""42["NotAuthorized"]""": - return False,m - else: - self.api = pocketoptionapi(self.websocket_url,header=self.SESSION_HEADER,proxies=self.proxies,set_ssid=self.set_ssid,auto_logout=self.auto_logout,_2FA_TOKEN=self._2FA_TOKEN) - c,m=self.api.connect() - - if m=="""42["NotAuthorized"]""": - return False,m - - if c: - self.change_balance("PRACTICE") - self._thread_ping_server=threading.Thread(target = ping_server, args = (self,)) - self._thread_ping_server.start() - return c,m - - - def check_connect(self): - # True/False - - if global_value.check_websocket_if_connect[self.api.object_id] == 0: - return False - else: - return True - # wait for timestamp getting - -# _________________________UPDATE ACTIVES OPCODE_____________________ - - def _init_get_raw_balance(self): - #[{"d":[{"value":3686.24}],"e":52},{"d":[{"value":20.10,"account_id":1250470807}],"e":50}] - - req_id="balance" - self.api.raw_e98[req_id]=None - self.api.Get_Balance(req_id) - - while self.api.raw_e98[req_id]==None: - pass - _tmp=self.api.raw_e98[req_id] - del self.api.raw_e98[req_id] - for d in _tmp: - try: - if "account_id" in d["d"][0]: - global_value.balance[self.api.object_id]["REAL"]["value"]=d["d"][0]["value"] - global_value.balance[self.api.object_id]["REAL"]["account_id"]=d["d"][0]["account_id"] - elif "value" in d["d"][0]: - global_value.balance[self.api.object_id]["PRACTICE"]["value"]=d["d"][0]["value"] - global_value.balance[self.api.object_id]["PRACTICE"]["account_id"]=0 - except: - pass - - - def get_balance(self): - if global_value.account_mode_isDemo[self.api.object_id]==0: - while global_value.real_balance[self.api.object_id]==None: - pass - return global_value.real_balance[self.api.object_id] - elif global_value.account_mode_isDemo[self.api.object_id]==1: - while global_value.practice_balance[self.api.object_id]==None: - pass - return global_value.practice_balance[self.api.object_id] - - def get_asset_data(self): - req_id=global_value.get_req_id(self.api.object_id) - - self.api.raw_e98["e_70"]=None - self.api.Get_Asset_Data(req_id) - while self.api.raw_e98["e_70"]==None: - pass - _tmp=self.api.raw_e98["e_70"] - del self.api.raw_e98["e_70"] - return _tmp - def change_balance(self, Balance_MODE): - - - if Balance_MODE=="REAL": - global_value.check_auth_finish[self.api.object_id]=False - while global_value.check_auth_finish[self.api.object_id]==False: - self.api.Auth_Mode(Balance_MODE) - time.sleep(0.5) - global_value.account_mode_isDemo[self.api.object_id]=0 - elif Balance_MODE=="PRACTICE": - global_value.check_auth_finish[self.api.object_id]=False - while global_value.check_auth_finish[self.api.object_id]==False: - self.api.Auth_Mode(Balance_MODE) - time.sleep(0.5) - global_value.account_mode_isDemo[self.api.object_id]=1 - else: - logging.error('**warning** change_balance() need input "REAL"/"PRACTICE" ') - - - -# ________________________________________________________________________ -# _______________________ CANDLE _____________________________ -# ________________________self.api.getcandles() wss________________________ - - def get_candle(self, Asset, _from, timeframe,request_id=""): - self.api.getcandles(Asset, _from, timeframe,request_id) - pass -####################################################### -# ______________________________________________________ -# _____________________REAL TIME CANDLE_________________ -# ______________________________________________________ -####################################################### - - def get_payment(self): - raw_asset=self.get_raw_asset() - ans=nested_dict(2,dict) - for i in raw_asset: - asset_name=i[1] - ans[asset_name]["payment"]=i[5] - ans[asset_name]["open"]=i[14] - - return ans - - def get_raw_asset(self): - while self.api.updateAssets_data==None: - pass - return self.api.updateAssets_data - def get_all_asset_name(self): - all_asset=self.get_raw_asset() - ans=[] - for i in all_asset: - ans.append(i[1]) - return ans - - def check_asset_open(self,asset): - all_asset=self.get_raw_asset() - for i in all_asset: - if i[1]==asset: - if True in i: - return True - else: - return False - - def start_candles_stream(self,asset,size): - #the list of the size - self.api.subscribe_realtime_candle(asset,size) - - def stop_candles_stream(self, asset): - self.api.unsubscribe_realtime_candle(asset) - - def get_realtime_candles(self, asset): - while True: - if asset in self.api.realtime_price: - if len(self.api.realtime_price[asset])>0: - return self.api.realtime_price[asset] - - - def buy(self,asset,amount,dir,duration): - # the min duration is 30 - #if duration<30: - # duration=30 - req_id=global_value.get_req_id(self.api.object_id) - self.api.request_data[req_id]=None - self.api.buy(asset,amount,dir,duration,req_id) - while self.api.request_data[req_id]==None: - pass - _tmp=self.api.request_data[req_id] - del self.api.request_data[req_id] - if "id" in _tmp: - self.api.buy_info[_tmp["id"]]=_tmp - return _tmp - - def sell_option(self,id): - # the min duration is 30 - self.api.sell_option(id) - - def get_candle(self,asset,time,offset,period): - req_id=global_value.get_req_id(self.api.object_id) - self.api.getcandle_data[req_id]=None - self.api.getcandles(asset,time,offset,period,req_id) - while self.api.getcandle_data[req_id]==None: - pass - return self.api.getcandle_data[req_id] - - - - def check_win(self,ticket,polling=1): - while True: - if ticket in self.api.check_win_refund_data: - return self.api.check_win_refund_data[ticket]["amount"]-self.api.buy_info[ticket] - elif ticket in self.api.check_win_close_data: - - - if self.api.check_win_close_data[ticket]["closePrice"]!=0: - return self.api.check_win_close_data[ticket]["profit"] - - time.sleep(polling) - - - - - def get_server_time(self): - req_id=global_value.get_req_id(self.api.object_id) - self.api.server_timestamp[req_id]=None - self.api.get_server_time(req_id) - while self.api.server_timestamp[req_id]==None: - pass - _tmp=self.api.server_timestamp[req_id] - del self.api.server_timestamp[req_id] - return _tmp - diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/__init__.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/__init__.py deleted file mode 100644 index 6c0340c..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Module for IQ Option API websocket.""" diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/__init__.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/__init__.py deleted file mode 100644 index d3d1307..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Module for IQ Option API websocket chanels.""" diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/auth.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/auth.py deleted file mode 100644 index c950bce..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/auth.py +++ /dev/null @@ -1,13 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import pocketoptionapi.constants as OP_code -import pocketoptionapi.global_value as global_value -import json -class auth_mode(Base): - def __call__(self,account_mode): - session=global_value.SSID[self.api.object_id] - if account_mode=="REAL": - global_value.SSID[self.api.object_id]=session.replace("\"isDemo\":1","\"isDemo\":0") - elif account_mode=="PRACTICE": - global_value.SSID[self.api.object_id]=session.replace("\"isDemo\":0","\"isDemo\":1") - self.send_websocket_request(global_value.SSID[self.api.object_id]) - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/base.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/base.py deleted file mode 100644 index 2eddc3f..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/base.py +++ /dev/null @@ -1,19 +0,0 @@ -"""Module for base IQ Option base websocket chanel.""" - - -class Base(object): - """Class for base IQ Option websocket chanel.""" - # pylint: disable=too-few-public-methods - - def __init__(self, api): - """ - :param api: The instance of :class:`pocketoptionapi - `. - """ - self.api = api - - def send_websocket_request(self, msg,no_force_send=True): - """Send request to IQ Option server websocket. - :returns: The instance of :class:`requests.Response`. - """ - return self.api.send_websocket_request(msg,no_force_send) diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/buy.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/buy.py deleted file mode 100644 index f93d951..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/buy.py +++ /dev/null @@ -1,29 +0,0 @@ - - -from pocketoptionapi.ws.chanels.base import Base -import pocketoptionapi.constants as OP_code -import pocketoptionapi.global_value as global_value -import json -class buy_binary(Base): - def __call__(self,asset,amount,dir,duration,req_id): - session=global_value.SSID[self.api.object_id] - data=[] - data.append("openOrder") - openorder={} - openorder["session"]=json.loads(session[2:])[1]["session"].replace("\"","\\\"") - openorder["asset"]=asset - openorder["amount"]=amount - openorder["action"]=dir - openorder["requestId"]=req_id - openorder["isDemo"]=global_value.account_mode_isDemo[self.api.object_id] - openorder["time"]=duration#sec - openorder["optionType"]=100 - data.append(openorder) - - self.send_websocket_request("42"+str(data)) - -class cancelOrder(Base): - def __call__(self,ticket): - data=["cancelOrder",{"ticket":str(ticket)}] - self.send_websocket_request("42"+str(data)) - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/candle.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/candle.py deleted file mode 100644 index 66e414f..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/candle.py +++ /dev/null @@ -1,42 +0,0 @@ - - -""" -42["loadHistoryPeriod",{"asset":"USDCAD","index":162513874160,"time":1625138122.445,"offset":1000,"period":5}] -""" - - -import collections -from pocketoptionapi.ws.chanels.base import Base -import pocketoptionapi.constants as OP_code -import pocketoptionapi.global_value as global_value -import json - - -class loadHistoryPeriod(Base): - def __call__(self,asset,time,offset,period,index): - data=["loadHistoryPeriod",{"asset":asset,"index":index,"time":time,"offset":offset,"period":period}] - self.send_websocket_request("42"+str(data)) - - -""" -42["changeSymbol",{"asset":"USDCAD","prevAsset":"USDCAD","reason":2,"otherData":{},"period":5}] -""" - - -class changeSymbol(Base): - def __call__(self,asset,size): - self.api.realtime_price[asset]=collections.deque([],size) - data=["changeSymbol",{"asset":asset,"prevAsset":asset,"reason":2,"otherData":{},"period":0}] - self.send_websocket_request("42"+str(data)) - - -""" -42["unsubfor","EURRUB_otc"] -""" - -class unsubfor(Base): - def __call__(self,asset): - data=["subfor",asset] - self.send_websocket_request("42"+str(data)) - - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_asset_data.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_asset_data.py deleted file mode 100644 index 686e55e..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_asset_data.py +++ /dev/null @@ -1,7 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import datetime -import pocketoptionapi.constants as OP_code -class get_asset_data(Base): - def __call__(self,req_id): - data=[{"t":2,"e":98,"uuid":req_id,"d":[70,73,72]}] - self.send_websocket_request(data) \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_balance.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_balance.py deleted file mode 100644 index a9b6999..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/get_balance.py +++ /dev/null @@ -1,7 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import datetime -import pocketoptionapi.constants as OP_code -class get_balance(Base): - def __call__(self,req_id): - data=[{"t":2,"e":98,"uuid":req_id,"d":[52,50]}] - self.send_websocket_request(data) \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/ping_server.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/ping_server.py deleted file mode 100644 index 9026079..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/ping_server.py +++ /dev/null @@ -1,9 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import pocketoptionapi.constants as OP_code -import pocketoptionapi.global_value as global_value -import json -class Ping_To_Server(Base): - def __call__(self): - self.send_websocket_request("""42["ps"]""") - - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/subscribe.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/subscribe.py deleted file mode 100644 index fb4f8ed..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/subscribe.py +++ /dev/null @@ -1,11 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import datetime -import pocketoptionapi.constants as OP_code -class Subscribe(Base): - def __call__(self,asset,timeframe,req_id): - #{"name":"subscribeMessage","msg":{"name":"candle-generated","params":{"routingFilters":{"active_id":1,"size":1}}}} - #data="""[{"t":2,"e":4,"uuid":"gg","d":[{"p":"EURUSD","tf":60}]}]""" - - data=[{"t":2,"e":4,"uuid":req_id,"d":[{"p":asset,"tf":timeframe}]}] - self.send_websocket_request(data) - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/unsubscribe.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/unsubscribe.py deleted file mode 100644 index ff51918..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/chanels/unsubscribe.py +++ /dev/null @@ -1,9 +0,0 @@ -from pocketoptionapi.ws.chanels.base import Base -import datetime -import pocketoptionapi.constants as OP_code -class Unsubscribe(Base): - def __call__(self,sub_uid,req_id=""): - data=[{"t":2,"e":5,"uuid":req_id,"d":[{"sub_uid":sub_uid}]}] - - self.send_websocket_request(data) - \ No newline at end of file diff --git a/v2/pocketoptionapi-v2/pocketoptionapi/ws/client.py b/v2/pocketoptionapi-v2/pocketoptionapi/ws/client.py deleted file mode 100644 index 494e9a8..0000000 --- a/v2/pocketoptionapi-v2/pocketoptionapi/ws/client.py +++ /dev/null @@ -1,140 +0,0 @@ -import json -import logging -import websocket -import pocketoptionapi.constants as OP_code -import pocketoptionapi.global_value as global_value -import collections - -import time -class WebsocketClient(object): - - def __init__(self, api): - - self.api = api - - self.wss = websocket.WebSocketApp( - self.api.wss_url, on_message=self.on_message, - on_error=self.on_error, on_close=self.on_close, - on_open=self.on_open,header=self.api.header) - - def on_message(self, wss,raw_message): - - global_value.ssl_Mutex[self.api.object_id].acquire() - logger = logging.getLogger(__name__) - logger.debug(raw_message) - #raw_message = json.loads(str(raw_message)) - if global_value.client_callback != None: - global_value.client_callback(raw_message) - #特殊處理 - if raw_message=="""451-["updateAssets",{"_placeholder":true,"num":0}]""": - - self.api.async_name=raw_message - - elif raw_message=="""451-["updateStream",{"_placeholder":true,"num":0}]""": - self.api.async_name=raw_message - elif raw_message=="""451-["successupdateBalance",{"_placeholder":true,"num":0}]""": - self.api.async_name=raw_message - elif raw_message=="2": - self.api.send_websocket_request("""3""",False) - elif self.api.async_name=="""451-["updateAssets",{"_placeholder":true,"num":0}]""": - - self.api.async_name="" - - ok_json=json.loads(raw_message.decode("utf-8")) - self.api.updateAssets_data=ok_json - elif self.api.async_name=="""451-["successupdateBalance",{"_placeholder":true,"num":0}]""": - - self.api.async_name="" - - ok_json=json.loads(raw_message.decode("utf-8")) - - if ok_json["isDemo"]==0: - global_value.real_balance[id(wss)]=ok_json["balance"] - elif ok_json["isDemo"]==1: - global_value.practice_balance[id(wss)]=ok_json["balance"] - - - elif self.api.async_name=="""451-["updateStream",{"_placeholder":true,"num":0}]""": - self.api.async_name="" - ok_json=json.loads(raw_message.decode("utf8")) - ans={} - ans["time"]=ok_json[0][1] - ans["price"]=ok_json[0][2] - - self.api.realtime_price[ok_json[0][0]].append(ans) - - - - - - if isinstance(raw_message,str): - if "pingTimeout" in raw_message and global_value.check_auth_finish[id(wss)]==False: - - logger.debug("40") - wss.send("40") - - - global_value.auth_send_count[self.api.object_id]=global_value.auth_send_count[self.api.object_id]+1 - elif "40" in raw_message and global_value.check_auth_finish[id(wss)]==False: - logger.debug(global_value.SSID[self.api.object_id]) - wss.send(global_value.SSID[self.api.object_id]) - pass - - - if "successauth" in raw_message: - - global_value.check_websocket_if_connect[id(wss)] = 1 - global_value.check_auth_finish[id(wss)]=True - pass - - - try: - - ok_json=json.loads(raw_message.decode("utf-8")) - - - - """ - b'\x04[["AUDCAD_otc",1625299325.048,0.87461]]' - """ - - if "index" in ok_json: - self.api.getcandle_data[ok_json["index"]]=ok_json - - if "requestId" in ok_json: - self.api.request_data[str(ok_json["requestId"])]=ok_json - if "ticket" in ok_json and "amount" in ok_json: - self.api.check_win_refund_data[ok_json["ticket"]]=ok_json - - try: - for info in ok_json: - if "id" in info and "profit" in info: - self.api.check_win_close_data[info["id"]]=info - except: - pass - - except: - pass - global_value.ssl_Mutex[self.api.object_id].release() - @staticmethod - def on_error(wss, error): - """Method to process websocket errors.""" - logger = logging.getLogger(__name__) - logger.error(error) - global_value.websocket_error_reason[id(wss)] = str(error) - global_value.check_websocket_if_error[id(wss)] = True - - @staticmethod - def on_open(wss): - """Method to process websocket open.""" - logger = logging.getLogger(__name__) - logger.debug("Websocket client connected.") - - - - @staticmethod - def on_close(wss,close_status_code,close_msg): - """Method to process websocket close.""" - logger = logging.getLogger(__name__) - logger.debug("Websocket connection closed.") - global_value.check_websocket_if_connect[id(wss)] = 0 diff --git a/v2/pocketoptionapi-v2/setup.py b/v2/pocketoptionapi-v2/setup.py deleted file mode 100644 index 727f663..0000000 --- a/v2/pocketoptionapi-v2/setup.py +++ /dev/null @@ -1,17 +0,0 @@ - -from setuptools import (setup, find_packages) - - -setup( - name="pocketoptionapiv2", - version="2.2", - packages=find_packages(), - install_requires=["pylint","requests","websocket-client==0.58","des"], - include_package_data = True, - description="Free PoacketOption API for python", - long_description="Free pocketoptionapi API for python", - url="https://github.com/theshadow76/PocketOptionAPI", - author="Vigo Wa;ler", - author_email="vigopaul05@gmail.com", - zip_safe=False -)