@@ -782,19 +782,64 @@ def get_list_of_exchanges(self):
782782 api_call = ListOfExchangesAPI ()
783783 return api_call .get_list_of_exchanges (api_token = self ._api_key )
784784
785- def get_list_of_tickers (self , code , delisted = 0 ):
786- """Available args:
787- delisted (not required) - by default, this API provides only tickers that were active at least a month ago,
788- to get the list of inactive (delisted) tickers please use the parameter “delisted=1”
789- code (required) - For US exchanges you can also get all US tickers,
790- then you should use the ‘US’ exchange code and tickers only for the particular exchange,
791- the list of possible US exchanges to request:'US', 'NYSE', 'NASDAQ', 'BATS', 'OTCQB', 'PINK', 'OTCQX',
792- 'OTCMKTS', 'NMFQS', 'NYSE MKT', 'OTCBB', 'OTCGREY', 'BATS', 'OTC'
793- For more information visit: https://eodhistoricaldata.com/financial-apis/exchanges-api-list-of-tickers-and-trading-hours/
785+ def get_list_of_tickers (self , code : str , delisted : int = 0 , include_delisted : bool = False ):
786+ """Get list of tickers for an exchange.
787+
788+ Parameters
789+ ----------
790+ code : str
791+ Exchange code (e.g., "US", "NYSE", "NASDAQ", etc.).
792+ delisted : int, optional
793+ 0 = listed only, 1 = delisted only. Ignored if include_delisted=True.
794+ include_delisted : bool, optional
795+ If True, returns both listed and delisted tickers.
796+
797+ Notes
798+ -----
799+ - By default, the API returns only tickers that were active at least a month ago.
800+ - delisted=1 returns delisted tickers only.
801+ - include_delisted=True returns both listed and delisted tickers.
794802 """
803+ if code is None or str (code ).strip () == "" :
804+ raise ValueError ("Parameter 'code' is required (exchange code)." )
805+
806+ # Allow 0/1 as well as True/False
807+ include_delisted = bool (include_delisted )
808+
809+ if delisted not in (0 , 1 ):
810+ raise ValueError ("Parameter 'delisted' must be 0 or 1." )
795811
796812 api_call = ListOfExchangesAPI ()
797- return api_call .get_list_of_tickers (api_token = self ._api_key , delisted = delisted , code = code )
813+
814+ if not include_delisted :
815+ return api_call .get_list_of_tickers (api_token = self ._api_key , delisted = delisted , code = code )
816+
817+ # include_delisted=True: fetch both
818+ listed = api_call .get_list_of_tickers (api_token = self ._api_key , delisted = 0 , code = code )
819+ delisted_list = api_call .get_list_of_tickers (api_token = self ._api_key , delisted = 1 , code = code )
820+
821+ if isinstance (listed , list ) and isinstance (delisted_list , list ):
822+ return listed + delisted_list
823+
824+ if isinstance (listed , dict ) and isinstance (delisted_list , dict ):
825+ if "data" in listed and "data" in delisted_list and isinstance (listed ["data" ], list ) and isinstance (
826+ delisted_list ["data" ], list ):
827+ merged = dict (listed )
828+ merged ["data" ] = listed ["data" ] + delisted_list ["data" ]
829+ # optional: recompute meta.total if present
830+ if "meta" in merged and isinstance (merged ["meta" ], dict ):
831+ total = None
832+ try :
833+ total = len (merged ["data" ])
834+ except Exception :
835+ total = None
836+ if total is not None :
837+ merged ["meta" ]["total" ] = total
838+ return merged
839+
840+ return {"listed" : listed , "delisted" : delisted_list }
841+
842+ return {"listed" : listed , "delisted" : delisted_list }
798843
799844 def get_details_trading_hours_stock_market_holidays (self , code , from_date = None , to_date = None ):
800845 """Available args:
0 commit comments