xync-client 0.0.16.dev7__tar.gz → 0.0.16.dev9__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.16.dev7/xync_client.egg-info → xync_client-0.0.16.dev9}/PKG-INFO +1 -1
- xync_client-0.0.16.dev9/tests/TestAgent.py +141 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/Agent.py +6 -6
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/agent.py +57 -19
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9/xync_client.egg-info}/PKG-INFO +1 -1
- xync_client-0.0.16.dev7/tests/TestAgent.py +0 -76
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/.env.sample +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/.gitignore +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/README.md +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/makefile +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/pyproject.toml +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/setup.cfg +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/TestEx.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/TestOrder.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Binance/test_binance.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Gate/test_gate.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Htx/test_htx_p2p.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Wallet/test_agent.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Wallet/test_ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/__init__.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/_test_ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/Auth.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/Base.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/BaseTest.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/Ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BingX/__init__.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BingX/base.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BingX/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BitGet/__init__.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BitGet/agent.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BitGet/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/BitGet/req.mjs +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Bybit/agent.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Bybit/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Gate/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Htx/agent.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Htx/earn.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Htx/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/KuCoin/pub.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/auth.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/ex.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/pyro.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/__init__.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client/loader.py +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client.egg-info/SOURCES.txt +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client.egg-info/requires.txt +0 -0
- {xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from xync_schema.enums import ExStatus, ExAction
|
|
5
|
+
from xync_schema.models import Ex, TestEx, Fiat, Ad, Coin, Cur
|
|
6
|
+
from xync_schema.pydantic import FiatNew
|
|
7
|
+
|
|
8
|
+
from xync_client.Abc.BaseTest import BaseTest
|
|
9
|
+
from xync_client.Abc.Agent import BaseAgentClient
|
|
10
|
+
from xync_client.Abc.Base import BaseClient, DictOfDicts, ListOfDicts
|
|
11
|
+
from xync_client.TgWallet.ex import ExClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.mark.asyncio(loop_scope="session")
|
|
15
|
+
class TestAgent(BaseTest):
|
|
16
|
+
@pytest.fixture(scope="class", autouse=True)
|
|
17
|
+
async def clients(self) -> tuple[BaseClient, BaseClient]:
|
|
18
|
+
exs = await Ex.filter(status__gt=ExStatus.plan).prefetch_related("agents__ex")
|
|
19
|
+
agents = [[ag for ag in ex.agents if ag.auth][:2] for ex in exs]
|
|
20
|
+
clients: list[tuple[BaseClient, BaseClient]] = [(t.client(), m.client()) for t, m in agents]
|
|
21
|
+
yield clients
|
|
22
|
+
[(await taker.close(), await maker.close()) for taker, maker in clients]
|
|
23
|
+
|
|
24
|
+
# 0
|
|
25
|
+
async def test_get_orders(self, clients: list[BaseAgentClient]):
|
|
26
|
+
for taker, maker in clients:
|
|
27
|
+
get_orders: ListOfDicts = await taker.get_orders()
|
|
28
|
+
ok = self.is_list_of_dicts(get_orders, False)
|
|
29
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.get_orders)
|
|
30
|
+
assert t.ok, "No get orders"
|
|
31
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.get_orders.name} - ok")
|
|
32
|
+
|
|
33
|
+
# 1
|
|
34
|
+
async def test_order_request(self, clients: list[BaseAgentClient]):
|
|
35
|
+
for taker, maker in clients:
|
|
36
|
+
await taker.agent.fetch_related("ex", "ex__agents")
|
|
37
|
+
ex_client: ExClient = taker.agent.ex.client()
|
|
38
|
+
ads = await ex_client.ads("NOT", "RUB", False)
|
|
39
|
+
for ad in ads:
|
|
40
|
+
order_request: dict | bool = await taker.order_request(ad["id"], ad["orderAmountLimits"]["min"])
|
|
41
|
+
if order_request:
|
|
42
|
+
break
|
|
43
|
+
ok = order_request["status"] == "SUCCESS"
|
|
44
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.order_request)
|
|
45
|
+
assert t.ok, "No get orders"
|
|
46
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.order_request.name} - ok")
|
|
47
|
+
|
|
48
|
+
# 25
|
|
49
|
+
async def test_my_fiats(self, clients: list[BaseAgentClient]):
|
|
50
|
+
for taker, maker in clients:
|
|
51
|
+
my_fiats: DictOfDicts = await taker.my_fiats()
|
|
52
|
+
ok = self.is_dict_of_dicts(my_fiats)
|
|
53
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.my_fiats)
|
|
54
|
+
assert t.ok, "No my fiats"
|
|
55
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.my_fiats.name} - ok")
|
|
56
|
+
|
|
57
|
+
# 26
|
|
58
|
+
async def test_fiat_new(self, clients: list[BaseAgentClient]):
|
|
59
|
+
for taker, maker in clients:
|
|
60
|
+
fn = FiatNew(cur_id=11, pm_id=22, detail="123456789")
|
|
61
|
+
fiat_new: Fiat = await taker.fiat_new(fn)
|
|
62
|
+
ok = isinstance(fiat_new, Fiat)
|
|
63
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.fiat_new)
|
|
64
|
+
assert t.ok, "No add fiat"
|
|
65
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.fiat_new.name} - ok")
|
|
66
|
+
|
|
67
|
+
# 27
|
|
68
|
+
async def test_fiat_upd(self, clients: list[BaseAgentClient]):
|
|
69
|
+
for taker, maker in clients:
|
|
70
|
+
my_fiats = await taker.my_fiats()
|
|
71
|
+
fiats = [fiat for fiat in my_fiats.values()]
|
|
72
|
+
fiat_upd: Fiat = await taker.fiat_upd(fiat_id=fiats[0]["id"], detail="347890789")
|
|
73
|
+
ok = isinstance(fiat_upd, Fiat)
|
|
74
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.fiat_upd)
|
|
75
|
+
assert t.ok, "No upd fiat"
|
|
76
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.fiat_upd.name} - ok")
|
|
77
|
+
|
|
78
|
+
# 28
|
|
79
|
+
async def test_fiat_del(self, clients: list[BaseAgentClient]):
|
|
80
|
+
for taker, maker in clients:
|
|
81
|
+
my_fiats = await taker.my_fiats()
|
|
82
|
+
fiats = [fiat for fiat in my_fiats.values()]
|
|
83
|
+
fiat_del: bool = await taker.fiat_del(fiat_id=fiats[0]["id"])
|
|
84
|
+
ok = fiat_del["status"] == "SUCCESS"
|
|
85
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.fiat_del)
|
|
86
|
+
assert t.ok, "No del fiat"
|
|
87
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.fiat_del.name} - ok")
|
|
88
|
+
|
|
89
|
+
# 29
|
|
90
|
+
async def test_my_ads(self, clients: list[BaseAgentClient]):
|
|
91
|
+
for taker, maker in clients:
|
|
92
|
+
my_ads: ListOfDicts = await taker.my_ads()
|
|
93
|
+
ok = self.is_list_of_dicts(my_ads, False)
|
|
94
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.my_ads)
|
|
95
|
+
assert t.ok, "No del fiat"
|
|
96
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.my_ads.name} - ok")
|
|
97
|
+
|
|
98
|
+
# 30
|
|
99
|
+
async def test_ad_new(self, clients: list[BaseAgentClient]):
|
|
100
|
+
for taker, maker in clients:
|
|
101
|
+
my_fiats = await taker.my_fiats()
|
|
102
|
+
my_fiat = list(my_fiats.values())[0]
|
|
103
|
+
coin = await Coin.get(ticker="USDT")
|
|
104
|
+
cur = await Cur.get(ticker=my_fiat["currency"])
|
|
105
|
+
# pm = await Fiatex.get()
|
|
106
|
+
ad_new: Ad.pyd() = await taker.ad_new(
|
|
107
|
+
coin=coin, cur=cur, is_sell=True, fiats=[my_fiat["id"]], amount="10", price="120", min_fiat="500"
|
|
108
|
+
)
|
|
109
|
+
ok = ad_new["status"] == "SUCCESS"
|
|
110
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.ad_new)
|
|
111
|
+
assert t.ok, "No add new ad"
|
|
112
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.ad_new.name} - ok")
|
|
113
|
+
|
|
114
|
+
# 31
|
|
115
|
+
async def test_ad_upd(self, clients: list[BaseAgentClient]):
|
|
116
|
+
for taker, maker in clients:
|
|
117
|
+
my_ads: ListOfDicts = await taker.my_ads()
|
|
118
|
+
ad_upd: Ad.pyd() = await taker.ad_upd(offer_id=my_ads[0]["id"], amount="11")
|
|
119
|
+
ok = ad_upd["status"] == "SUCCESS"
|
|
120
|
+
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.ad_upd)
|
|
121
|
+
assert t.ok, "No add new ad"
|
|
122
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.ad_upd.name} - ok")
|
|
123
|
+
|
|
124
|
+
# 32
|
|
125
|
+
async def test_ad_del(self, clients: list[BaseAgentClient]):
|
|
126
|
+
for taker, maker in clients:
|
|
127
|
+
my_ads: ListOfDicts = await taker.my_ads()
|
|
128
|
+
ad_del: bool = await taker.ad_del(offer_id=my_ads[0]["id"])
|
|
129
|
+
t, _ = await TestEx.update_or_create({"ok": ad_del}, ex_id=taker.agent.ex_id, action=ExAction.ad_del)
|
|
130
|
+
assert t.ok, "No add new ad"
|
|
131
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.ad_del.name} - ok")
|
|
132
|
+
|
|
133
|
+
# 33
|
|
134
|
+
async def test_ad_switch(self, clients: list[BaseAgentClient]):
|
|
135
|
+
for taker, maker in clients:
|
|
136
|
+
my_ads: ListOfDicts = await taker.my_ads()
|
|
137
|
+
new_status = not (my_ads[0]["status"] == "ACTIVE")
|
|
138
|
+
ad_switch: bool = await taker.ad_switch(offer_id=my_ads[0]["id"], active=new_status)
|
|
139
|
+
t, _ = await TestEx.update_or_create({"ok": ad_switch}, ex_id=taker.agent.ex_id, action=ExAction.ad_switch)
|
|
140
|
+
assert t.ok, "No ad active/off"
|
|
141
|
+
logging.info(f"{taker.agent.ex_id}:{ExAction.ad_switch.name} - ok")
|
|
@@ -28,11 +28,11 @@ class BaseAgentClient(BaseAuthClient):
|
|
|
28
28
|
|
|
29
29
|
# 26: Создание реквизита моего платежного метода
|
|
30
30
|
@abstractmethod
|
|
31
|
-
async def fiat_new(self, fiat: FiatNew) -> Fiat
|
|
31
|
+
async def fiat_new(self, fiat: FiatNew) -> Fiat: ...
|
|
32
32
|
|
|
33
33
|
# 27: Редактирование реквизита моего платежного метода
|
|
34
34
|
@abstractmethod
|
|
35
|
-
async def fiat_upd(self, fiat_id: int, detail: str, name: str = None) -> Fiat
|
|
35
|
+
async def fiat_upd(self, fiat_id: int, detail: str, name: str = None) -> Fiat: ...
|
|
36
36
|
|
|
37
37
|
# 28: Удаление реквизита моего платежного метода
|
|
38
38
|
@abstractmethod
|
|
@@ -50,11 +50,11 @@ class BaseAgentClient(BaseAuthClient):
|
|
|
50
50
|
coin: Coin,
|
|
51
51
|
cur: Cur,
|
|
52
52
|
is_sell: bool,
|
|
53
|
-
|
|
54
|
-
amount:
|
|
53
|
+
fiats: list[Fiat],
|
|
54
|
+
amount: str,
|
|
55
55
|
price: float,
|
|
56
|
+
min_fiat: str,
|
|
56
57
|
is_float: bool = True,
|
|
57
|
-
min_fiat: int = None,
|
|
58
58
|
details: str = None,
|
|
59
59
|
autoreply: str = None,
|
|
60
60
|
status: AdStatus = AdStatus.active,
|
|
@@ -66,7 +66,7 @@ class BaseAgentClient(BaseAuthClient):
|
|
|
66
66
|
self,
|
|
67
67
|
offer_id: int,
|
|
68
68
|
amount: int,
|
|
69
|
-
|
|
69
|
+
fiats: list[Fiat] = None,
|
|
70
70
|
price: float = None,
|
|
71
71
|
is_float: bool = None,
|
|
72
72
|
min_fiat: int = None,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
from asyncio import run
|
|
1
2
|
from enum import StrEnum
|
|
2
3
|
|
|
3
|
-
from
|
|
4
|
+
from x_model import init_db
|
|
5
|
+
from xync_schema import models
|
|
6
|
+
from xync_schema.enums import AdStatus, ExStatus
|
|
4
7
|
|
|
5
|
-
from xync_client.Abc.Base import ListOfDicts, DictOfDicts
|
|
8
|
+
from xync_client.Abc.Base import ListOfDicts, DictOfDicts, BaseClient
|
|
6
9
|
from xync_client.TgWallet.auth import AuthClient
|
|
7
|
-
from xync_schema.models import Cur, Coin, OrderStatus, Pmex, Fiat, Ad, Pm, Pmcur, Fiatex
|
|
10
|
+
from xync_schema.models import Cur, Coin, OrderStatus, Pmex, Fiat, Ad, Pm, Pmcur, Fiatex, Ex
|
|
8
11
|
from xync_schema.pydantic import FiatNew
|
|
9
12
|
|
|
10
13
|
from xync_client.Abc.Agent import BaseAgentClient
|
|
11
14
|
from xync_client.TgWallet.ex import ExClient
|
|
15
|
+
from xync_client.loader import PG_DSN
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
class Exceptions(StrEnum):
|
|
@@ -89,20 +93,29 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
89
93
|
return f
|
|
90
94
|
|
|
91
95
|
# 27: Редактирование реквизита моего платежного метода
|
|
92
|
-
async def fiat_upd(self, fiat_id: int, detail: str, name: str = None) -> Fiat
|
|
96
|
+
async def fiat_upd(self, fiat_id: int, detail: str, name: str = None) -> Fiat:
|
|
93
97
|
fiat = await Fiat.get(fiatexs__exid=fiat_id, fiatexs__ex=self.agent.ex).prefetch_related("pmcur")
|
|
94
|
-
pmex = await Pmex.get(pm_id=fiat.pmcur.pm_id)
|
|
98
|
+
pmex = await Pmex.get(pm_id=fiat.pmcur.pm_id, ex=self.agent.ex)
|
|
99
|
+
cur = await Cur[fiat.pmcur.cur_id]
|
|
95
100
|
edit_fiat = await self._post(
|
|
96
101
|
"/p2p/public-api/v3/payment-details/edit",
|
|
97
102
|
{
|
|
98
103
|
"id": fiat_id,
|
|
99
104
|
"paymentMethodCode": pmex.exid,
|
|
100
|
-
"currencyCode":
|
|
105
|
+
"currencyCode": cur.ticker,
|
|
101
106
|
"name": name,
|
|
102
107
|
"attributes": {"version": "V1", "values": [{"name": "PAYMENT_DETAILS_NUMBER", "value": detail}]},
|
|
103
108
|
},
|
|
104
109
|
)
|
|
105
|
-
|
|
110
|
+
pmex = await Pmex.get(exid=edit_fiat["data"]["paymentMethod"]["code"], ex=self.agent.ex)
|
|
111
|
+
cur = await Cur.get(ticker=edit_fiat["data"]["currency"])
|
|
112
|
+
pmcur, _ = await Pmcur.get_or_create(cur=cur, pm_id=pmex.pm_id)
|
|
113
|
+
attrs = {a["name"]: a["value"] for a in edit_fiat["data"]["attributes"]["values"]}
|
|
114
|
+
f, _ = await Fiat.update_or_create(
|
|
115
|
+
{"detail": attrs["PAYMENT_DETAILS_NUMBER"]}, pmcur=pmcur, user_id=self.agent.user_id
|
|
116
|
+
)
|
|
117
|
+
await Fiatex.update_or_create({"exid": edit_fiat["data"]["id"]}, ex=self.agent.ex, fiat=f)
|
|
118
|
+
return f
|
|
106
119
|
|
|
107
120
|
# 28: Удаление реквизита моего платежного метода
|
|
108
121
|
async def fiat_del(self, fiat_id: int) -> bool:
|
|
@@ -115,7 +128,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
115
128
|
ads = await self._post(
|
|
116
129
|
"/p2p/public-api/v2/offer/user-own/list", {"offset": 0, "limit": 20, "offerType": "SALE"}
|
|
117
130
|
)
|
|
118
|
-
return [ad for ad in ads["data"] if ad["status"] == mapping[status]] if status else ads
|
|
131
|
+
return [ad for ad in ads["data"] if ad["status"] == mapping[status]] if status else ads['data']
|
|
119
132
|
|
|
120
133
|
# 30: Создание объявления
|
|
121
134
|
async def ad_new(
|
|
@@ -123,11 +136,11 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
123
136
|
coin: Coin,
|
|
124
137
|
cur: Cur,
|
|
125
138
|
is_sell: bool,
|
|
126
|
-
|
|
127
|
-
amount:
|
|
139
|
+
fiats: list[Fiat],
|
|
140
|
+
amount: str,
|
|
128
141
|
price: float,
|
|
142
|
+
min_fiat: str,
|
|
129
143
|
is_float: bool = True,
|
|
130
|
-
min_fiat: int = None,
|
|
131
144
|
details: str = None,
|
|
132
145
|
autoreply: str = None,
|
|
133
146
|
status: AdStatus = AdStatus.active,
|
|
@@ -147,7 +160,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
147
160
|
"orderAmountLimits": {"min": min_fiat},
|
|
148
161
|
"paymentConfirmTimeout": "PT15M" if is_sell else "PT3H",
|
|
149
162
|
"comment": "",
|
|
150
|
-
"paymentDetailsIds":
|
|
163
|
+
"paymentDetailsIds": fiats,
|
|
151
164
|
},
|
|
152
165
|
)
|
|
153
166
|
return create
|
|
@@ -161,7 +174,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
161
174
|
self,
|
|
162
175
|
offer_id: int,
|
|
163
176
|
amount: int,
|
|
164
|
-
|
|
177
|
+
fiats: list[Fiat] = None,
|
|
165
178
|
price: float = None,
|
|
166
179
|
is_float: bool = None,
|
|
167
180
|
min_fiat: int = None,
|
|
@@ -177,11 +190,11 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
177
190
|
"paymentConfirmTimeout": ad["paymentConfirmTimeout"],
|
|
178
191
|
"type": ad["type"],
|
|
179
192
|
"orderRoundingRequired": False,
|
|
180
|
-
"price": {"type": "FIXED", "value": price},
|
|
181
|
-
"orderAmountLimits": {"min":
|
|
193
|
+
"price": {"type": "FIXED", "value": ad['price']['value']},
|
|
194
|
+
"orderAmountLimits": {"min": ad["orderAmountLimits"]["min"]},
|
|
182
195
|
"comment": "", # TODO: comment
|
|
183
196
|
"volume": f"{amount}",
|
|
184
|
-
"paymentDetailsIds":
|
|
197
|
+
"paymentDetailsIds": [a['id'] for a in ad["paymentDetails"]],
|
|
185
198
|
},
|
|
186
199
|
)
|
|
187
200
|
return upd
|
|
@@ -190,17 +203,17 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
190
203
|
async def ad_del(self, offer_id: int) -> bool:
|
|
191
204
|
ad = await self._get_my_ad(offer_id)
|
|
192
205
|
ad_del = await self._post("/p2p/public-api/v2/offer/delete", {"type": ad["type"], "offerId": offer_id})
|
|
193
|
-
return ad_del
|
|
206
|
+
return ad_del['status'] == "SUCCESS"
|
|
194
207
|
|
|
195
208
|
# 33: Вкл/выкл объявления
|
|
196
209
|
async def ad_switch(self, offer_id: int, active: bool) -> bool:
|
|
197
210
|
ad = await self._get_my_ad(offer_id)
|
|
198
211
|
if active:
|
|
199
212
|
active = await self._post("/p2p/public-api/v2/offer/activate", {"type": ad["type"], "offerId": offer_id})
|
|
200
|
-
return active
|
|
213
|
+
return active['status'] == "SUCCESS"
|
|
201
214
|
else:
|
|
202
215
|
off = await self._post("/p2p/public-api/v2/offer/deactivate", {"type": ad["type"], "offerId": offer_id})
|
|
203
|
-
return off
|
|
216
|
+
return off['status'] == "SUCCESS"
|
|
204
217
|
|
|
205
218
|
# 34: Вкл/выкл всех объявлений
|
|
206
219
|
async def ads_switch(self, active: bool) -> bool:
|
|
@@ -225,6 +238,13 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
225
238
|
# 39: Балансы моих монет
|
|
226
239
|
async def my_assets(self) -> dict: ...
|
|
227
240
|
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
228
248
|
# base_url = 'https://p2p.walletbot.me'
|
|
229
249
|
# middle_url = '/p2p/'
|
|
230
250
|
|
|
@@ -261,3 +281,21 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
261
281
|
async def order_payment_confirm(self, order_id: str):
|
|
262
282
|
payment_confirm = await self._post("/p2p/public-api/v2/payment-details/confirm", {"orderId": order_id})
|
|
263
283
|
return payment_confirm
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
# async def main():
|
|
287
|
+
# await init_db(PG_DSN, models, True)
|
|
288
|
+
# exs = await Ex.filter(status__gt=ExStatus.plan).prefetch_related("agents__ex")
|
|
289
|
+
# agents = [[ag for ag in ex.agents if ag.auth][:2] for ex in exs]
|
|
290
|
+
# clients: list[tuple[AgentClient, AgentClient]] = [(t.client(), m.client()) for t, m in agents]
|
|
291
|
+
# taker, maker = clients[0]
|
|
292
|
+
# my_fiats = await taker.my_fiats()
|
|
293
|
+
# my_fiat = list(my_fiats.values())[0]
|
|
294
|
+
# coin = await Coin.get(ticker="USDT")
|
|
295
|
+
# cur = await Cur.get(ticker=my_fiat["currency"])
|
|
296
|
+
# fiatex = await Fiatex.get(exid=my_fiat['id']).prefetch_related('fiat')
|
|
297
|
+
# e = await taker.ad_new(coin=coin, cur=cur, is_sell=True, fiats=[fiatex.fiat], amount='10', price='120', min_fiat='500')
|
|
298
|
+
# print(e)
|
|
299
|
+
#
|
|
300
|
+
# if __name__ == "__main__":
|
|
301
|
+
# run(main())
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
from xync_schema.enums import ExStatus, ExAction
|
|
5
|
-
from xync_schema.models import Ex, TestEx, Fiat
|
|
6
|
-
from xync_schema.pydantic import FiatNew
|
|
7
|
-
|
|
8
|
-
from xync_client.Abc.BaseTest import BaseTest
|
|
9
|
-
from xync_client.Abc.Agent import BaseAgentClient
|
|
10
|
-
from xync_client.Abc.Base import BaseClient, DictOfDicts, ListOfDicts
|
|
11
|
-
from xync_client.TgWallet.ex import ExClient
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@pytest.mark.asyncio(loop_scope="session")
|
|
15
|
-
class TestAgent(BaseTest):
|
|
16
|
-
@pytest.fixture(scope="class", autouse=True)
|
|
17
|
-
async def clients(self) -> tuple[BaseClient, BaseClient]:
|
|
18
|
-
exs = await Ex.filter(status__gt=ExStatus.plan).prefetch_related("agents__ex")
|
|
19
|
-
agents = [[ag for ag in ex.agents if ag.auth][:2] for ex in exs]
|
|
20
|
-
clients: list[tuple[BaseClient, BaseClient]] = [(t.client(), m.client()) for t, m in agents]
|
|
21
|
-
yield clients
|
|
22
|
-
[(await taker.close(), await maker.close()) for taker, maker in clients]
|
|
23
|
-
|
|
24
|
-
# 0
|
|
25
|
-
async def test_get_orders(self, clients: list[BaseAgentClient]):
|
|
26
|
-
for taker, maker in clients:
|
|
27
|
-
get_orders: ListOfDicts = await taker.get_orders()
|
|
28
|
-
ok = self.is_list_of_dicts(get_orders, False)
|
|
29
|
-
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.get_orders)
|
|
30
|
-
assert t.ok, "No get orders"
|
|
31
|
-
logging.info(f"{taker.agent.ex_id}:{ExAction.get_orders.name} - ok")
|
|
32
|
-
|
|
33
|
-
# 1
|
|
34
|
-
async def test_order_request(self, clients: list[BaseAgentClient]):
|
|
35
|
-
for taker, maker in clients:
|
|
36
|
-
await taker.agent.fetch_related("ex", "ex__agents")
|
|
37
|
-
ex_client: ExClient = taker.agent.ex.client()
|
|
38
|
-
ads = await ex_client.ads("NOT", "RUB", False)
|
|
39
|
-
for ad in ads:
|
|
40
|
-
order_request: dict | bool = await taker.order_request(ad["id"], ad["orderAmountLimits"]["min"])
|
|
41
|
-
if order_request:
|
|
42
|
-
break
|
|
43
|
-
ok = order_request["status"] == "SUCCESS"
|
|
44
|
-
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.order_request)
|
|
45
|
-
assert t.ok, "No get orders"
|
|
46
|
-
logging.info(f"{taker.agent.ex_id}:{ExAction.order_request.name} - ok")
|
|
47
|
-
|
|
48
|
-
# 25
|
|
49
|
-
async def test_my_fiats(self, clients: list[BaseAgentClient]):
|
|
50
|
-
for taker, maker in clients:
|
|
51
|
-
my_fiats: DictOfDicts = await taker.my_fiats()
|
|
52
|
-
ok = self.is_dict_of_dicts(my_fiats)
|
|
53
|
-
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.my_fiats)
|
|
54
|
-
assert t.ok, "No my fiats"
|
|
55
|
-
logging.info(f"{taker.agent.ex_id}:{ExAction.my_fiats.name} - ok")
|
|
56
|
-
|
|
57
|
-
# 26
|
|
58
|
-
async def test_fiat_new(self, clients: list[BaseAgentClient]):
|
|
59
|
-
for taker, maker in clients:
|
|
60
|
-
fn = FiatNew(cur_id=11, pm_id=22, detail="123456789")
|
|
61
|
-
fiat_new: Fiat.pyd() = await taker.fiat_new(fn)
|
|
62
|
-
ok = fiat_new["status"] == "SUCCESS"
|
|
63
|
-
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.fiat_new)
|
|
64
|
-
assert t.ok, "No add fiat"
|
|
65
|
-
logging.info(f"{taker.agent.ex_id}:{ExAction.fiat_new.name} - ok")
|
|
66
|
-
|
|
67
|
-
# 27
|
|
68
|
-
async def test_fiat_upd(self, clients: list[BaseAgentClient]):
|
|
69
|
-
for taker, maker in clients:
|
|
70
|
-
my_fiats = await taker.my_fiats()
|
|
71
|
-
fiats = [fiat for fiat in my_fiats.values()]
|
|
72
|
-
fiat_upd: Fiat.pyd() = await taker.fiat_upd(fiat_id=fiats[-1]["id"], detail="347890789")
|
|
73
|
-
ok = fiat_upd["status"] == "SUCCESS"
|
|
74
|
-
t, _ = await TestEx.update_or_create({"ok": ok}, ex_id=taker.agent.ex_id, action=ExAction.fiat_upd)
|
|
75
|
-
assert t.ok, "No upd fiat"
|
|
76
|
-
logging.info(f"{taker.agent.ex_id}:{ExAction.fiat_upd.name} - ok")
|
|
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.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Binance/test_binance.py
RENAMED
|
File without changes
|
|
File without changes
|
{xync_client-0.0.16.dev7 → xync_client-0.0.16.dev9}/tests/_todo_refact/Bybit/test_bybit_p2p.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
|
|
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
|
|
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.16.dev7 → xync_client-0.0.16.dev9}/xync_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|