Port everything to `Position.be_price`
parent
ff74f4302a
commit
c617a06905
|
@ -130,7 +130,7 @@ class Allocator(BaseModel):
|
||||||
l_sub_pp = self.units_limit - abs_live_size
|
l_sub_pp = self.units_limit - abs_live_size
|
||||||
|
|
||||||
elif size_unit == 'currency':
|
elif size_unit == 'currency':
|
||||||
live_cost_basis = abs_live_size * live_pp.avg_price
|
live_cost_basis = abs_live_size * live_pp.be_price
|
||||||
slot_size = currency_per_slot / price
|
slot_size = currency_per_slot / price
|
||||||
l_sub_pp = (self.currency_limit - live_cost_basis) / price
|
l_sub_pp = (self.currency_limit - live_cost_basis) / price
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class Allocator(BaseModel):
|
||||||
if size_unit == 'currency':
|
if size_unit == 'currency':
|
||||||
# compute the "projected" limit's worth of units at the
|
# compute the "projected" limit's worth of units at the
|
||||||
# current pp (weighted) price:
|
# current pp (weighted) price:
|
||||||
slot_size = currency_per_slot / live_pp.avg_price
|
slot_size = currency_per_slot / live_pp.be_price
|
||||||
|
|
||||||
else:
|
else:
|
||||||
slot_size = u_per_slot
|
slot_size = u_per_slot
|
||||||
|
@ -204,7 +204,7 @@ class Allocator(BaseModel):
|
||||||
Position(
|
Position(
|
||||||
symbol=sym,
|
symbol=sym,
|
||||||
size=order_size,
|
size=order_size,
|
||||||
avg_price=price,
|
be_price=price,
|
||||||
bsuid=sym,
|
bsuid=sym,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -233,8 +233,8 @@ class Allocator(BaseModel):
|
||||||
abs_pp_size = abs(pp.size)
|
abs_pp_size = abs(pp.size)
|
||||||
|
|
||||||
if self.size_unit == 'currency':
|
if self.size_unit == 'currency':
|
||||||
# live_currency_size = size or (abs_pp_size * pp.avg_price)
|
# live_currency_size = size or (abs_pp_size * pp.be_price)
|
||||||
live_currency_size = abs_pp_size * pp.avg_price
|
live_currency_size = abs_pp_size * pp.be_price
|
||||||
prop = live_currency_size / self.currency_limit
|
prop = live_currency_size / self.currency_limit
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -304,7 +304,7 @@ def mk_allocator(
|
||||||
# if the current position is already greater then the limit
|
# if the current position is already greater then the limit
|
||||||
# settings, increase the limit to the current position
|
# settings, increase the limit to the current position
|
||||||
if alloc.size_unit == 'currency':
|
if alloc.size_unit == 'currency':
|
||||||
startup_size = startup_pp.size * startup_pp.avg_price
|
startup_size = startup_pp.size * startup_pp.be_price
|
||||||
|
|
||||||
if startup_size > alloc.currency_limit:
|
if startup_size > alloc.currency_limit:
|
||||||
alloc.currency_limit = round(startup_size, ndigits=2)
|
alloc.currency_limit = round(startup_size, ndigits=2)
|
||||||
|
|
|
@ -263,7 +263,7 @@ class PaperBoi:
|
||||||
pp = Position(
|
pp = Position(
|
||||||
Symbol(key=symbol),
|
Symbol(key=symbol),
|
||||||
size=pp_msg.size,
|
size=pp_msg.size,
|
||||||
avg_price=pp_msg.avg_price,
|
be_price=pp_msg.avg_price,
|
||||||
uid=symbol.front_fqsn(),
|
uid=symbol.front_fqsn(),
|
||||||
)
|
)
|
||||||
pp_msg.size, pp_msg.avg_price = pp.lifo_update(size, price)
|
pp_msg.size, pp_msg.avg_price = pp.lifo_update(size, price)
|
||||||
|
|
|
@ -106,8 +106,8 @@ async def update_pnl_from_feed(
|
||||||
# compute and display pnl status
|
# compute and display pnl status
|
||||||
order_mode.pane.pnl_label.format(
|
order_mode.pane.pnl_label.format(
|
||||||
pnl=copysign(1, size) * pnl(
|
pnl=copysign(1, size) * pnl(
|
||||||
# live.avg_price,
|
# live.be_price,
|
||||||
order_mode.current_pp.live_pp.avg_price,
|
order_mode.current_pp.live_pp.be_price,
|
||||||
tick['price'],
|
tick['price'],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -357,7 +357,7 @@ class SettingsPane:
|
||||||
# last historical close price
|
# last historical close price
|
||||||
last = feed.shm.array[-1][['close']][0]
|
last = feed.shm.array[-1][['close']][0]
|
||||||
pnl_value = copysign(1, size) * pnl(
|
pnl_value = copysign(1, size) * pnl(
|
||||||
tracker.live_pp.avg_price,
|
tracker.live_pp.be_price,
|
||||||
last,
|
last,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ class PositionTracker:
|
||||||
pp = position or self.live_pp
|
pp = position or self.live_pp
|
||||||
|
|
||||||
self.update_line(
|
self.update_line(
|
||||||
pp.avg_price,
|
pp.be_price,
|
||||||
pp.size,
|
pp.size,
|
||||||
self.chart.linked.symbol.lot_size_digits,
|
self.chart.linked.symbol.lot_size_digits,
|
||||||
)
|
)
|
||||||
|
@ -571,7 +571,7 @@ class PositionTracker:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._level_marker.level = pp.avg_price
|
self._level_marker.level = pp.be_price
|
||||||
|
|
||||||
# these updates are critical to avoid lag on view/scene changes
|
# these updates are critical to avoid lag on view/scene changes
|
||||||
self._level_marker.update() # trigger paint
|
self._level_marker.update() # trigger paint
|
||||||
|
|
|
@ -606,7 +606,7 @@ async def open_order_mode(
|
||||||
startup_pp = Position(
|
startup_pp = Position(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
size=0,
|
size=0,
|
||||||
avg_price=0,
|
be_price=0,
|
||||||
|
|
||||||
# XXX: BLEH, do we care about this on the client side?
|
# XXX: BLEH, do we care about this on the client side?
|
||||||
bsuid=symbol,
|
bsuid=symbol,
|
||||||
|
|
Loading…
Reference in New Issue