Skip to content

Remove mutable default types. #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions ib_async/ib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ def reqRealTimeBars(
barSize: int,
whatToShow: str,
useRTH: bool,
realTimeBarsOptions: list[TagValue] = [],
realTimeBarsOptions: list[TagValue] | None = None,
) -> RealTimeBarList:
"""
Request realtime 5 second bars.
Expand Down Expand Up @@ -1165,7 +1165,7 @@ def reqHistoricalData(
useRTH: bool,
formatDate: int = 1,
keepUpToDate: bool = False,
chartOptions: list[TagValue] = [],
chartOptions: list[TagValue] | None = None,
timeout: float = 60,
) -> BarDataList:
"""
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def reqHistoricalTicks(
whatToShow: str,
useRth: bool,
ignoreSize: bool = False,
miscOptions: list[TagValue] = [],
miscOptions: list[TagValue] | None = None,
) -> List:
"""
Request historical ticks. The time resolution of the ticks
Expand Down Expand Up @@ -1352,7 +1352,7 @@ def reqMktData(
genericTickList: str = "",
snapshot: bool = False,
regulatorySnapshot: bool = False,
mktDataOptions: list[TagValue] = [],
mktDataOptions: list[TagValue] | None = None,
) -> Ticker:
"""
Subscribe to tick data or request a snapshot.
Expand Down Expand Up @@ -1582,7 +1582,7 @@ def reqFundamentalData(
self,
contract: Contract,
reportType: str,
fundamentalDataOptions: list[TagValue] = [],
fundamentalDataOptions: list[TagValue] | None = None,
) -> str:
"""
Get fundamental data of a contract in XML format.
Expand Down Expand Up @@ -1610,8 +1610,8 @@ def reqFundamentalData(
def reqScannerData(
self,
subscription: ScannerSubscription,
scannerSubscriptionOptions: list[TagValue] = [],
scannerSubscriptionFilterOptions: list[TagValue] = [],
scannerSubscriptionOptions: list[TagValue] | None = None,
scannerSubscriptionFilterOptions: list[TagValue] | None = None,
) -> ScanDataList:
"""
Do a blocking market scan by starting a subscription and canceling it
Expand All @@ -1637,8 +1637,8 @@ def reqScannerData(
def reqScannerSubscription(
self,
subscription: ScannerSubscription,
scannerSubscriptionOptions: list[TagValue] = [],
scannerSubscriptionFilterOptions: list[TagValue] = [],
scannerSubscriptionOptions: list[TagValue] | None = None,
scannerSubscriptionFilterOptions: list[TagValue] | None = None,
) -> ScanDataList:
"""
Subscribe to market scan data.
Expand All @@ -1655,9 +1655,7 @@ def reqScannerSubscription(
dataList.reqId = reqId
dataList.subscription = subscription
dataList.scannerSubscriptionOptions = scannerSubscriptionOptions or []
dataList.scannerSubscriptionFilterOptions = (
scannerSubscriptionFilterOptions or []
)
dataList.scannerSubscriptionFilterOptions = scannerSubscriptionFilterOptions or []
self.wrapper.startSubscription(reqId, dataList)
self.client.reqScannerSubscription(
reqId,
Expand Down Expand Up @@ -1693,7 +1691,7 @@ def calculateImpliedVolatility(
contract: Contract,
optionPrice: float,
underPrice: float,
implVolOptions: list[TagValue] = [],
implVolOptions: list[TagValue] | None = None,
) -> OptionComputation:
"""
Calculate the volatility given the option price.
Expand All @@ -1719,7 +1717,7 @@ def calculateOptionPrice(
contract: Contract,
volatility: float,
underPrice: float,
optPrcOptions: list[TagValue] = [],
optPrcOptions: list[TagValue] | None = None,
) -> OptionComputation:
"""
Calculate the option price given the volatility.
Expand All @@ -1732,7 +1730,7 @@ def calculateOptionPrice(
contract: Option contract.
volatility: Option volatility to use in calculation.
underPrice: Price of the underlier to use in calculation
implVolOptions: Unknown
optPrcOptions: TODO
"""
return self._run(
self.calculateOptionPriceAsync(
Expand Down Expand Up @@ -1806,7 +1804,7 @@ def reqNewsProviders(self) -> list[NewsProvider]:
return self._run(self.reqNewsProvidersAsync())

def reqNewsArticle(
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] = []
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] | None = None,
) -> NewsArticle:
"""
Get the body of a news article.
Expand All @@ -1831,7 +1829,7 @@ def reqHistoricalNews(
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
totalResults: int,
historicalNewsOptions: list[TagValue] = [],
historicalNewsOptions: list[TagValue] | None = None,
) -> HistoricalNews:
"""
Get historical news headline.
Expand Down Expand Up @@ -2297,7 +2295,7 @@ async def reqHistoricalDataAsync(
useRTH: bool,
formatDate: int = 1,
keepUpToDate: bool = False,
chartOptions: list[TagValue] = [],
chartOptions: list[TagValue] | None = None,
timeout: float = 60,
) -> BarDataList:
reqId = self.client.getReqId()
Expand Down Expand Up @@ -2372,7 +2370,7 @@ def reqHistoricalTicksAsync(
whatToShow: str,
useRth: bool,
ignoreSize: bool = False,
miscOptions: list[TagValue] = [],
miscOptions: list[TagValue] | None = None,
) -> Awaitable[List]:
reqId = self.client.getReqId()
future = self.wrapper.startReq(reqId, contract)
Expand Down Expand Up @@ -2428,7 +2426,7 @@ def reqFundamentalDataAsync(
self,
contract: Contract,
reportType: str,
fundamentalDataOptions: list[TagValue] = [],
fundamentalDataOptions: list[TagValue] | None = None,
) -> Awaitable[str]:
reqId = self.client.getReqId()

Expand All @@ -2441,8 +2439,8 @@ def reqFundamentalDataAsync(
async def reqScannerDataAsync(
self,
subscription: ScannerSubscription,
scannerSubscriptionOptions: list[TagValue] = [],
scannerSubscriptionFilterOptions: list[TagValue] = [],
scannerSubscriptionOptions: list[TagValue] | None = None,
scannerSubscriptionFilterOptions: list[TagValue] | None = None,
) -> ScanDataList:
dataList = self.reqScannerSubscription(
subscription,
Expand All @@ -2466,7 +2464,7 @@ async def calculateImpliedVolatilityAsync(
contract: Contract,
optionPrice: float,
underPrice: float,
implVolOptions: list[TagValue] = [],
implVolOptions: list[TagValue] | None = None,
) -> Optional[OptionComputation]:
reqId = self.client.getReqId()
future = self.wrapper.startReq(reqId, contract)
Expand All @@ -2487,7 +2485,7 @@ async def calculateOptionPriceAsync(
contract: Contract,
volatility: float,
underPrice: float,
optPrcOptions: list[TagValue] = [],
optPrcOptions: list[TagValue] | None = None,
) -> Optional[OptionComputation]:
reqId = self.client.getReqId()
future = self.wrapper.startReq(reqId, contract)
Expand Down Expand Up @@ -2524,7 +2522,7 @@ def reqNewsProvidersAsync(self) -> Awaitable[list[NewsProvider]]:
return future

def reqNewsArticleAsync(
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] = []
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] | None = None
) -> Awaitable[NewsArticle]:
reqId = self.client.getReqId()

Expand All @@ -2539,7 +2537,7 @@ async def reqHistoricalNewsAsync(
startDateTime: Union[str, datetime.date],
endDateTime: Union[str, datetime.date],
totalResults: int,
historicalNewsOptions: list[TagValue] = [],
historicalNewsOptions: list[TagValue] | None = None,
) -> Optional[HistoricalNews]:
reqId = self.client.getReqId()

Expand Down