xync-client 0.0.94.dev0__tar.gz → 0.0.95.dev0__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.94.dev0/xync_client.egg-info → xync_client-0.0.95.dev0}/PKG-INFO +1 -1
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/TestAgent.py +3 -3
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/TestEx.py +5 -5
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Agent.py +1 -1
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Ex.py +23 -25
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/xtype.py +2 -2
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/agent.py +23 -20
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/InAgent.py +1 -1
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/agent.py +20 -20
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/agent.py +3 -3
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/ex.py +1 -1
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Volet/__init__.py +2 -2
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/agent.py +15 -15
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/ex.py +2 -2
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/inAgent.py +3 -5
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/pm_unifier.py +3 -3
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0/xync_client.egg-info}/PKG-INFO +1 -1
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client.egg-info/SOURCES.txt +0 -1
- xync_client-0.0.94.dev0/index.html +0 -397
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/.env.sample +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/.gitignore +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/README.md +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/makefile +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/pyproject.toml +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/setup.cfg +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/TestAsset.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/TestOrder.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Binance/test_binance.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Gate/test_gate.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Wallet/test_agent.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/Wallet/test_ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/tests/_todo_refact/_test_ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Asset.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Auth.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/BaseTest.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Exception.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/InAgent.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Abc/PmAgent.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/base.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BitGet/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BitGet/agent.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BitGet/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BitGet/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/BitPapa/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/etype/cred.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/etype/order.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/order.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Bybit/ws.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Gate/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Gate/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Gmail/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/earn.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/etype/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/etype/cred.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Htx/etype/test.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/KuCoin/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/KuCoin/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/KuCoin/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Mexc/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Mexc/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Mexc/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Okx/etype/ad.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Okx/etype/pm.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/.gitignore +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Alfa/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Alfa/state.json +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/MTS/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Ozon/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Payeer/.gitignore +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Payeer/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Payeer/api.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Payeer/login.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Sber/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Sber/utils.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Tinkoff/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Volet/_todo_req/req.mjs +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Volet/_todo_req/req.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Volet/api.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Volet/pl.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Xync/__main__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Xync/ed.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/Pms/Yandex/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/asset.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/auth.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/pyd.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/pyro.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/__init__.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client/loader.py +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client.egg-info/requires.txt +0 -0
- {xync_client-0.0.94.dev0 → xync_client-0.0.95.dev0}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ import logging
|
|
|
3
3
|
import pytest
|
|
4
4
|
from tortoise.functions import Count
|
|
5
5
|
from xync_schema.enums import ExStatus, ExAction, UserStatus
|
|
6
|
-
from xync_schema.models import Ex, ExStat, Ad, Coin, Cur,
|
|
6
|
+
from xync_schema.models import Ex, ExStat, Ad, Coin, Cur, PmCur, Cred, CredEx, Actor, Person
|
|
7
7
|
from xync_schema.xtype import BaseAd
|
|
8
8
|
|
|
9
9
|
from xync_client.Abc.BaseTest import BaseTest
|
|
@@ -32,9 +32,9 @@ class TestAgent(BaseTest):
|
|
|
32
32
|
# 26
|
|
33
33
|
async def test_cred_new(self, clients: list[tuple[BaseAgentClient, BaseAgentClient]]):
|
|
34
34
|
for maker, taker in clients:
|
|
35
|
-
pmcur = await
|
|
35
|
+
pmcur = await PmCur.filter(pm__pmexs__ex=taker.actor.ex, cur__ticker="RUB", pm__norm="payeer").first()
|
|
36
36
|
cred = await Cred.create(person_id=taker.actor.person_id, name="Tst", detail="79990001234", pmcur=pmcur)
|
|
37
|
-
# await cred.banks.add(await
|
|
37
|
+
# await cred.banks.add(await PmExBank.get(exid="mts"), await PmExBank.get(exid="sberbankru"))
|
|
38
38
|
cred_new: CredEx = await taker.cred_new(cred)
|
|
39
39
|
ok = isinstance(cred_new, CredEx)
|
|
40
40
|
t, _ = await ExStat.update_or_create({"ok": ok}, ex=taker.actor.ex, action=ExAction.cred_new)
|
|
@@ -104,8 +104,8 @@ class TestEx(BaseTest):
|
|
|
104
104
|
# 24
|
|
105
105
|
async def test_ads(self, clients: list[BaseExClient]):
|
|
106
106
|
for client in clients:
|
|
107
|
-
cur = await models.
|
|
108
|
-
coin = await models.
|
|
107
|
+
cur = await models.CurEx.filter(cur__ticker="EUR", ex=client.ex).first().values_list("exid", flat=True)
|
|
108
|
+
coin = await models.CoinEx.filter(coin__ticker="USDT", ex=client.ex).first().values_list("exid", flat=True)
|
|
109
109
|
ads: list[BaseAd] = await client.ads(coin, cur, False)
|
|
110
110
|
ok = self.is_list_of_objects(ads, BaseAd)
|
|
111
111
|
t, _ = await models.ExStat.update_or_create({"ok": ok}, ex=client.ex, action=ExAction.ads)
|
|
@@ -123,10 +123,10 @@ class TestEx(BaseTest):
|
|
|
123
123
|
continue
|
|
124
124
|
for race in races:
|
|
125
125
|
# получаем данные направления текущей гонки
|
|
126
|
-
coinex = await models.
|
|
127
|
-
curex = await models.
|
|
126
|
+
coinex = await models.CoinEx.get(ex=client.ex, coin_id=race.road.ad.pair_side.pair.coin_id)
|
|
127
|
+
curex = await models.CurEx.get(ex=client.ex, cur_id=race.road.ad.pair_side.pair.cur_id)
|
|
128
128
|
pm_ids = [pm.id for pm in race.road.ad.pms]
|
|
129
|
-
pmex_exids = await models.
|
|
129
|
+
pmex_exids = await models.PmEx.filter(ex=client.ex, pm_id__in=pm_ids).values_list("exid", flat=True)
|
|
130
130
|
# получаем объявления по этому направлению
|
|
131
131
|
ads = await client.ads(coinex.exid, curex.exid, race.road.ad.pair_side.is_sell, pmex_exids)
|
|
132
132
|
# if race.vm_filter:
|
|
@@ -128,5 +128,5 @@ class BaseAgentClient(HttpClient):
|
|
|
128
128
|
# credex_in = models.CredEx.validate({"exid": cred_in.id, "cred_id": cred_db.id})
|
|
129
129
|
# credex_db, _ = await models.CredEx.update_or_create(**credex_in.df_unq())
|
|
130
130
|
# if banks: # only for SBP
|
|
131
|
-
# await cred_db.banks.add(*[await
|
|
131
|
+
# await cred_db.banks.add(*[await PmExBank.get(exid=b) for b in banks])
|
|
132
132
|
# return True
|
|
@@ -36,7 +36,7 @@ class BaseExClient(HttpClient):
|
|
|
36
36
|
super().__init__(getattr(ex, attr), headers, cookies, proxy and proxy.str())
|
|
37
37
|
|
|
38
38
|
@abstractmethod
|
|
39
|
-
def pm_type_map(self, typ: models.
|
|
39
|
+
def pm_type_map(self, typ: models.PmEx) -> str: ...
|
|
40
40
|
|
|
41
41
|
# 19: Список поддерживаемых валют тейкера
|
|
42
42
|
@abstractmethod
|
|
@@ -87,7 +87,7 @@ class BaseExClient(HttpClient):
|
|
|
87
87
|
async def countries(self) -> list[Struct]:
|
|
88
88
|
return []
|
|
89
89
|
|
|
90
|
-
# Импорт валют Cur-ов (с
|
|
90
|
+
# Импорт валют Cur-ов (с CurEx-ами)
|
|
91
91
|
async def set_curs(self, cookies: dict = None) -> bool:
|
|
92
92
|
# Curs
|
|
93
93
|
cur_pyds: dict[str, CurEx] = await self.curs()
|
|
@@ -96,14 +96,12 @@ class BaseExClient(HttpClient):
|
|
|
96
96
|
for exid, cur_pyd in cur_pyds.items()
|
|
97
97
|
}
|
|
98
98
|
curexs = [
|
|
99
|
-
models.
|
|
99
|
+
models.CurEx(**c.model_dump(exclude_none=True), cur=curs[c.exid], ex=self.ex) for c in cur_pyds.values()
|
|
100
100
|
]
|
|
101
|
-
#
|
|
102
|
-
await models.
|
|
103
|
-
curexs, update_fields=["minimum", "rounding_scale"], on_conflict=["cur_id", "ex_id"]
|
|
104
|
-
)
|
|
101
|
+
# CurEx
|
|
102
|
+
await models.CurEx.bulk_create(curexs, update_fields=["minimum", "scale"], on_conflict=["cur_id", "ex_id"])
|
|
105
103
|
|
|
106
|
-
# Импорт Pm-ов (с
|
|
104
|
+
# Импорт Pm-ов (с PmCur-, PmEx- и Pmcurex-ами) и валют (с CurEx-ами) с биржи в бд
|
|
107
105
|
async def set_pms(self, cookies: dict = None) -> bool:
|
|
108
106
|
if cookies:
|
|
109
107
|
self.session.cookie_jar.update_cookies(cookies)
|
|
@@ -134,19 +132,19 @@ class BaseExClient(HttpClient):
|
|
|
134
132
|
logging.warning(f"Pm: '{pmex.name}' duplicated with ids {prev[0]}: {k} on {self.ex.name}")
|
|
135
133
|
# новый Pm не добавляем, а берем старый с этим названием
|
|
136
134
|
pm_ = pms.get(prev[0], await models.Pm.get_or_none(norm=prev[1], country_id=country_id))
|
|
137
|
-
# и добавляем
|
|
138
|
-
await models.
|
|
135
|
+
# и добавляем PmEx для него
|
|
136
|
+
await models.PmEx.update_or_create({"name": pmex.name}, ex=self.ex, exid=k, pm=pm_)
|
|
139
137
|
elif (
|
|
140
138
|
prev[1] == pmu.norm and pmu.country == prev[3]
|
|
141
139
|
): # 2 разных оригинальных имени на этой бирже совпали при нормализации
|
|
142
140
|
logging.error(
|
|
143
141
|
f"Pm: {pmex.name}&{prev[2]} overnormd as {pmu.norm} with ids {prev[0]}: {k} on {self.ex.name}"
|
|
144
142
|
)
|
|
145
|
-
# новый Pm не добавляем, только
|
|
143
|
+
# новый Pm не добавляем, только PmEx для него
|
|
146
144
|
# новый Pm не добавляем, а берем старый с этим названием
|
|
147
145
|
pm_ = pms.get(prev[0], await models.Pm.get_or_none(norm=prev[1], country_id=country_id))
|
|
148
|
-
# и добавляем.обновляем
|
|
149
|
-
await models.
|
|
146
|
+
# и добавляем.обновляем PmEx для него
|
|
147
|
+
await models.PmEx.update_or_create({"pm": pm_}, ex=self.ex, exid=k, name=pmex.name)
|
|
150
148
|
else:
|
|
151
149
|
pmin = models.Pm.validate({**pmu.model_dump(), "country_id": country_id, "typ": pmex.typ})
|
|
152
150
|
try:
|
|
@@ -154,14 +152,14 @@ class BaseExClient(HttpClient):
|
|
|
154
152
|
except (MultipleObjectsReturned, IntegrityError) as e:
|
|
155
153
|
raise e
|
|
156
154
|
prev = k, pmu.norm, pmex.name, pmu.country
|
|
157
|
-
await models.
|
|
155
|
+
await models.PmCur.update_or_create( # todo: NA HU YA???
|
|
158
156
|
cur=await models.Cur.get(ticker="THB"), pm=await models.Pm.get(norm="cash in person")
|
|
159
157
|
)
|
|
160
158
|
|
|
161
159
|
# Pmexs
|
|
162
160
|
async with ClientSession(headers=getattr(self, "logo_headers", None)) as ss:
|
|
163
161
|
pmexs = [
|
|
164
|
-
models.
|
|
162
|
+
models.PmEx(
|
|
165
163
|
# todo: refact logo
|
|
166
164
|
exid=k,
|
|
167
165
|
ex=self.ex,
|
|
@@ -172,13 +170,13 @@ class BaseExClient(HttpClient):
|
|
|
172
170
|
for k, pm in pms.items()
|
|
173
171
|
]
|
|
174
172
|
|
|
175
|
-
await models.
|
|
176
|
-
#
|
|
173
|
+
await models.PmEx.bulk_create(pmexs, on_conflict=["ex_id", "exid"], update_fields=["pm_id", "logo_id", "name"])
|
|
174
|
+
# PmEx banks
|
|
177
175
|
for k, pmex in pmexs_epyds.items():
|
|
178
176
|
if banks := pmex.banks:
|
|
179
|
-
pmex = await models.
|
|
177
|
+
pmex = await models.PmEx.get(ex=self.ex, exid=k) # pm=pms[k],
|
|
180
178
|
for b in banks:
|
|
181
|
-
await models.
|
|
179
|
+
await models.PmExBank.update_or_create({"name": b.name}, exid=b.exid, pmex=pmex)
|
|
182
180
|
|
|
183
181
|
cur2pms = await self.cur_pms_map()
|
|
184
182
|
# # Link PayMethods with currencies
|
|
@@ -186,13 +184,13 @@ class BaseExClient(HttpClient):
|
|
|
186
184
|
for cur_id, exids in cur2pms.items():
|
|
187
185
|
for exid in exids:
|
|
188
186
|
if not (pm_id := pms.get(exid) and pms[exid].id):
|
|
189
|
-
if pmex := await models.
|
|
187
|
+
if pmex := await models.PmEx.get_or_none(ex=self.ex, exid=exid):
|
|
190
188
|
pm_id = pmex.pm_id
|
|
191
189
|
else:
|
|
192
190
|
logging.critical(f"For cur {cur_id} not found pm#{exid}")
|
|
193
191
|
continue
|
|
194
192
|
if cur_db := curs.get(cur_id):
|
|
195
|
-
pmcurs.add((await models.
|
|
193
|
+
pmcurs.add((await models.PmCur.update_or_create(cur=cur_db, pm_id=pm_id))[0])
|
|
196
194
|
# pmcurexs = [Pmcurex(pmcur=pmcur, ex=self.ex) for pmcur in pmcurs]
|
|
197
195
|
# await Pmcurex.bulk_create(pmcurexs)
|
|
198
196
|
return True
|
|
@@ -206,7 +204,7 @@ class BaseExClient(HttpClient):
|
|
|
206
204
|
return await self.file_upsert(url, ss)
|
|
207
205
|
return file
|
|
208
206
|
|
|
209
|
-
# Импорт монет (с
|
|
207
|
+
# Импорт монет (с CoinEx-ами) с биржи в бд
|
|
210
208
|
async def set_coins(self):
|
|
211
209
|
coins: dict[str, CoinEx] = await self.coins()
|
|
212
210
|
coins_db: dict[int, models.Coin] = {
|
|
@@ -215,10 +213,10 @@ class BaseExClient(HttpClient):
|
|
|
215
213
|
)[0]
|
|
216
214
|
for c in coins.values()
|
|
217
215
|
}
|
|
218
|
-
coinexs: list[models.
|
|
219
|
-
models.
|
|
216
|
+
coinexs: list[models.CoinEx] = [
|
|
217
|
+
models.CoinEx(coin=coins_db[c.exid], ex=self.ex, exid=c.exid, minimum=c.minimum) for c in coins.values()
|
|
220
218
|
]
|
|
221
|
-
await models.
|
|
219
|
+
await models.CoinEx.bulk_create(coinexs, update_fields=["minimum"], on_conflict=["coin_id", "ex_id"])
|
|
222
220
|
return True
|
|
223
221
|
|
|
224
222
|
# Импорт пар биржи в бд
|
|
@@ -4,7 +4,7 @@ from pydantic import BaseModel, model_validator
|
|
|
4
4
|
from x_model.types import BaseUpd
|
|
5
5
|
from xync_schema.enums import PmType
|
|
6
6
|
from xync_schema.models import Country, Pm, Ex
|
|
7
|
-
from xync_schema.xtype import
|
|
7
|
+
from xync_schema.xtype import PmExBank
|
|
8
8
|
|
|
9
9
|
from xync_client.pm_unifier import PmUni
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ MapOfIdsList = dict[int | str, list[int | str]]
|
|
|
17
17
|
class PmTrait:
|
|
18
18
|
typ: PmType | None = None
|
|
19
19
|
logo: str | None = None
|
|
20
|
-
banks: list[
|
|
20
|
+
banks: list[PmExBank] | None = None
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class PmEx(BaseModel, PmTrait):
|
|
@@ -2,7 +2,8 @@ from xync_client.Abc.Agent import BaseAgentClient
|
|
|
2
2
|
from xync_schema.pydantic import FiatNew
|
|
3
3
|
from xync_schema.models import Cur, Fiat
|
|
4
4
|
from xync_client.Abc.Base import DictOfDicts
|
|
5
|
-
from xync_schema.models import
|
|
5
|
+
from xync_schema.models import Coin, OrderStatus
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
class AgentClient(BaseAgentClient):
|
|
8
9
|
headers = {
|
|
@@ -37,18 +38,20 @@ class AgentClient(BaseAgentClient):
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
# 0: Получшение заявок за заданное время, в статусе, по валюте, монете
|
|
40
|
-
async def get_orders(
|
|
41
|
+
async def get_orders(
|
|
42
|
+
self, status: OrderStatus = OrderStatus.created, coin: Coin = None, cur: Cur = None, is_sell: bool = None
|
|
43
|
+
):
|
|
41
44
|
params = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
"pageId": "0",
|
|
46
|
+
"pageSize": "10",
|
|
47
|
+
"messageStatus": "0",
|
|
48
|
+
"orderType": "1",
|
|
49
|
+
"orderStatus": "",
|
|
50
|
+
"fiat": "",
|
|
51
|
+
"searchKeyword": "",
|
|
52
|
+
"tradeType": "",
|
|
53
|
+
"beginTime": "1706475600000",
|
|
54
|
+
"endTime": "1738184399999",
|
|
52
55
|
}
|
|
53
56
|
order = await self._get("/api/c2c/v2/order/list", params=params)
|
|
54
57
|
return order["data"]["result"]
|
|
@@ -56,14 +59,14 @@ class AgentClient(BaseAgentClient):
|
|
|
56
59
|
# 1: [T] Запрос на старт сделки
|
|
57
60
|
async def order_request(self, ad_id: int, amount: float):
|
|
58
61
|
json_data = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
"advertNo": f"{ad_id}",
|
|
63
|
+
"asset": "USDT",
|
|
64
|
+
"fiat": "RUB",
|
|
65
|
+
"type": 1,
|
|
66
|
+
"userPrice": 103,
|
|
67
|
+
"areaType": 2,
|
|
68
|
+
"amount": f"{amount}",
|
|
69
|
+
"paymentMethodId": 110,
|
|
67
70
|
}
|
|
68
71
|
order = await self._post("/api/c2c/v1/order/create", json=json_data)
|
|
69
72
|
if order["data"]:
|
|
@@ -251,7 +251,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
251
251
|
pma, cur = await self.get_pma_by_pmex(order_db)
|
|
252
252
|
async with in_transaction():
|
|
253
253
|
# отмечаем ордер на бирже "оплачен"
|
|
254
|
-
pmex = await models.
|
|
254
|
+
pmex = await models.PmEx.get(pm_id=order_db.cred.pmcur.pm_id, ex=self.agent_client.actor.ex)
|
|
255
255
|
credex = await models.CredEx.get(cred=order_db.cred, ex=self.agent_client.actor.ex)
|
|
256
256
|
self.agent_client.api.mark_as_paid(
|
|
257
257
|
orderId=str(order_db.exid),
|
|
@@ -29,7 +29,7 @@ from x_model.func import ArrayAgg
|
|
|
29
29
|
from xync_schema import models
|
|
30
30
|
from xync_schema.enums import OrderStatus
|
|
31
31
|
|
|
32
|
-
from xync_schema.models import Actor, Cond, CondSim,
|
|
32
|
+
from xync_schema.models import Actor, Cond, CondSim, PmCur, PairSide
|
|
33
33
|
|
|
34
34
|
from xync_client.Abc.Agent import BaseAgentClient
|
|
35
35
|
from xync_client.Abc.xtype import BaseOrderReq, FlatDict
|
|
@@ -132,11 +132,11 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
132
132
|
if ecdx.paymentType in (416,): # what is 416??
|
|
133
133
|
return None
|
|
134
134
|
if not (
|
|
135
|
-
pmex := await models.
|
|
135
|
+
pmex := await models.PmEx.get_or_none(exid=ecdx.paymentType, ex=self.ex_client.ex).prefetch_related(
|
|
136
136
|
"pm__curs"
|
|
137
137
|
)
|
|
138
138
|
):
|
|
139
|
-
raise HTTPException(f"No
|
|
139
|
+
raise HTTPException(f"No PmEx {ecdx.paymentType} on ex#{self.ex_client.ex.name}", 404)
|
|
140
140
|
if cred_old := await models.Cred.get_or_none(credexs__exid=ecdx.id, credexs__ex=self.actor.ex).prefetch_related(
|
|
141
141
|
"pmcur"
|
|
142
142
|
):
|
|
@@ -151,8 +151,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
151
151
|
)
|
|
152
152
|
if not cur_id:
|
|
153
153
|
raise Exception(f"Set default cur for {pmex.name}")
|
|
154
|
-
if not (pmcur := await models.
|
|
155
|
-
raise HTTPException(f"No
|
|
154
|
+
if not (pmcur := await models.PmCur.get_or_none(cur_id=cur_id, pm_id=pmex.pm_id)):
|
|
155
|
+
raise HTTPException(f"No PmCur with cur#{ecdx.currencyBalance} and pm#{ecdx.paymentType}", 404)
|
|
156
156
|
dct = {
|
|
157
157
|
"pmcur_id": pmcur.id,
|
|
158
158
|
"name": ecdx.realName,
|
|
@@ -229,10 +229,10 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
229
229
|
|
|
230
230
|
async def ads(
|
|
231
231
|
self,
|
|
232
|
-
cnx: models.
|
|
233
|
-
crx: models.
|
|
232
|
+
cnx: models.CoinEx,
|
|
233
|
+
crx: models.CurEx,
|
|
234
234
|
is_sell: bool,
|
|
235
|
-
pmxs: list[models.
|
|
235
|
+
pmxs: list[models.PmEx],
|
|
236
236
|
amount: int = None,
|
|
237
237
|
lim: int = 50,
|
|
238
238
|
vm_filter: bool = False,
|
|
@@ -445,7 +445,7 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
445
445
|
# cur_id = await Cur.get(ticker=ad.currencyId).values_list('id', flat=True)
|
|
446
446
|
# await self.cred_epyd2db(ecredex, ad_db.maker.person_id, cur_id)
|
|
447
447
|
if (
|
|
448
|
-
await
|
|
448
|
+
await PmCur.filter(
|
|
449
449
|
pm__pmexs__ex=self.ex_client.ex,
|
|
450
450
|
pm__pmexs__exid=ecredex.paymentType,
|
|
451
451
|
cur__ticker=ad.currencyId,
|
|
@@ -454,7 +454,7 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
454
454
|
):
|
|
455
455
|
...
|
|
456
456
|
if not (
|
|
457
|
-
pmcur := await
|
|
457
|
+
pmcur := await PmCur.get_or_none(
|
|
458
458
|
pm__pmexs__ex=self.ex_client.ex,
|
|
459
459
|
pm__pmexs__exid=ecredex.paymentType,
|
|
460
460
|
cur__ticker=ad.currencyId,
|
|
@@ -614,15 +614,15 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
614
614
|
self,
|
|
615
615
|
race: models.Race,
|
|
616
616
|
):
|
|
617
|
-
coinex: models.
|
|
617
|
+
coinex: models.CoinEx = await models.CoinEx.get(
|
|
618
618
|
coin_id=race.road.ad.pair_side.pair.coin_id, ex=self.actor.ex
|
|
619
619
|
).prefetch_related("coin")
|
|
620
|
-
curex: models.
|
|
620
|
+
curex: models.CurEx = await models.CurEx.get(
|
|
621
621
|
cur_id=race.road.ad.pair_side.pair.cur_id, ex=self.actor.ex
|
|
622
622
|
).prefetch_related("cur")
|
|
623
623
|
taker_side: bool = not race.road.ad.pair_side.is_sell
|
|
624
624
|
pm_ids = [pm.id for pm in race.road.ad.pms]
|
|
625
|
-
pmexs: list[models.
|
|
625
|
+
pmexs: list[models.PmEx] = await models.PmEx.filter(pm_id__in=pm_ids, ex=self.actor.ex).prefetch_related("pm")
|
|
626
626
|
k = (-1) ** int(taker_side) # on_buy=1, on_sell=-1
|
|
627
627
|
sleep_sec = 3 # 1 if set(pms) & {"volet"} and coinex.coin_id == 1 else 5
|
|
628
628
|
creds: list[models.CredEx] = await self.get_credexs_by_pms(race.road.ad.pms, curex.cur_id)
|
|
@@ -773,7 +773,7 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
773
773
|
await sleep(6)
|
|
774
774
|
|
|
775
775
|
async def get_books(
|
|
776
|
-
self, coinex: models.
|
|
776
|
+
self, coinex: models.CoinEx, curex: models.CurEx, pmexs: list[models.PmEx]
|
|
777
777
|
) -> tuple[list[Ad], list[Ad]]:
|
|
778
778
|
buy: list[Ad] = await self.ads(coinex, curex, False, pmexs, None, 30)
|
|
779
779
|
sell: list[Ad] = await self.ads(coinex, curex, True, pmexs, None, 30)
|
|
@@ -795,9 +795,9 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
795
795
|
|
|
796
796
|
async def get_ceils(
|
|
797
797
|
self,
|
|
798
|
-
coinex: models.
|
|
799
|
-
curex: models.
|
|
800
|
-
pmexs: list[models.
|
|
798
|
+
coinex: models.CoinEx,
|
|
799
|
+
curex: models.CurEx,
|
|
800
|
+
pmexs: list[models.PmEx],
|
|
801
801
|
min_prof=0.01,
|
|
802
802
|
vmf: bool = False,
|
|
803
803
|
place: int = 0,
|
|
@@ -815,8 +815,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
815
815
|
|
|
816
816
|
async def parse_ads(
|
|
817
817
|
self,
|
|
818
|
-
coinex: models.
|
|
819
|
-
curex: models.
|
|
818
|
+
coinex: models.CoinEx,
|
|
819
|
+
curex: models.CurEx,
|
|
820
820
|
taker_side: bool,
|
|
821
821
|
pms: list[str] = None,
|
|
822
822
|
ceil: float = None,
|
|
@@ -827,7 +827,7 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
827
827
|
k = (-1) ** int(taker_side) # on_buy=1, on_sell=-1
|
|
828
828
|
|
|
829
829
|
if pms:
|
|
830
|
-
creds: dict[models.
|
|
830
|
+
creds: dict[models.PmEx, models.CredEx] = await self.get_credexs_by_norms(pms, curex.cur_id)
|
|
831
831
|
[str(p.exid) for p in creds.values()]
|
|
832
832
|
|
|
833
833
|
if taker_side: # гонка в стакане продажи - мы покупаем монету за ФИАТ
|
|
@@ -46,7 +46,7 @@ class AgentClient(BaseAgentClient):
|
|
|
46
46
|
|
|
47
47
|
async def cred_new(self, cred: models.Cred) -> models.CredEx:
|
|
48
48
|
pmcur = await cred.pmcur
|
|
49
|
-
exid = str(await models.
|
|
49
|
+
exid = str(await models.PmEx.get(pm_id=pmcur.pm_id, ex=self.ex_client.ex).values_list("exid", flat=True))
|
|
50
50
|
field_map = {
|
|
51
51
|
"payee": "name",
|
|
52
52
|
"bank": "extra",
|
|
@@ -71,7 +71,7 @@ class AgentClient(BaseAgentClient):
|
|
|
71
71
|
|
|
72
72
|
async def cred_upd(self, cred: models.Cred, exid: int) -> models.CredEx:
|
|
73
73
|
pmcur = await cred.pmcur
|
|
74
|
-
_exid = str(await models.
|
|
74
|
+
_exid = str(await models.PmEx.get(pm_id=pmcur.pm_id, ex=self.ex_client.ex).values_list("exid", flat=True))
|
|
75
75
|
field_map = {
|
|
76
76
|
"payee": "name",
|
|
77
77
|
"bank": "extra",
|
|
@@ -86,7 +86,7 @@ class AgentClient(BaseAgentClient):
|
|
|
86
86
|
"modelFields": dumps(
|
|
87
87
|
[{"fieldId": fid, "fieldType": ft, "value": getattr(cred, field_map[ft])} for ft, fid in fields.items()]
|
|
88
88
|
),
|
|
89
|
-
|
|
89
|
+
"id": exid,
|
|
90
90
|
}
|
|
91
91
|
await self._post("/-/x/otc/v1/user/receipt-account/modifyByDynamicModel", data=data)
|
|
92
92
|
cred_ids = await models.Cred.filter(credexs__exid=exid).values_list("id", flat=True)
|
|
@@ -12,7 +12,7 @@ from playwright._impl._errors import TimeoutError
|
|
|
12
12
|
from pyro_client.client.bot import BotClient
|
|
13
13
|
from pyro_client.client.user import UserClient
|
|
14
14
|
from xync_schema.enums import UserStatus
|
|
15
|
-
from xync_schema.models import Cur, User, PmAgent, Cred,
|
|
15
|
+
from xync_schema.models import Cur, User, PmAgent, Cred, PmCur, Fiat
|
|
16
16
|
|
|
17
17
|
from xync_client.Gmail import GmClient
|
|
18
18
|
from xync_client.Pms.Volet.api import APIClient
|
|
@@ -193,7 +193,7 @@ class Client:
|
|
|
193
193
|
(
|
|
194
194
|
await Cred.update_or_create(
|
|
195
195
|
{"detail": k},
|
|
196
|
-
pmcur=(await
|
|
196
|
+
pmcur=(await PmCur.get_or_create(pm__norm="volet", cur=await Cur.get(ticker=t)))[0],
|
|
197
197
|
person_id=self.agent.user.person_id,
|
|
198
198
|
)
|
|
199
199
|
)[0],
|
|
@@ -206,12 +206,12 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
206
206
|
return [CredEpyd(**cred) for cred in resp["data"]]
|
|
207
207
|
|
|
208
208
|
async def cred_epyd2db(self, cred: CredEpyd) -> models.CredEx:
|
|
209
|
-
if not (pmex := await models.
|
|
210
|
-
raise HTTPException(f"No
|
|
211
|
-
if not (pmcur := await models.
|
|
212
|
-
raise HTTPException(f"No
|
|
209
|
+
if not (pmex := await models.PmEx.get_or_none(exid=cred.paymentMethod.code, ex=self.ex_client.ex)):
|
|
210
|
+
raise HTTPException(f"No PmEx {cred.paymentMethod.code} on ex#{self.ex_client.ex.name}", 404)
|
|
211
|
+
if not (pmcur := await models.PmCur.get_or_none(cur__ticker=cred.currency, pm_id=pmex.pm_id)):
|
|
212
|
+
raise HTTPException(f"No PmCur with cur#{cred.currency} and pm#{cred.paymentMethod.code}", 404)
|
|
213
213
|
if not (person := await models.Person.get_or_none(actors__exid=cred.userId)):
|
|
214
|
-
raise HTTPException(f"No
|
|
214
|
+
raise HTTPException(f"No PmCur with cur#{cred.currency} and pm#{cred.paymentMethod.code}", 404)
|
|
215
215
|
dct = {"pmcur_id": pmcur.id, "name": cred.name, "person_id": person.id}
|
|
216
216
|
banks: list[str] | None = None
|
|
217
217
|
for val in cred.attributes.values:
|
|
@@ -224,7 +224,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
224
224
|
cred_db, _ = await models.Cred.update_or_create(**cred_in.df_unq())
|
|
225
225
|
credex_in = models.CredEx.validate({"exid": cred.id, "cred_id": cred_db.id, "ex_id": self.ex.id})
|
|
226
226
|
if banks: # only for SBP
|
|
227
|
-
await cred_db.banks.add(*[await models.
|
|
227
|
+
await cred_db.banks.add(*[await models.PmExBank.get(exid=b) for b in banks])
|
|
228
228
|
credex_db, _ = await models.CredEx.update_or_create(**credex_in.df_unq())
|
|
229
229
|
return credex_db
|
|
230
230
|
|
|
@@ -246,8 +246,8 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
246
246
|
|
|
247
247
|
# 26: Создание реквизита моего платежного метода
|
|
248
248
|
async def cred_new(self, cred: models.Cred) -> models.CredEx:
|
|
249
|
-
pmcur: models.
|
|
250
|
-
exid = await models.
|
|
249
|
+
pmcur: models.PmCur = await cred.pmcur
|
|
250
|
+
exid = await models.PmEx.get(pm_id=pmcur.pm_id, ex=self.ex_client.ex).values_list("exid", flat=True)
|
|
251
251
|
cur = await models.Cur[pmcur.cur_id]
|
|
252
252
|
vals = (
|
|
253
253
|
[
|
|
@@ -277,8 +277,8 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
277
277
|
|
|
278
278
|
# 27: Редактирование реквизита моего платежного метода
|
|
279
279
|
async def cred_upd(self, cred: models.Cred, exid: int) -> models.CredEx:
|
|
280
|
-
pmcur: models.
|
|
281
|
-
pmex = await models.
|
|
280
|
+
pmcur: models.PmCur = await cred.pmcur
|
|
281
|
+
pmex = await models.PmEx.get(pm_id=pmcur.pm_id, ex=self.ex_client.ex)
|
|
282
282
|
cur = await models.Cur[pmcur.cur_id]
|
|
283
283
|
vals = (
|
|
284
284
|
[{"name": "PHONE", "value": cred.detail}, {"name": "BANKS", "value": [b.exid for b in banks]}]
|
|
@@ -316,7 +316,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
316
316
|
if isinstance(ad_, _PmsTrait):
|
|
317
317
|
return AdBuyIn(
|
|
318
318
|
**ad_in.model_dump(),
|
|
319
|
-
pmexs_=await models.
|
|
319
|
+
pmexs_=await models.PmEx.filter(ex=self.ex_client.ex, exid__in=[p.code for p in ad_.paymentMethods]),
|
|
320
320
|
)
|
|
321
321
|
credsexs: list[models.CredEx] = [await self.cred_epyd2db(c) for c in ad_.paymentDetails]
|
|
322
322
|
return AdSaleIn(**ad_in.model_dump(), credexs_=credsexs)
|
|
@@ -344,8 +344,8 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
344
344
|
async def ad_f2ein(
|
|
345
345
|
self, coin: models.Coin, cur: models.Cur, is_sell: bool, vol: int = None, cur_min: int = None
|
|
346
346
|
) -> AdMakerNewSale | AdMakerNewBuy:
|
|
347
|
-
coinex = await models.
|
|
348
|
-
curex = await models.
|
|
347
|
+
coinex = await models.CoinEx.get(coin=coin, ex=self.ex)
|
|
348
|
+
curex = await models.CurEx.get(ex=self.ex, cur=cur)
|
|
349
349
|
credexs = (
|
|
350
350
|
await models.CredEx.filter(cred__person_id=self.actor.person_id, cred__pmcur__cur=cur)
|
|
351
351
|
.limit(5)
|
|
@@ -355,7 +355,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
355
355
|
ad_ein = _AdNew(
|
|
356
356
|
type="SALE" if is_sell else "PURCHASE",
|
|
357
357
|
initVolume=AvailableAmountVolume(currencyCode=coinex.exid, amount=str(vol or coinex.minimum)),
|
|
358
|
-
orderRoundingRequired=curex.
|
|
358
|
+
orderRoundingRequired=curex.scale is not None,
|
|
359
359
|
price={
|
|
360
360
|
"type": "FLOATING",
|
|
361
361
|
"baseCurrencyCode": coinex.exid,
|
|
@@ -369,7 +369,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
369
369
|
if ad_ein.type == "SALE":
|
|
370
370
|
ad_ein = AdMakerNewSale(**ad_ein.model_dump(exclude_none=True), paymentDetailsIds=[c.exid for c in credexs])
|
|
371
371
|
else:
|
|
372
|
-
pmexs = await models.
|
|
372
|
+
pmexs = await models.PmEx.filter(ex=self.actor.ex, pm__pmcurs__id__in=[cx.cred.pmcur_id for cx in credexs])
|
|
373
373
|
ad_ein = AdMakerNewBuy(**ad_ein.model_dump(exclude_none=True), paymentMethodCodes=[p.exid for p in pmexs])
|
|
374
374
|
return ad_ein
|
|
375
375
|
|
|
@@ -45,7 +45,7 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
45
45
|
minimums: dict[str, str] = stg["offerSettings"]["minOrderAmountByCurrencyCode"]
|
|
46
46
|
return {
|
|
47
47
|
c["code"]: xtype.CurEx(
|
|
48
|
-
exid=c["code"], ticker=c["code"],
|
|
48
|
+
exid=c["code"], ticker=c["code"], scale=roundings.get(c["code"]), minimum=minimums[c["code"]]
|
|
49
49
|
)
|
|
50
50
|
for c in coins_curs["data"]["fiat"]
|
|
51
51
|
}
|
|
@@ -66,7 +66,7 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
66
66
|
k: PmEx(
|
|
67
67
|
exid=pm.code,
|
|
68
68
|
name=pm.nameEng,
|
|
69
|
-
banks=[xtype.
|
|
69
|
+
banks=[xtype.PmExBank(exid=b.code, name=b.name) for b in pm.banks or []],
|
|
70
70
|
)
|
|
71
71
|
for k, pm in pms.items()
|
|
72
72
|
}
|
|
@@ -7,12 +7,10 @@ from tg_auth import UserStatus
|
|
|
7
7
|
from tortoise.functions import Count
|
|
8
8
|
from x_model import init_db
|
|
9
9
|
|
|
10
|
-
from xync_schema import models
|
|
11
10
|
from xync_schema.enums import AssetType
|
|
12
|
-
from xync_schema.models import Agent, Order, Ad, Asset, Coin, Fiat, Fiatex,
|
|
11
|
+
from xync_schema.models import Agent, Order, Ad, Asset, Coin, Fiat, Fiatex, PmEx, PmCur, Cur
|
|
13
12
|
|
|
14
13
|
from xync_client.TgWallet.pyro import PyroClient
|
|
15
|
-
from xync_client.loader import PG_DSN
|
|
16
14
|
from xync_client.Abc.InAgent import BaseInAgentClient
|
|
17
15
|
from xync_client.TgWallet.agent import AgentClient
|
|
18
16
|
|
|
@@ -118,8 +116,8 @@ async def main():
|
|
|
118
116
|
for k, f in (await mc.my_fiats()).items():
|
|
119
117
|
fiatex, is_new = Fiatex.get_or_create(ex=maker.ex, exid=k)
|
|
120
118
|
if is_new:
|
|
121
|
-
pmex = await
|
|
122
|
-
pmcur = await
|
|
119
|
+
pmex = await PmEx.get(ex=maker.ex, exid=f["paymentMethod"]["code"]).prefetch_related("pm")
|
|
120
|
+
pmcur = await PmCur.get(pm=pmex.pm, cur=await Cur.get(ticker=f["currency"]))
|
|
123
121
|
await Fiat.create(
|
|
124
122
|
pmcur=pmcur,
|
|
125
123
|
user=maker.user,
|
|
@@ -74,7 +74,7 @@ class PmUnifier:
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
def __init__(self, countries: list[tuple[str, str]], pm_reps: list[PmRep]):
|
|
77
|
-
self.pm_map = {p.src: p.
|
|
77
|
+
self.pm_map = {p.src: p.target for p in pm_reps}
|
|
78
78
|
self.cts = countries
|
|
79
79
|
|
|
80
80
|
def countries(self, name: str):
|
|
@@ -153,8 +153,8 @@ class PmUnifier:
|
|
|
153
153
|
self.pms[name].norm = re.sub(rm, "", self.pms[name].norm)
|
|
154
154
|
|
|
155
155
|
def i18n(self, name: str):
|
|
156
|
-
for src,
|
|
157
|
-
self.pms[name].norm = self.pms[name].norm.replace(src,
|
|
156
|
+
for src, target in self.i18n_map.items():
|
|
157
|
+
self.pms[name].norm = self.pms[name].norm.replace(src, target)
|
|
158
158
|
|
|
159
159
|
def clear(self, name: str):
|
|
160
160
|
self.pms[name].norm = self.pms[name].norm.replace("()", "").replace(" ", " ").strip(" -:. ")
|