Use pnl calc in order mode (i.e. no x100%)
parent
4247f28e04
commit
30dfcc4530
|
@ -33,7 +33,7 @@ import tractor
|
||||||
import trio
|
import trio
|
||||||
|
|
||||||
from .. import brokers
|
from .. import brokers
|
||||||
from ..calc import percent_change
|
from ..calc import pnl
|
||||||
from ..clearing._client import open_ems, OrderBook
|
from ..clearing._client import open_ems, OrderBook
|
||||||
from ..data._source import Symbol
|
from ..data._source import Symbol
|
||||||
from ..data._normalize import iterticks
|
from ..data._normalize import iterticks
|
||||||
|
@ -587,14 +587,11 @@ async def open_order_mode(
|
||||||
|
|
||||||
# compute and display pnl status immediately
|
# compute and display pnl status immediately
|
||||||
mode.pane.pnl_label.format(
|
mode.pane.pnl_label.format(
|
||||||
pnl=round(
|
pnl=copysign(1, size) * pnl(
|
||||||
copysign(1, size) * percent_change(
|
live_pp.avg_price,
|
||||||
live_pp.avg_price,
|
# last historical close price
|
||||||
# last historical close price
|
feed.shm.array[-1][['close']][0],
|
||||||
feed.shm.array[-1][['close']][0],
|
),
|
||||||
),
|
|
||||||
ndigits=2,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# spawn updater task
|
# spawn updater task
|
||||||
|
@ -682,7 +679,7 @@ async def display_pnl(
|
||||||
for sym, quote in quotes.items():
|
for sym, quote in quotes.items():
|
||||||
|
|
||||||
for tick in iterticks(quote, types):
|
for tick in iterticks(quote, types):
|
||||||
# print(f'{1/period} Hz')
|
print(f'{1/period} Hz')
|
||||||
|
|
||||||
size = live.size
|
size = live.size
|
||||||
|
|
||||||
|
@ -696,13 +693,10 @@ async def display_pnl(
|
||||||
else:
|
else:
|
||||||
# compute and display pnl status
|
# compute and display pnl status
|
||||||
order_mode.pane.pnl_label.format(
|
order_mode.pane.pnl_label.format(
|
||||||
pnl=round(
|
pnl=copysign(1, size) * pnl(
|
||||||
copysign(1, size) * percent_change(
|
live.avg_price,
|
||||||
live.avg_price,
|
tick['price'],
|
||||||
tick['price'],
|
),
|
||||||
),
|
|
||||||
ndigits=2,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
last_tick = time.time()
|
last_tick = time.time()
|
||||||
|
|
Loading…
Reference in New Issue