From fa0aefff4dfaab158cf0aa8d92fa2c117a3c79f3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 12 Jun 2018 15:33:11 -0400 Subject: [PATCH] Take that QT nulls --- piker/brokers/questrade.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index feea6396..5662b812 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -394,12 +394,13 @@ def format_quote( previous = symbol_data[symbol]['prevDayClosePrice'] change = percent_change(previous, last) 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 = { 'symbol': quote['symbol'], '%': round(change, 3), '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, } new = {}