xync-schema 0.6.70__tar.gz → 0.6.72__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_schema-0.6.70/xync_schema.egg-info → xync_schema-0.6.72}/PKG-INFO +1 -1
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema/enums.py +2 -3
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema/models.py +93 -86
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema/pydantic.py +41 -36
- {xync_schema-0.6.70 → xync_schema-0.6.72/xync_schema.egg-info}/PKG-INFO +1 -1
- {xync_schema-0.6.70 → xync_schema-0.6.72}/.env.sample +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/.gitignore +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/README.md +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/makefile +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/pyproject.toml +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/setup.cfg +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/tests/__init__.py +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/tests/test_db.py +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema.egg-info/SOURCES.txt +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.6.70 → xync_schema-0.6.72}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -112,9 +112,7 @@ class ExAction(IntEnum):
|
|
|
112
112
|
coins = 22 # Список торгуемых монет (с ограничениям по валютам, если есть)
|
|
113
113
|
pairs = 23 # Список пар валюта/монет
|
|
114
114
|
ads = 24 # Список объяв по покупке/продаже, валюте, монете, платежному методу (buy/sell, cur, coin, pm)
|
|
115
|
-
ad = 42 #
|
|
116
|
-
cur_mins = 43 # Минимальные объемы валют в объявлении
|
|
117
|
-
coin_mins = 44 # Минимальные объемы монет в объявлении
|
|
115
|
+
ad = 42 # Чужая объява по id
|
|
118
116
|
""" Agent: Fiat """
|
|
119
117
|
my_fiats = 25 # Список реквизитов моих платежных методов
|
|
120
118
|
fiat_new = 26 # Создание реквизита моего платежного метода
|
|
@@ -122,6 +120,7 @@ class ExAction(IntEnum):
|
|
|
122
120
|
fiat_del = 28 # Удаление реквизита моего платежного метода
|
|
123
121
|
""" Agent: Ad """
|
|
124
122
|
my_ads = 29 # Список моих объявлений
|
|
123
|
+
my_ad = 43 # Моя объява по id
|
|
125
124
|
ad_new = 30 # Создание объявления
|
|
126
125
|
ad_upd = 31 # Редактирование объявления
|
|
127
126
|
ad_del = 32 # Удаление объявления
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
|
|
4
|
-
from pydantic import BaseModel as PydModel
|
|
5
3
|
from tortoise import fields
|
|
6
4
|
from tortoise.queryset import QuerySet
|
|
7
5
|
from tortoise import Model as BaseModel
|
|
@@ -71,7 +69,7 @@ class Ex(Model):
|
|
|
71
69
|
pmcurs: fields.ManyToManyRelation["Pmcur"] = fields.ManyToManyField("models.Pmcur", through="pmcurex")
|
|
72
70
|
coins: fields.ManyToManyRelation[Coin]
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
contragents: fields.ReverseRelation["Contragent"]
|
|
75
73
|
pmexs: fields.ReverseRelation["Pmex"]
|
|
76
74
|
pairs: fields.ReverseRelation["Pair"]
|
|
77
75
|
# deps: fields.ReverseRelation["Dep"]
|
|
@@ -161,7 +159,7 @@ class User(Model, TsTrait, UserInfoTrait):
|
|
|
161
159
|
|
|
162
160
|
proteges: fields.BackwardFKRelation["User"]
|
|
163
161
|
agents: fields.BackwardFKRelation["Agent"]
|
|
164
|
-
fiats: fields.BackwardFKRelation["Fiat"]
|
|
162
|
+
# fiats: fields.BackwardFKRelation["Fiat"]
|
|
165
163
|
limits: fields.BackwardFKRelation["Limit"]
|
|
166
164
|
# vpn: fields.BackwardOneToOneRelation["Vpn"]
|
|
167
165
|
# invite_requests: fields.BackwardFKRelation["Invite"]
|
|
@@ -190,36 +188,47 @@ class User(Model, TsTrait, UserInfoTrait):
|
|
|
190
188
|
# computed = ["balance"]
|
|
191
189
|
|
|
192
190
|
|
|
193
|
-
class
|
|
191
|
+
class Contragent(Model):
|
|
194
192
|
exid: int = fields.BigIntField()
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"models.User", related_name="agents", null=True
|
|
199
|
-
)
|
|
200
|
-
user_id: int
|
|
193
|
+
name: int = fields.CharField(63)
|
|
194
|
+
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="contragents")
|
|
195
|
+
ex_id: int
|
|
201
196
|
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
202
197
|
|
|
198
|
+
agent: fields.BackwardOneToOneRelation["Agent"]
|
|
199
|
+
creds: fields.BackwardFKRelation["Cred"]
|
|
200
|
+
my_ads: fields.BackwardFKRelation["Ad"]
|
|
201
|
+
taken_orders: fields.BackwardFKRelation["Order"]
|
|
202
|
+
|
|
203
|
+
class Meta:
|
|
204
|
+
table_description = "Agents"
|
|
205
|
+
unique_together = (("ex", "exid"),)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class Agent(Model, TsTrait):
|
|
209
|
+
auth: dict[str, str] = fields.JSONField(null=True)
|
|
210
|
+
contragent: fields.OneToOneRelation[Contragent] = fields.OneToOneField("models.Contragent", "agent")
|
|
211
|
+
contragent_id: int
|
|
212
|
+
user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="agents")
|
|
213
|
+
user_id: int
|
|
203
214
|
assets: fields.ReverseRelation["Asset"]
|
|
204
|
-
orders: fields.ReverseRelation["Order"]
|
|
205
|
-
ads: fields.ReverseRelation["Ad"]
|
|
206
215
|
|
|
207
|
-
_name = {"
|
|
216
|
+
_name = {"contragent__name"}
|
|
208
217
|
|
|
209
218
|
def balance(self) -> int:
|
|
210
219
|
return sum(asset.free * (asset.coin.rate or 0) for asset in self.assets)
|
|
211
220
|
|
|
212
221
|
class Meta:
|
|
213
222
|
table_description = "Agents"
|
|
214
|
-
unique_together = (("
|
|
223
|
+
unique_together = (("contragent", "user"),)
|
|
215
224
|
|
|
216
225
|
class PydanticMeta(Model.PydanticMeta):
|
|
217
226
|
# max_recursion = 3
|
|
218
|
-
include = "id", "
|
|
227
|
+
include = "id", "contragent__ex", "assets", "auth", "updated_at"
|
|
219
228
|
computed = ["balance"]
|
|
220
229
|
|
|
221
230
|
def client(self):
|
|
222
|
-
module_name = f"xync_client.{self.ex.name}.agent"
|
|
231
|
+
module_name = f"xync_client.{self.contragent.ex.name}.agent"
|
|
223
232
|
__import__(module_name)
|
|
224
233
|
client = sys.modules[module_name].AgentClient
|
|
225
234
|
return client(self)
|
|
@@ -233,7 +242,7 @@ class Agent(Model):
|
|
|
233
242
|
# return client(self)
|
|
234
243
|
|
|
235
244
|
def asset_client(self):
|
|
236
|
-
module_name = f"xync_client.{self.ex.name}.asset"
|
|
245
|
+
module_name = f"xync_client.{self.contragent.ex.name}.asset"
|
|
237
246
|
__import__(module_name)
|
|
238
247
|
client = sys.modules[module_name].AssetClient
|
|
239
248
|
return client(self)
|
|
@@ -249,14 +258,14 @@ class Adpm(Model):
|
|
|
249
258
|
table_description = "P2P Advertisements - Payment methods"
|
|
250
259
|
|
|
251
260
|
|
|
252
|
-
class
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
# class AdCred(Model):
|
|
262
|
+
# ad: fields.ForeignKeyRelation["Ad"] = fields.ForeignKeyField("models.Ad")
|
|
263
|
+
# cred: fields.ForeignKeyRelation["Cred"] = fields.ForeignKeyField("models.Cred")
|
|
264
|
+
#
|
|
265
|
+
# _name = {"ad__id", "cred__id"}
|
|
266
|
+
#
|
|
267
|
+
# class Meta:
|
|
268
|
+
# table_description = "P2P Advertisements - Payment details"
|
|
260
269
|
|
|
261
270
|
|
|
262
271
|
class Ad(Model, TsTrait):
|
|
@@ -269,10 +278,11 @@ class Ad(Model, TsTrait):
|
|
|
269
278
|
auto_msg: str | None = fields.CharField(255, null=True)
|
|
270
279
|
status: AdStatus = fields.IntEnumField(AdStatus, defaut=AdStatus.active)
|
|
271
280
|
|
|
272
|
-
|
|
273
|
-
|
|
281
|
+
maker: fields.ForeignKeyRelation[Contragent] = fields.ForeignKeyField("models.Contragent", "my_ads")
|
|
282
|
+
maker_id: int
|
|
274
283
|
|
|
275
284
|
pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="adpm") # only root pms
|
|
285
|
+
creds: fields.ManyToManyRelation["Cred"] = fields.ManyToManyField("models.Cred", through="adcred")
|
|
276
286
|
orders: fields.ReverseRelation["Order"]
|
|
277
287
|
|
|
278
288
|
_icon = "ad"
|
|
@@ -281,17 +291,17 @@ class Ad(Model, TsTrait):
|
|
|
281
291
|
class Meta:
|
|
282
292
|
table_description = "P2P Advertisements"
|
|
283
293
|
|
|
284
|
-
def epyds(self) -> tuple[PydModel, PydModel, PydModel, PydModel, PydModel, PydModel]:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
# def epyds(self) -> tuple[PydModel, PydModel, PydModel, PydModel, PydModel, PydModel]:
|
|
295
|
+
# module_name = f"xync_client.{self.maker.ex.name}.pyd"
|
|
296
|
+
# __import__(module_name)
|
|
297
|
+
# return (
|
|
298
|
+
# sys.modules[module_name].AdEpyd,
|
|
299
|
+
# sys.modules[module_name].AdFullEpyd,
|
|
300
|
+
# sys.modules[module_name].MyAdEpydPurchase,
|
|
301
|
+
# sys.modules[module_name].MyAdInEpydPurchase,
|
|
302
|
+
# sys.modules[module_name].MyAdEpydSale,
|
|
303
|
+
# sys.modules[module_name].MyAdInEpydSale,
|
|
304
|
+
# )
|
|
295
305
|
|
|
296
306
|
|
|
297
307
|
class Pm(Model):
|
|
@@ -328,7 +338,7 @@ class Pmcur(Model): # for fiat with no exs tie
|
|
|
328
338
|
cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
|
|
329
339
|
cur_id: int
|
|
330
340
|
|
|
331
|
-
|
|
341
|
+
creds: fields.BackwardFKRelation["Cred"]
|
|
332
342
|
exs: fields.ManyToManyRelation[Ex]
|
|
333
343
|
|
|
334
344
|
class Meta:
|
|
@@ -364,52 +374,64 @@ class PmexBank(BaseModel): # banks for SBP
|
|
|
364
374
|
unique_together = (("pmex", "exid"),)
|
|
365
375
|
|
|
366
376
|
|
|
367
|
-
class
|
|
368
|
-
pmexbank: fields.ForeignKeyRelation[PmexBank] = fields.ForeignKeyField("models.PmexBank", "
|
|
377
|
+
class CredBank(BaseModel): # banks for SBP
|
|
378
|
+
pmexbank: fields.ForeignKeyRelation[PmexBank] = fields.ForeignKeyField("models.PmexBank", "credbanks")
|
|
369
379
|
pmexbank_id: int
|
|
370
|
-
|
|
371
|
-
|
|
380
|
+
cred: fields.ForeignKeyRelation["Cred"] = fields.ForeignKeyField("models.Cred", "credbanks")
|
|
381
|
+
cred_id: int
|
|
372
382
|
|
|
373
383
|
class Meta:
|
|
374
|
-
unique_together = (("
|
|
375
|
-
|
|
384
|
+
unique_together = (("cred_id", "pmexbank_id"),)
|
|
376
385
|
|
|
377
|
-
class Pmcurex(BaseModel): # existence pm in ex for exact cur, with "blocked" flag
|
|
378
|
-
pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
|
|
379
|
-
pmcur_id: int
|
|
380
|
-
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
|
|
381
|
-
ex_id: int
|
|
382
|
-
blocked: bool = fields.BooleanField(default=False)
|
|
383
386
|
|
|
384
|
-
|
|
385
|
-
|
|
387
|
+
# class Pmcurex(BaseModel): # existence pm in ex for exact cur, with "blocked" flag
|
|
388
|
+
# pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
|
|
389
|
+
# pmcur_id: int
|
|
390
|
+
# ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
|
|
391
|
+
# ex_id: int
|
|
392
|
+
# blocked: bool = fields.BooleanField(default=False) # todo: move to cureex or pmex?
|
|
393
|
+
#
|
|
394
|
+
# # class Meta:
|
|
395
|
+
# # unique_together = (("ex_id", "pmcur_id"),)
|
|
386
396
|
|
|
387
397
|
|
|
388
|
-
class
|
|
389
|
-
|
|
398
|
+
class Cred(Model):
|
|
399
|
+
exid: int = fields.BigIntField()
|
|
390
400
|
pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
|
|
391
401
|
pmcur_id: int
|
|
392
402
|
# country: fields.ForeignKeyRelation[Country] = fields.ForeignKeyField("models.Country", related_name="fiats")
|
|
393
403
|
# country_id: int
|
|
394
404
|
detail: str = fields.CharField(127)
|
|
395
405
|
name: str | None = fields.CharField(127, null=True)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
amount: float | None = fields.FloatField(default=0)
|
|
399
|
-
target: float | None = fields.FloatField(default=None, null=True)
|
|
406
|
+
contragent: fields.ForeignKeyRelation[Contragent] = fields.ForeignKeyField("models.Contragent", "creds")
|
|
407
|
+
contragent_id: int
|
|
400
408
|
|
|
401
|
-
|
|
402
|
-
|
|
409
|
+
fiat: fields.BackwardOneToOneRelation["Fiat"]
|
|
410
|
+
ads: fields.BackwardFKRelation[Ad]
|
|
411
|
+
orders: fields.BackwardFKRelation["Order"]
|
|
403
412
|
|
|
404
|
-
|
|
413
|
+
_name = {"exid"}
|
|
405
414
|
|
|
406
415
|
class Meta:
|
|
407
|
-
table_description = "Currency accounts
|
|
416
|
+
table_description = "Currency accounts"
|
|
417
|
+
unique_together = (("pmcur_id", "detail"), ("contragent", "exid"))
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
class Fiat(Model):
|
|
421
|
+
cred: fields.OneToOneRelation[Cred] = fields.OneToOneField("models.Cred", "fiat")
|
|
422
|
+
cred_id: int
|
|
423
|
+
# user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", "fiats")
|
|
424
|
+
# user_id: int # cred.contragent.agent.user_id
|
|
425
|
+
amount: float | None = fields.FloatField(default=0)
|
|
426
|
+
target: float | None = fields.FloatField(default=None, null=True)
|
|
427
|
+
|
|
428
|
+
class Meta:
|
|
429
|
+
table_description = "Currency balances"
|
|
408
430
|
|
|
409
431
|
class PydanticMeta(Model.PydanticMeta):
|
|
410
432
|
# max_recursion: int = 2
|
|
411
433
|
backward_relations = False
|
|
412
|
-
include = "id", "
|
|
434
|
+
include = "id", "cred__pmcur", "cred__detail", "cred__name", "amount"
|
|
413
435
|
|
|
414
436
|
@staticmethod
|
|
415
437
|
def epyd(ex: Ex):
|
|
@@ -418,18 +440,6 @@ class Fiat(Model):
|
|
|
418
440
|
return sys.modules[module_name].FiatEpyd
|
|
419
441
|
|
|
420
442
|
|
|
421
|
-
class Fiatex(BaseModel): # existence pm in ex with no cur tie
|
|
422
|
-
fiat: fields.ForeignKeyRelation[Fiat] = fields.ForeignKeyField("models.Fiat", "fiatexs")
|
|
423
|
-
fiat_id: int
|
|
424
|
-
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "fiatexs")
|
|
425
|
-
ex_id: int
|
|
426
|
-
exid: int = fields.BigIntField()
|
|
427
|
-
|
|
428
|
-
class Meta:
|
|
429
|
-
table_description = "Fiat on Ex"
|
|
430
|
-
unique_together = (("fiat_id", "ex_id"), ("ex_id", "exid"))
|
|
431
|
-
|
|
432
|
-
|
|
433
443
|
class Limit(Model):
|
|
434
444
|
pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
|
|
435
445
|
pmcur_id: int
|
|
@@ -479,9 +489,9 @@ class Order(Model):
|
|
|
479
489
|
ad: fields.ForeignKeyRelation[Ad] = fields.ForeignKeyField("models.Ad", related_name="ads")
|
|
480
490
|
ad_id: int
|
|
481
491
|
amount: float = fields.FloatField()
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
taker: fields.ForeignKeyRelation[
|
|
492
|
+
cred: fields.ForeignKeyRelation[Cred] = fields.ForeignKeyField("models.Cred", related_name="orders", null=True)
|
|
493
|
+
cred_id: int | None
|
|
494
|
+
taker: fields.ForeignKeyRelation[Contragent] = fields.ForeignKeyField("models.Contragent", "taken_orders")
|
|
485
495
|
taker_id: int
|
|
486
496
|
maker_topic: int = fields.IntField()
|
|
487
497
|
taker_topic: int = fields.IntField()
|
|
@@ -493,10 +503,7 @@ class Order(Model):
|
|
|
493
503
|
|
|
494
504
|
msgs: fields.BackwardFKRelation["Msg"]
|
|
495
505
|
|
|
496
|
-
_name = {"
|
|
497
|
-
|
|
498
|
-
def repr(self):
|
|
499
|
-
return f"{self.fiat.pmcur.pm.name}/{self.fiat_id}:{self.amount:.3g} {self.status.name}"
|
|
506
|
+
_name = {"cred__pmcur__pm__name"}
|
|
500
507
|
|
|
501
508
|
async def client(self):
|
|
502
509
|
if isinstance(self.ad, QuerySet):
|
|
@@ -508,7 +515,7 @@ class Order(Model):
|
|
|
508
515
|
elif isinstance(self.ad.agent, Agent) and isinstance(self.ad.agent.ex, QuerySet):
|
|
509
516
|
# noinspection PyTypeChecker
|
|
510
517
|
self.ad.agent.ex = await self.ad.agent.ex
|
|
511
|
-
client = sys.modules[f"xync_client.{self.ad.
|
|
518
|
+
client = sys.modules[f"xync_client.{self.ad.maker.ex.name}.order"].Client
|
|
512
519
|
return client(self)
|
|
513
520
|
|
|
514
521
|
# def epyd(self): # todo: for who?
|
|
@@ -522,7 +529,7 @@ class Order(Model):
|
|
|
522
529
|
class PydanticMeta(Model.PydanticMeta):
|
|
523
530
|
max_recursion: int = 0
|
|
524
531
|
exclude_raw_fields: bool = False
|
|
525
|
-
exclude = ("taker", "ad", "
|
|
532
|
+
exclude = ("taker", "ad", "cred", "msgs")
|
|
526
533
|
|
|
527
534
|
|
|
528
535
|
class Msg(Model):
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
-
|
|
3
2
|
from pydantic import BaseModel, model_validator
|
|
4
3
|
|
|
5
4
|
from xync_schema.enums import AdStatus, PmType
|
|
6
|
-
from xync_schema.models import
|
|
5
|
+
from xync_schema.models import Direction, Pmcur, Ex, Cred, Contragent
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
class
|
|
8
|
+
class _CurCoin(BaseModel):
|
|
10
9
|
exid: int | str
|
|
11
10
|
ticker: str
|
|
12
11
|
rate: float | None = None
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CoinEpyd(_CurCoin):
|
|
15
|
+
p2p: bool = True
|
|
16
|
+
minimum: float | None = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CurEpyd(_CurCoin):
|
|
14
20
|
rounding_scale: int | None = None
|
|
21
|
+
minimum: int | None = None
|
|
15
22
|
|
|
16
23
|
|
|
17
24
|
class PmexBankPyd(BaseModel):
|
|
@@ -50,20 +57,15 @@ class FiatNew(FiatUpd):
|
|
|
50
57
|
target: int | None = None
|
|
51
58
|
|
|
52
59
|
|
|
53
|
-
class
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
class CredPydIn(BaseModel):
|
|
61
|
+
id: int | None = None
|
|
62
|
+
exid: str
|
|
63
|
+
ex: Ex | None = None
|
|
64
|
+
ex_id: int | None = None
|
|
58
65
|
pmcur_id: int | None = None
|
|
59
66
|
pmcur: Pmcur | None = None
|
|
60
|
-
# df
|
|
61
67
|
detail: str
|
|
62
68
|
name: str = ""
|
|
63
|
-
amount: float
|
|
64
|
-
target: float | None = None
|
|
65
|
-
|
|
66
|
-
banks: list[str] = []
|
|
67
69
|
|
|
68
70
|
class Config:
|
|
69
71
|
arbitrary_types_allowed = True
|
|
@@ -71,24 +73,21 @@ class FiatPydIn(BaseModel):
|
|
|
71
73
|
@classmethod
|
|
72
74
|
@model_validator(mode="before")
|
|
73
75
|
def check_at_least_one_field(cls, values):
|
|
74
|
-
if (values.get("
|
|
76
|
+
if (values.get("ex") or values.get("ex_id")) and (values.get("pmcur") or values.get("pmcur_id")):
|
|
75
77
|
return values
|
|
76
|
-
raise ValueError("
|
|
78
|
+
raise ValueError("ex(_id) and pmcur(_id) is required")
|
|
77
79
|
|
|
78
|
-
def args(self) -> tuple[dict, dict]:
|
|
79
|
-
unq: tuple[str, ...] = "id", "user_id", "user", "pmcur_id", "pmcur"
|
|
80
|
-
df: tuple[str, ...] = "detail", "name", "amount", "target"
|
|
81
|
-
d = self.model_dump()
|
|
82
|
-
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)}
|
|
83
80
|
|
|
81
|
+
class FiatPydIn(BaseModel):
|
|
82
|
+
# unq
|
|
83
|
+
id: int = None
|
|
84
|
+
cred_id: int | None = None
|
|
85
|
+
cred: Cred | None = None
|
|
86
|
+
# df
|
|
87
|
+
amount: float
|
|
88
|
+
target: float | None = None
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
id: int | None = None
|
|
87
|
-
exid: str
|
|
88
|
-
ex: Ex | None = None
|
|
89
|
-
ex_id: int | None = None
|
|
90
|
-
fiat: Fiat | None = None
|
|
91
|
-
fiat_id: int | None = None
|
|
90
|
+
banks: list[str] = []
|
|
92
91
|
|
|
93
92
|
class Config:
|
|
94
93
|
arbitrary_types_allowed = True
|
|
@@ -96,9 +95,15 @@ class FiatexPydIn(BaseModel):
|
|
|
96
95
|
@classmethod
|
|
97
96
|
@model_validator(mode="before")
|
|
98
97
|
def check_at_least_one_field(cls, values):
|
|
99
|
-
if
|
|
98
|
+
if values.get("cred") or values.get("cred_id"):
|
|
100
99
|
return values
|
|
101
|
-
raise ValueError("
|
|
100
|
+
raise ValueError("cred(_id) is required")
|
|
101
|
+
|
|
102
|
+
def args(self) -> tuple[dict, dict]:
|
|
103
|
+
unq: tuple[str, ...] = "id", "cred_id", "cred"
|
|
104
|
+
df: tuple[str, ...] = "amount", "target"
|
|
105
|
+
d = self.model_dump()
|
|
106
|
+
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)}
|
|
102
107
|
|
|
103
108
|
|
|
104
109
|
class BaseAd(BaseModel):
|
|
@@ -112,9 +117,9 @@ class AdPydIn(BaseAd):
|
|
|
112
117
|
detail: str | None = None
|
|
113
118
|
auto_msg: str | None = None
|
|
114
119
|
status: AdStatus = AdStatus.active
|
|
115
|
-
|
|
120
|
+
maker_id: int | None = None
|
|
121
|
+
maker: Contragent | None = None
|
|
116
122
|
direction_id: int | None = None
|
|
117
|
-
agent: Agent | None = None
|
|
118
123
|
direction: Direction | None = None
|
|
119
124
|
pms_: list | None = None
|
|
120
125
|
fiats_: list | None = None
|
|
@@ -125,12 +130,12 @@ class AdPydIn(BaseAd):
|
|
|
125
130
|
@classmethod
|
|
126
131
|
@model_validator(mode="before")
|
|
127
132
|
def check_at_least_one_field(cls, values):
|
|
128
|
-
|
|
133
|
+
maker = values.get("maker") or values.get("maker_id")
|
|
129
134
|
direction = values.get("direction") or values.get("direction_id")
|
|
130
135
|
pms_or_fiats = values.get("pms_") or values.get("fiats_")
|
|
131
|
-
if
|
|
136
|
+
if maker and direction and pms_or_fiats:
|
|
132
137
|
return values
|
|
133
|
-
raise ValueError("(pms or fiats) and
|
|
138
|
+
raise ValueError("(pms or fiats) and maker(_id) and direction(_id) is required")
|
|
134
139
|
|
|
135
140
|
|
|
136
141
|
class OrderPyd(BaseModel):
|
|
@@ -138,7 +143,7 @@ class OrderPyd(BaseModel):
|
|
|
138
143
|
amount: float
|
|
139
144
|
status: str
|
|
140
145
|
actions: dict | None = {}
|
|
141
|
-
|
|
146
|
+
cred: Cred.pyd()
|
|
142
147
|
is_sell: bool
|
|
143
148
|
contragent: int | None = None
|
|
144
149
|
created_at: datetime
|
|
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
|