Skip to content

Commit cbb2337

Browse files
jogobenyjcoelho93
authored andcommitted
Fix 'historical_order_data'
1 parent 6e58a82 commit cbb2337

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

trading212/models.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -185,32 +185,32 @@ class Tax(BaseModel):
185185

186186
class HistoryItem(BaseModel):
187187
dateCreated: datetime
188-
dateExecuted: datetime
188+
dateExecuted: datetime | None
189189
dateModified: datetime
190190
executor: str
191-
fillCost: float
192-
fillId: int
193-
fillPrice: float
194-
fillResult: float
195-
fillType: str
196-
filledQuantity: float
197-
filledValue: float
191+
fillCost: float | None
192+
fillId: int | None
193+
fillPrice: float | None
194+
fillResult: float | None
195+
fillType: str | None
196+
filledQuantity: float | None
197+
filledValue: float | None
198198
id: int
199-
limitPrice: float
200-
orderedQuantity: float
201-
orderedValue: float
199+
limitPrice: float | None
200+
orderedQuantity: float | None
201+
orderedValue: float | None
202202
parentOrder: int
203203
status: str
204-
stopPrice: float
204+
stopPrice: float | None
205205
taxes: List[Tax]
206206
ticker: str
207-
timeValidity: str
207+
timeValidity: str | None
208208
type: str
209209

210210

211211
class HistoricalOrderData(BaseModel):
212212
items: List[HistoryItem]
213-
nextPagePath: str
213+
nextPagePath: str | None
214214

215215

216216
class LimitOrder(BaseModel):

trading212/trading212.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def fetch_specific_position(self, ticker: str) -> Position:
353353

354354
return Position(**response)
355355

356-
def historical_order_data(self, cursor: int, ticker: str, limit: int) -> HistoricalOrderData:
356+
def historical_order_data(self, cursor: int | None = None, ticker: str | None = None, limit: int = None) -> HistoricalOrderData:
357357
"""Fetch historical order data
358358
359359
https://t212public-api-docs.redoc.ly/#operation/orders_1
@@ -367,14 +367,11 @@ def historical_order_data(self, cursor: int, ticker: str, limit: int) -> Histori
367367
HistoricalOrderData: _description_
368368
"""
369369
endpoint = self.url + "equity/history/orders"
370-
params = None
371-
if cursor or ticker or limit:
372-
params = {
373-
"cursor": cursor,
374-
"ticker": ticker,
375-
"limit": limit
376-
}
377-
response = self._get(endpoint, params)
370+
response = self._get(endpoint, {
371+
"cursor": cursor,
372+
"ticker": ticker,
373+
"limit": limit
374+
})
378375

379376
return HistoricalOrderData(**response)
380377

0 commit comments

Comments
 (0)