@@ -154,21 +154,33 @@ def stats(rpc: RPC = Depends(get_rpc)):
154
154
155
155
156
156
@router .get ("/daily" , response_model = DailyWeeklyMonthly , tags = ["info" ])
157
- def daily (timescale : int = 7 , rpc : RPC = Depends (get_rpc ), config = Depends (get_config )):
157
+ def daily (
158
+ timescale : int = Query (7 , ge = 1 , description = "Number of days to fetch data for" ),
159
+ rpc : RPC = Depends (get_rpc ),
160
+ config = Depends (get_config ),
161
+ ):
158
162
return rpc ._rpc_timeunit_profit (
159
163
timescale , config ["stake_currency" ], config .get ("fiat_display_currency" , "" )
160
164
)
161
165
162
166
163
167
@router .get ("/weekly" , response_model = DailyWeeklyMonthly , tags = ["info" ])
164
- def weekly (timescale : int = 4 , rpc : RPC = Depends (get_rpc ), config = Depends (get_config )):
168
+ def weekly (
169
+ timescale : int = Query (4 , ge = 1 , description = "Number of weeks to fetch data for" ),
170
+ rpc : RPC = Depends (get_rpc ),
171
+ config = Depends (get_config ),
172
+ ):
165
173
return rpc ._rpc_timeunit_profit (
166
174
timescale , config ["stake_currency" ], config .get ("fiat_display_currency" , "" ), "weeks"
167
175
)
168
176
169
177
170
178
@router .get ("/monthly" , response_model = DailyWeeklyMonthly , tags = ["info" ])
171
- def monthly (timescale : int = 3 , rpc : RPC = Depends (get_rpc ), config = Depends (get_config )):
179
+ def monthly (
180
+ timescale : int = Query (3 , ge = 1 , description = "Number of months to fetch data for" ),
181
+ rpc : RPC = Depends (get_rpc ),
182
+ config = Depends (get_config ),
183
+ ):
172
184
return rpc ._rpc_timeunit_profit (
173
185
timescale , config ["stake_currency" ], config .get ("fiat_display_currency" , "" ), "months"
174
186
)
@@ -185,7 +197,11 @@ def status(rpc: RPC = Depends(get_rpc)):
185
197
# Using the responsemodel here will cause a ~100% increase in response time (from 1s to 2s)
186
198
# on big databases. Correct response model: response_model=TradeResponse,
187
199
@router .get ("/trades" , tags = ["info" , "trading" ])
188
- def trades (limit : int = 500 , offset : int = 0 , rpc : RPC = Depends (get_rpc )):
200
+ def trades (
201
+ limit : int = Query (500 , ge = 1 , description = "Maximum number of different trades to return data" ),
202
+ offset : int = Query (0 , ge = 0 , description = "Number of trades to skip for pagination" ),
203
+ rpc : RPC = Depends (get_rpc ),
204
+ ):
189
205
return rpc ._rpc_trade_history (limit , offset = offset , order_by_id = True )
190
206
191
207
0 commit comments