Skip to content

Commit 340cd7c

Browse files
author
Nick Baskerville
committed
Remove mutable default types.
1 parent 38cf54a commit 340cd7c

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

ib_async/ib.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import datetime
66
import logging
77
import time
8-
from typing import Any, Awaitable, Dict, Iterator, List, Optional, Union
8+
from typing import Any, Awaitable, Iterator, List, Optional, Sequence, Union
99

1010
from eventkit import Event
1111
from enum import Flag, auto
@@ -1114,7 +1114,7 @@ def reqRealTimeBars(
11141114
barSize: int,
11151115
whatToShow: str,
11161116
useRTH: bool,
1117-
realTimeBarsOptions: List[TagValue] = [],
1117+
realTimeBarsOptions: Sequence[TagValue] = (),
11181118
) -> RealTimeBarList:
11191119
"""
11201120
Request realtime 5 second bars.
@@ -1137,7 +1137,7 @@ def reqRealTimeBars(
11371137
bars.barSize = barSize
11381138
bars.whatToShow = whatToShow
11391139
bars.useRTH = useRTH
1140-
bars.realTimeBarsOptions = realTimeBarsOptions or []
1140+
bars.realTimeBarsOptions = list(realTimeBarsOptions or [])
11411141
self.wrapper.startSubscription(reqId, bars, contract)
11421142
self.client.reqRealTimeBars(
11431143
reqId, contract, barSize, whatToShow, useRTH, realTimeBarsOptions
@@ -1164,7 +1164,7 @@ def reqHistoricalData(
11641164
useRTH: bool,
11651165
formatDate: int = 1,
11661166
keepUpToDate: bool = False,
1167-
chartOptions: List[TagValue] = [],
1167+
chartOptions: Sequence[TagValue] = (),
11681168
timeout: float = 60,
11691169
) -> BarDataList:
11701170
"""
@@ -1271,7 +1271,7 @@ def reqHistoricalTicks(
12711271
whatToShow: str,
12721272
useRth: bool,
12731273
ignoreSize: bool = False,
1274-
miscOptions: List[TagValue] = [],
1274+
miscOptions: Sequence[TagValue] = (),
12751275
) -> List:
12761276
"""
12771277
Request historical ticks. The time resolution of the ticks
@@ -1351,7 +1351,7 @@ def reqMktData(
13511351
genericTickList: str = "",
13521352
snapshot: bool = False,
13531353
regulatorySnapshot: bool = False,
1354-
mktDataOptions: List[TagValue] = [],
1354+
mktDataOptions: Sequence[TagValue] = (),
13551355
) -> Ticker:
13561356
"""
13571357
Subscribe to tick data or request a snapshot.
@@ -1568,7 +1568,7 @@ def reqFundamentalData(
15681568
self,
15691569
contract: Contract,
15701570
reportType: str,
1571-
fundamentalDataOptions: List[TagValue] = [],
1571+
fundamentalDataOptions: Sequence[TagValue] = (),
15721572
) -> str:
15731573
"""
15741574
Get fundamental data of a contract in XML format.
@@ -1596,8 +1596,8 @@ def reqFundamentalData(
15961596
def reqScannerData(
15971597
self,
15981598
subscription: ScannerSubscription,
1599-
scannerSubscriptionOptions: List[TagValue] = [],
1600-
scannerSubscriptionFilterOptions: List[TagValue] = [],
1599+
scannerSubscriptionOptions: Sequence[TagValue] = (),
1600+
scannerSubscriptionFilterOptions: Sequence[TagValue] = (),
16011601
) -> ScanDataList:
16021602
"""
16031603
Do a blocking market scan by starting a subscription and canceling it
@@ -1623,8 +1623,8 @@ def reqScannerData(
16231623
def reqScannerSubscription(
16241624
self,
16251625
subscription: ScannerSubscription,
1626-
scannerSubscriptionOptions: List[TagValue] = [],
1627-
scannerSubscriptionFilterOptions: List[TagValue] = [],
1626+
scannerSubscriptionOptions: Sequence[TagValue] = (),
1627+
scannerSubscriptionFilterOptions: Sequence[TagValue] = (),
16281628
) -> ScanDataList:
16291629
"""
16301630
Subscribe to market scan data.
@@ -1640,8 +1640,8 @@ def reqScannerSubscription(
16401640
dataList = ScanDataList()
16411641
dataList.reqId = reqId
16421642
dataList.subscription = subscription
1643-
dataList.scannerSubscriptionOptions = scannerSubscriptionOptions or []
1644-
dataList.scannerSubscriptionFilterOptions = (
1643+
dataList.scannerSubscriptionOptions = list(scannerSubscriptionOptions or [])
1644+
dataList.scannerSubscriptionFilterOptions = list(
16451645
scannerSubscriptionFilterOptions or []
16461646
)
16471647
self.wrapper.startSubscription(reqId, dataList)
@@ -1679,7 +1679,7 @@ def calculateImpliedVolatility(
16791679
contract: Contract,
16801680
optionPrice: float,
16811681
underPrice: float,
1682-
implVolOptions: List[TagValue] = [],
1682+
implVolOptions: Sequence[TagValue] = (),
16831683
) -> OptionComputation:
16841684
"""
16851685
Calculate the volatility given the option price.
@@ -1705,7 +1705,7 @@ def calculateOptionPrice(
17051705
contract: Contract,
17061706
volatility: float,
17071707
underPrice: float,
1708-
optPrcOptions: List[TagValue] = [],
1708+
optPrcOptions: Sequence[TagValue] = (),
17091709
) -> OptionComputation:
17101710
"""
17111711
Calculate the option price given the volatility.
@@ -1718,7 +1718,7 @@ def calculateOptionPrice(
17181718
contract: Option contract.
17191719
volatility: Option volatility to use in calculation.
17201720
underPrice: Price of the underlier to use in calculation
1721-
implVolOptions: Unknown
1721+
optPrcOptions: TODO
17221722
"""
17231723
return self._run(
17241724
self.calculateOptionPriceAsync(
@@ -1792,7 +1792,7 @@ def reqNewsProviders(self) -> List[NewsProvider]:
17921792
return self._run(self.reqNewsProvidersAsync())
17931793

17941794
def reqNewsArticle(
1795-
self, providerCode: str, articleId: str, newsArticleOptions: List[TagValue] = []
1795+
self, providerCode: str, articleId: str, newsArticleOptions: Sequence[TagValue] = ()
17961796
) -> NewsArticle:
17971797
"""
17981798
Get the body of a news article.
@@ -1817,7 +1817,7 @@ def reqHistoricalNews(
18171817
startDateTime: Union[str, datetime.date],
18181818
endDateTime: Union[str, datetime.date],
18191819
totalResults: int,
1820-
historicalNewsOptions: List[TagValue] = [],
1820+
historicalNewsOptions: Sequence[TagValue] = (),
18211821
) -> HistoricalNews:
18221822
"""
18231823
Get historical news headline.
@@ -2261,7 +2261,7 @@ async def reqHistoricalDataAsync(
22612261
useRTH: bool,
22622262
formatDate: int = 1,
22632263
keepUpToDate: bool = False,
2264-
chartOptions: List[TagValue] = [],
2264+
chartOptions: Sequence[TagValue] = (),
22652265
timeout: float = 60,
22662266
) -> BarDataList:
22672267
reqId = self.client.getReqId()
@@ -2275,7 +2275,7 @@ async def reqHistoricalDataAsync(
22752275
bars.useRTH = useRTH
22762276
bars.formatDate = formatDate
22772277
bars.keepUpToDate = keepUpToDate
2278-
bars.chartOptions = chartOptions or []
2278+
bars.chartOptions = list(chartOptions or [])
22792279
future = self.wrapper.startReq(reqId, contract, container=bars)
22802280
if keepUpToDate:
22812281
self.wrapper.startSubscription(reqId, bars, contract)
@@ -2336,7 +2336,7 @@ def reqHistoricalTicksAsync(
23362336
whatToShow: str,
23372337
useRth: bool,
23382338
ignoreSize: bool = False,
2339-
miscOptions: List[TagValue] = [],
2339+
miscOptions: Sequence[TagValue] = (),
23402340
) -> Awaitable[List]:
23412341
reqId = self.client.getReqId()
23422342
future = self.wrapper.startReq(reqId, contract)
@@ -2392,7 +2392,7 @@ def reqFundamentalDataAsync(
23922392
self,
23932393
contract: Contract,
23942394
reportType: str,
2395-
fundamentalDataOptions: List[TagValue] = [],
2395+
fundamentalDataOptions: Sequence[TagValue] = (),
23962396
) -> Awaitable[str]:
23972397
reqId = self.client.getReqId()
23982398

@@ -2405,13 +2405,13 @@ def reqFundamentalDataAsync(
24052405
async def reqScannerDataAsync(
24062406
self,
24072407
subscription: ScannerSubscription,
2408-
scannerSubscriptionOptions: List[TagValue] = [],
2409-
scannerSubscriptionFilterOptions: List[TagValue] = [],
2408+
scannerSubscriptionOptions: Sequence[TagValue] = (),
2409+
scannerSubscriptionFilterOptions: Sequence[TagValue] = (),
24102410
) -> ScanDataList:
24112411
dataList = self.reqScannerSubscription(
24122412
subscription,
2413-
scannerSubscriptionOptions or [],
2414-
scannerSubscriptionFilterOptions or [],
2413+
list(scannerSubscriptionOptions or []),
2414+
list(scannerSubscriptionFilterOptions or []),
24152415
)
24162416

24172417
future = self.wrapper.startReq(dataList.reqId, container=dataList)
@@ -2430,7 +2430,7 @@ async def calculateImpliedVolatilityAsync(
24302430
contract: Contract,
24312431
optionPrice: float,
24322432
underPrice: float,
2433-
implVolOptions: List[TagValue] = [],
2433+
implVolOptions: Sequence[TagValue] = (),
24342434
) -> Optional[OptionComputation]:
24352435
reqId = self.client.getReqId()
24362436
future = self.wrapper.startReq(reqId, contract)
@@ -2451,7 +2451,7 @@ async def calculateOptionPriceAsync(
24512451
contract: Contract,
24522452
volatility: float,
24532453
underPrice: float,
2454-
optPrcOptions: List[TagValue] = [],
2454+
optPrcOptions: Sequence[TagValue] = (),
24552455
) -> Optional[OptionComputation]:
24562456
reqId = self.client.getReqId()
24572457
future = self.wrapper.startReq(reqId, contract)
@@ -2488,7 +2488,7 @@ def reqNewsProvidersAsync(self) -> Awaitable[List[NewsProvider]]:
24882488
return future
24892489

24902490
def reqNewsArticleAsync(
2491-
self, providerCode: str, articleId: str, newsArticleOptions: List[TagValue] = []
2491+
self, providerCode: str, articleId: str, newsArticleOptions: Sequence[TagValue] = ()
24922492
) -> Awaitable[NewsArticle]:
24932493
reqId = self.client.getReqId()
24942494

@@ -2503,7 +2503,7 @@ async def reqHistoricalNewsAsync(
25032503
startDateTime: Union[str, datetime.date],
25042504
endDateTime: Union[str, datetime.date],
25052505
totalResults: int,
2506-
historicalNewsOptions: List[TagValue] = [],
2506+
historicalNewsOptions: Sequence[TagValue] = (),
25072507
) -> Optional[HistoricalNews]:
25082508
reqId = self.client.getReqId()
25092509

0 commit comments

Comments
 (0)