# Index our market information by market string
common = self.api.get("/v1/common")
self.currencies_map = {c['code']: c for c in common['currencies']}
# Set some convenience keys so we can pass around just the dict
for m in common['markets']:
m['string'] = "{market_currency}_{base_currency}".format(**m)
m['base_currency'] = self.currencies_map[m['base_currency']]
self.market_map = {m['string']: m for m in common['markets']}
Can be done as lazy loader
@property
def currency_obj(self):
self._refresh_config()
return self._currency_config
def _refresh_config(self):
""" Lazy load and reload every 180 seconds """
if self._currency_config is None or (time.time() - self._currency_config_age) > 180:
try:
currency = self.qtrade.get("/internal/v1/relay/currency/{}".format(self.cfg.Currency))
except APIException as e:
if e.code == 500:
raise Exception("No remote currency configuration present")
else:
raise
self.log.info("Loaded currency config {}".format(currency))
self._currency_config = currency
self._currency_config_age = time.time()
# TODO: Do some sanity checking on the returned config. Proceeding
# with incomplete confis can cause issues
Balances_all method
Balanced merged method
cancel all orders helper method
Market/Currency class data wrappers
Increase flexability to placeing orders with order helper function
Can be done as lazy loader