xync-client 0.1.3__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.
Potentially problematic release.
This version of xync-client might be problematic. Click here for more details.
- xync_client-0.1.3/PKG-INFO +20 -0
- xync_client-0.1.3/README.md +160 -0
- xync_client-0.1.3/pyproject.toml +33 -0
- xync_client-0.1.3/setup.cfg +4 -0
- xync_client-0.1.3/tests/test_binance.py +8 -0
- xync_client-0.1.3/tests/test_bybit.py +80 -0
- xync_client-0.1.3/tests/test_bybit_p2p.py +184 -0
- xync_client-0.1.3/tests/test_gate.py +38 -0
- xync_client-0.1.3/tests/test_htx_p2p.py +0 -0
- xync_client-0.1.3/tests/test_wallet.py +182 -0
- xync_client-0.1.3/xync_client/Binance/binance_async.py +83 -0
- xync_client-0.1.3/xync_client/Binance/earn_api.py +83 -0
- xync_client-0.1.3/xync_client/Binance/sapi.py +267 -0
- xync_client-0.1.3/xync_client/Binance/web.py +30 -0
- xync_client-0.1.3/xync_client/Binance/web_c2c.py +227 -0
- xync_client-0.1.3/xync_client/Bybit/web_earn.py +78 -0
- xync_client-0.1.3/xync_client/Bybit/web_p2p.py +329 -0
- xync_client-0.1.3/xync_client/Gate/premarket.py +65 -0
- xync_client-0.1.3/xync_client/Htx/watchdog/Ad.py +0 -0
- xync_client-0.1.3/xync_client/Htx/watchdog/init.py +0 -0
- xync_client-0.1.3/xync_client/Htx/watchdog/lib.py +0 -0
- xync_client-0.1.3/xync_client/Htx/watchdog/main.py +0 -0
- xync_client-0.1.3/xync_client/Htx/web.py +76 -0
- xync_client-0.1.3/xync_client/Htx/web_c2c.py +18 -0
- xync_client-0.1.3/xync_client/KuCoin/web.py +30 -0
- xync_client-0.1.3/xync_client/Okx/web.py +6 -0
- xync_client-0.1.3/xync_client/Proto.py +168 -0
- xync_client-0.1.3/xync_client/TgWallet/pyro.py +29 -0
- xync_client-0.1.3/xync_client/TgWallet/web.py +70 -0
- xync_client-0.1.3/xync_client/TgWallet/web_p2p.py +182 -0
- xync_client-0.1.3/xync_client/__init__.py +0 -0
- xync_client-0.1.3/xync_client/exceptions.py +27 -0
- xync_client-0.1.3/xync_client/loader.py +23 -0
- xync_client-0.1.3/xync_client/rs.py +38 -0
- xync_client-0.1.3/xync_client.egg-info/PKG-INFO +20 -0
- xync_client-0.1.3/xync_client.egg-info/SOURCES.txt +37 -0
- xync_client-0.1.3/xync_client.egg-info/dependency_links.txt +1 -0
- xync_client-0.1.3/xync_client.egg-info/requires.txt +14 -0
- xync_client-0.1.3/xync_client.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: xync-client
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
5
|
+
Project-URL: Homepage, https://gitlab.com/xync/back/cex-clients
|
|
6
|
+
Project-URL: Repository, https://gitlab.com/xync/back/cex-clients
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: http-client-async
|
|
9
|
+
Requires-Dist: asynchuobi
|
|
10
|
+
Requires-Dist: python-binance
|
|
11
|
+
Requires-Dist: pybit
|
|
12
|
+
Requires-Dist: pyrogram
|
|
13
|
+
Requires-Dist: python-okx
|
|
14
|
+
Requires-Dist: xync-schema
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: build; extra == "dev"
|
|
17
|
+
Requires-Dist: python-dotenv; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
19
|
+
Requires-Dist: setuptools_scm; extra == "dev"
|
|
20
|
+
Requires-Dist: twine; extra == "dev"
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
## Order Flow:
|
|
2
|
+
- 0: Получшение заявок за заданное время, в статусе, по валюте, монете, направлению: `get_orders(stauts=OrderStatus.active, coin='USDT', cur='RUB', is_sell=False) => [order]`
|
|
3
|
+
|
|
4
|
+
### Order Class description:
|
|
5
|
+
- 1: [T] Запрос на старт сделки (`order`) по чужому объявлению (`ad`) тейкером на сумму amount: `order_request(ad_id, amount) => order_id`
|
|
6
|
+
- 1N: [M] - Запрос мейкеру на сделку `order_request_ask => Order`
|
|
7
|
+
- 2: [T] Отмена запроса на сделку `cancel_request()`
|
|
8
|
+
- 2N: [M] - Уведомление об отмене запроса на сделку `request_canceled_notify`
|
|
9
|
+
- 3: [M] Одобрить запрос на сделку `accept_request()`
|
|
10
|
+
- 3N: [T] Уведомление об одобрении запроса на сделку `request_accepted_notify`
|
|
11
|
+
- 4: [M] Отклонить запрос на сделку `reject_request()`
|
|
12
|
+
- 4T: Бездействие 15мин `wait15m_on_order_request`
|
|
13
|
+
- 4N: [T] Уведомление об отклонении запроса на сделку `request_rejected_notify`
|
|
14
|
+
- 5: [B] Перевод сделки в состояние "оплачено", c отправкой чека `mark_payed(receipt)`
|
|
15
|
+
- 5N: [S] Уведомиление продавца об оплате `payed_notify`
|
|
16
|
+
- 6T: Бездействие 15мин `wait15m_on_order_creaed`
|
|
17
|
+
- 6: [B] Отмена сделки `cancel_order()`
|
|
18
|
+
- 6N: [S] Уведомиление продавцу об отмене оредера покупателем `order_canceled_notify`
|
|
19
|
+
- 7: [S] Подтвердить получение оплаты `confirm()`
|
|
20
|
+
- 7N: [B] Уведомиление покупателю об успешном завершении продавцом `order_completed_notify`
|
|
21
|
+
- 8T: Бездействие 10мин `wait10m_on_payed`
|
|
22
|
+
- 8N: [S,B] Уведомление о наступлении возможности подать аппеляцию `appeal_available_notify`
|
|
23
|
+
- 9,10: [S,B] Подать аппеляцию cо скриншотом/видео/файлом `start_appeal(file)`
|
|
24
|
+
- 9N,10N: [S,B] Уведомление о поданной на меня аппеляци `appeal_started`
|
|
25
|
+
- 11,12: [S,B] Встречное оспаривание полученной аппеляции cо скриншотом/видео/файлом `dispute_appeal(file)`
|
|
26
|
+
- 11N,12N: [S,B] Уведомление о встречном оспаривание поданной аппеляции `dispute_appeal(file)`
|
|
27
|
+
- 13T: [S] Бездействие продавца 3часа `seller_wait3h_on_appeal`
|
|
28
|
+
- 14T: [B] Бездействие покупателя 3часа `buyer_wait3h_on_appeal`
|
|
29
|
+
- 13N: [S,B] Уведомление о завершении сделки по аппеляции `order_completed_by_appeal`
|
|
30
|
+
- 14N: [B,S] Уведомление об отмене сделки по аппеляции `order_canceled_by_appeal`
|
|
31
|
+
- 15: [B,S] Отмена аппеляции`cancel_appeal()`
|
|
32
|
+
- 15N: [B,S] Уведомление об отмене аппеляции против меня `appeal_canceled`
|
|
33
|
+
- 16: Отправка сообщения юзеру в чат по ордеру с приложенным файлом `send_order_msg(msg:str, file=None)`
|
|
34
|
+
- 16N Получение сообщения в чате по ордеру `get_order_msg => (msg:str, file=None)`
|
|
35
|
+
- 17: Отправка сообщения по апелляции `send_appeal_msg(file, msg:str=None)`
|
|
36
|
+
- 17N: Получение сообщения по апелляции `get_appeal_msg => msg:str`
|
|
37
|
+
|
|
38
|
+
### Scheme
|
|
39
|
+
```mermaid
|
|
40
|
+
flowchart TD
|
|
41
|
+
T1((T)) -->|"`1: [T] **Creates**`"| 1[Requested]
|
|
42
|
+
|
|
43
|
+
1 .->|1N: Request Notify|M1((M))
|
|
44
|
+
|
|
45
|
+
M1 ==>|"`3: [M] **Accepts**`"| 3[Created]
|
|
46
|
+
|
|
47
|
+
subgraph Rejected
|
|
48
|
+
2(["[T] Request Canceled"]):::red
|
|
49
|
+
4(["[M] Rejected"]):::red
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
M1 ==x|"`4: [M] **Rejects**`"| 4
|
|
53
|
+
1 --x|4T: Wait 15m| 4
|
|
54
|
+
1 ==x|"`2: [T] **Cancels**`"| 2
|
|
55
|
+
|
|
56
|
+
2 .->|2N: Taker cancel\norder request| M2((M))
|
|
57
|
+
4 .->|4N: Maker reject\norder request| T2((T))
|
|
58
|
+
|
|
59
|
+
3 ==>|"`5: [B] **Marks: PAYED**<br>(with Receipt?)`"| 5[PAYED]
|
|
60
|
+
3 .-> |3N: Request\nAcepted Notify| T3((T))
|
|
61
|
+
3 ---x|6T: Delay 15m| 6(((by<br>buyer))):::red
|
|
62
|
+
3 ===x|"`6: [B] **Cancels**`"| 6
|
|
63
|
+
|
|
64
|
+
Payed ==>|"`7: [S] **Confirms**`"| 7(((By<br>Seller))):::green
|
|
65
|
+
7 .->|7N: Seller Completed order| B4((B))
|
|
66
|
+
|
|
67
|
+
S2 -->|Delay 3h| 13
|
|
68
|
+
|
|
69
|
+
subgraph Payed
|
|
70
|
+
subgraph Completed
|
|
71
|
+
direction TB
|
|
72
|
+
13(((By\nAppeal))):::green
|
|
73
|
+
7
|
|
74
|
+
end
|
|
75
|
+
5 -->|8T: Wait 10m| 8(PAYED +10m)
|
|
76
|
+
5 .-> |5N: Order\nPayed Notify| S1((S))
|
|
77
|
+
15(Appeal Canceled)
|
|
78
|
+
8 .->|8N: Appeal Available| B3((B))
|
|
79
|
+
8 .->|8N: Appeal Available| S3((S))
|
|
80
|
+
|
|
81
|
+
B2 <-->|17,17N| SP
|
|
82
|
+
subgraph Appeal
|
|
83
|
+
subgraph ABB [By Buyer]
|
|
84
|
+
10 .->|10N: Buyer started appeal| S2((S))
|
|
85
|
+
S2 ==>|"`12: **No! I've no payment**<br>(with Screenshot)`"|12{{"[B] Appeal\nDisputed"}}
|
|
86
|
+
end
|
|
87
|
+
SP((Sp))
|
|
88
|
+
subgraph ABS [By Seller]
|
|
89
|
+
9 .->|9N: Seller started appeal| B2((B))
|
|
90
|
+
B2 ==>|"`11: **No! I've paid**<br>(with Receipt)`"|11{{"[S] Appeal\nDisputed"}}
|
|
91
|
+
end
|
|
92
|
+
S2 <-->|17,17N| SP
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
Payed ==x|"`6: [B] **Cancels**`"| 6
|
|
97
|
+
6 .-> |6N: Buyer Canceled Order| S4((S))
|
|
98
|
+
|
|
99
|
+
B3 ==>|"`10: [B] **No release**<br>(with Receipt!)`"| 10{{Appeled<br>by Buyer}}
|
|
100
|
+
15 <===|"`15: [B] **Cancels<br>appeal**`"| ABB
|
|
101
|
+
S3 ==>|"`9: [S] **No payment**<br>(with Screenshot)`"| 9{{Appeled<br>by Seller}}
|
|
102
|
+
15 <===|"`15: [S] **Cancels<br>appeal**`"| ABS
|
|
103
|
+
15 .->|15N: Appeal Canceled| B3
|
|
104
|
+
15 .->|15N: Appeal Canceled| S3
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
B2 -->|Delay 3h| 14(((by<br>appeal))):::red
|
|
108
|
+
Appeal o-->|50%: Wait for<br>sup decision| 13
|
|
109
|
+
Appeal o-->|50%: Wait for<br>sup decision| 14
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
13 .->|13N: Done by appeal| B4
|
|
113
|
+
13 .->|13N: Done by appeal| S4
|
|
114
|
+
14 .->|14N: Canceled by appeal| B4
|
|
115
|
+
14 .->|14N: Canceled by appeal| S4
|
|
116
|
+
|
|
117
|
+
subgraph Canceled
|
|
118
|
+
direction TB
|
|
119
|
+
6
|
|
120
|
+
14
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
classDef green stroke:#0f0
|
|
124
|
+
classDef red stroke:#f00
|
|
125
|
+
```
|
|
126
|
+
###### Legend
|
|
127
|
+
***[T] - Taker, [M] - Maker, [S] - Seller, [B] - Buyer***.<br>
|
|
128
|
+
*Clean digits (1, 2, ..)*: Simple outbound HTTP Requests;<br>
|
|
129
|
+
*N suffix (1N, 2N, ..)*: Inbound Notifications - from SSE/WS/Pyrogram client;<br>
|
|
130
|
+
*T suffix (4T, 8T, ..)*: Only Tests with idle waithing time.
|
|
131
|
+
|
|
132
|
+
### Public
|
|
133
|
+
- 21: Список поддерживаемых валют тейкера `taker_curs() => [Cur]`
|
|
134
|
+
- 22: Список торгуемых монет (с ограничениям по валютам, если есть) `coins(cur:Cur=None) => [Coin]`
|
|
135
|
+
- 23: Список платежных методов по каждой валюте `pms(cur: Cur) => [Pm]`
|
|
136
|
+
- 24: Список объяв по (buy/sell, cur, coin, pm) `ads(coin: Coin, cur: Cur, is_sell: bool, pms:list[Pm]=None)`
|
|
137
|
+
|
|
138
|
+
### Fiat
|
|
139
|
+
- 25: Список реквизитов моих платежных методов `my_fiats(cur:Cur=None) => [Fiat]`
|
|
140
|
+
- 26: Создание `fiat_new(cur:Cur, pm:Pm, detail:str, type:PmType=None)`
|
|
141
|
+
- 27: Редактирование `fiat_upd(detail:str=None, type:PmType=None)`
|
|
142
|
+
- 28: Удаление `fiat_del(fiat_id:int)`
|
|
143
|
+
|
|
144
|
+
### Ad
|
|
145
|
+
- 29: Список моих ad
|
|
146
|
+
- 30: Создание ad: `ad_new(coin: Coin, cur:Cur, is_sell: bool, pms:[Pm], price:float, is_float:bool=True, min_fiat:int=None, details:str=None, autoreply:str=None, status:AdvStatus=AdvStatus.active)`
|
|
147
|
+
- 31: Редактирование `ad_upd(pms:[Pm]=None, price:float=None, is_float:bool=None, min_fiat:int=None, details:str=None, autoreply:str=None, status:AdvStatus=None)`
|
|
148
|
+
- 32: Удаление `ad_del()`
|
|
149
|
+
- 33: Вкл/выкл объявления `ad_switch() => result: bool`
|
|
150
|
+
- 34: Вкл/выкл всех объявлений `ads_switch() => result: bool`
|
|
151
|
+
|
|
152
|
+
### User
|
|
153
|
+
- 35: Получить объект юзера по его ид `get_user(user_id) => user`
|
|
154
|
+
- 36: Отправка сообщения юзеру с приложенным файлом `send_user_msg(msg:str, file=None)`*
|
|
155
|
+
- 37: (Раз)Блокировать юзера `block_user(is_blocked:bool=True)`
|
|
156
|
+
- 38: Поставить отзыв юзеру `rate_user(positive:bool)`<br>
|
|
157
|
+
**Inbound:**
|
|
158
|
+
- 36N: Получение сообщения от юзера `get_user_msg => (msg:str, file=None)`
|
|
159
|
+
- 37N: Получение уведомления о (раз)блокировке юзером `got_blocked => is_blocked:bool`
|
|
160
|
+
- 38N: Получение уведомления о полученном отзыве `got_rated => (user_id:int, order_id:int)`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "xync-client"
|
|
3
|
+
requires-python = ">=3.12"
|
|
4
|
+
authors = [
|
|
5
|
+
{name = "Mike Artemiev", email = "mixartemev@gmail.com"},
|
|
6
|
+
]
|
|
7
|
+
dependencies = [
|
|
8
|
+
"http-client-async",
|
|
9
|
+
"asynchuobi",
|
|
10
|
+
"python-binance",
|
|
11
|
+
"pybit",
|
|
12
|
+
"pyrogram",
|
|
13
|
+
"python-okx",
|
|
14
|
+
"xync-schema"
|
|
15
|
+
]
|
|
16
|
+
version = "0.1.3"
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
dev = [
|
|
20
|
+
"build",
|
|
21
|
+
"python-dotenv",
|
|
22
|
+
"pytest-asyncio",
|
|
23
|
+
"setuptools_scm",
|
|
24
|
+
"twine",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://gitlab.com/xync/back/cex-clients"
|
|
29
|
+
Repository = "https://gitlab.com/xync/back/cex-clients"
|
|
30
|
+
|
|
31
|
+
[tool.pytest.ini_options]
|
|
32
|
+
asyncio_mode = "auto"
|
|
33
|
+
asyncio_default_fixture_loop_scope = "class" # , "session", "module", "package", "function"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from uuid import uuid4
|
|
3
|
+
from pybit.unified_trading import HTTP
|
|
4
|
+
|
|
5
|
+
from cex_clients.bybit.web_earn import BybitEarn, type_map
|
|
6
|
+
from cex_clients.loader import BYT, BYKEY, BYSEC
|
|
7
|
+
|
|
8
|
+
client = HTTP(
|
|
9
|
+
testnet=False,
|
|
10
|
+
api_key=BYKEY,
|
|
11
|
+
api_secret=BYSEC,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async def test_get_home_products():
|
|
16
|
+
bbt = BybitEarn(BYT)
|
|
17
|
+
for pt in type_map:
|
|
18
|
+
resp = await bbt.get_home_earn_products(pt.value)
|
|
19
|
+
assert len(resp[pt.name]), "No home products"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async def test_get_coins():
|
|
23
|
+
bbt = BybitEarn(BYT)
|
|
24
|
+
resp = await bbt.get_coins()
|
|
25
|
+
assert resp, 'No coins'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async def test_get_eth():
|
|
29
|
+
bbt = BybitEarn(BYT)
|
|
30
|
+
resp = await bbt.get_product_detail()
|
|
31
|
+
assert resp, 'No eth'
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_get_rate():
|
|
35
|
+
resp = client.get_tickers(category='spot', symbol='TONUSDT')
|
|
36
|
+
assert float(resp['result']['list'][0]['lastPrice']) > 0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_send_coin_internal():
|
|
40
|
+
coin = "USDT"
|
|
41
|
+
old_sender_balance = client.get_coins_balance(
|
|
42
|
+
accountType="FUND",
|
|
43
|
+
coin=coin,
|
|
44
|
+
)['result']['balance'][0]
|
|
45
|
+
# sender_id = 23477628
|
|
46
|
+
# receiver_id = 138687729
|
|
47
|
+
receiver_id = 69798104
|
|
48
|
+
sent_amount = 24.9266
|
|
49
|
+
assert float(old_sender_balance['transferBalance']) >= sent_amount, 'sender have not enough money'
|
|
50
|
+
|
|
51
|
+
trans_sent_id = client.withdraw(
|
|
52
|
+
coin=coin,
|
|
53
|
+
# chain=None,
|
|
54
|
+
address=str(receiver_id),
|
|
55
|
+
amount=str(sent_amount),
|
|
56
|
+
timestamp=int(datetime.now().timestamp()*1000),
|
|
57
|
+
forceChain=2,
|
|
58
|
+
accountType="FUND"
|
|
59
|
+
)['result']
|
|
60
|
+
new_sender_balance = client.get_coins_balance(
|
|
61
|
+
accountType="FUND",
|
|
62
|
+
coin=coin,
|
|
63
|
+
)['result']['balance'][0]
|
|
64
|
+
assert trans_sent_id and float(new_sender_balance['walletBalance']) == float(old_sender_balance['walletBalance']) - sent_amount, 'transfer failed'
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_send_coin_subaccount():
|
|
68
|
+
sender_id = 23477628
|
|
69
|
+
receiver_id = 69798104
|
|
70
|
+
sent_amount = 15.5
|
|
71
|
+
sent = client.create_universal_transfer( # its only for subaccount transfers
|
|
72
|
+
transferId=str(uuid4()),
|
|
73
|
+
coin="USDT",
|
|
74
|
+
amount=str(sent_amount),
|
|
75
|
+
fromMemberId=sender_id,
|
|
76
|
+
toMemberId=receiver_id,
|
|
77
|
+
fromAccountType="FUND",
|
|
78
|
+
toAccountType="FUND",
|
|
79
|
+
)['result']
|
|
80
|
+
assert sent, 'transfer failed'
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
from time import sleep
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from tortoise import Tortoise, connections
|
|
5
|
+
from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
6
|
+
from xync_schema import models
|
|
7
|
+
from xync_schema.models import TestEx, ExAction, Pmcur
|
|
8
|
+
|
|
9
|
+
from cex_clients.bybit.web_p2p import BybitP2P, NoMakerException, AdsStatus
|
|
10
|
+
from cex_clients.loader import BYTP2P, DSN
|
|
11
|
+
|
|
12
|
+
bybit_p2p = BybitP2P(headers={'cookie': 'secure-token=' + BYTP2P})
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
async def dbc() -> AsyncpgDBClient:
|
|
17
|
+
await Tortoise.init(db_url=DSN, modules={'models': [models]})
|
|
18
|
+
cn: AsyncpgDBClient = connections.get('default')
|
|
19
|
+
yield cn
|
|
20
|
+
await cn.close()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# получение валют (1)
|
|
24
|
+
async def test_get_currencies(dbc):
|
|
25
|
+
currencies = bybit_p2p.get_currencies()
|
|
26
|
+
Pmcur.update_or_create({}, )
|
|
27
|
+
ok = True if len(currencies) > 0 else False
|
|
28
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.all_curs_taker)
|
|
29
|
+
assert ok, "No currencies found"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# получение не тестовых монет торгуемых на p2p (2)
|
|
33
|
+
async def test_get_coins(dbc):
|
|
34
|
+
result_get_coins = bybit_p2p.get_coins()
|
|
35
|
+
ok = True if len([c for c in result_get_coins['result'] if c['tokenType'] == "CHAIN_TOKEN" and not c['isTest']]) > 0 else False
|
|
36
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.all_coins)
|
|
37
|
+
assert ok, "No coins found"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# получение платежных методов (3)
|
|
41
|
+
async def test_get_payment_methods(dbc):
|
|
42
|
+
result_get_payment_methods = bybit_p2p.get_payment_methods()
|
|
43
|
+
ok = True if len(result_get_payment_methods['result']['paymentConfigVo']) > 0 else False
|
|
44
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.all_pms)
|
|
45
|
+
assert ok, "No payment method found"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# получение первого объявления на покупку USDT за рубли (покупка - "side": "1", продажа - "side": "0") (4)
|
|
49
|
+
async def test_get_best_price(dbc):
|
|
50
|
+
all_ads = bybit_p2p.get_ads('USDT', 'RUB')
|
|
51
|
+
ok1 = True if bybit_p2p.get_rate(all_ads) > 0 else False # "Ad's price USDT/RUB no found no Payeer, no Advcash"
|
|
52
|
+
ok2 = True if len(all_ads) > 0 else False
|
|
53
|
+
await TestEx.update_or_create({'ok': ok1 and ok2}, ex_id=10, action=ExAction.all_ads)
|
|
54
|
+
assert ok2, "Ad's price USDT/RUB no found"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# получение платежных методов залогиненного юзера (5)
|
|
58
|
+
async def test_get_user_pay_methods(dbc):
|
|
59
|
+
result_get_user_pay_methods = bybit_p2p.get_user_pay_methods()
|
|
60
|
+
ok = True if len(result_get_user_pay_methods) > 0 else False
|
|
61
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.fiats)
|
|
62
|
+
assert ok, 'No payment method requisites found'
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# создание моего платежного реквизита (fiat) (6)
|
|
66
|
+
async def test_create_user_payment_methods(dbc):
|
|
67
|
+
result = bybit_p2p.create_payment_method(379, 'ЕЛЕНА АРТЕМЬЕВА', '42454342536453')
|
|
68
|
+
ok = True if result['ret_msg'] == 'SUCCESS' else False
|
|
69
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.fiat_new)
|
|
70
|
+
assert ok, "Fiat isn't created: " + result['ret_msg']
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# редактирование моего платежного реквизита (fiat) (7)
|
|
74
|
+
async def test_update_user_payment_methods(dbc):
|
|
75
|
+
result = bybit_p2p.update_payment_method('ЕЛЕНА АРТЕМЬЕВА', '424543425364532')
|
|
76
|
+
if result['ret_msg'] != 'SUCCESS':
|
|
77
|
+
print('Wrong 2fa on Fiat updating, wait 10 secs and retry..')
|
|
78
|
+
sleep(10)
|
|
79
|
+
return await test_update_user_payment_methods(dbc)
|
|
80
|
+
await TestEx.update_or_create({'ok': True}, ex_id=10, action=ExAction.fiat_upd)
|
|
81
|
+
assert True, "Fiat isn't updated: " + result['ret_msg']
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# удаление моего платежного реквизита (fiat) (8)
|
|
85
|
+
async def test_delete_user_payment_methods(dbc):
|
|
86
|
+
last_fiat = bybit_p2p.get_payment_method()
|
|
87
|
+
result = bybit_p2p.delete_payment_method(last_fiat['id'])
|
|
88
|
+
if result['ret_msg'] != 'SUCCESS':
|
|
89
|
+
print('Wrong 2fa on Fiat deleting, wait 10 secs and retry..')
|
|
90
|
+
sleep(10)
|
|
91
|
+
return await test_delete_user_payment_methods(dbc)
|
|
92
|
+
await TestEx.update_or_create({'ok': True}, ex_id=10, action=ExAction.fiat_del)
|
|
93
|
+
assert True, "Fiat isn't deleted: " + result['ret_msg']
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# получение списка объявлений залогиненного юзера (9)
|
|
97
|
+
async def test_get_user_ads(dbc):
|
|
98
|
+
result_get_user_ads = bybit_p2p.get_user_ads()
|
|
99
|
+
ok = True if len(result_get_user_ads) >= 0 else False
|
|
100
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.my_ads)
|
|
101
|
+
assert ok, 'No ads found'
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# создание/редактирование/удаление объявления (10,11,12)
|
|
105
|
+
async def test_delete_ad(dbc):
|
|
106
|
+
try:
|
|
107
|
+
token = bybit_p2p.get_security_token_create()
|
|
108
|
+
bybit_p2p.post_create_ad(token)
|
|
109
|
+
token = bybit_p2p.get_security_token_update()
|
|
110
|
+
bybit_p2p.post_update_ad(token)
|
|
111
|
+
result_delete_ad = bybit_p2p.delete_ad(bybit_p2p.last_ad_id[0])
|
|
112
|
+
except NoMakerException as e:
|
|
113
|
+
print(e.args[0]['ret_msg'])
|
|
114
|
+
result_delete_ad = e.args[0]
|
|
115
|
+
ok = True if result_delete_ad['ret_msg'] == 'SUCCESS' else False
|
|
116
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.ad_new)
|
|
117
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.ad_upd)
|
|
118
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.ad_del)
|
|
119
|
+
assert ok, "Ad isn't deleted"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
async def _switch_ad(new_status: AdsStatus, dbc):
|
|
123
|
+
result = bybit_p2p.switch_ads(new_status)
|
|
124
|
+
ok = True if result['ret_msg'] == 'SUCCESS' else False
|
|
125
|
+
action = {AdsStatus.REST: ExAction.ad_off, AdsStatus.WORKING: ExAction.ad_on}[new_status]
|
|
126
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=action)
|
|
127
|
+
return ok
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# выключение/включение объявления (13,14)
|
|
131
|
+
async def test_on_off_ads(dbc):
|
|
132
|
+
old_status = AdsStatus[bybit_p2p.online_ads()]
|
|
133
|
+
new_status = AdsStatus(int(not bool(old_status.name)))
|
|
134
|
+
ok = await _switch_ad(new_status, dbc)
|
|
135
|
+
assert ok, 'Ads no ' + new_status.name
|
|
136
|
+
# возвращаем как было:
|
|
137
|
+
ok = await _switch_ad(old_status, dbc)
|
|
138
|
+
assert ok, 'Ads no ' + old_status.name
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# старт заявки (тейкером 17)
|
|
142
|
+
async def test_create_order_taker():
|
|
143
|
+
ads = bybit_p2p.get_ads('USDT', 'RUB', payment=['51'])
|
|
144
|
+
ad = ads[0]
|
|
145
|
+
get_order_info = bybit_p2p.get_order_info(ad['id'])
|
|
146
|
+
result = bybit_p2p.create_order_taker(ad['id'], 'USDT', 'RUB', False, ad['minAmount'], float(ad['minAmount'])/float(ad['price']), ad['price'])
|
|
147
|
+
ok = True if result['ret_msg'] == 'SUCCESS' else False
|
|
148
|
+
await TestEx.update_or_create({'ok': ok}, ex_id=10, action=ExAction.take_ad)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# сообщения чата (тейкером 21)
|
|
152
|
+
async def test_get_chat_msgs(dbc):
|
|
153
|
+
msgs = bybit_p2p.get_chat_msg('1832490804709646336')
|
|
154
|
+
assert len(msgs) > 0, 'No have msgs'
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
async def test_user_block(dbc):
|
|
158
|
+
bu = bybit_p2p.block_user('146246740')
|
|
159
|
+
assert bu['result'], 'User don\'t block'
|
|
160
|
+
ubu = bybit_p2p.unblock_user('146246740')
|
|
161
|
+
assert ubu['result'], 'User don\'t unblock'
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# поставить отзыв (27)
|
|
165
|
+
async def test_user_review_post(dbc):
|
|
166
|
+
result = bybit_p2p.user_review_post('1831422797854318592')
|
|
167
|
+
assert result['ret_msg'] == 'SUCCESS', 'Review post failed'
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# получшение заявок по всем ордерам за заданное время, статус, направление, монета (32)
|
|
171
|
+
async def test_get_orders_done(dbc):
|
|
172
|
+
result = bybit_p2p.get_orders_done(1717189200000, 1722545999999, 50, 1, 'USDT')
|
|
173
|
+
assert result['ret_msg'] == 'SUCCESS', 'No orders done'
|
|
174
|
+
|
|
175
|
+
# получшение заявок по активным ордерам за заданное время, статус, направление, монета (32)
|
|
176
|
+
async def test_get_orders_active(dbc):
|
|
177
|
+
result = bybit_p2p.get_orders_active(1717189200000, 1722545999999, 50, 1, 'USDT')
|
|
178
|
+
assert result['ret_msg'] == 'SUCCESS', 'No active orders'
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
# 33
|
|
182
|
+
async def test_get_order_info(dbc):
|
|
183
|
+
get_order_info = bybit_p2p.get_order_info('1819108572048125952')
|
|
184
|
+
assert get_order_info, 'No order info'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from cex_clients.gate.premarket import Priv
|
|
2
|
+
from cex_clients.loader import GATE_UID, GATE_PVER
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def test_get_premarket_ads():
|
|
6
|
+
gate = Priv(GATE_UID, GATE_PVER)
|
|
7
|
+
resp = await gate.get_premarket_ads()
|
|
8
|
+
assert len(resp), "No premarket ads"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def test_get_my_premarket_ads():
|
|
12
|
+
gate = Priv(GATE_UID, GATE_PVER)
|
|
13
|
+
resp = await gate.get_my_premarket_ads()
|
|
14
|
+
assert len(resp), "No my premarket ads"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def test_create_premarket_ad():
|
|
18
|
+
gate = Priv(GATE_UID, GATE_PVER)
|
|
19
|
+
resp = await gate.post_premarket_ad(0.649, 5)
|
|
20
|
+
assert resp, "Premarket ad not created"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def test_delate_premarket_ad():
|
|
24
|
+
gate = Priv(GATE_UID, GATE_PVER)
|
|
25
|
+
resp = await gate.del_premarket_ad(62089)
|
|
26
|
+
assert resp, "Premarket ad not delated"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def test_set_premarket_ads():
|
|
30
|
+
gate = Priv(GATE_UID, GATE_PVER)
|
|
31
|
+
my_ads = await gate.get_my_premarket_ads()
|
|
32
|
+
my_ids = [ad['order_id'] for ad in my_ads]
|
|
33
|
+
resp = await gate.get_premarket_ads()
|
|
34
|
+
for ad in resp:
|
|
35
|
+
if ad['order_id'] in my_ids:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
assert len(resp), "No premarket ads"
|
|
File without changes
|