@@ -82,26 +82,24 @@ def process_ticker(ticker, mongo_client):
82
82
time .sleep (10 )
83
83
84
84
for strategy in strategies :
85
- try :
86
85
87
- db = mongo_client .trading_simulator
88
- holdings_collection = db .algorithm_holdings
89
- print (f"Processing { strategy .__name__ } for { ticker } " )
90
- strategy_doc = holdings_collection .find_one ({"strategy" : strategy .__name__ })
91
- if not strategy_doc :
92
- logging .warning (f"Strategy { strategy .__name__ } not found in database. Skipping." )
93
- continue
86
+ db = mongo_client .trading_simulator
87
+ holdings_collection = db .algorithm_holdings
88
+ print (f"Processing { strategy .__name__ } for { ticker } " )
89
+ strategy_doc = holdings_collection .find_one ({"strategy" : strategy .__name__ })
90
+ if not strategy_doc :
91
+ logging .warning (f"Strategy { strategy .__name__ } not found in database. Skipping." )
92
+ continue
94
93
95
- account_cash = strategy_doc ["amount_cash" ]
96
- total_portfolio_value = strategy_doc ["portfolio_value" ]
94
+ account_cash = strategy_doc ["amount_cash" ]
95
+ total_portfolio_value = strategy_doc ["portfolio_value" ]
97
96
98
-
99
- portfolio_qty = strategy_doc ["holdings" ].get (ticker , {}).get ("quantity" , 0 )
97
+
98
+ portfolio_qty = strategy_doc ["holdings" ].get (ticker , {}).get ("quantity" , 0 )
100
99
101
- simulate_trade (ticker , strategy , historical_data , current_price ,
102
- account_cash , portfolio_qty , total_portfolio_value , mongo_client )
103
- except Exception as e :
104
- logging .error (f"Error processing { ticker } for { strategy .__name__ } : { e } " )
100
+ simulate_trade (ticker , strategy , historical_data , current_price ,
101
+ account_cash , portfolio_qty , total_portfolio_value , mongo_client )
102
+
105
103
print (f"{ ticker } processing completed." )
106
104
except Exception as e :
107
105
logging .error (f"Error in thread for { ticker } : { e } " )
0 commit comments