xync-client 0.0.57.dev23__tar.gz → 0.0.57.dev24__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.57.dev23/xync_client.egg-info → xync_client-0.0.57.dev24}/PKG-INFO +1 -1
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/agent.py +175 -85
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24/xync_client.egg-info}/PKG-INFO +1 -1
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/.env.sample +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/.gitignore +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/README.md +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/makefile +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/pyproject.toml +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/setup.cfg +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/TestAgent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/TestAsset.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/TestEx.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/TestOrder.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Binance/test_binance.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Gate/test_gate.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Htx/test_htx_p2p.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Wallet/test_agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Wallet/test_ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/_test_ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/Agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/Asset.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/Auth.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/BaseTest.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/Ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/InAgent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Abc/xtype.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/base.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BitGet/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BitGet/agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BitGet/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BitGet/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/BitPapa/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/InAgent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/etype/cred.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/etype/order.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/order.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Bybit/ws.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Gate/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Gate/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Gmail/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/earn.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/etype/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/etype/cred.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/etype/test.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Htx/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/KuCoin/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/KuCoin/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/KuCoin/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Mexc/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Mexc/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Mexc/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Okx/etype/ad.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Okx/etype/pm.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/.gitignore +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Alfa/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Alfa/state.json +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Ozon/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Sber/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Tinkoff/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Tinkoff/state.json +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/_todo_req/req.mjs +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/_todo_req/req.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/api.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/pl.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/agent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/asset.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/auth.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/ex.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/inAgent.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/pyd.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/pyro.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/__init__.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/loader.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/pm_unifier.py +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client.egg-info/SOURCES.txt +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client.egg-info/requires.txt +0 -0
- {xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -79,9 +79,10 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
79
79
|
"actionType": "MODIFY",
|
|
80
80
|
"securityRiskToken": "",
|
|
81
81
|
}
|
|
82
|
-
all_conds: dict[int, tuple[str, set[
|
|
83
|
-
cond_sims: dict[int,
|
|
84
|
-
|
|
82
|
+
all_conds: dict[int, tuple[str, set[int]]] = {}
|
|
83
|
+
cond_sims: dict[int, int] = defaultdict(set)
|
|
84
|
+
rcond_sims: dict[int, set[int]] = defaultdict(set) # backward
|
|
85
|
+
tree: dict = {}
|
|
85
86
|
|
|
86
87
|
def __init__(self, actor: Actor, bot: FileClient, **kwargs):
|
|
87
88
|
super().__init__(actor, bot, **kwargs)
|
|
@@ -395,8 +396,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
395
396
|
size=30,
|
|
396
397
|
# status=status, # 50 - завершено
|
|
397
398
|
# tokenId=token_id,
|
|
398
|
-
|
|
399
|
-
|
|
399
|
+
beginTime=begin_time,
|
|
400
|
+
endTime=end_time,
|
|
400
401
|
# side=side, # 1 - продажа, 0 - покупка
|
|
401
402
|
)
|
|
402
403
|
except FailedRequestError as e:
|
|
@@ -729,36 +730,62 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
729
730
|
ad_db.cond.raw_txt = cleaned
|
|
730
731
|
self.all_conds[ad_db.cond_id] = cleaned, {ad_db.maker.exid}
|
|
731
732
|
await ad_db.cond.save()
|
|
732
|
-
await self.
|
|
733
|
+
await self.sim_check_rels(ad_db.cond_id, cleaned)
|
|
733
734
|
return ad_db, False
|
|
734
735
|
|
|
735
|
-
# находим все старые тексты похожие на 90% и более
|
|
736
|
-
if _sims := {
|
|
737
|
-
old_cid: (txt, sim)
|
|
738
|
-
for old_cid, (txt, uids) in self.all_conds.items()
|
|
739
|
-
if len(cleaned) > 15 and ad.userId not in uids and (sim := get_sim(cleaned, txt))
|
|
740
|
-
}:
|
|
741
|
-
# если есть, берем самый похожий из них
|
|
742
|
-
old_cid, (txt, sim) = max(_sims.items(), key=lambda x: x[1][1])
|
|
743
|
-
old_ads = await models.Ad.filter(cond_id=old_cid, maker__exid=int(ad.userId)).prefetch_related("cond")
|
|
744
|
-
for old_ad in old_ads:
|
|
745
|
-
# и у этого чела есть объява с почти таким же текстом
|
|
746
|
-
if old_ad.exid == int(ad.id): # и он изменил текст как раз в ней
|
|
747
|
-
# заменяем текст без создания нового cond
|
|
748
|
-
await old_ad.cond.update_or_create(raw_txt=cleaned)
|
|
749
|
-
await old_ad.fetch_related("cond")
|
|
750
|
-
return old_ad, False
|
|
751
|
-
# но это не она, значит у него есть другая объява с похожим, но чуть отличающимся текстом
|
|
752
|
-
logging.warning(f"ad#{ad.id}-cond#{old_cid} txt updated:\n{txt}\n|\nV\n{cleaned}")
|
|
753
|
-
|
|
754
736
|
new_cond = await Cond.create(raw_txt=cleaned)
|
|
755
|
-
|
|
737
|
+
# находим все старые тексты похожие на 90% и более
|
|
738
|
+
old_cid, sim = await self.cond_get_max_sim(new_cond.id, new_cond.raw_txt, {int(ad.userId)})
|
|
739
|
+
# old_ads = await models.Ad.filter(cond_id=old_cid, maker__exid=int(ad.userId)).prefetch_related("cond")
|
|
740
|
+
# for old_ad in old_ads:
|
|
741
|
+
# # и у этого чела есть объява с почти таким же текстом
|
|
742
|
+
# if old_ad.exid == int(ad.id): # и он изменил текст как раз в ней
|
|
743
|
+
# # заменяем текст без создания нового cond
|
|
744
|
+
# await old_ad.cond.update_or_create(raw_txt=cleaned)
|
|
745
|
+
# await old_ad.fetch_related("cond")
|
|
746
|
+
# return old_ad, False
|
|
747
|
+
# # но это не она, значит у него есть другая объява с похожим, но чуть отличающимся текстом
|
|
748
|
+
# logging.warning(f"ad#{ad.id}-cond#{old_cid} txt updated:\n{txt}\n|\nV\n{cleaned}")
|
|
749
|
+
|
|
750
|
+
self.all_conds[new_cond.id] = new_cond.raw_txt, {int(ad.userId)}
|
|
756
751
|
# если нашелся похожий текст у другого юзера, добавим связь с % похожести
|
|
757
752
|
if sim:
|
|
758
|
-
await
|
|
753
|
+
await CondSim.create(cond_id=new_cond.id, similarity=sim, cond_rel_id=old_cid)
|
|
759
754
|
|
|
760
755
|
return await self.ad_create(ad, new_cond.id), True
|
|
761
756
|
|
|
757
|
+
def find_in_tree(self, cid: int, old_cid: int) -> bool:
|
|
758
|
+
if p := self.cond_sims.get(old_cid):
|
|
759
|
+
if p == cid:
|
|
760
|
+
return True
|
|
761
|
+
return self.find_in_tree(cid, p)
|
|
762
|
+
return False
|
|
763
|
+
|
|
764
|
+
async def cond_get_max_sim(self, cid: int, txt: str, uids: set[int]) -> tuple[int | None, int | None]:
|
|
765
|
+
# находим все старые тексты похожие на 90% и более
|
|
766
|
+
sims: dict[int, int] = {}
|
|
767
|
+
for old_cid, (old_txt, old_uids) in self.all_conds.items():
|
|
768
|
+
if len(old_txt) < 15 or cid == old_cid or uids == old_uids:
|
|
769
|
+
continue
|
|
770
|
+
elif self.cond_sims.get(cid) == old_cid:
|
|
771
|
+
continue
|
|
772
|
+
elif self.cond_sims.get(old_cid) == cid:
|
|
773
|
+
continue
|
|
774
|
+
elif cid in self.rcond_sims.get(old_cid, {}):
|
|
775
|
+
continue
|
|
776
|
+
elif old_cid in self.rcond_sims.get(cid, {}):
|
|
777
|
+
continue
|
|
778
|
+
elif self.find_in_tree(cid, old_cid):
|
|
779
|
+
continue
|
|
780
|
+
if sim := get_sim(txt, old_txt):
|
|
781
|
+
sims[old_cid] = sim
|
|
782
|
+
# если есть, берем самый похожий из них
|
|
783
|
+
if sims:
|
|
784
|
+
old_cid, sim = max(sims.items(), key=lambda x: x[1])
|
|
785
|
+
await sleep(0.3)
|
|
786
|
+
return old_cid, sim
|
|
787
|
+
return None, None
|
|
788
|
+
|
|
762
789
|
async def person_upsert(self, name: str, exid: int) -> models.Person:
|
|
763
790
|
if actor := await models.Actor.get_or_none(exid=exid, ex=self.ex_client.ex).prefetch_related("person"):
|
|
764
791
|
if not actor.person:
|
|
@@ -798,24 +825,75 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
798
825
|
return None
|
|
799
826
|
return await CondSim.create(cond_id=new_cid, similarity=sim, cond_rel_id=old_cid)
|
|
800
827
|
|
|
801
|
-
async def
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
828
|
+
async def sim_check_rels(self, cid: int, new_txt: int):
|
|
829
|
+
if _old_sims := await CondSim.filter(Q(join_type="OR", cond_id=cid, cond_rel_id=cid)):
|
|
830
|
+
for sim_db in _old_sims:
|
|
831
|
+
(op,) = {sim_db.cond_id, sim_db.cond_rel_id} - {cid}
|
|
832
|
+
op_cond = await Cond[op]
|
|
833
|
+
sim_db.similarity = get_sim(new_txt, op_cond.raw_txt)
|
|
834
|
+
await sim_db.save()
|
|
835
|
+
|
|
836
|
+
def build_tree(self):
|
|
837
|
+
set(self.cond_sims.keys()) | set(self.cond_sims.values())
|
|
838
|
+
tree = defaultdict(dict)
|
|
839
|
+
# Группируем родителей по детям
|
|
840
|
+
for child, par in self.cond_sims.items():
|
|
841
|
+
tree[par] |= {child: {}} # todo: make from self.rcond_sim
|
|
842
|
+
|
|
843
|
+
# Строим дерево снизу вверх
|
|
844
|
+
def subtree(node):
|
|
845
|
+
if not node:
|
|
846
|
+
return node
|
|
847
|
+
for key in node:
|
|
848
|
+
subnode = tree.pop(key, {})
|
|
849
|
+
d = subtree(subnode)
|
|
850
|
+
node[key] |= d # actual tree rebuilding here!
|
|
851
|
+
return node # todo: refact?
|
|
852
|
+
|
|
853
|
+
# Находим корни / без родителей
|
|
854
|
+
roots = set(self.cond_sims.values()) - set(self.cond_sims.keys())
|
|
855
|
+
for root in roots:
|
|
856
|
+
_ = subtree(tree[root])
|
|
857
|
+
|
|
858
|
+
self.tree = tree
|
|
807
859
|
|
|
808
860
|
async def actual_cond(self):
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
861
|
+
for curr, old in await CondSim.all().values_list("cond_id", "cond_rel_id"):
|
|
862
|
+
self.cond_sims[curr] = old
|
|
863
|
+
self.rcond_sims[old] |= {curr}
|
|
864
|
+
self.build_tree()
|
|
865
|
+
for cid, (txt, uids) in self.all_conds.items():
|
|
866
|
+
old_cid, sim = await self.cond_get_max_sim(cid, txt, uids)
|
|
867
|
+
if sim:
|
|
868
|
+
if old_sim := await CondSim.get_or_none(cond_id=cid):
|
|
869
|
+
if old_sim.cond_rel_id != old_cid:
|
|
870
|
+
if sim <= old_sim.similarity:
|
|
871
|
+
# old_rsim = await CondSim.get_or_none(cond_id=old_cid)
|
|
872
|
+
# if not old_rsim:
|
|
873
|
+
# await CondSim.create(cond_id=old_cid, cond_rel_id=cid, similarity=sim)
|
|
874
|
+
# self.cond_sims[old_cid] = cid
|
|
875
|
+
# self.rcond_sims[cid] |= {old_cid}
|
|
876
|
+
# # self.add_to_tree(old_cid, cid, self.tree)
|
|
877
|
+
# elif old_rsim.similarity < sim:
|
|
878
|
+
# await CondSim.update_or_create({"cond_rel_id": cid, "similarity": sim}, cond_id=old_cid)
|
|
879
|
+
# self.cond_sims[old_cid] = cid
|
|
880
|
+
# self.rcond_sims[cid] |= {old_cid}
|
|
881
|
+
# self.rcond_sims[old_rsim.cond_rel_id].remove(old_rsim.cond_id)
|
|
882
|
+
# logging.warning(f'{old_cid}: {old_sim.similarity}->{sim} ({old_sim.cond_rel_id}->{cid})')
|
|
883
|
+
continue
|
|
884
|
+
logging.warning(f"R {cid}: {old_sim.similarity}->{sim} ({old_sim.cond_rel_id}->{old_cid})")
|
|
885
|
+
await old_sim.update_from_dict({"similarity": sim, "old_rel_id": old_cid}).save()
|
|
886
|
+
elif sim != old_sim.similarity:
|
|
887
|
+
logging.info(f"{cid}: {old_sim.similarity}->{sim}")
|
|
888
|
+
await old_sim.update_from_dict({"similarity": sim}).save()
|
|
889
|
+
else:
|
|
890
|
+
await CondSim.create(cond_id=cid, cond_rel_id=old_cid, similarity=sim)
|
|
891
|
+
self.cond_sims[cid] = old_cid
|
|
892
|
+
self.rcond_sims[old_cid] |= {cid}
|
|
893
|
+
# self.add_to_tree(cid, old_cid, self.tree)
|
|
894
|
+
# for ad_db in await models.Ad.filter(direction__pairex__ex=self.ex_client.ex).prefetch_related("cond", "maker"):
|
|
895
|
+
# ad = Ad(id=str(ad_db.exid), userId=str(ad_db.maker.exid), remark=ad_db.cond.raw_txt)
|
|
896
|
+
# await self.cond_upsert(ad, force=True)
|
|
819
897
|
|
|
820
898
|
async def get_credexs_by_norms(self, norms: list[str], cur_id: int) -> dict[models.Pmex, models.CredEx] | None:
|
|
821
899
|
try:
|
|
@@ -833,7 +911,7 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
833
911
|
|
|
834
912
|
|
|
835
913
|
def get_sim(s1, s2) -> int:
|
|
836
|
-
sim = int((SequenceMatcher(None, s1, s2).ratio() - 0.
|
|
914
|
+
sim = int((SequenceMatcher(None, s1, s2).ratio() - 0.6) * 10_000)
|
|
837
915
|
return sim if sim > 0 else 0
|
|
838
916
|
|
|
839
917
|
|
|
@@ -890,48 +968,60 @@ async def main():
|
|
|
890
968
|
actor = (
|
|
891
969
|
await models.Actor.filter(ex_id=9, agent__isnull=False).prefetch_related("ex", "agent", "person__user").first()
|
|
892
970
|
)
|
|
893
|
-
async with FileClient(TOKEN) as b:
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
971
|
+
# async with FileClient(TOKEN) as b:
|
|
972
|
+
cl: AgentClient = actor.client(FileClient(TOKEN))
|
|
973
|
+
# await cl.ex_client.set_pmcurexs(cookies=actor.agent.auth["cookies"]) # 617 -> 639
|
|
974
|
+
# await cl.set_creds()
|
|
975
|
+
# await cl.ex_client.set_pairs()
|
|
976
|
+
usdt = await models.Coinex.get(coin__ticker="USDT", ex=cl.actor.ex).prefetch_related("coin")
|
|
977
|
+
btc = await models.Coinex.get(coin__ticker="BTC", ex=cl.actor.ex).prefetch_related("coin")
|
|
978
|
+
eth = await models.Coinex.get(coin__ticker="ETH", ex=cl.actor.ex).prefetch_related("coin")
|
|
979
|
+
usdc = await models.Coinex.get(coin__ticker="USDC", ex=cl.actor.ex).prefetch_related("coin")
|
|
980
|
+
rub = await models.Curex.get(cur__ticker="RUB", ex=cl.actor.ex).prefetch_related("cur")
|
|
981
|
+
cl.all_conds = {
|
|
982
|
+
c.id: (c.raw_txt, {a.maker.exid for a in c.ads}) for c in await Cond.all().prefetch_related("ads__maker")
|
|
983
|
+
}
|
|
984
|
+
for curr, old in await CondSim.filter().values_list("cond_id", "cond_rel_id"):
|
|
985
|
+
cl.cond_sims[curr] = old
|
|
986
|
+
cl.rcond_sims[old] |= {curr}
|
|
987
|
+
cl.build_tree()
|
|
988
|
+
a = set()
|
|
989
|
+
|
|
990
|
+
def check_tree(tre):
|
|
991
|
+
for p, c in tre.items():
|
|
992
|
+
a.add(p)
|
|
993
|
+
check_tree(c)
|
|
994
|
+
|
|
995
|
+
for pr, ch in cl.tree.items():
|
|
996
|
+
check_tree(ch)
|
|
997
|
+
await cl.actual_cond()
|
|
998
|
+
await gather(
|
|
999
|
+
cl.get_api_orders(10, 1737493200000, 1742590800000), # 10, 1738357200000, 1742504399999
|
|
1000
|
+
cl.battle(usdt, rub, False, ["volet"], 79.8), # гонка в стакане покупки - мы продаем
|
|
1001
|
+
cl.battle(usdt, rub, True, ["volet"], 79.8), # гонка в стакане продажи - мы покупаем
|
|
1002
|
+
cl.battle(eth, rub, False, ["volet"], 206_000),
|
|
1003
|
+
cl.battle(eth, rub, True, ["volet"], 200_000),
|
|
1004
|
+
cl.battle(btc, rub, False, ["volet"], 8_500_000),
|
|
1005
|
+
cl.battle(btc, rub, True, ["volet"], 8_400_000),
|
|
1006
|
+
cl.battle(usdc, rub, False, ["volet"], 80.5),
|
|
1007
|
+
cl.battle(usdc, rub, True, ["volet"], 79),
|
|
1008
|
+
cl.take(usdt, rub, False, ceil=80, volume=360),
|
|
1009
|
+
cl.take(usdt, rub, True, ceil=80, volume=360),
|
|
1010
|
+
)
|
|
921
1011
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1012
|
+
bor = BaseOrderReq(
|
|
1013
|
+
ad_id="1861440060199632896",
|
|
1014
|
+
# asset_amount=40,
|
|
1015
|
+
fiat_amount=3000,
|
|
1016
|
+
amount_is_fiat=True,
|
|
1017
|
+
is_sell=False,
|
|
1018
|
+
cur_exid=rub.exid,
|
|
1019
|
+
coin_exid=usdt.exid,
|
|
1020
|
+
coin_scale=usdt.coin.scale,
|
|
1021
|
+
)
|
|
1022
|
+
res: OrderResp = await cl.order_request(bor)
|
|
1023
|
+
await cl.cancel_order(res.orderId)
|
|
1024
|
+
await cl.close()
|
|
935
1025
|
|
|
936
1026
|
|
|
937
1027
|
if __name__ == "__main__":
|
|
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.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Binance/test_binance.py
RENAMED
|
File without changes
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Bybit/test_bybit.py
RENAMED
|
File without changes
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Bybit/test_bybit_p2p.py
RENAMED
|
File without changes
|
|
File without changes
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Htx/test_htx_p2p.py
RENAMED
|
File without changes
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/tests/_todo_refact/Wallet/test_agent.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
|
|
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.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/_todo_req/req.mjs
RENAMED
|
File without changes
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client/Pms/Volet/_todo_req/req.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
|
{xync_client-0.0.57.dev23 → xync_client-0.0.57.dev24}/xync_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|