xync-schema 0.6.67__py3-none-any.whl → 0.6.68__py3-none-any.whl
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_schema/enums.py +2 -0
- xync_schema/models.py +26 -12
- xync_schema/pydantic.py +90 -2
- {xync_schema-0.6.67.dist-info → xync_schema-0.6.68.dist-info}/METADATA +1 -1
- xync_schema-0.6.68.dist-info/RECORD +8 -0
- xync_schema-0.6.67.dist-info/RECORD +0 -8
- {xync_schema-0.6.67.dist-info → xync_schema-0.6.68.dist-info}/WHEEL +0 -0
- {xync_schema-0.6.67.dist-info → xync_schema-0.6.68.dist-info}/top_level.txt +0 -0
xync_schema/enums.py
CHANGED
|
@@ -112,6 +112,8 @@ class ExAction(IntEnum):
|
|
|
112
112
|
coins = 22 # Список торгуемых монет (с ограничениям по валютам, если есть)
|
|
113
113
|
pairs = 23 # Список пар валюта/монет
|
|
114
114
|
ads = 24 # Список объяв по покупке/продаже, валюте, монете, платежному методу (buy/sell, cur, coin, pm)
|
|
115
|
+
cur_mins = 42 # Минимальные объемы валют в объявлении
|
|
116
|
+
coin_mins = 43 # Минимальные объемы монет в объявлении
|
|
115
117
|
""" Agent: Fiat """
|
|
116
118
|
my_fiats = 25 # Список реквизитов моих платежных методов
|
|
117
119
|
fiat_new = 26 # Создание реквизита моего платежного метода
|
xync_schema/models.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel as PydModel
|
|
3
5
|
from tortoise import fields
|
|
4
6
|
from tortoise.queryset import QuerySet
|
|
5
7
|
from tortoise import Model as BaseModel
|
|
@@ -93,6 +95,7 @@ class Curex(BaseModel):
|
|
|
93
95
|
cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
|
|
94
96
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
|
|
95
97
|
exid: str = fields.CharField(31)
|
|
98
|
+
minimum: float = fields.FloatField(null=True)
|
|
96
99
|
# countries: fields.ManyToManyRelation[Country] = fields.ManyToManyField(
|
|
97
100
|
# "models.Country", through="curexcountry", backward_key="curexs"
|
|
98
101
|
# )
|
|
@@ -119,7 +122,7 @@ class Pair(Model, TsTrait):
|
|
|
119
122
|
id = fields.SmallIntField(True)
|
|
120
123
|
coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin", related_name="pairs")
|
|
121
124
|
cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur", related_name="pairs")
|
|
122
|
-
fee: float = fields.FloatField()
|
|
125
|
+
fee: float = fields.FloatField(default=0)
|
|
123
126
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="pairs")
|
|
124
127
|
directions: fields.ReverseRelation["Direction"]
|
|
125
128
|
|
|
@@ -134,7 +137,7 @@ class Direction(Model):
|
|
|
134
137
|
id = fields.SmallIntField(True)
|
|
135
138
|
pair: fields.ForeignKeyRelation[Pair] = fields.ForeignKeyField("models.Pair", related_name="directions")
|
|
136
139
|
sell: bool = fields.BooleanField()
|
|
137
|
-
total: int = fields.IntField()
|
|
140
|
+
total: int = fields.IntField(null=True)
|
|
138
141
|
ads: fields.ReverseRelation["Ad"]
|
|
139
142
|
|
|
140
143
|
_name = {"pair__coin__ticker", "pair__cur__ticker", "sell"}
|
|
@@ -190,7 +193,9 @@ class Agent(Model):
|
|
|
190
193
|
exid: int = fields.BigIntField()
|
|
191
194
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="agents")
|
|
192
195
|
auth: dict[str, str] = fields.JSONField(null=True)
|
|
193
|
-
user: fields.
|
|
196
|
+
user: fields.ForeignKeyNullableRelation[User] = fields.ForeignKeyField(
|
|
197
|
+
"models.User", related_name="agents", null=True
|
|
198
|
+
)
|
|
194
199
|
user_id: int
|
|
195
200
|
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
196
201
|
|
|
@@ -247,15 +252,16 @@ class Ad(Model, TsTrait):
|
|
|
247
252
|
id: int = fields.BigIntField(True)
|
|
248
253
|
direction: fields.ForeignKeyRelation[Direction] = fields.ForeignKeyField("models.Direction", related_name="ads")
|
|
249
254
|
price: float = fields.FloatField()
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
minFiat: float = fields.FloatField()
|
|
255
|
+
max_fiat: float = fields.FloatField()
|
|
256
|
+
min_fiat: float = fields.FloatField()
|
|
253
257
|
detail: str | None = fields.CharField(4095, null=True)
|
|
254
|
-
|
|
258
|
+
auto_msg: str | None = fields.CharField(255, null=True)
|
|
259
|
+
status: AdStatus = fields.IntEnumField(AdStatus, defaut=AdStatus.active)
|
|
260
|
+
|
|
255
261
|
agent: fields.ForeignKeyRelation[Agent] = fields.ForeignKeyField("models.Agent", "ads")
|
|
256
262
|
agent_id: int
|
|
257
|
-
status: AdStatus = fields.IntEnumField(AdStatus)
|
|
258
263
|
|
|
264
|
+
pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="adpm") # only root pms
|
|
259
265
|
orders: fields.ReverseRelation["Order"]
|
|
260
266
|
|
|
261
267
|
_icon = "ad"
|
|
@@ -264,10 +270,17 @@ class Ad(Model, TsTrait):
|
|
|
264
270
|
class Meta:
|
|
265
271
|
table_description = "P2P Advertisements"
|
|
266
272
|
|
|
267
|
-
def
|
|
268
|
-
module_name = f"xync_client.{self.ex.name}.pyd"
|
|
273
|
+
def epyds(self) -> tuple[PydModel, PydModel, PydModel, PydModel, PydModel, PydModel]:
|
|
274
|
+
module_name = f"xync_client.{self.agent.ex.name}.pyd"
|
|
269
275
|
__import__(module_name)
|
|
270
|
-
return
|
|
276
|
+
return (
|
|
277
|
+
sys.modules[module_name].AdEpyd,
|
|
278
|
+
sys.modules[module_name].AdFullEpyd,
|
|
279
|
+
sys.modules[module_name].MyAdEpydPurchase,
|
|
280
|
+
sys.modules[module_name].MyAdInEpydPurchase,
|
|
281
|
+
sys.modules[module_name].MyAdEpydSale,
|
|
282
|
+
sys.modules[module_name].MyAdInEpydSale,
|
|
283
|
+
)
|
|
271
284
|
|
|
272
285
|
|
|
273
286
|
class Pm(Model):
|
|
@@ -362,6 +375,7 @@ class Pmcurex(BaseModel): # existence pm in ex for exact cur, with "blocked" fl
|
|
|
362
375
|
|
|
363
376
|
|
|
364
377
|
class Fiat(Model):
|
|
378
|
+
id: int = fields.BigIntField(True)
|
|
365
379
|
pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
|
|
366
380
|
pmcur_id: int
|
|
367
381
|
# country: fields.ForeignKeyRelation[Country] = fields.ForeignKeyField("models.Country", related_name="fiats")
|
|
@@ -398,7 +412,7 @@ class Fiatex(BaseModel): # existence pm in ex with no cur tie
|
|
|
398
412
|
fiat_id: int
|
|
399
413
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "fiatexs")
|
|
400
414
|
ex_id: int
|
|
401
|
-
exid: int = fields.
|
|
415
|
+
exid: int = fields.BigIntField()
|
|
402
416
|
|
|
403
417
|
class Meta:
|
|
404
418
|
table_description = "Fiat on Ex"
|
xync_schema/pydantic.py
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
|
|
3
|
-
from pydantic import BaseModel
|
|
3
|
+
from pydantic import BaseModel, model_validator
|
|
4
4
|
|
|
5
|
-
from xync_schema.
|
|
5
|
+
from xync_schema.enums import AdStatus, PmType
|
|
6
|
+
from xync_schema.models import Fiat, Agent, Direction, Pm, Pmcur, User
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PmexBankPyd(BaseModel):
|
|
10
|
+
id: int | None = None
|
|
11
|
+
exid: str
|
|
12
|
+
name: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PmPyd(BaseModel):
|
|
16
|
+
id: int | None = None
|
|
17
|
+
name: str
|
|
18
|
+
identifier: str | None = None
|
|
19
|
+
type_: PmType | None = None
|
|
20
|
+
logo: str | None = None
|
|
21
|
+
banks: list[PmexBankPyd] | None = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# class PmcurPyd(BaseModel):
|
|
25
|
+
# id: int | None = None
|
|
26
|
+
# pm_id: int
|
|
27
|
+
# cur_id: int
|
|
6
28
|
|
|
7
29
|
|
|
8
30
|
class FiatUpd(BaseModel):
|
|
@@ -20,6 +42,72 @@ class FiatNew(FiatUpd):
|
|
|
20
42
|
target: int | None = None
|
|
21
43
|
|
|
22
44
|
|
|
45
|
+
class FiatPydIn(BaseModel):
|
|
46
|
+
# unq
|
|
47
|
+
id: int = None
|
|
48
|
+
user_id: int | None = None
|
|
49
|
+
user: User | None = None
|
|
50
|
+
pmcur_id: int | None = None
|
|
51
|
+
pmcur: Pmcur | None = None
|
|
52
|
+
# df
|
|
53
|
+
detail: str
|
|
54
|
+
name: str = ""
|
|
55
|
+
amount: float
|
|
56
|
+
target: float | None = None
|
|
57
|
+
|
|
58
|
+
banks: list[str] = []
|
|
59
|
+
|
|
60
|
+
class Config:
|
|
61
|
+
arbitrary_types_allowed = True
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
@model_validator(mode="before")
|
|
65
|
+
def check_at_least_one_field(cls, values):
|
|
66
|
+
if (values.get("pmcur") or values.get("pmcur_id")) and (values.get("user") or values.get("user_id")):
|
|
67
|
+
return values
|
|
68
|
+
raise ValueError("pmcur_id or pmcur is required")
|
|
69
|
+
|
|
70
|
+
def args(self) -> tuple[dict, dict]:
|
|
71
|
+
unq: tuple[str, ...] = "id", "user_id", "user", "pmcur_id", "pmcur"
|
|
72
|
+
df: tuple[str, ...] = "detail", "name", "amount", "target"
|
|
73
|
+
d = self.model_dump()
|
|
74
|
+
return {k: getattr(self, k) for k in df if d.get(k)}, {k: getattr(self, k) for k in unq if d.get(k)}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# class FiatexPyd(BaseModel):
|
|
78
|
+
# id: int | None = None
|
|
79
|
+
# exid: str
|
|
80
|
+
# ex_id: int
|
|
81
|
+
# fiat_id: int
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class AdPydIn(BaseModel):
|
|
85
|
+
# unq
|
|
86
|
+
id: int
|
|
87
|
+
# df
|
|
88
|
+
price: float
|
|
89
|
+
min_fiat: float
|
|
90
|
+
max_fiat: float | None = None
|
|
91
|
+
detail: str | None = None
|
|
92
|
+
auto_msg: str | None = None
|
|
93
|
+
status: AdStatus = AdStatus.active
|
|
94
|
+
agent_id: int | None = None
|
|
95
|
+
direction_id: int | None = None
|
|
96
|
+
agent: Agent | None = None
|
|
97
|
+
direction: Direction | None = None
|
|
98
|
+
payMeths: list[Pm]
|
|
99
|
+
|
|
100
|
+
class Config:
|
|
101
|
+
arbitrary_types_allowed = True
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
@model_validator(mode="before")
|
|
105
|
+
def check_at_least_one_field(cls, values):
|
|
106
|
+
if (values.get("agent") or values.get("agent_id")) and (values.get("direction") or values.get("direction_id")):
|
|
107
|
+
return values
|
|
108
|
+
raise ValueError("pmcur_id or pmcur is required")
|
|
109
|
+
|
|
110
|
+
|
|
23
111
|
class OrderPyd(BaseModel):
|
|
24
112
|
id: int
|
|
25
113
|
amount: float
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
xync_schema/enums.py,sha256=i9VyTiOFdoKeiw71w-5t4UoMQMJtU5qkBwe8zyJIm5A,12392
|
|
3
|
+
xync_schema/models.py,sha256=_IzK9e4H6lXl8VMjyl0m-Ir7RfrCHAc2JM0RZiWJxBA,24722
|
|
4
|
+
xync_schema/pydantic.py,sha256=14wzPsDL4BkmSyTVoa1EGdWWpqCTCIGSjiBAupNaweY,3123
|
|
5
|
+
xync_schema-0.6.68.dist-info/METADATA,sha256=x4OEJKvnsJFg8Rpk8ZwLLeQ9J6NvCg1FrZZJH93NH9M,3985
|
|
6
|
+
xync_schema-0.6.68.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
+
xync_schema-0.6.68.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
|
|
8
|
+
xync_schema-0.6.68.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
xync_schema/enums.py,sha256=la85coRbxXL0HiAgJYpOU4Yyf_atVp6DZSlAV3ICvEk,12207
|
|
3
|
-
xync_schema/models.py,sha256=rPvWqAMNl0JdEXTGhpcNHQEekPhQp1wGMgtEbETYznE,24141
|
|
4
|
-
xync_schema/pydantic.py,sha256=7uTAqoN3WT1w9RByyBwn78FOkD3nfO9b3UGnR-DWAro,794
|
|
5
|
-
xync_schema-0.6.67.dist-info/METADATA,sha256=Ij-gJ-Zixk-pfBRayN2JraYYQ45dwxGpe5YrK1x8OAA,3985
|
|
6
|
-
xync_schema-0.6.67.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
-
xync_schema-0.6.67.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
|
|
8
|
-
xync_schema-0.6.67.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|