Skip to content

Commit 9c0de48

Browse files
author
T. Ismael Verdugo
committed
feat: order price_average field
1 parent 5169693 commit 9c0de48

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

cryptomarket/dataclasses/order.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Order:
2020
created_at: str
2121
updated_at: str
2222
price: Optional[str] = None
23+
price_average: Optional[str] = None
2324
expire_time: Optional[str] = None
2425
stop_price: Optional[str] = None
2526
post_only: Optional[bool] = None

tests/websockets/test_helpers.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import time
22
from dataclasses import asdict
3-
from typing import Any, Dict, List
3+
from typing import Any, Callable, Dict, List
44

55
from cryptomarket.dataclasses import (Balance, OrderBookLevel, Report,
66
WSCandle, WSMiniTicker, WSOrderBook,
77
WSOrderBookTop, WSPublicTrade, WSTicker,
88
WSTrade)
9+
from cryptomarket.dataclasses.commission import Commission
910
from cryptomarket.dataclasses.wsPriceRate import WSPriceRate
10-
from tests.rest.test_helpers import good_list
11+
12+
13+
def good_list(check_fn: Callable[[Any], bool], list: List[Any]) -> bool:
14+
for elem in list:
15+
if not check_fn(elem):
16+
print(elem)
17+
return False
18+
return True
1119

1220

1321
def defined(a_dict, key):
@@ -19,6 +27,28 @@ def defined(a_dict, key):
1927
return True
2028

2129

30+
def good_balance(balance: Balance) -> bool:
31+
return good_dict(
32+
asdict(balance),
33+
[
34+
"currency",
35+
"available",
36+
"reserved",
37+
]
38+
)
39+
40+
41+
def good_trading_commission(commission: Commission) -> bool:
42+
return good_dict(
43+
asdict(commission),
44+
[
45+
"symbol",
46+
"take_rate",
47+
"make_rate",
48+
]
49+
)
50+
51+
2252
def good_dict(a_dict: Dict[str, Any], fields: List[str]) -> bool:
2353
if not isinstance(a_dict, dict):
2454
return False

tests/websockets/test_market_data_subs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
WSOrderBookTop, WSTicker, WSTrade)
88
from cryptomarket.dataclasses.wsPriceRate import WSPriceRate
99
from cryptomarket.websockets import MarketDataClient
10-
from tests.rest.test_helpers import good_list
11-
from tests.websockets.test_helpers import Veredict, good_candle_list, good_mini_ticker, good_orderbook_top, good_price_rate, good_wsorder_book, good_wsticker, good_wstrade
10+
from test_helpers import *
1211

1312
SECOND = 1
1413
MINUTE = 60

tests/websockets/test_trading_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from test_helpers import *
88

99
from cryptomarket.websockets import TradingClient
10-
from tests.rest.test_helpers import good_balance, good_trading_commission
1110

1211
with open('/home/ismael/cryptomarket/keys.json') as fd:
1312
keys = json.load(fd)

0 commit comments

Comments
 (0)