@@ -193,8 +193,9 @@ def pandl_for_instrument_across_contracts(
193193    ) ->  pd .DataFrame :
194194        ## can return missing contract 
195195        pandl_store  =  self .instrument_pandl_store 
196-         pandl_for_instrument  =  pandl_store .get (instrument_code , missing_data )
197-         if  pandl_for_instrument  is  missing_data :
196+         try :
197+             pandl_for_instrument  =  pandl_store [instrument_code ]
198+         except  KeyError :
198199            pandl_for_instrument  =  self ._get_pandl_for_instrument_across_contracts (
199200                instrument_code 
200201            )
@@ -204,9 +205,11 @@ def pandl_for_instrument_across_contracts(
204205
205206    @property  
206207    def  instrument_pandl_store (self ):
207-         store  =  getattr (self , "_instrument_pandl_store" , missing_data )
208-         if  store  is  missing_data :
209-             store  =  self ._instrument_pandl_store  =  {}
208+         try :
209+             store  =  getattr (self , "_instrument_pandl_store" )
210+         except  AttributeError :
211+             store  =  {}
212+             setattr (self , "_instrument_pandl_store" , store )
210213        return  store 
211214
212215    def  _get_pandl_for_instrument_across_contracts (
@@ -274,8 +277,9 @@ def perc_pandl_series_for_strategy_instrument_vs_total_capital(
274277        strategy_pandl_store  =  self .strategy_pandl_store 
275278        store_key  =  instrument_strategy .key 
276279
277-         pandl_series  =  strategy_pandl_store .get (store_key , missing_data )
278-         if  pandl_series  is  missing_data :
280+         try :
281+             pandl_series  =  strategy_pandl_store [store_key ]
282+         except  KeyError :
279283            pandl_series  =  (
280284                self ._get_perc_pandl_series_for_strategy_instrument_vs_total_capital (
281285                    instrument_strategy 
@@ -297,9 +301,11 @@ def _get_perc_pandl_series_for_strategy_instrument_vs_total_capital(
297301
298302    @property  
299303    def  strategy_pandl_store (self ):
300-         store  =  getattr (self , "_strategy_pandl_store" , missing_data )
301-         if  store  is  missing_data :
302-             store  =  self ._strategy_pandl_store  =  {}
304+         try :
305+             store  =  getattr (self , "_strategy_pandl_store" )
306+         except  AttributeError :
307+             store  =  {}
308+             setattr (self , "_strategy_pandl_store" , store )
303309        return  store 
304310
305311
0 commit comments