Skip to content

Commit

Permalink
Use Optional instead of | None
Browse files Browse the repository at this point in the history
  • Loading branch information
jogobeny authored and jcoelho93 committed Dec 4, 2024
1 parent cbb2337 commit 13f6f7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions trading212/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Order(BaseModel):


class AccountCash(BaseModel):
blocked: float | None
blocked: Optional[float]
free: float
invested: float
pieCash: float
Expand Down Expand Up @@ -185,32 +185,32 @@ class Tax(BaseModel):

class HistoryItem(BaseModel):
dateCreated: datetime
dateExecuted: datetime | None
dateExecuted: Optional[datetime]
dateModified: datetime
executor: str
fillCost: float | None
fillId: int | None
fillPrice: float | None
fillResult: float | None
fillType: str | None
filledQuantity: float | None
filledValue: float | None
fillCost: Optional[float]
fillId: Optional[int]
fillPrice: Optional[float]
fillResult: Optional[float]
fillType: Optional[str]
filledQuantity: Optional[float]
filledValue: Optional[float]
id: int
limitPrice: float | None
orderedQuantity: float | None
orderedValue: float | None
limitPrice: Optional[float]
orderedQuantity: Optional[float]
orderedValue: Optional[float]
parentOrder: int
status: str
stopPrice: float | None
stopPrice: Optional[float]
taxes: List[Tax]
ticker: str
timeValidity: str | None
timeValidity: Optional[str]
type: str


class HistoricalOrderData(BaseModel):
items: List[HistoryItem]
nextPagePath: str | None
nextPagePath: Optional[str]


class LimitOrder(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions trading212/trading212.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import requests
from typing import List, Dict
from typing import List, Dict, Optional
from requests.exceptions import HTTPError
from trading212.models import (
Position, Exchange, Instrument,
Expand Down Expand Up @@ -353,7 +353,7 @@ def fetch_specific_position(self, ticker: str) -> Position:

return Position(**response)

def historical_order_data(self, cursor: int | None = None, ticker: str | None = None, limit: int = None) -> HistoricalOrderData:
def historical_order_data(self, cursor: Optional[int] = None, ticker: Optional[str] = None, limit: Optional[int]) -> HistoricalOrderData:
"""Fetch historical order data
https://t212public-api-docs.redoc.ly/#operation/orders_1
Expand Down

0 comments on commit 13f6f7a

Please sign in to comment.