@@ -119,7 +119,7 @@ def _p(name):
119119 self ._id_instrument_map : Dict [str , Dict [datetime , Instrument ]] = {}
120120 self ._sym_instrument_map : Dict [str , Dict [datetime , Instrument ]] = {}
121121 self ._id_or_sym_instrument_map : Mapping [str , Dict [datetime , Instrument ]] = ChainMap (self ._id_instrument_map , self ._sym_instrument_map )
122- self ._grouped_instruments : Dict [INSTRUMENT_TYPE , Dict [ datetime , Instrument ]] = {}
122+ self ._grouped_instruments : Dict [INSTRUMENT_TYPE , List [ Instrument ]] = {}
123123
124124 # register instruments
125125 self .register_instruments (load_instruments_from_pkl (_p ('instruments.pk' ), self ._future_info_store ))
@@ -152,7 +152,7 @@ def register_instruments(self, instruments: Iterable[Instrument]):
152152 for ins in instruments :
153153 self ._id_instrument_map .setdefault (ins .order_book_id , {})[ins .listed_date ] = ins
154154 self ._sym_instrument_map .setdefault (ins .symbol , {})[ins .listed_date ] = ins
155- self ._grouped_instruments .setdefault (ins .type , {})[ ins . listed_date ] = ins
155+ self ._grouped_instruments .setdefault (ins .type , []). append ( ins )
156156
157157 def register_dividend_store (self , instrument_type : INSTRUMENT_TYPE , dividend_store : AbstractDividendStore , market : MARKET = MARKET .CN ):
158158 self ._dividend_stores [instrument_type , market ] = dividend_store
@@ -197,7 +197,7 @@ def get_instruments(self, id_or_syms: Optional[Iterable[str]] = None, types: Opt
197197 yield ins
198198 else :
199199 for t in types or self ._grouped_instruments .keys ():
200- yield from self ._grouped_instruments [t ]. values ()
200+ yield from self ._grouped_instruments [t ]
201201
202202 def get_share_transformation (self , order_book_id ):
203203 return self ._share_transformation .get_share_transformation (order_book_id )
0 commit comments