Skip to content

Commit 108c544

Browse files
author
Nick Baskerville
committed
Remove mutable default types.
1 parent dab8622 commit 108c544

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

ib_async/ib.py

+29-29
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def reqRealTimeBars(
11151115
barSize: int,
11161116
whatToShow: str,
11171117
useRTH: bool,
1118-
realTimeBarsOptions: list[TagValue] = [],
1118+
realTimeBarsOptions: Optional[List[TagValue]] = None,
11191119
) -> RealTimeBarList:
11201120
"""
11211121
Request realtime 5 second bars.
@@ -1138,7 +1138,7 @@ def reqRealTimeBars(
11381138
bars.barSize = barSize
11391139
bars.whatToShow = whatToShow
11401140
bars.useRTH = useRTH
1141-
bars.realTimeBarsOptions = realTimeBarsOptions or []
1141+
bars.realTimeBarsOptions = list(realTimeBarsOptions or [])
11421142
self.wrapper.startSubscription(reqId, bars, contract)
11431143
self.client.reqRealTimeBars(
11441144
reqId, contract, barSize, whatToShow, useRTH, realTimeBarsOptions
@@ -1165,7 +1165,7 @@ def reqHistoricalData(
11651165
useRTH: bool,
11661166
formatDate: int = 1,
11671167
keepUpToDate: bool = False,
1168-
chartOptions: list[TagValue] = [],
1168+
chartOptions: Optional[List[TagValue]] = None,
11691169
timeout: float = 60,
11701170
) -> BarDataList:
11711171
"""
@@ -1272,7 +1272,7 @@ def reqHistoricalTicks(
12721272
whatToShow: str,
12731273
useRth: bool,
12741274
ignoreSize: bool = False,
1275-
miscOptions: list[TagValue] = [],
1275+
miscOptions: Optional[List[TagValue]] = None,
12761276
) -> List:
12771277
"""
12781278
Request historical ticks. The time resolution of the ticks
@@ -1352,7 +1352,7 @@ def reqMktData(
13521352
genericTickList: str = "",
13531353
snapshot: bool = False,
13541354
regulatorySnapshot: bool = False,
1355-
mktDataOptions: list[TagValue] = [],
1355+
mktDataOptions: Optional[List[TagValue]] = None,
13561356
) -> Ticker:
13571357
"""
13581358
Subscribe to tick data or request a snapshot.
@@ -1582,7 +1582,7 @@ def reqFundamentalData(
15821582
self,
15831583
contract: Contract,
15841584
reportType: str,
1585-
fundamentalDataOptions: list[TagValue] = [],
1585+
fundamentalDataOptions: Optional[List[TagValue]] = None,
15861586
) -> str:
15871587
"""
15881588
Get fundamental data of a contract in XML format.
@@ -1610,8 +1610,8 @@ def reqFundamentalData(
16101610
def reqScannerData(
16111611
self,
16121612
subscription: ScannerSubscription,
1613-
scannerSubscriptionOptions: list[TagValue] = [],
1614-
scannerSubscriptionFilterOptions: list[TagValue] = [],
1613+
scannerSubscriptionOptions: Optional[List[TagValue]] = None,
1614+
scannerSubscriptionFilterOptions: Optional[List[TagValue]] = None,
16151615
) -> ScanDataList:
16161616
"""
16171617
Do a blocking market scan by starting a subscription and canceling it
@@ -1637,8 +1637,8 @@ def reqScannerData(
16371637
def reqScannerSubscription(
16381638
self,
16391639
subscription: ScannerSubscription,
1640-
scannerSubscriptionOptions: list[TagValue] = [],
1641-
scannerSubscriptionFilterOptions: list[TagValue] = [],
1640+
scannerSubscriptionOptions: Optional[List[TagValue]] = None,
1641+
scannerSubscriptionFilterOptions: Optional[List[TagValue]] = None,
16421642
) -> ScanDataList:
16431643
"""
16441644
Subscribe to market scan data.
@@ -1654,8 +1654,8 @@ def reqScannerSubscription(
16541654
dataList = ScanDataList()
16551655
dataList.reqId = reqId
16561656
dataList.subscription = subscription
1657-
dataList.scannerSubscriptionOptions = scannerSubscriptionOptions or []
1658-
dataList.scannerSubscriptionFilterOptions = (
1657+
dataList.scannerSubscriptionOptions = list(scannerSubscriptionOptions or [])
1658+
dataList.scannerSubscriptionFilterOptions = list(
16591659
scannerSubscriptionFilterOptions or []
16601660
)
16611661
self.wrapper.startSubscription(reqId, dataList)
@@ -1693,7 +1693,7 @@ def calculateImpliedVolatility(
16931693
contract: Contract,
16941694
optionPrice: float,
16951695
underPrice: float,
1696-
implVolOptions: list[TagValue] = [],
1696+
implVolOptions: Optional[List[TagValue]] = None,
16971697
) -> OptionComputation:
16981698
"""
16991699
Calculate the volatility given the option price.
@@ -1719,7 +1719,7 @@ def calculateOptionPrice(
17191719
contract: Contract,
17201720
volatility: float,
17211721
underPrice: float,
1722-
optPrcOptions: list[TagValue] = [],
1722+
optPrcOptions: Optional[List[TagValue]] = None,
17231723
) -> OptionComputation:
17241724
"""
17251725
Calculate the option price given the volatility.
@@ -1732,7 +1732,7 @@ def calculateOptionPrice(
17321732
contract: Option contract.
17331733
volatility: Option volatility to use in calculation.
17341734
underPrice: Price of the underlier to use in calculation
1735-
implVolOptions: Unknown
1735+
optPrcOptions: TODO
17361736
"""
17371737
return self._run(
17381738
self.calculateOptionPriceAsync(
@@ -1806,7 +1806,7 @@ def reqNewsProviders(self) -> list[NewsProvider]:
18061806
return self._run(self.reqNewsProvidersAsync())
18071807

18081808
def reqNewsArticle(
1809-
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] = []
1809+
self, providerCode: str, articleId: str, newsArticleOptions: Optional[List[TagValue]] = None,
18101810
) -> NewsArticle:
18111811
"""
18121812
Get the body of a news article.
@@ -1831,7 +1831,7 @@ def reqHistoricalNews(
18311831
startDateTime: Union[str, datetime.date],
18321832
endDateTime: Union[str, datetime.date],
18331833
totalResults: int,
1834-
historicalNewsOptions: list[TagValue] = [],
1834+
historicalNewsOptions: Optional[List[TagValue]] = None,
18351835
) -> HistoricalNews:
18361836
"""
18371837
Get historical news headline.
@@ -2297,7 +2297,7 @@ async def reqHistoricalDataAsync(
22972297
useRTH: bool,
22982298
formatDate: int = 1,
22992299
keepUpToDate: bool = False,
2300-
chartOptions: list[TagValue] = [],
2300+
chartOptions: Optional[List[TagValue]] = None,
23012301
timeout: float = 60,
23022302
) -> BarDataList:
23032303
reqId = self.client.getReqId()
@@ -2311,7 +2311,7 @@ async def reqHistoricalDataAsync(
23112311
bars.useRTH = useRTH
23122312
bars.formatDate = formatDate
23132313
bars.keepUpToDate = keepUpToDate
2314-
bars.chartOptions = chartOptions or []
2314+
bars.chartOptions = list(chartOptions or [])
23152315
future = self.wrapper.startReq(reqId, contract, container=bars)
23162316
if keepUpToDate:
23172317
self.wrapper.startSubscription(reqId, bars, contract)
@@ -2372,7 +2372,7 @@ def reqHistoricalTicksAsync(
23722372
whatToShow: str,
23732373
useRth: bool,
23742374
ignoreSize: bool = False,
2375-
miscOptions: list[TagValue] = [],
2375+
miscOptions: Optional[List[TagValue]] = None,
23762376
) -> Awaitable[List]:
23772377
reqId = self.client.getReqId()
23782378
future = self.wrapper.startReq(reqId, contract)
@@ -2428,7 +2428,7 @@ def reqFundamentalDataAsync(
24282428
self,
24292429
contract: Contract,
24302430
reportType: str,
2431-
fundamentalDataOptions: list[TagValue] = [],
2431+
fundamentalDataOptions: Optional[List[TagValue]] = None,
24322432
) -> Awaitable[str]:
24332433
reqId = self.client.getReqId()
24342434

@@ -2441,13 +2441,13 @@ def reqFundamentalDataAsync(
24412441
async def reqScannerDataAsync(
24422442
self,
24432443
subscription: ScannerSubscription,
2444-
scannerSubscriptionOptions: list[TagValue] = [],
2445-
scannerSubscriptionFilterOptions: list[TagValue] = [],
2444+
scannerSubscriptionOptions: Optional[List[TagValue]] = None,
2445+
scannerSubscriptionFilterOptions: Optional[List[TagValue]] = None,
24462446
) -> ScanDataList:
24472447
dataList = self.reqScannerSubscription(
24482448
subscription,
2449-
scannerSubscriptionOptions or [],
2450-
scannerSubscriptionFilterOptions or [],
2449+
list(scannerSubscriptionOptions or []),
2450+
list(scannerSubscriptionFilterOptions or []),
24512451
)
24522452

24532453
future = self.wrapper.startReq(dataList.reqId, container=dataList)
@@ -2466,7 +2466,7 @@ async def calculateImpliedVolatilityAsync(
24662466
contract: Contract,
24672467
optionPrice: float,
24682468
underPrice: float,
2469-
implVolOptions: list[TagValue] = [],
2469+
implVolOptions: Optional[List[TagValue]] = None,
24702470
) -> Optional[OptionComputation]:
24712471
reqId = self.client.getReqId()
24722472
future = self.wrapper.startReq(reqId, contract)
@@ -2487,7 +2487,7 @@ async def calculateOptionPriceAsync(
24872487
contract: Contract,
24882488
volatility: float,
24892489
underPrice: float,
2490-
optPrcOptions: list[TagValue] = [],
2490+
optPrcOptions: Optional[List[TagValue]] = None,
24912491
) -> Optional[OptionComputation]:
24922492
reqId = self.client.getReqId()
24932493
future = self.wrapper.startReq(reqId, contract)
@@ -2524,7 +2524,7 @@ def reqNewsProvidersAsync(self) -> Awaitable[list[NewsProvider]]:
25242524
return future
25252525

25262526
def reqNewsArticleAsync(
2527-
self, providerCode: str, articleId: str, newsArticleOptions: list[TagValue] = []
2527+
self, providerCode: str, articleId: str, newsArticleOptions: Optional[List[TagValue]] = None
25282528
) -> Awaitable[NewsArticle]:
25292529
reqId = self.client.getReqId()
25302530

@@ -2539,7 +2539,7 @@ async def reqHistoricalNewsAsync(
25392539
startDateTime: Union[str, datetime.date],
25402540
endDateTime: Union[str, datetime.date],
25412541
totalResults: int,
2542-
historicalNewsOptions: list[TagValue] = [],
2542+
historicalNewsOptions: Optional[List[TagValue]] = None,
25432543
) -> Optional[HistoricalNews]:
25442544
reqId = self.client.getReqId()
25452545

0 commit comments

Comments
 (0)