Skip to content

Commit 756d386

Browse files
committed
fixed error escape problem
1 parent 89f009d commit 756d386

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

ranking_client.py

+14-16
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,24 @@ def process_ticker(ticker, mongo_client):
8282
time.sleep(10)
8383

8484
for strategy in strategies:
85-
try:
8685

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
9493

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"]
9796

98-
99-
portfolio_qty = strategy_doc["holdings"].get(ticker, {}).get("quantity", 0)
97+
98+
portfolio_qty = strategy_doc["holdings"].get(ticker, {}).get("quantity", 0)
10099

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+
105103
print(f"{ticker} processing completed.")
106104
except Exception as e:
107105
logging.error(f"Error in thread for {ticker}: {e}")

0 commit comments

Comments
 (0)