Make monitor handle non-full quote messages
parent
d66cfb8fa0
commit
3cfb15ed6e
|
@ -51,23 +51,25 @@ async def update_quotes(
|
||||||
chngcell = row.get_cell('%')
|
chngcell = row.get_cell('%')
|
||||||
|
|
||||||
# determine daily change color
|
# determine daily change color
|
||||||
color = colorcode('gray')
|
|
||||||
percent_change = record.get('%')
|
percent_change = record.get('%')
|
||||||
if percent_change:
|
if percent_change is not None and percent_change != chngcell:
|
||||||
daychange = float(record['%'])
|
daychange = float(percent_change)
|
||||||
if daychange < 0.:
|
if daychange < 0.:
|
||||||
color = colorcode('red2')
|
color = colorcode('red2')
|
||||||
elif daychange > 0.:
|
elif daychange > 0.:
|
||||||
color = colorcode('forestgreen')
|
color = colorcode('forestgreen')
|
||||||
|
else:
|
||||||
|
color = colorcode('gray')
|
||||||
|
|
||||||
# update row header and '%' cell text color
|
|
||||||
if chngcell:
|
|
||||||
chngcell.color = color
|
|
||||||
hdrcell.color = color
|
|
||||||
# if the cell has been "highlighted" make sure to change its color
|
# if the cell has been "highlighted" make sure to change its color
|
||||||
if hdrcell.background_color != [0]*4:
|
if hdrcell.background_color != [0]*4:
|
||||||
hdrcell.background_color = color
|
hdrcell.background_color = color
|
||||||
|
|
||||||
|
# update row header and '%' cell text color
|
||||||
|
chngcell.color = color
|
||||||
|
hdrcell.color = color
|
||||||
|
|
||||||
|
|
||||||
# briefly highlight bg of certain cells on each trade execution
|
# briefly highlight bg of certain cells on each trade execution
|
||||||
unflash = set()
|
unflash = set()
|
||||||
tick_color = None
|
tick_color = None
|
||||||
|
@ -123,10 +125,13 @@ async def update_quotes(
|
||||||
record, displayable = formatter(
|
record, displayable = formatter(
|
||||||
quote, symbol_data=symbol_data)
|
quote, symbol_data=symbol_data)
|
||||||
|
|
||||||
|
# don't red/green the header cell in ``row.update()``
|
||||||
|
record.pop('symbol')
|
||||||
|
|
||||||
# determine if sorting should happen
|
# determine if sorting should happen
|
||||||
sort_key = table.sort_key
|
sort_key = table.sort_key
|
||||||
new = record[sort_key]
|
|
||||||
last = row.get_field(sort_key)
|
last = row.get_field(sort_key)
|
||||||
|
new = record.get(sort_key, last)
|
||||||
if new != last:
|
if new != last:
|
||||||
to_sort.add(row.widget)
|
to_sort.add(row.widget)
|
||||||
|
|
||||||
|
|
|
@ -340,6 +340,7 @@ class Row(HoverBehavior, GridLayout):
|
||||||
gray = colorcode('gray')
|
gray = colorcode('gray')
|
||||||
fgreen = colorcode('forestgreen')
|
fgreen = colorcode('forestgreen')
|
||||||
red = colorcode('red2')
|
red = colorcode('red2')
|
||||||
|
|
||||||
for key, val in record.items():
|
for key, val in record.items():
|
||||||
last = self.get_field(key)
|
last = self.get_field(key)
|
||||||
color = gray
|
color = gray
|
||||||
|
@ -361,7 +362,7 @@ class Row(HoverBehavior, GridLayout):
|
||||||
if color != gray:
|
if color != gray:
|
||||||
cells[key] = cell
|
cells[key] = cell
|
||||||
|
|
||||||
self._last_record = record
|
self._last_record.update(record)
|
||||||
return cells
|
return cells
|
||||||
|
|
||||||
# mouse over handlers
|
# mouse over handlers
|
||||||
|
|
Loading…
Reference in New Issue