Skip to content

Commit 7667816

Browse files
committed
#91 Fixed incorrect .upper() conversion for FIGI in CLI argument parsing.
FIGI identifiers are case-sensitive and must be preserved as-is. Tickers remain uppercased for normalization.
1 parent 3218963 commit 7667816

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tksbrokerapi/TKSBrokerAPI.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,19 +615,25 @@ def ticker(self, value):
615615

616616
@property
617617
def figi(self) -> str:
618-
"""String with FIGI, e.g. ticker `GOOGL` has FIGI `BBG009S39JX6`. FIGIs may be upper case only.
618+
"""
619+
String with FIGI identifier. FIGIs are case-sensitive and must be used as provided.
620+
621+
Example: ticker `GOOGL` has FIGI `BBG009S39JX6`.
619622
620623
See also: `SearchByFIGI()`, `SearchInstruments()`.
621624
"""
622625
return self._figi
623626

624627
@figi.setter
625628
def figi(self, value):
626-
"""Setter for string with FIGI, e.g. ticker `GOOGL` has FIGI `BBG009S39JX6`. FIGIs may be upper case only.
629+
"""
630+
Setter for FIGI. FIGIs are case-sensitive and must be stored exactly as provided.
631+
632+
Do not apply case conversion to avoid breaking identification in the Tinkoff Invest API.
627633
628634
See also: `SearchByFIGI()`, `SearchInstruments()`.
629635
"""
630-
self._figi = str(value).upper() # FIGI may be upper case only
636+
self._figi = str(value) # Preserve FIGI case as-is.
631637

632638
def _ParseJSON(self, rawData="{}") -> dict:
633639
"""
@@ -5400,7 +5406,7 @@ def Main(**kwargs):
54005406
trader.ticker = ticker
54015407

54025408
if args.figi:
5403-
trader.figi = str(args.figi).upper() # FIGIs may be upper case only
5409+
trader.figi = str(args.figi) # FIGIs are case-sensitive — do not convert case.
54045410

54055411
if args.depth is not None:
54065412
trader.depth = args.depth
@@ -5684,7 +5690,7 @@ def Main(**kwargs):
56845690
trader.CloseTrades([str(args.ticker).upper()]) # close only one trade by ticker (priority)
56855691

56865692
else:
5687-
trader.CloseTrades([str(args.figi).upper()]) # close only one trade by FIGI
5693+
trader.CloseTrades([str(args.figi)]) # FIGIs are case-sensitive — must be used as-is
56885694

56895695
elif args.close_trades is not None:
56905696
trader.CloseTrades(args.close_trades) # close trades for list of tickers
@@ -5694,7 +5700,7 @@ def Main(**kwargs):
56945700
trader.CloseAllByTicker(instrument=str(args.ticker).upper())
56955701

56965702
elif args.figi:
5697-
trader.CloseAllByFIGI(instrument=str(args.figi).upper())
5703+
trader.CloseAllByFIGI(instrument=str(args.figi)) # Preserve FIGI case (do not modify).
56985704

56995705
else:
57005706
trader.CloseAll(*args.close_all)

0 commit comments

Comments
 (0)