forked from edeng23/binance-trade-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
68 lines (57 loc) · 2.73 KB
/
config.py
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
58
59
60
61
62
63
64
65
66
67
68
# Config consts
import configparser
import os
from .models import Coin
CFG_FL_NAME = "user.cfg"
USER_CFG_SECTION = "binance_user_config"
class Config: # pylint: disable=too-few-public-methods
def __init__(self):
# Init config
config = configparser.ConfigParser()
config["DEFAULT"] = {
"bridge": "USDT",
"scout_transaction_fee": "0.001",
"scout_multiplier": "5",
"scout_sleep_time": "5",
"hourToKeepScoutHistory": "1",
"tld": "com",
}
if not os.path.exists(CFG_FL_NAME):
print("No configuration file (user.cfg) found! See README. Assuming default config...")
config[USER_CFG_SECTION] = {}
else:
config.read(CFG_FL_NAME)
self.BRIDGE_SYMBOL = os.environ.get("BRIDGE_SYMBOL") or config.get(USER_CFG_SECTION, "bridge")
self.BRIDGE = Coin(self.BRIDGE_SYMBOL, False)
# Prune settings
self.SCOUT_HISTORY_PRUNE_TIME = float(
os.environ.get("HOURS_TO_KEEP_SCOUTING_HISTORY") or config.get(USER_CFG_SECTION, "hourToKeepScoutHistory")
)
# Get config for scout
self.SCOUT_TRANSACTION_FEE = float(
os.environ.get("SCOUT_TRANSACTION_FEE") or config.get(USER_CFG_SECTION, "scout_transaction_fee")
)
self.SCOUT_MULTIPLIER = float(
os.environ.get("SCOUT_MULTIPLIER") or config.get(USER_CFG_SECTION, "scout_multiplier")
)
self.SCOUT_SLEEP_TIME = int(
os.environ.get("SCOUT_SLEEP_TIME") or config.get(USER_CFG_SECTION, "scout_sleep_time")
)
# Get config for binance
self.BINANCE_API_KEY = os.environ.get("API_KEY") or config.get(USER_CFG_SECTION, "api_key")
self.BINANCE_API_SECRET_KEY = os.environ.get("API_SECRET_KEY") or config.get(USER_CFG_SECTION, "api_secret_key")
self.BINANCE_TLD = os.environ.get("TLD") or config.get(USER_CFG_SECTION, "tld")
# Get supported coin list from the environment
supported_coin_list = [
coin.strip() for coin in os.environ.get("SUPPORTED_COIN_LIST", "").split() if coin.strip()
]
# Get supported coin list from supported_coin_list file
if not supported_coin_list and os.path.exists("supported_coin_list"):
with open("supported_coin_list") as rfh:
for line in rfh:
line = line.strip()
if not line or line.startswith("#") or line in supported_coin_list:
continue
supported_coin_list.append(line)
self.SUPPORTED_COIN_LIST = supported_coin_list
self.CURRENT_COIN_SYMBOL = os.environ.get("CURRENT_COIN_SYMBOL") or config.get(USER_CFG_SECTION, "current_coin")