Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-629] Fix entryPrice calc #2455

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('LiquidationHandler', () => {
perpetualId: testConstants.defaultPerpetualMarket.id,
side: PositionSide.LONG,
status: PerpetualPositionStatus.OPEN,
size: '10',
size: '5',
maxSize: '25',
sumOpen: '10',
entryPrice: '15000',
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('LiquidationHandler', () => {
defaultPerpetualPosition.openEventId,
),
{
sumOpen: Big(defaultPerpetualPosition.size).plus(totalFilled).toFixed(),
sumOpen: Big(defaultPerpetualPosition.sumOpen!).plus(totalFilled).toFixed(),
entryPrice: getWeightedAverage(
defaultPerpetualPosition.entryPrice!,
defaultPerpetualPosition.size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('OrderHandler', () => {
perpetualId: testConstants.defaultPerpetualMarket.id,
side: PositionSide.LONG,
status: PerpetualPositionStatus.OPEN,
size: '10',
size: '5',
maxSize: '25',
sumOpen: '10',
entryPrice: '15000',
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('OrderHandler', () => {
defaultPerpetualPosition.openEventId,
),
{
sumOpen: Big(defaultPerpetualPosition.size).plus(totalFilled).toFixed(),
sumOpen: Big(defaultPerpetualPosition.sumOpen!).plus(totalFilled).toFixed(),
entryPrice: getWeightedAverage(
defaultPerpetualPosition.entryPrice!,
defaultPerpetualPosition.size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ BEGIN
perpetual_position_record."side", order_side) THEN
sum_open = dydx_trim_scale(perpetual_position_record."sumOpen" + fill_amount);
entry_price = dydx_get_weighted_average(
perpetual_position_record."entryPrice", perpetual_position_record."sumOpen",
perpetual_position_record."entryPrice", perpetual_position_record."size",
maker_price, fill_amount);
perpetual_position_record."sumOpen" = sum_open;
perpetual_position_record."entryPrice" = entry_price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ BEGIN
IF dydx_perpetual_position_and_order_side_matching(perpetual_position_record."side", side) THEN
sum_open := dydx_trim_scale(perpetual_position_record."sumOpen" + size);
entry_price := dydx_get_weighted_average(
perpetual_position_record."entryPrice", perpetual_position_record."sumOpen", price, size
perpetual_position_record."entryPrice", perpetual_position_record."size", price, size
);
perpetual_position_record."sumOpen" = sum_open;
perpetual_position_record."entryPrice" = entry_price;
Expand Down
Loading