diff --git a/apps/trader.js b/apps/trader.js index bf2f44c..872b0e9 100644 --- a/apps/trader.js +++ b/apps/trader.js @@ -54,7 +54,7 @@ async function main(config, { bybit, stats, trades, events, tickers }) { if (trade) { close = trader.close(trade.id, price, trade.qty) } - return { ...trade, ...close } + return { ...trade, ...close, updated: r.created } } // close the previous position. @@ -69,11 +69,11 @@ async function main(config, { bybit, stats, trades, events, tickers }) { switch (r.type) { case 'LONG': { const long = trader.openLong(r.id, price) - return { ...r, ...long } + return { ...r, ...long, created: r.created } } case 'SHORT': { const short = trader.openShort(r.id, price) - return { ...r, ...short } + return { ...r, ...short, created: r.created } } // case 'MARKET_TREND': { // // const stats = trader.updateMarketCondition(r.marketCondition) diff --git a/libs/actions.js b/libs/actions.js index 4e6d06f..ef7dace 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -117,7 +117,7 @@ module.exports = ({ const provider = await users.get(providerid) assert(provider.userid === userid, 'provider does not belong to you.') - return trades.listUserSorted(provider.id) + return trades.listUserSorted(provider.id, 'desc') }, async listMyProviderStats({ token }) { assert(token, 'token required') diff --git a/models/events.js b/models/events.js index 3cb41fe..5419cb8 100644 --- a/models/events.js +++ b/models/events.js @@ -34,7 +34,7 @@ module.exports = async con => { const q = table .table() .orderBy({ index: table.r.desc('created') }) - .limit(100) + .limit(1000) .coerceTo('array') return table.run(q) }, @@ -43,7 +43,7 @@ module.exports = async con => { .table() .orderBy({ index: 'created' }) .filter({ userid }) - .limit(100) + .limit(1000) .coerceTo('array') return table.run(query) }, @@ -52,7 +52,7 @@ module.exports = async con => { .table() .orderBy({ index: 'created' }) .filter({ [index]: value }) - .limit(100) + .limit(1000) .coerceTo('array') return table.run(query) }, diff --git a/models/trades.js b/models/trades.js index 994e6f0..4dabddc 100644 --- a/models/trades.js +++ b/models/trades.js @@ -29,16 +29,16 @@ module.exports = async con => { const q = table .table() .orderBy({ index: table.r.desc('created') }) - .limit(100) + .limit(1000) .coerceTo('array') return table.run(q) }, - listUserSorted(userid) { + listUserSorted(userid, sort ='desc') { const query = table .table() - .orderBy({ index: 'created' }) + .orderBy({ index: table.r[sort]('created') }) .filter({ userid }) - .limit(100) + .limit(1000) .coerceTo('array') return table.run(query) },