1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-23 07:38:09 -05:00

Handle empty quotes in Tradeking

This commit is contained in:
Bradlee Speice 2016-08-25 17:47:36 -04:00
parent 117f4d60b2
commit 003a0024a0
2 changed files with 21 additions and 14 deletions

View File

@ -1,2 +1,2 @@
__version__ = '0.3.4'
__version__ = '0.3.5'
__release__ = __version__

View File

@ -48,15 +48,21 @@ class Tradeking1mTimesales(MongoCreateTask):
interval=timedelta(minutes=1)
)
if did_acquire:
json_data = tradeking.api_request('market/timesales', {
response = tradeking.api_request('market/timesales', {
'symbols': symbol,
'interval': '1min',
'startdate': present.strftime('%Y-%m-%d'),
'enddate': present.strftime('%Y-%m-%d')
}).json()
})
json_data = response.json()
quotes = json_data['response']['quotes']['quote']
def format_quote(quote):
if quote == '':
logging.warning('Empty quote for symbol {}'.format(symbol))
return {}
else:
return {
'last': float(quote['last']),
'lo': float(quote['lo']),
@ -68,6 +74,7 @@ class Tradeking1mTimesales(MongoCreateTask):
'date': parse(quote['date']),
'opn': float(quote['opn'])
}
quotes_typed = [format_quote(q) for q in quotes]
return {