How can I get the total trading volume made by a specific user on the exchange during a specific period?
You can use a code like this if you are developing a plugin:
const getOracleIndex = async () => {
const coins = toolsLib.getKitCoins();
const data = await toolsLib.getAssetsPrices(
coins,
toolsLib.getKitConfig().native_currency
);
return data;
};
// calculate the trades of a user
const calculateUserTradeAmounts = async (user_id, from, to) => {
let volume = 0;
const oracleIndex = await getOracleIndex();
const trades = await toolsLib.order.getAllUserTradesByKitId(
user_id,
null,
null,
null,
null,
null,
from,
to,
'all'
);
loggerPlugin.info(
trades.data.length
);
if (trades.data && trades.data.length > 0) {
for (const trade of trades.data) {
const { symbol } = trade;
let size = trade.size;
const basePair = symbol.split('-')[0];
if (basePair !== toolsLib.getKitConfig().native_currency) {
if (!isNumber(oracleIndex[basePair]) || oracleIndex[basePair] <= 0) {
continue;
}
size = multiplyAmounts(oracleIndex[basePair], size);
}
volume = addAmounts(volume, size);
}
}
return volume;
};
If this is not within the context if a plugin, can also easily convert this code and use admin APIs to achieve this.