Skip to content

Commit

Permalink
Merge pull request waditu#680 from MetalworkColossus/patch-2
Browse files Browse the repository at this point in the history
Update domestic.py
  • Loading branch information
jimmysoa authored Jun 27, 2018
2 parents 73c49f9 + 12f73ea commit faa7719
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tushare/futures/domestic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,17 @@ def get_cffex_daily(date = None):
row_dict = {'date': day_const, 'symbol': row[0], 'variety': m.group(1)}

for i,field in enumerate(ct.CFFEX_COLUMNS):
if row[i+1] == u"":
row_dict[field] = 0.0
elif field in ['volume', 'open_interest', 'oi_chg']:
row_dict[field] = int(row[i+1])
else:
row_dict[field] = float(row[i+1])
## some data was missing in the csv files. e.g. 2018-01-19
## using error handle to avoid crushing
try:
if row[i+1] == u"":
row_dict[field] = 0.0
elif field in ['volume', 'open_interest', 'oi_chg']:
row_dict[field] = int(row[i+1])
else:
row_dict[field] = float(row[i+1])
except Exception:
row_dict[field] = None
row_dict['pre_settle'] = row_dict['close'] - row_dict['change1']
dict_data.append(row_dict)

Expand Down

0 comments on commit faa7719

Please sign in to comment.