trade_history should paginate through results

this avoids huge results
This commit is contained in:
Matthias
2021-04-18 16:05:28 +02:00
parent b230558294
commit bd92ce938c
5 changed files with 20 additions and 11 deletions

View File

@@ -199,6 +199,7 @@ class OpenTradeSchema(TradeSchema):
class TradeResponse(BaseModel):
trades: List[TradeSchema]
trades_count: int
total_trades: int
class ForceBuyResponse(BaseModel):

View File

@@ -85,8 +85,8 @@ def status(rpc: RPC = Depends(get_rpc)):
# Using the responsemodel here will cause a ~100% increase in response time (from 1s to 2s)
# on big databases. Correct response model: response_model=TradeResponse,
@router.get('/trades', tags=['info', 'trading'])
def trades(limit: int = 0, rpc: RPC = Depends(get_rpc)):
return rpc._rpc_trade_history(limit)
def trades(limit: int = 500, offset: int = 0, rpc: RPC = Depends(get_rpc)):
return rpc._rpc_trade_history(min(limit, 500), offset=offset, order_by_id=True)
@router.get('/trade/{tradeid}', response_model=OpenTradeSchema, tags=['info', 'trading'])