ranked-pnl: Fix off-by-one in index

This commit is contained in:
Christian Kamm 2022-01-07 08:47:44 +01:00
parent 3d0dce56e7
commit d25c86c2da
1 changed files with 3 additions and 1 deletions

View File

@ -866,6 +866,8 @@ def ranked_pnl():
market_index = int(market_index)
except TypeError:
raise Exception('market-index must be an int')
# Postgres indices are 1-based
postgres_market_index = market_index + 1
order = request.args.get('order')
if order not in ['ASC', 'DESC']:
@ -882,7 +884,7 @@ def ranked_pnl():
sql = "select * from accountsdb.pnl(%(market_index)s, %(order)s, %(limit)s)"
cur.execute(sql, {'market_index': market_index, 'order': order, 'limit': limit})
cur.execute(sql, {'market_index': postgres_market_index, 'order': order, 'limit': limit})
data = cur.fetchone()[0]
if data is None: