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:
32
src/index.ts
32
src/index.ts
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user