Take that QT nulls

kivy_mainline_and_py3.8
Tyler Goodlet 2018-06-12 15:33:11 -04:00
parent 623291cc69
commit fa0aefff4d
1 changed files with 3 additions and 2 deletions

View File

@ -394,12 +394,13 @@ def format_quote(
previous = symbol_data[symbol]['prevDayClosePrice'] previous = symbol_data[symbol]['prevDayClosePrice']
change = percent_change(previous, last) change = percent_change(previous, last)
share_count = symbol_data[symbol].get('outstandingShares', None) share_count = symbol_data[symbol].get('outstandingShares', None)
mktcap = share_count * last if share_count else 'NA' mktcap = share_count * last if (last and share_count) else 'NA'
computed = { computed = {
'symbol': quote['symbol'], 'symbol': quote['symbol'],
'%': round(change, 3), '%': round(change, 3),
'mktcap': mktcap, 'mktcap': mktcap,
'$ vol': round(quote['VWAP'] * quote['volume'], 3), # why QT do you have to be an asshole shipping null values!!!
'$ vol': round((quote['VWAP'] or 0) * (quote['volume'] or 0), 3),
'close': previous, 'close': previous,
} }
new = {} new = {}