ccxt: market summaries

This commit is contained in:
Samuel Husso 2018-02-08 07:46:23 +02:00
parent 5da034c313
commit d3038d155b
2 changed files with 14 additions and 5 deletions

View File

@ -149,6 +149,7 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict:
@cached(TTLCache(maxsize=100, ttl=30))
def get_ticker_history(pair: str, tick_interval) -> List[Dict]:
## implement https://github.com/ccxt/ccxt/blob/master/python/ccxt/bittrex.py#L394-L400
return _API.get_ticker_history(pair, tick_interval)
@ -179,7 +180,13 @@ def get_markets() -> List[str]:
def get_market_summaries() -> List[Dict]:
return _API.public_get_marketsummaries()['result']
# TODO: check other exchanges how they implement market summaries
summaries = _API.public_get_marketsummaries()['result']
for market in summaries:
name = market['MarketName'].split('-')
market['MarketName'] = name[-1] + '/' + name[0]
return summaries
def get_name() -> str:

View File

@ -35,8 +35,9 @@ def refresh_whitelist(whitelist: List[str]) -> List[str]:
sanitized_whitelist = whitelist
health = exchange.get_wallet_health()
known_pairs = set()
for status in health:
pair = '{}_{}'.format(_CONF['stake_currency'], status['Currency'])
pair = '{}/{}'.format(status['Currency'], _CONF['stake_currency'])
# pair is not int the generated dynamic market, or in the blacklist ... ignore it
if pair not in whitelist or pair in _CONF['exchange'].get('pair_blacklist', []):
continue
@ -374,7 +375,10 @@ def create_trade(stake_amount: float, interval: int) -> bool:
'Checking buy signals to create a new trade with stake_amount: %f ...',
stake_amount
)
whitelist = copy.deepcopy(_CONF['exchange']['pair_whitelist'])
print('*******whitelist {}*****'.format(whitelist))
# Check if stake_amount is fulfilled
if exchange.get_balance(_CONF['stake_currency']) < stake_amount:
raise DependencyException(
@ -466,14 +470,12 @@ def gen_pair_whitelist(base_currency: str, key: str = 'BaseVolume') -> List[str]
:param key: sort key (defaults to 'BaseVolume')
:return: List of pairs
"""
summaries = sorted(
(s for s in exchange.get_market_summaries() if s['MarketName'].endswith(base_currency)),
key=lambda s: s.get(key) or 0.0,
reverse=True
)
return [s['MarketName'].replace('-', '_') for s in summaries]
return [s['MarketName'] for s in summaries]
def cleanup() -> None: