Drop old blessings code, general cleanups
parent
b7ddf9cb05
commit
f92c289842
|
@ -22,10 +22,8 @@ from typing import (
|
||||||
Any,
|
Any,
|
||||||
)
|
)
|
||||||
|
|
||||||
from rich import print
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
# from blessings import Terminal
|
|
||||||
import tractor
|
import tractor
|
||||||
import trio
|
import trio
|
||||||
import typer
|
import typer
|
||||||
|
@ -53,7 +51,6 @@ def broker_init(
|
||||||
the relevant `brokerd` service endpoint.
|
the relevant `brokerd` service endpoint.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# log.info(f'Spawning {brokername} broker daemon')
|
|
||||||
from ..brokers import get_brokermod
|
from ..brokers import get_brokermod
|
||||||
brokermod = get_brokermod(brokername)
|
brokermod = get_brokermod(brokername)
|
||||||
modpath = brokermod.__name__
|
modpath = brokermod.__name__
|
||||||
|
@ -95,8 +92,6 @@ def broker_init(
|
||||||
@ledger.command()
|
@ledger.command()
|
||||||
def sync(
|
def sync(
|
||||||
fully_qualified_account_name: str,
|
fully_qualified_account_name: str,
|
||||||
# brokername: str,
|
|
||||||
# account: str,
|
|
||||||
pdb: bool = False,
|
pdb: bool = False,
|
||||||
|
|
||||||
loglevel: str = typer.Option(
|
loglevel: str = typer.Option(
|
||||||
|
@ -119,7 +114,6 @@ def sync(
|
||||||
console.print(md)
|
console.print(md)
|
||||||
return
|
return
|
||||||
|
|
||||||
# term = Terminal()
|
|
||||||
start_kwargs, _, trades_ep = broker_init(
|
start_kwargs, _, trades_ep = broker_init(
|
||||||
brokername,
|
brokername,
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
|
@ -168,23 +162,12 @@ def sync(
|
||||||
(positions, accounts,),
|
(positions, accounts,),
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
# XXX: ``blessings`` lib syntax..
|
|
||||||
# summary: str = (
|
|
||||||
# term.dim('Position Summary ')
|
|
||||||
# + term.dim_blue_underline(f'{brokername}')
|
|
||||||
# + term.dim('.')
|
|
||||||
# + term.blue_underline(f'{account}')
|
|
||||||
# + term.dim(':\n')
|
|
||||||
# + term.dim('|-> total pps: ')
|
|
||||||
# + term.green(f'{len(positions)}\n')
|
|
||||||
# )
|
|
||||||
|
|
||||||
summary: str = (
|
summary: str = (
|
||||||
'[dim]PP Summary[/] '
|
'[dim underline]Piker Position Summary[/] '
|
||||||
f'[dim blue underline]{brokername}[/]'
|
f'[dim blue underline]{brokername}[/]'
|
||||||
'[dim].[/]'
|
'[dim].[/]'
|
||||||
f'[blue underline]{account}[/]'
|
f'[blue underline]{account}[/]'
|
||||||
f'[dim]:\n|-> total pps: [/]'
|
f'[dim underline] -> total pps: [/]'
|
||||||
f'[green]{len(positions)}[/]\n'
|
f'[green]{len(positions)}[/]\n'
|
||||||
)
|
)
|
||||||
for ppdict in positions:
|
for ppdict in positions:
|
||||||
|
@ -195,46 +178,23 @@ def sync(
|
||||||
ppmsg.avg_price,
|
ppmsg.avg_price,
|
||||||
ndigits=2,
|
ndigits=2,
|
||||||
)
|
)
|
||||||
cb: str = humanize(size * ppu)
|
cost_basis: str = humanize(size * ppu)
|
||||||
h_size: str = humanize(size)
|
h_size: str = humanize(size)
|
||||||
|
|
||||||
if size < 0:
|
if size < 0:
|
||||||
# pcolor = term.red
|
|
||||||
pcolor = 'red'
|
pcolor = 'red'
|
||||||
else:
|
else:
|
||||||
# pcolor = term.green
|
|
||||||
pcolor = 'green'
|
pcolor = 'green'
|
||||||
|
|
||||||
# sematic-highligh of fqme
|
# sematic-highlight of fqme
|
||||||
fqme = ppmsg.symbol
|
fqme = ppmsg.symbol
|
||||||
tokens = fqme.split('.')
|
tokens = fqme.split('.')
|
||||||
# styled_fqme = term.blue_underline(f'{tokens[0]}')
|
|
||||||
styled_fqme = f'[blue underline]{tokens[0]}[/]'
|
styled_fqme = f'[blue underline]{tokens[0]}[/]'
|
||||||
for tok in tokens[1:]:
|
for tok in tokens[1:]:
|
||||||
# styled_fqme += term.dim('.')
|
|
||||||
styled_fqme += '[dim].[/]'
|
styled_fqme += '[dim].[/]'
|
||||||
# styled_fqme += term.dim_blue_underline(tok)
|
|
||||||
styled_fqme += f'[dim blue underline]{tok}[/]'
|
styled_fqme += f'[dim blue underline]{tok}[/]'
|
||||||
|
|
||||||
# blessing.Terminal code.
|
# TODO: instead display in a ``rich.Table``?
|
||||||
# summary += (
|
|
||||||
# # term.dim('- ')
|
|
||||||
# # + term.dim_blue(f'{ppmsg.symbol}')
|
|
||||||
# styled_fqme
|
|
||||||
# + term.dim(': ')
|
|
||||||
# + pcolor(f'{h_size}')
|
|
||||||
# # + term.dim_blue('u \n')
|
|
||||||
# # + term.dim_blue('@ ')
|
|
||||||
# + term.dim_blue('u @')
|
|
||||||
# # + term.dim(f' |-> ppu: ')
|
|
||||||
# # + pcolor(f'{ppu}\n')
|
|
||||||
# + pcolor(f'{ppu}')
|
|
||||||
|
|
||||||
# # + term.dim(f' |-> book value: ')
|
|
||||||
# + term.dim_blue(' = ')
|
|
||||||
# + pcolor(f'$ {cb}\n')
|
|
||||||
# )
|
|
||||||
|
|
||||||
summary += (
|
summary += (
|
||||||
styled_fqme +
|
styled_fqme +
|
||||||
'[dim]: [/]'
|
'[dim]: [/]'
|
||||||
|
@ -242,11 +202,10 @@ def sync(
|
||||||
'[dim blue]u @[/]'
|
'[dim blue]u @[/]'
|
||||||
f'[{pcolor}]{ppu}[/]'
|
f'[{pcolor}]{ppu}[/]'
|
||||||
'[dim blue] = [/]'
|
'[dim blue] = [/]'
|
||||||
f'[{pcolor}]$ {cb}\n[/]'
|
f'[{pcolor}]$ {cost_basis}\n[/]'
|
||||||
)
|
)
|
||||||
|
|
||||||
# console.print(summar)
|
console.print(summary)
|
||||||
print(summary)
|
|
||||||
await brokerd_ctx.cancel()
|
await brokerd_ctx.cancel()
|
||||||
|
|
||||||
await portal.cancel_actor()
|
await portal.cancel_actor()
|
||||||
|
|
Loading…
Reference in New Issue