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:
parent
117f4d60b2
commit
003a0024a0
@ -1,2 +1,2 @@
|
|||||||
__version__ = '0.3.4'
|
__version__ = '0.3.5'
|
||||||
__release__ = __version__
|
__release__ = __version__
|
@ -48,26 +48,33 @@ class Tradeking1mTimesales(MongoCreateTask):
|
|||||||
interval=timedelta(minutes=1)
|
interval=timedelta(minutes=1)
|
||||||
)
|
)
|
||||||
if did_acquire:
|
if did_acquire:
|
||||||
json_data = tradeking.api_request('market/timesales', {
|
response = tradeking.api_request('market/timesales', {
|
||||||
'symbols': symbol,
|
'symbols': symbol,
|
||||||
'interval': '1min',
|
'interval': '1min',
|
||||||
'startdate': present.strftime('%Y-%m-%d'),
|
'startdate': present.strftime('%Y-%m-%d'),
|
||||||
'enddate': present.strftime('%Y-%m-%d')
|
'enddate': present.strftime('%Y-%m-%d')
|
||||||
}).json()
|
})
|
||||||
|
json_data = response.json()
|
||||||
|
|
||||||
quotes = json_data['response']['quotes']['quote']
|
quotes = json_data['response']['quotes']['quote']
|
||||||
|
|
||||||
def format_quote(quote):
|
def format_quote(quote):
|
||||||
return {
|
if quote == '':
|
||||||
'last': float(quote['last']),
|
logging.warning('Empty quote for symbol {}'.format(symbol))
|
||||||
'lo': float(quote['lo']),
|
return {}
|
||||||
'vl': int(quote['vl']),
|
else:
|
||||||
'datetime': parse(quote['datetime']),
|
return {
|
||||||
'incr_vl': int(quote['incr_vl']),
|
'last': float(quote['last']),
|
||||||
'hi': float(quote['hi']),
|
'lo': float(quote['lo']),
|
||||||
'timestamp': parse(quote['timestamp']),
|
'vl': int(quote['vl']),
|
||||||
'date': parse(quote['date']),
|
'datetime': parse(quote['datetime']),
|
||||||
'opn': float(quote['opn'])
|
'incr_vl': int(quote['incr_vl']),
|
||||||
}
|
'hi': float(quote['hi']),
|
||||||
|
'timestamp': parse(quote['timestamp']),
|
||||||
|
'date': parse(quote['date']),
|
||||||
|
'opn': float(quote['opn'])
|
||||||
|
}
|
||||||
|
|
||||||
quotes_typed = [format_quote(q) for q in quotes]
|
quotes_typed = [format_quote(q) for q in quotes]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user