xync-client 0.0.11.dev12__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.
- {xync_client-0.0.11.dev12/xync_client.egg-info → xync_client-0.0.11.dev14}/PKG-INFO +1 -1
- xync_client-0.0.11.dev14/tests/Abc/AgentTest.py +17 -0
- xync_client-0.0.11.dev14/tests/Abc/BaseTest.py +53 -0
- xync_client-0.0.11.dev14/tests/TestEx.py +44 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Abc/Agent.py +1 -1
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Abc/Auth.py +7 -5
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/ex.py +4 -5
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BingX/base.py +1 -1
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BingX/ex.py +4 -3
- xync_client-0.0.11.dev14/xync_client/BingX/test/main.py +22 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BitGet/agent.py +1 -1
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BitGet/ex.py +27 -12
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Bybit/ex.py +6 -6
- xync_client-0.0.11.dev12/xync_client/Gate/pub.py → xync_client-0.0.11.dev14/xync_client/Gate/ex.py +4 -3
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Htx/ex.py +5 -4
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/agent.py +6 -13
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/ex.py +3 -2
- xync_client-0.0.11.dev14/xync_client/__init__.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14/xync_client.egg-info}/PKG-INFO +1 -1
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client.egg-info/SOURCES.txt +7 -6
- xync_client-0.0.11.dev12/xync_client/AbcTest/AgentTest.py +0 -13
- xync_client-0.0.11.dev12/xync_client/AbcTest/BaseTest.py +0 -42
- xync_client-0.0.11.dev12/xync_client/AbcTest/ExTest.py +0 -12
- xync_client-0.0.11.dev12/xync_client/BingX/test/main.py +0 -39
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/.env.sample +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/.gitignore +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/README.md +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/makefile +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/pyproject.toml +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/setup.cfg +0 -0
- {xync_client-0.0.11.dev12/xync_client/AbcTest → xync_client-0.0.11.dev14/tests/Abc}/OrderTest.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/Binance/test_binance.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/Gate/test_gate.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/Htx/test_htx_p2p.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/tests/__init__.py +0 -0
- /xync_client-0.0.11.dev12/tests/test_ex.py → /xync_client-0.0.11.dev14/tests/_test_ex.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Abc/Base.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Abc/Ex.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.11.dev12/xync_client/BitGet → xync_client-0.0.11.dev14/xync_client/BingX}/__init__.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.11.dev12/xync_client → xync_client-0.0.11.dev14/xync_client/BitGet}/__init__.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/BitGet/req.mjs +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Htx/agent.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Htx/earn.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/KuCoin/pub.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/auth.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/pyro.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client/loader.py +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client.egg-info/requires.txt +0 -0
- {xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -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.
|
|
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
|
-
|
|
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__(
|
|
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
|
|
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
|
|
9
|
-
def __init__(self, ex: Ex
|
|
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:
|
|
@@ -11,7 +11,7 @@ class BaseBingXClient(BaseClient):
|
|
|
11
11
|
traceid = str(uuid4()).replace("-", "")
|
|
12
12
|
now = str(int(datetime.now().timestamp() * 1000))
|
|
13
13
|
payload = dumps(_payload, separators=(",", ":"), sort_keys=True) if _payload else "{}"
|
|
14
|
-
p = subprocess.Popen(["node", "req.mjs", now, traceid, payload], stdout=subprocess.PIPE)
|
|
14
|
+
p = subprocess.Popen(["node", "../xync_client/BingX/req.mjs", now, traceid, payload], stdout=subprocess.PIPE)
|
|
15
15
|
sign = p.stdout.read().decode().strip()
|
|
16
16
|
return {
|
|
17
17
|
"sign": sign,
|
|
@@ -10,7 +10,7 @@ from xync_client.BingX.base import BaseBingXClient
|
|
|
10
10
|
from xync_client.loader import PG_DSN
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class ExClient(BaseExClient, BaseBingXClient):
|
|
14
14
|
headers: dict[str, str] = {
|
|
15
15
|
"app_version": "9.0.5",
|
|
16
16
|
"device_id": "ccfb6d50-b63b-11ef-b31f-ef1f76f67c4e",
|
|
@@ -53,9 +53,10 @@ class Client(BaseExClient, BaseBingXClient):
|
|
|
53
53
|
async def main():
|
|
54
54
|
_ = await init_db(PG_DSN, models, True)
|
|
55
55
|
bg = await Ex.get(name="BingX")
|
|
56
|
-
cl =
|
|
56
|
+
cl = ExClient(bg)
|
|
57
57
|
await cl.pms()
|
|
58
58
|
await cl.close()
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
run(main())
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
headers = {
|
|
4
|
+
"app_version": "8.10.0",
|
|
5
|
+
"device_id": "64a8c630-acc2-11ef-aa5e-9f6ee3baa1a5",
|
|
6
|
+
"lang": "ru-RU",
|
|
7
|
+
"platformid": "30",
|
|
8
|
+
"sign": "5679FBAAF1D0A199E6B0975616B44807220C5FC8824D41F0DE21D2261F2D8E18",
|
|
9
|
+
"timestamp": "1733496004073",
|
|
10
|
+
"traceid": "8557cddbfe574e07b36c3014b5773358",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
params = {
|
|
14
|
+
"coinName": "USDT",
|
|
15
|
+
"tradeCoinName": "USD",
|
|
16
|
+
"type": "1",
|
|
17
|
+
"amount": "500",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
response = requests.get("https://api-app.qq-os.com/api/fiat/v1/rapid-buy-integration", params=params, headers=headers)
|
|
21
|
+
|
|
22
|
+
print([i.get("paymentMethod")["name"] for i in response.json()["data"]["matchOptimalAdvertListVo"]["optimals"]])
|
|
@@ -19,7 +19,7 @@ class Client(BaseAgentClient):
|
|
|
19
19
|
super().__init__(agent)
|
|
20
20
|
|
|
21
21
|
async def get_orders(
|
|
22
|
-
self, stauts: OrderStatus = OrderStatus.
|
|
22
|
+
self, stauts: OrderStatus = OrderStatus.created, coin: Coin = None, cur: Cur = None, is_sell: bool = None
|
|
23
23
|
) -> list[Order]:
|
|
24
24
|
pass
|
|
25
25
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import os
|
|
2
3
|
import subprocess
|
|
3
4
|
from asyncio import run
|
|
4
5
|
|
|
@@ -7,12 +8,16 @@ from xync_client.Abc.Base import DictOfDicts
|
|
|
7
8
|
from xync_schema import models
|
|
8
9
|
from xync_schema.models import Cur, Ex
|
|
9
10
|
|
|
10
|
-
from xync_client.Abc.Ex import
|
|
11
|
+
from xync_client.Abc.Ex import BaseExClient
|
|
11
12
|
from xync_client.loader import PG_DSN
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
class
|
|
15
|
-
headers = {
|
|
15
|
+
class ExClient(BaseExClient):
|
|
16
|
+
headers = {
|
|
17
|
+
"accept-language": "ru,en;q=0.9",
|
|
18
|
+
"content-type": "application/json;charset=UTF-8",
|
|
19
|
+
"deviceid": "883e1394d8a2278418b6f02804df16c4",
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
async def curs(self) -> dict[str, str]:
|
|
18
23
|
curs = (await self._post("/v1/p2p/pub/currency/queryAllCoinAndFiat"))["data"]["fiatInfoRespList"]
|
|
@@ -23,14 +28,23 @@ class Client(BaseClient):
|
|
|
23
28
|
return {coin["coinCode"]: coin["coinCode"] for coin in coins}
|
|
24
29
|
|
|
25
30
|
async def pms(self) -> DictOfDicts: # {pm.exid: pm}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
for id_, cur in (await self.curs()).items():
|
|
32
|
+
pref = "../xync_client/BitGet/" if os.getcwd().split("/")[-1] == "tests" else ""
|
|
33
|
+
data = {"fiatCode": cur, "languageType": 6}
|
|
34
|
+
p = subprocess.Popen(
|
|
35
|
+
[
|
|
36
|
+
"node",
|
|
37
|
+
pref + "req.mjs",
|
|
38
|
+
"pub/currency/query-popular-paymethod",
|
|
39
|
+
json.dumps(data, separators=(",", ":")),
|
|
40
|
+
json.dumps(self.headers, separators=(",", ":")),
|
|
41
|
+
],
|
|
42
|
+
stdout=subprocess.PIPE,
|
|
43
|
+
)
|
|
44
|
+
out = p.stdout.read().decode()
|
|
45
|
+
pms: list[dict] = json.loads(out)
|
|
32
46
|
|
|
33
|
-
pmcurs = {
|
|
47
|
+
pmcurs = {pm["fiatCode"]: pm["paymethodInfo"] for pm in pms}
|
|
34
48
|
pp = {}
|
|
35
49
|
[
|
|
36
50
|
[pp.update({int(p["paymethodId"]): {"name": p["paymethodName"], "logo": p.get("iconUrl")}}) for p in ps]
|
|
@@ -76,7 +90,7 @@ class Client(BaseClient):
|
|
|
76
90
|
async def main():
|
|
77
91
|
_ = await init_db(PG_DSN, models, True)
|
|
78
92
|
bg = await Ex.get(name="BitGet")
|
|
79
|
-
cl =
|
|
93
|
+
cl = ExClient(bg)
|
|
80
94
|
# await cl.curs()
|
|
81
95
|
# await cl.coins()
|
|
82
96
|
# await cl.ads("BTC", "RUB", True, [1, 289, 375])
|
|
@@ -87,4 +101,5 @@ async def main():
|
|
|
87
101
|
await cl.close()
|
|
88
102
|
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
run(main())
|
|
@@ -2,7 +2,7 @@ from enum import IntEnum
|
|
|
2
2
|
from time import sleep
|
|
3
3
|
|
|
4
4
|
import pyotp
|
|
5
|
-
from x_client.
|
|
5
|
+
from x_client.aiohttp import Client
|
|
6
6
|
|
|
7
7
|
from xync_client.loader import BYT2FA
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ class AdsStatus(IntEnum):
|
|
|
16
16
|
WORKING = 1
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class
|
|
19
|
+
class ExClient(Client): # Bybit client
|
|
20
20
|
host = "api2.bybit.com"
|
|
21
21
|
|
|
22
22
|
pub_header = {"cookie": ";"} # rewrite token for public methods
|
|
@@ -97,12 +97,12 @@ class BybitP2P(Client): # Bybit client
|
|
|
97
97
|
ads = self._post("/fiat/otc/item/online/", data, self.pub_header)
|
|
98
98
|
return ads["result"]["items"]
|
|
99
99
|
|
|
100
|
-
def get_config(self):
|
|
101
|
-
resp = self._get("/fiat/p2p/config/initial", self.pub_header)
|
|
100
|
+
async def get_config(self):
|
|
101
|
+
resp = await self._get("/fiat/p2p/config/initial", self.pub_header)
|
|
102
102
|
return resp["result"] # todo: tokens, pairs, ...
|
|
103
103
|
|
|
104
|
-
def
|
|
105
|
-
config = self.get_config()
|
|
104
|
+
async def curs(self):
|
|
105
|
+
config = await self.get_config()
|
|
106
106
|
return config["symbols"]
|
|
107
107
|
|
|
108
108
|
def get_coins(self):
|
xync_client-0.0.11.dev12/xync_client/Gate/pub.py → xync_client-0.0.11.dev14/xync_client/Gate/ex.py
RENAMED
|
@@ -12,7 +12,7 @@ from xync_client.Abc.Ex import BaseExClient
|
|
|
12
12
|
from xync_client.loader import PG_DSN
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class ExClient(BaseExClient):
|
|
16
16
|
async def cur_pms_map(self) -> MapOfIdsList:
|
|
17
17
|
pass
|
|
18
18
|
|
|
@@ -60,10 +60,11 @@ class PublicClient(BaseExClient):
|
|
|
60
60
|
async def main():
|
|
61
61
|
_ = await init_db(PG_DSN, models, True)
|
|
62
62
|
bg = await Ex.get(name="Gate")
|
|
63
|
-
cl =
|
|
63
|
+
cl = ExClient(bg)
|
|
64
64
|
# await cl.curs()
|
|
65
65
|
# await cl.coins()
|
|
66
66
|
await cl.pms()
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
run(main())
|
|
@@ -5,11 +5,11 @@ from xync_schema import models
|
|
|
5
5
|
from xync_schema.models import Ex, Coin, Cur, Pm, Ad
|
|
6
6
|
from xync_schema.enums import PmType
|
|
7
7
|
|
|
8
|
-
from xync_client.Abc.Ex import
|
|
8
|
+
from xync_client.Abc.Ex import BaseExClient
|
|
9
9
|
from xync_client.loader import PG_DSN
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class ExClient(BaseExClient):
|
|
13
13
|
# 20: Get all pms
|
|
14
14
|
async def pms(self) -> dict[int, dict]:
|
|
15
15
|
dist = {
|
|
@@ -64,10 +64,11 @@ class Client(ExClient):
|
|
|
64
64
|
async def main():
|
|
65
65
|
_ = await init_db(PG_DSN, models, True)
|
|
66
66
|
ex = await Ex.get(name="Htx")
|
|
67
|
-
cl =
|
|
67
|
+
cl = ExClient(ex)
|
|
68
68
|
await cl.set_pmcurexs()
|
|
69
69
|
await cl.set_coinexs()
|
|
70
70
|
await cl.close()
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
run(main())
|
|
@@ -1,38 +1,31 @@
|
|
|
1
|
-
from enum import StrEnum
|
|
1
|
+
from enum import StrEnum
|
|
2
2
|
from typing import Literal
|
|
3
3
|
|
|
4
|
-
from
|
|
4
|
+
from xync_client.TgWallet.auth import AuthClient
|
|
5
5
|
from xync_schema.models import User, Cur, Order, Coin, OrderStatus, Pmex
|
|
6
6
|
from xync_schema.pydantic import FiatNew
|
|
7
7
|
|
|
8
8
|
from xync_client.Abc.Agent import BaseAgentClient
|
|
9
|
-
from xync_client.TgWallet.pyro import PyroClient
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
class Exceptions(StrEnum):
|
|
13
12
|
PM_KYC = "OFFER_FIAT_COUNTRY_NOT_SUPPORTED_BY_USER_KYC_COUNTRY"
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
class Status(IntEnum):
|
|
17
|
-
|
|
15
|
+
# class Status(IntEnum):
|
|
16
|
+
# ALL_ACTIVE = OrderStatus.active
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
class AgentClient(BaseAgentClient):
|
|
19
|
+
class AgentClient(BaseAgentClient, AuthClient):
|
|
21
20
|
async def order_request(self, ad_id: int, amount: float) -> Order:
|
|
22
21
|
pass
|
|
23
22
|
|
|
24
|
-
async def _get_auth_hdrs(self) -> dict[str, str]:
|
|
25
|
-
pyro = PyroClient(self.agent)
|
|
26
|
-
init_data = await pyro.get_init_data()
|
|
27
|
-
tokens = HttpClient("walletbot.me")._post("/api/v1/users/auth/", init_data)
|
|
28
|
-
return {"Wallet-Authorization": tokens["jwt"], "Authorization": "Bearer " + tokens["value"]}
|
|
29
|
-
|
|
30
23
|
async def get_orders(
|
|
31
24
|
self, stauts: OrderStatus = OrderStatus.active, coin: Coin = None, cur: Cur = None, is_sell: bool = None
|
|
32
25
|
) -> list[Order]:
|
|
33
26
|
orders = await self._post(
|
|
34
27
|
"/p2p/public-api/v2/offer/order/history/get-by-user-id",
|
|
35
|
-
{"offset": 0, "limit": 100, "filter": {"status":
|
|
28
|
+
{"offset": 0, "limit": 100, "filter": {"status": "ALL_ACTIVE"}}, # "limit": 20
|
|
36
29
|
)
|
|
37
30
|
return orders
|
|
38
31
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from xync_client.
|
|
1
|
+
from xync_client.TgWallet.auth import AuthClient
|
|
2
|
+
|
|
2
3
|
from xync_schema.models import Pm
|
|
3
4
|
|
|
4
5
|
from xync_client.Abc.Ex import BaseExClient
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
class ExClient(BaseExClient,
|
|
8
|
+
class ExClient(BaseExClient, AuthClient):
|
|
8
9
|
async def curs(self) -> dict[str, str]:
|
|
9
10
|
coins_curs = await self._post("/p2p/public-api/v2/currency/all-supported")
|
|
10
11
|
return {c["code"]: c["code"] for c in coins_curs["data"]["fiat"]}
|
|
File without changes
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
README.md
|
|
5
5
|
makefile
|
|
6
6
|
pyproject.toml
|
|
7
|
+
tests/TestEx.py
|
|
7
8
|
tests/__init__.py
|
|
8
|
-
tests/
|
|
9
|
+
tests/_test_ex.py
|
|
10
|
+
tests/Abc/AgentTest.py
|
|
11
|
+
tests/Abc/BaseTest.py
|
|
12
|
+
tests/Abc/OrderTest.py
|
|
9
13
|
tests/Binance/test_binance.py
|
|
10
14
|
tests/Bybit/test_bybit.py
|
|
11
15
|
tests/Bybit/test_bybit_p2p.py
|
|
@@ -23,10 +27,6 @@ xync_client/Abc/Auth.py
|
|
|
23
27
|
xync_client/Abc/Base.py
|
|
24
28
|
xync_client/Abc/Ex.py
|
|
25
29
|
xync_client/Abc/Order.py
|
|
26
|
-
xync_client/AbcTest/AgentTest.py
|
|
27
|
-
xync_client/AbcTest/BaseTest.py
|
|
28
|
-
xync_client/AbcTest/ExTest.py
|
|
29
|
-
xync_client/AbcTest/OrderTest.py
|
|
30
30
|
xync_client/Binance/__init__.py
|
|
31
31
|
xync_client/Binance/binance_async.py
|
|
32
32
|
xync_client/Binance/earn_api.py
|
|
@@ -34,6 +34,7 @@ xync_client/Binance/ex.py
|
|
|
34
34
|
xync_client/Binance/exceptions.py
|
|
35
35
|
xync_client/Binance/sapi.py
|
|
36
36
|
xync_client/Binance/web_c2c.py
|
|
37
|
+
xync_client/BingX/__init__.py
|
|
37
38
|
xync_client/BingX/base.py
|
|
38
39
|
xync_client/BingX/ex.py
|
|
39
40
|
xync_client/BingX/req.mjs
|
|
@@ -46,8 +47,8 @@ xync_client/BitGet/req.mjs
|
|
|
46
47
|
xync_client/Bybit/ex.py
|
|
47
48
|
xync_client/Bybit/web_earn.py
|
|
48
49
|
xync_client/Bybit/web_p2p.py
|
|
50
|
+
xync_client/Gate/ex.py
|
|
49
51
|
xync_client/Gate/premarket.py
|
|
50
|
-
xync_client/Gate/pub.py
|
|
51
52
|
xync_client/Htx/agent.py
|
|
52
53
|
xync_client/Htx/earn.py
|
|
53
54
|
xync_client/Htx/ex.py
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from xync_client.Abc.Base import BaseClient
|
|
4
|
-
from xync_client.Abc.BaseTest import BaseTest
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class AgentTest(BaseTest):
|
|
8
|
-
@pytest.fixture(scope="class", autouse=True)
|
|
9
|
-
async def cl(self) -> BaseClient:
|
|
10
|
-
agent = (await self.exq).agents.filter(auth__not_isnull=True).first()
|
|
11
|
-
acl = BaseClient(agent)
|
|
12
|
-
yield acl
|
|
13
|
-
await acl.close()
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from typing import TypeGuard
|
|
3
|
-
from src.loader import PG_DSN
|
|
4
|
-
from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
5
|
-
from x_model import init_db
|
|
6
|
-
from xync_schema import models
|
|
7
|
-
from xync_schema.models import Ex
|
|
8
|
-
|
|
9
|
-
from xync_client.Abc.Base import DictOfDicts, ListOfDicts, FlatDict, MapOfIdsList, BaseClient
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class BaseTest:
|
|
13
|
-
def __init__(self, ex_name: str):
|
|
14
|
-
self.exq = Ex.get(name=ex_name)
|
|
15
|
-
|
|
16
|
-
@pytest.fixture(scope="class", autouse=True)
|
|
17
|
-
async def cn(self) -> AsyncpgDBClient:
|
|
18
|
-
cn: AsyncpgDBClient = await init_db(PG_DSN, models, True)
|
|
19
|
-
yield cn
|
|
20
|
-
await cn.close()
|
|
21
|
-
|
|
22
|
-
@pytest.fixture(scope="class", autouse=True)
|
|
23
|
-
async def cl(self) -> BaseClient:
|
|
24
|
-
bcl = BaseClient(await self.exq)
|
|
25
|
-
yield bcl
|
|
26
|
-
await bcl.close()
|
|
27
|
-
|
|
28
|
-
@staticmethod
|
|
29
|
-
def is_dict_of_dicts(dct: DictOfDicts) -> TypeGuard[DictOfDicts]:
|
|
30
|
-
return all(isinstance(k, int | str) and isinstance(v, dict) for k, v in dct.items())
|
|
31
|
-
|
|
32
|
-
@staticmethod
|
|
33
|
-
def is_list_of_dicts(lst: ListOfDicts) -> TypeGuard[ListOfDicts]:
|
|
34
|
-
return all(isinstance(el, dict) for el in lst)
|
|
35
|
-
|
|
36
|
-
@staticmethod
|
|
37
|
-
def is_flat_dict(dct: FlatDict) -> TypeGuard[FlatDict]:
|
|
38
|
-
return all(isinstance(k, int | str) and isinstance(v, str) for k, v in dct.items())
|
|
39
|
-
|
|
40
|
-
@staticmethod
|
|
41
|
-
def is_map_of_ids(dct: MapOfIdsList) -> TypeGuard[MapOfIdsList]:
|
|
42
|
-
return all(isinstance(k, int | str) and isinstance(v, str) for k, v in dct.items())
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from xync_client.Abc.Ex import BaseExClient
|
|
4
|
-
from xync_client.Abc.BaseTest import BaseTest
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class ExTest(BaseTest):
|
|
8
|
-
@pytest.fixture(scope="class", autouse=True)
|
|
9
|
-
async def cl(self) -> BaseExClient:
|
|
10
|
-
ecl = BaseExClient(await self.exq)
|
|
11
|
-
yield ecl
|
|
12
|
-
await ecl.close()
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
|
|
3
|
-
headers = {
|
|
4
|
-
"accept": "application/json, text/plain, */*",
|
|
5
|
-
"accept-language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
6
|
-
"app_version": "9.0.0",
|
|
7
|
-
"appid": "30004",
|
|
8
|
-
"appsiteid": "0",
|
|
9
|
-
"channel": "official",
|
|
10
|
-
"device_brand": "Linux_Chrome_131.0.0.0",
|
|
11
|
-
"device_id": "64a8c630-acc2-11ef-aa5e-9f6ee3baa1a5",
|
|
12
|
-
"lang": "ru-RU",
|
|
13
|
-
"mainappid": "10009",
|
|
14
|
-
"origin": "https://bingx.paycat.com",
|
|
15
|
-
"platformid": "30",
|
|
16
|
-
"priority": "u=1, i",
|
|
17
|
-
"referer": "https://bingx.paycat.com/",
|
|
18
|
-
"reg_channel": "official",
|
|
19
|
-
"sec-ch-ua": '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
|
|
20
|
-
"sec-ch-ua-mobile": "?0",
|
|
21
|
-
"sec-ch-ua-platform": '"Linux"',
|
|
22
|
-
"sec-fetch-dest": "empty",
|
|
23
|
-
"sec-fetch-mode": "cors",
|
|
24
|
-
"sec-fetch-site": "cross-site",
|
|
25
|
-
"sign": "C2F082935161A29256CDD98F2E33FBE3C9B2C0864A6FBCB1881013CBE6272AC8",
|
|
26
|
-
"timestamp": "1734637010958",
|
|
27
|
-
"timezone": "3",
|
|
28
|
-
"traceid": "3e38538d69fb43c9a009ea1fc00a9b8f",
|
|
29
|
-
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
|
30
|
-
"x-requested-with": "XMLHttpRequest",
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
params = {
|
|
34
|
-
"fiat": "RUB",
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
response = requests.get("https://api-app.we-api.com/api/c2c/v1/advert/payment/list", params=params, headers=headers)
|
|
38
|
-
|
|
39
|
-
print(i for i in response.json()["data"]["paymentMethodList"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.11.dev12/xync_client/AbcTest → xync_client-0.0.11.dev14/tests/Abc}/OrderTest.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.11.dev12/xync_client → xync_client-0.0.11.dev14/xync_client/BitGet}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.11.dev12 → xync_client-0.0.11.dev14}/xync_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|