Add some notes about using multi-ine strings instead of `print()`s
parent
289b63bb2a
commit
cdb41e4881
|
@ -18,6 +18,8 @@ import pyqtgraph as pg
|
||||||
from PyQt6 import QtCore
|
from PyQt6 import QtCore
|
||||||
from pyqtgraph import ScatterPlotItem, InfiniteLine
|
from pyqtgraph import ScatterPlotItem, InfiniteLine
|
||||||
from PyQt6.QtWidgets import QApplication
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
# XXX, use 2 newlines between top level LOC (even between these
|
||||||
|
# imports and the next function line ;)
|
||||||
|
|
||||||
def check_if_complete(
|
def check_if_complete(
|
||||||
oi: dict[str, dict[str, Decimal | None]]
|
oi: dict[str, dict[str, Decimal | None]]
|
||||||
|
@ -50,6 +52,7 @@ async def max_pain_daemon(
|
||||||
expiry_date = input('Please enter a valid expiration date: ').upper()
|
expiry_date = input('Please enter a valid expiration date: ').upper()
|
||||||
print('Starting little daemon...')
|
print('Starting little daemon...')
|
||||||
|
|
||||||
|
# maybe move this type annot down to the assignment line?
|
||||||
oi_by_strikes: dict[str, dict[str, Decimal]]
|
oi_by_strikes: dict[str, dict[str, Decimal]]
|
||||||
instruments = await client.get_instruments(
|
instruments = await client.get_instruments(
|
||||||
expiry_date=expiry_date,
|
expiry_date=expiry_date,
|
||||||
|
@ -260,6 +263,28 @@ async def max_pain_daemon(
|
||||||
# graph here
|
# graph here
|
||||||
plot_graph(oi_by_strikes, plot)
|
plot_graph(oi_by_strikes, plot)
|
||||||
|
|
||||||
|
# TODO, use a single multiline string with `()`
|
||||||
|
# and drop the multiple `print()` calls (this
|
||||||
|
# should be done elsewhere in this file as well!
|
||||||
|
#
|
||||||
|
# As per the docs,
|
||||||
|
# https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation
|
||||||
|
# you could instead do,
|
||||||
|
# print(
|
||||||
|
# '-----------------------------------------------\n'
|
||||||
|
# f'timestamp: {datetime.fromtimestamp(max_pain['timestamp'])}\n'
|
||||||
|
# )
|
||||||
|
# WHY?
|
||||||
|
# |_ less ctx-switches/calls to `print()`
|
||||||
|
# |_ the `str` can then be modified / passed
|
||||||
|
# around as a variable more easily if needed in
|
||||||
|
# the future ;)
|
||||||
|
#
|
||||||
|
# ALSO, i believe there already is a stdlib
|
||||||
|
# module to do "alignment" of text which you
|
||||||
|
# could try for doing the right-side alignment,
|
||||||
|
# https://docs.python.org/3/library/textwrap.html#textwrap.indent
|
||||||
|
#
|
||||||
print('-----------------------------------------------')
|
print('-----------------------------------------------')
|
||||||
print(f'timestamp: {datetime.fromtimestamp(max_pain['timestamp'])}')
|
print(f'timestamp: {datetime.fromtimestamp(max_pain['timestamp'])}')
|
||||||
print(f'expiry_date: {max_pain['expiry_date']}')
|
print(f'expiry_date: {max_pain['expiry_date']}')
|
||||||
|
|
Loading…
Reference in New Issue