Nick/usermap pnl script (#223)

* WIP unsettled pnl script

* update

* add commented out debugging stuff

* update script and create endpoint

* finalize

* rm test file

* try to fix package diff

* add marketIndex + fix logger

* fix package

* remove runningLocal logic
This commit is contained in:
lowkeynicc
2024-08-07 17:39:24 -04:00
committed by GitHub
parent 6288370bcf
commit 0f9521af30
3 changed files with 269 additions and 1 deletions

View File

@@ -647,6 +647,38 @@ const main = async (): Promise<void> => {
}
});
// returns top 20 unsettled gainers and losers
app.get('/unsettledPnlUsers', async (req, res, next) => {
try {
const marketIndex = Number(req.query.marketIndex as string);
if (isNaN(marketIndex)) {
res.status(400).send('Bad Request: must include a marketIndex');
return;
}
const redisClient = perpMarketRedisMap.get(marketIndex).client;
const redisResponseGainers = await redisClient.getRaw(
`perp_market_${marketIndex}_gainers`
);
const redisResponseLosers = await redisClient.getRaw(
`perp_market_${marketIndex}_losers`
);
const response = {
marketIndex,
gainers: JSON.parse(redisResponseGainers),
losers: JSON.parse(redisResponseLosers),
};
res.end(JSON.stringify(response));
return;
} catch (err) {
next(err);
}
});
app.get('/l2', async (req, res, next) => {
try {
const {