forked from chrisacheson/liquidbot
-
Notifications
You must be signed in to change notification settings - Fork 763
/
settings.py
43 lines (35 loc) · 1.17 KB
/
settings.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
from __future__ import absolute_import
import importlib
import os
import sys
from market_maker.utils.dotdict import dotdict
import market_maker._settings_base as baseSettings
def import_path(fullpath):
"""
Import a file with full path specification. Allows one to
import from anywhere, something __import__ does not do.
"""
path, filename = os.path.split(fullpath)
filename, ext = os.path.splitext(filename)
sys.path.insert(0, path)
module = importlib.import_module(filename, path)
importlib.reload(module) # Might be out of date
del sys.path[0]
return module
userSettings = import_path(os.path.join('.', 'settings'))
symbolSettings = None
symbol = sys.argv[1] if len(sys.argv) > 1 else None
if symbol:
print("Importing symbol settings for %s..." % symbol)
try:
symbolSettings = import_path(os.path.join('..', 'settings-%s' % symbol))
except Exception as e:
print("Unable to find settings-%s.py." % symbol)
# Assemble settings.
settings = {}
settings.update(vars(baseSettings))
settings.update(vars(userSettings))
if symbolSettings:
settings.update(vars(symbolSettings))
# Main export
settings = dotdict(settings)