Coverage for django_napse/utils/constants.py: 98%
65 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from enum import EnumMeta, StrEnum
4class CustomEnumMeta(EnumMeta):
5 """Custom EnumMeta class to allow string comparison for Enums."""
7 def __contains__(cls, obj):
8 """Check if obj is a str in Enum's value or if it's an Enum in Enum's members."""
9 if isinstance(obj, str):
10 return any(obj == item for item in cls)
11 return super().__contains__(obj)
13 def __iter__(cls):
14 """Allow to iterate over the Enum's values."""
15 return (cls._member_map_[name].value for name in cls._member_names_)
17 def __str__(cls) -> str:
18 """Return the Enum's value."""
19 return f"{[cls._member_map_[name].value for name in cls._member_names_]}"
22class EXCHANGES(StrEnum, metaclass=CustomEnumMeta):
23 """The exchange for a fleet or a bot."""
25 BINANCE = "BINANCE"
28class TRANSACTION_TYPES(StrEnum, metaclass=CustomEnumMeta):
29 TRANSFER = "TRANSFER"
30 CONNECTION_DEPOSIT = "CONNECTION_DEPOSIT"
31 CONNECTION_WITHDRAW = "CONNECTION_WITHDRAW"
32 ORDER_DEPOSIT = "ORDER_DEPOSIT"
33 ORDER_PAYOUT = "ORDER_PAYOUT"
34 ORDER_REFUND = "ORDER_REFUND"
35 FLEET_REBALANCE = "FLEET_REBALANCE"
38class ORDER_STATUS(StrEnum, metaclass=CustomEnumMeta):
39 PENDING = "PENDING"
40 READY = "READY"
41 PASSED = "PASSED"
42 ONLY_BUY_PASSED = "ONLY_BUY_PASSED"
43 ONLY_SELL_PASSED = "ONLY_SELL_PASSED"
44 FAILED = "FAILED"
47class SIDES(StrEnum, metaclass=CustomEnumMeta):
48 BUY = "BUY"
49 SELL = "SELL"
50 KEEP = "KEEP"
53class DOWNLOAD_STATUS(StrEnum, metaclass=CustomEnumMeta):
54 IDLE = "IDLE"
55 DOWNLOADING = "DOWNLOADING"
58class SIMULATION_STATUS(StrEnum, metaclass=CustomEnumMeta):
59 IDLE = "IDLE"
60 RUNNING = "RUNNING"
63class MODIFICATION_STATUS(StrEnum, metaclass=CustomEnumMeta):
64 PENDING = "PENDING"
65 APPLIED = "APPLIED"
66 REJECTED = "REJECTED"
69class PLUGIN_CATEGORIES(StrEnum, metaclass=CustomEnumMeta):
70 """The category for a plugin."""
72 PRE_ORDER = "PRE_ORDER"
73 POST_ORDER = "POST_ORDER"
76class PERMISSION_TYPES(StrEnum, metaclass=CustomEnumMeta):
77 """The permission type for a key."""
79 ADMIN = "ADMIN"
80 FULL_ACCESS = "FULL_ACCESS"
81 READ_ONLY = "READ_ONLY"
84class HISTORY_DATAPOINT_FIELDS(StrEnum, metaclass=CustomEnumMeta):
85 """The different fields for a history data point."""
87 AMOUNT = "AMOUNT"
88 ASSET = "ASSET"
89 PRICE = "PRICE"
90 MBP = "MBP"
91 LBO = "LBO"
92 VALUE = "VALUE"
95ORDER_LEEWAY_PERCENTAGE = 10
97DEFAULT_TAX = {
98 "BINANCE": 0.1,
99}
101EXCHANGE_TICKERS = {
102 "BINANCE": ["BTC", "ETH", "USDT", "BNB", "XRP", "ADA", "DOGE", "MATIC", "SOL", "DOT", "LTC", "TRX", "SHIB", "AVAX", "LINK", "ATOM", "UNI", "XLM"],
103}
104EXCHANGE_PAIRS = {
105 "BINANCE": {ticker + "USDT": {"base": ticker, "quote": "USDT"} for ticker in EXCHANGE_TICKERS["BINANCE"] if ticker != "USDT"},
106}
107EXCHANGE_INTERVALS = {
108 "BINANCE": ("1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M"),
109}
110EXCHANGE_TESTING = {
111 "BINANCE": [True],
112}
113EXCHANGE_SIMULATION = {
114 "BINANCE": True,
115}
117STABLECOINS = {
118 "BINANCE": ["USDT", "DAI", "BUSD"],
119}
121EXCHANGE_CONSTANTS = {
122 "EXCHANGES": list(EXCHANGES),
123 "EXCHANGE_TICKERS": EXCHANGE_TICKERS,
124 "EXCHANGE_PAIRS": EXCHANGE_PAIRS,
125 "EXCHANGE_INTERVALS": EXCHANGE_INTERVALS,
126 "EXCHANGE_TESTING": EXCHANGE_TESTING,
127 "EXCHANGE_SIMULATION": EXCHANGE_SIMULATION,
128 "STABLECOINS": STABLECOINS,
129}
132MONTH_NUM_TO_STR = {
133 1: "Jan",
134 2: "Feb",
135 3: "Mar",
136 4: "Apr",
137 5: "May",
138 6: "Jun",
139 7: "Jul",
140 8: "Aug",
141 9: "Sep",
142 10: "Oct",
143 11: "Nov",
144 12: "Dec",
145}