xync-client 0.0.11.dev10__tar.gz → 0.0.11.dev14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {xync_client-0.0.11.dev10/xync_client.egg-info → xync_client-0.0.11.dev14}/PKG-INFO +2 -2
  2. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/pyproject.toml +1 -1
  3. xync_client-0.0.11.dev14/tests/Abc/AgentTest.py +17 -0
  4. xync_client-0.0.11.dev14/tests/Abc/BaseTest.py +53 -0
  5. xync_client-0.0.11.dev14/tests/TestEx.py +44 -0
  6. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Abc/Agent.py +1 -1
  7. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Abc/Auth.py +7 -5
  8. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/ex.py +4 -5
  9. xync_client-0.0.11.dev14/xync_client/BingX/base.py +20 -0
  10. xync_client-0.0.11.dev14/xync_client/BingX/ex.py +62 -0
  11. xync_client-0.0.11.dev14/xync_client/BingX/req.mjs +14 -0
  12. xync_client-0.0.11.dev14/xync_client/BingX/sign.js +3368 -0
  13. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/BitGet/agent.py +1 -1
  14. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/BitGet/ex.py +29 -13
  15. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Bybit/ex.py +6 -6
  16. xync_client-0.0.11.dev10/xync_client/Gate/pub.py → xync_client-0.0.11.dev14/xync_client/Gate/ex.py +4 -3
  17. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Htx/ex.py +5 -4
  18. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/agent.py +6 -13
  19. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/ex.py +3 -2
  20. xync_client-0.0.11.dev14/xync_client/__init__.py +0 -0
  21. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14/xync_client.egg-info}/PKG-INFO +2 -2
  22. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client.egg-info/SOURCES.txt +10 -6
  23. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client.egg-info/requires.txt +1 -1
  24. xync_client-0.0.11.dev10/xync_client/AbcTest/AgentTest.py +0 -13
  25. xync_client-0.0.11.dev10/xync_client/AbcTest/BaseTest.py +0 -42
  26. xync_client-0.0.11.dev10/xync_client/AbcTest/ExTest.py +0 -12
  27. xync_client-0.0.11.dev10/xync_client/BingX/ex.py +0 -66
  28. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/.env.sample +0 -0
  29. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/.gitignore +0 -0
  30. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/.pre-commit-config.yaml +0 -0
  31. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/README.md +0 -0
  32. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/makefile +0 -0
  33. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/setup.cfg +0 -0
  34. {xync_client-0.0.11.dev10/xync_client/AbcTest → xync_client-0.0.11.dev14/tests/Abc}/OrderTest.py +0 -0
  35. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/Binance/test_binance.py +0 -0
  36. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/Bybit/test_bybit.py +0 -0
  37. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/Bybit/test_bybit_p2p.py +0 -0
  38. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/Gate/test_gate.py +0 -0
  39. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/Htx/test_htx_p2p.py +0 -0
  40. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/tests/__init__.py +0 -0
  41. /xync_client-0.0.11.dev10/tests/test_ex.py → /xync_client-0.0.11.dev14/tests/_test_ex.py +0 -0
  42. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Abc/Base.py +0 -0
  43. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Abc/Ex.py +0 -0
  44. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Abc/Order.py +0 -0
  45. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/__init__.py +0 -0
  46. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/binance_async.py +0 -0
  47. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/earn_api.py +0 -0
  48. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/exceptions.py +0 -0
  49. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/sapi.py +0 -0
  50. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Binance/web_c2c.py +0 -0
  51. {xync_client-0.0.11.dev10/xync_client/BitGet → xync_client-0.0.11.dev14/xync_client/BingX}/__init__.py +0 -0
  52. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/BingX/test/main.py +0 -0
  53. {xync_client-0.0.11.dev10/xync_client → xync_client-0.0.11.dev14/xync_client/BitGet}/__init__.py +0 -0
  54. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/BitGet/req.mjs +0 -0
  55. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Bybit/web_earn.py +0 -0
  56. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Bybit/web_p2p.py +0 -0
  57. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Gate/premarket.py +0 -0
  58. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Htx/agent.py +0 -0
  59. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Htx/earn.py +0 -0
  60. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/KuCoin/pub.py +0 -0
  61. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/KuCoin/web.py +0 -0
  62. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/Okx/ex.py +0 -0
  63. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/auth.py +0 -0
  64. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/order.py +0 -0
  65. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/pyro.py +0 -0
  66. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/TgWallet/web.py +0 -0
  67. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client/loader.py +0 -0
  68. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client.egg-info/dependency_links.txt +0 -0
  69. {xync_client-0.0.11.dev10 → xync_client-0.0.11.dev14}/xync_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xync-client
3
- Version: 0.0.11.dev10
3
+ Version: 0.0.11.dev14
4
4
  Author-email: Mike Artemiev <mixartemev@gmail.com>
5
5
  Project-URL: Homepage, https://gitlab.com/XyncNet/client
6
6
  Project-URL: Repository, https://gitlab.com/XyncNet/client
@@ -11,7 +11,7 @@ Requires-Dist: pybit
11
11
  Requires-Dist: pyotp
12
12
  Requires-Dist: pyrogram
13
13
  Requires-Dist: python-okx
14
- Requires-Dist: xn-client>=0.0.3dev2
14
+ Requires-Dist: xn-client>=0.0.3dev3
15
15
  Requires-Dist: xync-schema
16
16
  Provides-Extra: dev
17
17
  Requires-Dist: build; extra == "dev"
@@ -13,7 +13,7 @@ dependencies = [
13
13
  "pyotp",
14
14
  "pyrogram",
15
15
  "python-okx",
16
- "xn-client>=0.0.3dev2",
16
+ "xn-client>=0.0.3dev3",
17
17
  "xync-schema"
18
18
  ]
19
19
 
@@ -0,0 +1,17 @@
1
+ import pytest
2
+
3
+ from tests.Abc.BaseTest import BaseTest
4
+ from xync_client.Abc.Agent import BaseAgentClient
5
+ from xync_client.Abc.Base import BaseClient
6
+
7
+
8
+ class AgentTest(BaseTest):
9
+ async def clients(self) -> list[BaseClient]:
10
+ pass
11
+
12
+ @pytest.fixture(scope="class", autouse=True)
13
+ async def cl(self) -> BaseAgentClient:
14
+ agent = (await self.ex).agents.filter(auth__not_isnull=True).first()
15
+ acl = BaseClient(agent)
16
+ yield acl
17
+ await acl.close()
@@ -0,0 +1,53 @@
1
+ from abc import abstractmethod
2
+ from asyncio import AbstractEventLoop
3
+ from typing import TypeGuard
4
+
5
+ import pytest
6
+ from tortoise.backends.asyncpg import AsyncpgDBClient
7
+ from x_model import init_db
8
+ from xync_client.Abc.Base import BaseClient, DictOfDicts, ListOfDicts, FlatDict, MapOfIdsList
9
+ from xync_schema import models
10
+
11
+ from xync_client.loader import PG_DSN
12
+
13
+
14
+ class BaseTest:
15
+ loop: AbstractEventLoop
16
+
17
+ # @pytest.fixture(scope="class", autouse=True)
18
+ # def event_loop_policy(self):
19
+ # return uvloop.EventLoopPolicy()
20
+
21
+ @pytest.fixture(scope="class", autouse=True)
22
+ async def cn(self) -> AsyncpgDBClient:
23
+ cn: AsyncpgDBClient = await init_db(PG_DSN, models, True)
24
+ yield cn
25
+ await cn.close()
26
+
27
+ @abstractmethod
28
+ @pytest.fixture(scope="class")
29
+ async def clients(self) -> list[BaseClient]: ...
30
+
31
+ @staticmethod
32
+ def is_dict_of_dicts(dct: DictOfDicts, not_empty: bool = True) -> TypeGuard[DictOfDicts]:
33
+ if not_empty and not len(dct):
34
+ return False
35
+ return all(isinstance(k, int | str) and isinstance(v, dict) for k, v in dct.items())
36
+
37
+ @staticmethod
38
+ def is_list_of_dicts(lst: ListOfDicts, not_empty: bool = True) -> TypeGuard[ListOfDicts]:
39
+ if not_empty and not len(lst):
40
+ return False
41
+ return all(isinstance(el, dict) for el in lst)
42
+
43
+ @staticmethod
44
+ def is_flat_dict(dct: FlatDict, not_empty: bool = True) -> TypeGuard[FlatDict]:
45
+ if not_empty and not len(dct):
46
+ return False
47
+ return all(isinstance(k, int | str) and isinstance(v, str) for k, v in dct.items())
48
+
49
+ @staticmethod
50
+ def is_map_of_ids(dct: MapOfIdsList, not_empty: bool = True) -> TypeGuard[MapOfIdsList]:
51
+ if not_empty and not len(dct):
52
+ return False
53
+ return all(isinstance(k, int | str) and isinstance(v, str) for k, v in dct.items())
@@ -0,0 +1,44 @@
1
+ import logging
2
+
3
+ import pytest
4
+ from xync_schema.enums import ExStatus, ExType, ExAction
5
+ from xync_schema.models import Ex, TestEx as TestExs
6
+
7
+ from tests.Abc.BaseTest import BaseTest
8
+ from xync_client.Abc.Base import BaseClient, DictOfDicts, FlatDict
9
+ from xync_client.Abc.Ex import BaseExClient
10
+
11
+
12
+ class TestEx(BaseTest):
13
+ @pytest.fixture(scope="class")
14
+ async def clients(self) -> list[BaseClient]:
15
+ exs = await Ex.filter(status__gt=ExStatus.plan)
16
+ [await ex.fetch_related("agents") for ex in exs if ex.type_ == ExType.tg]
17
+ clients: list[BaseExClient] = [ex.client() for ex in exs]
18
+ yield clients
19
+ [await cl.close() for cl in clients]
20
+
21
+ # 20
22
+ async def test_pms(self, clients: list[BaseExClient]):
23
+ for client in clients:
24
+ pms: DictOfDicts = await client.pms()
25
+ t, _ = await TestExs.update_or_create({"ok": self.is_dict_of_dicts(pms)}, ex=client.ex, action=ExAction.pms)
26
+ assert t.ok, "No pms"
27
+ logging.info(f"{client.ex.name}:{ExAction.pms.name} - ok")
28
+
29
+ # 21
30
+ async def test_curs(self, clients: list[BaseExClient]):
31
+ for client in clients:
32
+ curs: FlatDict = await client.curs()
33
+ t, _ = await TestExs.update_or_create({"ok": self.is_flat_dict(curs)}, ex=client.ex, action=ExAction.curs)
34
+ assert t.ok, "No curs"
35
+ logging.info(f"{client.ex.name}:{ExAction.pms.name} - ok")
36
+
37
+ # 22
38
+ async def test_cur_pms_map(self, clients: list[BaseExClient]):
39
+ for client in clients:
40
+ cur_pms: DictOfDicts = await client.cur_pms_map()
41
+ ok = self.is_dict_of_dicts(cur_pms)
42
+ t, _ = await TestExs.update_or_create({"ok": ok}, ex=client.ex, action=ExAction.cur_pms_map)
43
+ assert t.ok, "No pms for cur"
44
+ logging.info(f"{client.ex.name}:{ExAction.pms.name} - ok")
@@ -10,7 +10,7 @@ class BaseAgentClient(BaseAuthClient):
10
10
  # 0: Получшение ордеров в статусе status, по монете coin, в валюте coin, в направлении is_sell: bool
11
11
  @abstractmethod
12
12
  async def get_orders(
13
- self, stauts: OrderStatus = OrderStatus.active, coin: Coin = None, cur: Cur = None, is_sell: bool = None
13
+ self, stauts: OrderStatus = OrderStatus.created, coin: Coin = None, cur: Cur = None, is_sell: bool = None
14
14
  ) -> list[Order]: ...
15
15
 
16
16
  # 1: [T] Получшение ордеров в статусе status, по монете coin, в валюте coin, в направлении is_sell: bool
@@ -3,21 +3,23 @@ from abc import abstractmethod
3
3
 
4
4
  from aiohttp import ClientResponse
5
5
  from aiohttp.http_exceptions import HttpProcessingError
6
- from xync_schema.models import Agent
6
+ from xync_schema.models import Agent, Ex
7
7
 
8
8
  from xync_client.Abc.Base import BaseClient
9
9
 
10
10
 
11
11
  class BaseAuthClient(BaseClient):
12
- def __init__(self, agent: Agent):
13
- self.headers.update(agent.auth)
14
- self.agent = agent
12
+ def __init__(self, agent: Agent | Ex):
13
+ # dirty hack for multi-inheritance
14
+ self.agent = agent if isinstance(agent, Agent) else agent.agents[0]
15
+ ex = agent if isinstance(agent, Ex) else agent.ex
16
+ self.headers.update(self.agent.auth)
15
17
  self.meth = {
16
18
  "GET": self._get,
17
19
  "POST": self._post,
18
20
  "DELETE": self._delete,
19
21
  }
20
- super().__init__(agent.ex)
22
+ super().__init__(ex)
21
23
 
22
24
  @abstractmethod
23
25
  async def _get_auth_hdrs(self) -> dict[str, str]: ...
@@ -1,13 +1,12 @@
1
1
  from xync_schema.enums import PmType
2
2
 
3
- from xync_client.Abc.Ex import BaseClient
4
- from xync_client.Binance.sapi import Sapi
3
+ from xync_client.Abc.Ex import BaseExClient
5
4
  from xync_schema.models import Ex
6
5
 
7
6
 
8
- class Client(BaseClient):
9
- def __init__(self, ex: Ex, bkeys):
10
- self.sapi = Sapi(*bkeys)
7
+ class ExClient(BaseExClient):
8
+ def __init__(self, ex: Ex):
9
+ # self.sapi = Sapi(*bkeys)
11
10
  super().__init__(ex)
12
11
 
13
12
  async def curs(self) -> dict:
@@ -0,0 +1,20 @@
1
+ import subprocess
2
+ from datetime import datetime
3
+ from json import dumps
4
+ from uuid import uuid4
5
+
6
+ from xync_client.Abc.Base import BaseClient
7
+
8
+
9
+ class BaseBingXClient(BaseClient):
10
+ def _prehook(self, _payload: dict = None):
11
+ traceid = str(uuid4()).replace("-", "")
12
+ now = str(int(datetime.now().timestamp() * 1000))
13
+ payload = dumps(_payload, separators=(",", ":"), sort_keys=True) if _payload else "{}"
14
+ p = subprocess.Popen(["node", "../xync_client/BingX/req.mjs", now, traceid, payload], stdout=subprocess.PIPE)
15
+ sign = p.stdout.read().decode().strip()
16
+ return {
17
+ "sign": sign,
18
+ "timestamp": now,
19
+ "traceid": traceid,
20
+ }
@@ -0,0 +1,62 @@
1
+ from asyncio import run
2
+
3
+ from x_model import init_db
4
+ from xync_client.Abc.Base import DictOfDicts, FlatDict
5
+ from xync_schema import models
6
+ from xync_schema.models import Ex
7
+
8
+ from xync_client.Abc.Ex import BaseExClient
9
+ from xync_client.BingX.base import BaseBingXClient
10
+ from xync_client.loader import PG_DSN
11
+
12
+
13
+ class ExClient(BaseExClient, BaseBingXClient):
14
+ headers: dict[str, str] = {
15
+ "app_version": "9.0.5",
16
+ "device_id": "ccfb6d50-b63b-11ef-b31f-ef1f76f67c4e",
17
+ "lang": "ru-RU",
18
+ "platformid": "30",
19
+ }
20
+
21
+ # 20: Список всех платежных методов на бирже
22
+ async def pms(self) -> DictOfDicts: # {pm.exid: pm}
23
+ curs = await self.curs()
24
+ pp = {}
25
+ for _id, cur in curs.items():
26
+ pms = await self._get("/api/c2c/v1/advert/payment/list", params={"fiat": cur})
27
+ [pp.update({p["id"]: {"name": p["name"], "logo": p["icon"]}}) for p in pms["data"]["paymentMethodList"]]
28
+ return pp
29
+
30
+ # 21: Список поддерживаемых валют
31
+ async def curs(self) -> FlatDict: # {cur.exid: cur.ticker}
32
+ params = {
33
+ "type": "1",
34
+ "asset": "USDT",
35
+ "coinType": "2",
36
+ }
37
+ curs = await self._get("/api/c2c/v1/common/supportCoins", params=params)
38
+ return {cur["id"]: cur["name"] for cur in curs["data"]["coins"]}
39
+
40
+ # 22: cur_pms_map
41
+ async def cur_pms_map(self):
42
+ pass
43
+
44
+ # 23: coins
45
+ async def coins(self):
46
+ pass
47
+
48
+ # 24: ads
49
+ async def ads(self, coin_exid: str, cur_exid: str, is_sell: bool, pm_exids: list[str | int] = None):
50
+ pass
51
+
52
+
53
+ async def main():
54
+ _ = await init_db(PG_DSN, models, True)
55
+ bg = await Ex.get(name="BingX")
56
+ cl = ExClient(bg)
57
+ await cl.pms()
58
+ await cl.close()
59
+
60
+
61
+ if __name__ == "__main__":
62
+ run(main())
@@ -0,0 +1,14 @@
1
+ import cC from './sign.js'
2
+
3
+ const [_, __, now, trace, payload] = process.argv
4
+ const e = {
5
+ timestamp: now,
6
+ traceId: trace,
7
+ deviceId: "ccfb6d50-b63b-11ef-b31f-ef1f76f67c4e",
8
+ platformId: "30",
9
+ appVersion: "9.0.5",
10
+ requestPayload: JSON.parse(payload)
11
+ };
12
+
13
+ const sgn = cC(e).sign;
14
+ console.log(sgn);