-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodels.py
More file actions
57 lines (48 loc) · 2.18 KB
/
models.py
File metadata and controls
57 lines (48 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Balance:
def __init__(self, info):
self.initial_margin = float(info['initialMargin'])
self.maintenance_margin = float(info['maintMargin'])
self.margin_balance = float(info['marginBalance'])
self.wallet_balance = float(info['walletBalance'])
self.unrealized_pnl = float(info['unrealizedProfit'])
class Candle:
def __init__(self, candle_info, timeframe, exchange):
if exchange == "binance":
self.timestamp = candle_info[0]
self.open = float(candle_info[1])
self.high = float(candle_info[2])
self.low = float(candle_info[3])
self.close = float(candle_info[4])
self.volume = float(candle_info[5])
elif exchange == "parse_trade":
self.timestamp = candle_info['ts']
self.open = candle_info['open']
self.high = candle_info['high']
self.low = candle_info['low']
self.close = candle_info['close']
self.volume = candle_info['volume']
class Contracts:
def __init__(self, contract_info):
self.symbol = contract_info['symbol']
self.base_asset = contract_info['baseAsset']
self.quote_asset = contract_info['quoteAsset']
self.price_decimals = contract_info['pricePrecision']
self.quantity_decimals = contract_info['quantityPrecision']
self.tick_size = 1 / pow(10, contract_info['pricePrecision'])
self.lot_size = 1 / pow(10, contract_info['quantityPrecision'])
class OrderStatus:
def __init__(self, order_info):
self.order_id = order_info['orderId']
self.status = order_info['status'].lower()
self.avg_price = float(order_info['avgPrice'])
class Trade:
def __init__(self, trade_info):
self.time: int = trade_info['time']
self.contract: Contracts = trade_info['contract']
self.strategy: str = trade_info['strategy']
self.side: str = trade_info['side']
self.entry_price: float = trade_info['entry_price']
self.status: str = trade_info['status']
self.pnl: float = trade_info['pnl']
self.quantity = trade_info['quantity']
self.entry_id = trade_info['entry_id']