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

[TRA-890] Return nearest hour PnL as final data point for vaults pnl. #2616

Merged
merged 3 commits into from
Nov 26, 2024
Merged
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
Prev Previous commit
Next Next commit
Fix typos.
vincentwschau committed Nov 26, 2024
commit 014315ca787b9ca726af69a127e883a2af697f1b
Original file line number Diff line number Diff line change
@@ -347,7 +347,7 @@ describe('vault-controller#V4', () => {
queryParam: string,
expectedTicksIndex1: number[],
expectedTicksIndex2: number[],
curerntTickIndex1: number,
currentTickIndex1: number,
currentTickIndex2: number,
) => {
await Promise.all([
@@ -364,7 +364,7 @@ describe('vault-controller#V4', () => {
]);
const createdPnlTicks: PnlTicksFromDatabase[] = await createPnlTicks();
const finalTick1: PnlTicksFromDatabase = {
...createdPnlTicks[curerntTickIndex1],
...createdPnlTicks[currentTickIndex1],
equity: Big(vault1Equity).toFixed(),
blockHeight: latestBlockHeight,
blockTime: latestTime.toISO(),
Original file line number Diff line number Diff line change
@@ -358,13 +358,13 @@ async function getVaultSubaccountPnlTicks(
VaultPnlTicksView.getVaultsPnl(
resolution,
windowSeconds,
getVautlPnlStartDate(),
getVaultPnlStartDate(),
),
PnlTicksTable.getLatestPnlTick(
vaultSubaccountIds,
// Add a buffer of 10 minutes to get the first PnL tick for PnL data as PnL ticks aren't
// created exactly on the hour.
getVautlPnlStartDate().plus({ minutes: 10 }),
getVaultPnlStartDate().plus({ minutes: 10 }),
),
]);

@@ -577,7 +577,7 @@ export async function getLatestPnlTicks(
vaultSubaccountIds,
// Add a buffer of 10 minutes to get the first PnL tick for PnL data as PnL ticks aren't
// created exactly on the hour.
getVautlPnlStartDate().plus({ minutes: 10 }),
getVaultPnlStartDate().plus({ minutes: 10 }),
),
]);
const adjustedPnlTicks: PnlTicksFromDatabase[] = adjustVaultPnlTicks(
@@ -601,13 +601,13 @@ export async function getLatestPnlTick(
VaultPnlTicksView.getVaultsPnl(
PnlTickInterval.hour,
config.VAULT_LATEST_PNL_TICK_WINDOW_HOURS * 60 * 60,
getVautlPnlStartDate(),
getVaultPnlStartDate(),
),
PnlTicksTable.getLatestPnlTick(
vaultSubaccountIds,
// Add a buffer of 10 minutes to get the first PnL tick for PnL data as PnL ticks aren't
// created exactly on the hour.
getVautlPnlStartDate().plus({ minutes: 10 }),
getVaultPnlStartDate().plus({ minutes: 10 }),
),
]);
const adjustedPnlTicks: PnlTicksFromDatabase[] = adjustVaultPnlTicks(
@@ -834,7 +834,7 @@ async function getVaultMapping(): Promise<VaultMapping> {
return validVaultMapping;
}

function getVautlPnlStartDate(): DateTime {
function getVaultPnlStartDate(): DateTime {
const startDate: DateTime = DateTime.fromISO(config.VAULT_PNL_START_DATE).toUTC();
return startDate;
}