Skip to content

Commit 4589e84

Browse files
committed
minor bot update, update tests
1 parent 9b33ce7 commit 4589e84

File tree

4 files changed

+81
-166
lines changed

4 files changed

+81
-166
lines changed

src/three_commas/model/generated_models.py

-64
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ class IndexEntity(ThreeCommasModel):
99
total: int
1010
page: int
1111

12-
def parsed(self, parsed: bool) -> IndexEntity:
13-
return ParsedProxy(model=self, parsed=parsed)
14-
1512
_parse_map = {
1613
}
17-
1814
_name_proxy = {
1915
}
2016

@@ -31,12 +27,8 @@ class MarketplaceBotEntity(ThreeCommasModel):
3127
copies: int
3228
is_favorite: bool
3329

34-
def parsed(self, parsed: bool) -> MarketplaceBotEntity:
35-
return ParsedProxy(model=self, parsed=parsed)
36-
3730
_parse_map = {
3831
}
39-
4032
_name_proxy = {
4133
}
4234

@@ -46,12 +38,8 @@ class MarketplaceItem(ThreeCommasModel):
4638
name: str
4739
icon_url: str
4840

49-
def parsed(self, parsed: bool) -> MarketplaceItem:
50-
return ParsedProxy(model=self, parsed=parsed)
51-
5241
_parse_map = {
5342
}
54-
5543
_name_proxy = {
5644
}
5745

@@ -61,38 +49,26 @@ class Profit(ThreeCommasModel):
6149
amount: float
6250
chart_data: list
6351

64-
def parsed(self, parsed: bool) -> Profit:
65-
return ParsedProxy(model=self, parsed=parsed)
66-
6752
_parse_map = {
6853
}
69-
7054
_name_proxy = {
7155
}
7256

7357

7458
class PongEntity(ThreeCommasModel):
7559
pong: str
7660

77-
def parsed(self, parsed: bool) -> PongEntity:
78-
return ParsedProxy(model=self, parsed=parsed)
79-
8061
_parse_map = {
8162
}
82-
8363
_name_proxy = {
8464
}
8565

8666

8767
class TimeEntity(ThreeCommasModel):
8868
server_time: int
8969

90-
def parsed(self, parsed: bool) -> TimeEntity:
91-
return ParsedProxy(model=self, parsed=parsed)
92-
9370
_parse_map = {
9471
}
95-
9672
_name_proxy = {
9773
}
9874

@@ -150,9 +126,6 @@ class BotEntity(ThreeCommasModel):
150126
start_order_type: str
151127
active_deals_usd_profit: Union[str, float]
152128

153-
def parsed(self, parsed: bool) -> BotEntity:
154-
return ParsedProxy(model=self, parsed=parsed)
155-
156129
_parse_map = {
157130
'created_at': DatetimeParser,
158131
'updated_at': DatetimeParser,
@@ -170,7 +143,6 @@ def parsed(self, parsed: bool) -> BotEntity:
170143
'finished_deals_count': IntParser,
171144
'active_deals_usd_profit': FloatParser,
172145
}
173-
174146
_name_proxy = {
175147
'deletable': 'deletable?',
176148
}
@@ -230,9 +202,6 @@ class AccountEntity(ThreeCommasModel):
230202
market_code: str
231203
address: str
232204

233-
def parsed(self, parsed: bool) -> AccountEntity:
234-
return ParsedProxy(model=self, parsed=parsed)
235-
236205
_parse_map = {
237206
'created_at': DatetimeParser,
238207
'updated_at': DatetimeParser,
@@ -249,7 +218,6 @@ def parsed(self, parsed: bool) -> AccountEntity:
249218
'total_btc_profit': FloatParser,
250219
'total_usd_profit': FloatParser,
251220
}
252-
253221
_name_proxy = {
254222
}
255223

@@ -283,12 +251,8 @@ class GridBotEntity(ThreeCommasModel):
283251
investment_quote_currency: str
284252
grid_lines: None
285253

286-
def parsed(self, parsed: bool) -> GridBotEntity:
287-
return ParsedProxy(model=self, parsed=parsed)
288-
289254
_parse_map = {
290255
}
291-
292256
_name_proxy = {
293257
}
294258

@@ -298,12 +262,8 @@ class GridLineEntity(ThreeCommasModel):
298262
side: str
299263
order_placed: bool
300264

301-
def parsed(self, parsed: bool) -> GridLineEntity:
302-
return ParsedProxy(model=self, parsed=parsed)
303-
304265
_parse_map = {
305266
}
306-
307267
_name_proxy = {
308268
}
309269

@@ -314,12 +274,8 @@ class GridBotProfitsEntity(ThreeCommasModel):
314274
usd_profit: str
315275
created_at: str
316276

317-
def parsed(self, parsed: bool) -> GridBotProfitsEntity:
318-
return ParsedProxy(model=self, parsed=parsed)
319-
320277
_parse_map = {
321278
}
322-
323279
_name_proxy = {
324280
}
325281

@@ -398,9 +354,6 @@ class DealEntity(ThreeCommasModel):
398354
reserved_quote_funds: Union[float, float]
399355
reserved_base_funds: float
400356

401-
def parsed(self, parsed: bool) -> DealEntity:
402-
return ParsedProxy(model=self, parsed=parsed)
403-
404357
_parse_map = {
405358
'created_at': DatetimeParser,
406359
'updated_at': DatetimeParser,
@@ -434,7 +387,6 @@ def parsed(self, parsed: bool) -> DealEntity:
434387
'trailing_max_price': FloatParser,
435388
'reserved_quote_funds': FloatParser,
436389
}
437-
438390
_name_proxy = {
439391
'finished': 'finished?',
440392
'cancellable': 'cancellable?',
@@ -460,12 +412,8 @@ class SmartTradeV2Entity(ThreeCommasModel):
460412
margin: dict
461413
is_position_not_filled: bool
462414

463-
def parsed(self, parsed: bool) -> SmartTradeV2Entity:
464-
return ParsedProxy(model=self, parsed=parsed)
465-
466415
_parse_map = {
467416
}
468-
469417
_name_proxy = {
470418
}
471419

@@ -488,12 +436,8 @@ class TakeProfitStep(ThreeCommasModel):
488436
margin: dict
489437
is_position_not_filled: bool
490438

491-
def parsed(self, parsed: bool) -> TakeProfitStep:
492-
return ParsedProxy(model=self, parsed=parsed)
493-
494439
_parse_map = {
495440
}
496-
497441
_name_proxy = {
498442
}
499443

@@ -510,12 +454,8 @@ class BotDealsStatsEntity(ThreeCommasModel):
510454
active_deals_usd_profit: str
511455
active_deals_btc_profit: str
512456

513-
def parsed(self, parsed: bool) -> BotDealsStatsEntity:
514-
return ParsedProxy(model=self, parsed=parsed)
515-
516457
_parse_map = {
517458
}
518-
519459
_name_proxy = {
520460
}
521461

@@ -529,12 +469,8 @@ class LooseAccountEntity(ThreeCommasModel):
529469
is_deleted: bool
530470
is_locked: bool
531471

532-
def parsed(self, parsed: bool) -> LooseAccountEntity:
533-
return ParsedProxy(model=self, parsed=parsed)
534-
535472
_parse_map = {
536473
}
537-
538474
_name_proxy = {
539475
}
540476

src/three_commas/model/models.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,15 @@ def wrapper(*args, parsed: bool = True, **kwargs):
125125

126126

127127
class ThreeCommasDict(dict):
128-
def __init__(self, d: dict = None):
129-
if d is None:
128+
def __init__(self, *args, **kwargs):
129+
if not args and not kwargs or (args and args[0] is None):
130130
return
131-
super().__init__(d)
132-
133-
@classmethod
134-
def of(cls, d: dict) -> Union[None, cls]:
135-
if d is None:
136-
return None
137-
return cls(d)
131+
super().__init__(*args, **kwargs)
138132

139133
@classmethod
140134
def of_list(cls, list_of_d: List[dict]) -> List[cls]:
141135
if list_of_d is None:
142-
return None
136+
return list()
143137
return [cls(d) for d in list_of_d]
144138

145139
def __repr__(self):
@@ -176,6 +170,11 @@ def __setattr__(self, name, value):
176170
else:
177171
self[name] = value
178172

173+
TP = TypeVar('TP')
174+
175+
def parsed(self: TP, parsed: bool) -> TP:
176+
return ParsedProxy(model=self, parsed=parsed)
177+
179178

180179
class ParsedProxy:
181180
MODEL_KEY = '_model'

0 commit comments

Comments
 (0)