@@ -105,10 +105,10 @@ def build_account_state_from_portfolio_snapshot(
105105) -> dict [str , Any ]:
106106 metadata = getattr (snapshot , "metadata" , {}) or {}
107107 raw_sellable_quantities = metadata .get ("sellable_quantities" ) if isinstance (metadata , Mapping ) else None
108- resolved_sellable_quantities : dict [str , int ] = {}
108+ resolved_sellable_quantities : dict [str , float ] = {}
109109 if isinstance (raw_sellable_quantities , Mapping ):
110110 resolved_sellable_quantities = {
111- str (symbol ).strip ().upper (): int (quantity )
111+ str (symbol ).strip ().upper (): float (quantity )
112112 for symbol , quantity in raw_sellable_quantities .items ()
113113 if str (symbol ).strip ()
114114 }
@@ -117,25 +117,25 @@ def build_account_state_from_portfolio_snapshot(
117117
118118 if filter_enabled :
119119 market_values = {symbol : 0.0 for symbol in normalized_symbols }
120- quantities = {symbol : 0 for symbol in normalized_symbols }
121- sellable_quantities = {symbol : 0 for symbol in normalized_symbols }
120+ quantities = {symbol : 0.0 for symbol in normalized_symbols }
121+ sellable_quantities = {symbol : 0.0 for symbol in normalized_symbols }
122122 else :
123123 market_values : dict [str , float ] = {}
124- quantities : dict [str , int ] = {}
125- sellable_quantities : dict [str , int ] = {}
124+ quantities : dict [str , float ] = {}
125+ sellable_quantities : dict [str , float ] = {}
126126
127127 for position in getattr (snapshot , "positions" , ()) or ():
128128 symbol = str (position .symbol ).strip ().upper ()
129129 if filter_enabled and symbol not in market_values :
130130 continue
131131 if symbol not in market_values :
132132 market_values [symbol ] = 0.0
133- quantities [symbol ] = 0
134- sellable_quantities [symbol ] = 0
133+ quantities [symbol ] = 0.0
134+ sellable_quantities [symbol ] = 0.0
135135
136- quantity = int (position .quantity )
136+ quantity = float (position .quantity )
137137 quantities [symbol ] = quantity
138- sellable_quantities [symbol ] = int (resolved_sellable_quantities .get (symbol , quantity ))
138+ sellable_quantities [symbol ] = float (resolved_sellable_quantities .get (symbol , quantity ))
139139 market_values [symbol ] = float (position .market_value )
140140
141141 resolved_liquid_cash = liquid_cash
@@ -179,7 +179,7 @@ def build_portfolio_snapshot_from_account_state(
179179
180180 positions : list [Position ] = []
181181 for symbol in symbols :
182- quantity = int (quantities .get (symbol , 0 ))
182+ quantity = float (quantities .get (symbol , 0. 0 ))
183183 market_value = float (market_values .get (symbol , 0.0 ))
184184 if quantity <= 0 and market_value <= 0.0 :
185185 continue
@@ -208,7 +208,7 @@ def build_portfolio_snapshot_from_account_state(
208208 raw_sellable_quantities = account_state .get ("sellable_quantities" )
209209 if isinstance (raw_sellable_quantities , Mapping ):
210210 sellable_quantities = {
211- str (symbol ).strip ().upper (): int (quantity )
211+ str (symbol ).strip ().upper (): float (quantity )
212212 for symbol , quantity in raw_sellable_quantities .items ()
213213 if str (symbol ).strip ()
214214 }
0 commit comments