Skip to content

Commit 162c140

Browse files
committedDec 8, 2024
removed dynamic ranking for now - testing failed because of yfinance throttling
1 parent 7c2e43c commit 162c140

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed
 

‎ranking_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def process_ticker(ticker, mongo_client):
7575
time.sleep(10)
7676
while historical_data is None:
7777
try:
78-
period = dynamic_period_selector(ticker)
79-
historical_data = get_data(ticker, period)
78+
79+
historical_data = get_data(ticker)
8080
except Exception as fetch_error:
8181
logging.warning(f"Error fetching historical data for {ticker}. Retrying... {fetch_error}")
8282
time.sleep(10)

‎strategies/talib_indicators.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ def MAMA_indicator(ticker, data):
103103
close_prices = data['Close'].values
104104

105105
# Validate enough data
106+
"""
106107
if len(close_prices) < 32: # Minimum length required by MAMA
107108
raise ValueError("Not enough data to compute MAMA.")
108-
109+
"""
109110
# Calculate MAMA and FAMA
110111
try:
111112
mama, fama = ta.MAMA(close_prices, fastlimit=0.5, slowlimit=0.05)
@@ -136,11 +137,11 @@ def MAVP_indicator(ticker, data):
136137
"""
137138

138139
close_prices = data['Close'].values
139-
140+
"""
140141
# Validate enough data
141142
if len(close_prices) < 30: # Ensure enough data for MAVP calculation
142143
raise ValueError("Not enough data to compute MAVP.")
143-
144+
"""
144145
# Define variable periods as a NumPy array
145146
variable_periods = np.full(len(close_prices), 30, dtype=np.float64)
146147
# Calculate MAVP

‎testing_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ def test_strategies():
4141

4242

4343
if __name__ == "__main__":
44-
test_strategies()
44+
print(get_latest_price('VRTX'))
45+
"""
46+
test_strategies()
47+
"""

‎trading_client.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def main():
114114
early_hour_first_iteration = False
115115
post_hour_first_iteration = True
116116
account = trading_client.get_account()
117-
117+
qqq_latest = get_latest_price('QQQ')
118+
spy_latest = get_latest_price('SPY')
118119
buy_heap = []
119120
for ticker in ndaq_tickers:
120121
decisions_and_quantities = []
@@ -134,13 +135,15 @@ def main():
134135
we update instead of insert
135136
"""
136137
portfolio_collection.update_one({"name" : "portfolio_percentage"}, {"$set": {"portfolio_percentage": (portfolio_value-50000)/50000}})
137-
portfolio_collection.update_one({"name" : "ndaq_percentage"}, {"$set": {"portfolio_percentage": (get_latest_price('QQQ')-503.17)/503.17}})
138-
portfolio_collection.update_one({"name" : "spy_percentage"}, {"$set": {"portfolio_percentage": (get_latest_price('SPY')-590.50)/590.50}})
138+
portfolio_collection.update_one({"name" : "ndaq_percentage"}, {"$set": {"portfolio_percentage": (qqq_latest-503.17)/503.17}})
139+
portfolio_collection.update_one({"name" : "spy_percentage"}, {"$set": {"portfolio_percentage": (spy_latest-590.50)/590.50}})
140+
139141
historical_data = None
140142
while historical_data is None:
141143
try:
142-
period = dynamic_period_selector(ticker)
143-
historical_data = get_data(ticker, period)
144+
145+
146+
historical_data = get_data(ticker)
144147
except:
145148
print(f"Error fetching data for {ticker}. Retrying...")
146149

@@ -151,6 +154,7 @@ def main():
151154
current_price = get_latest_price(ticker)
152155
except:
153156
print(f"Error fetching price for {ticker}. Retrying...")
157+
time.sleep(10)
154158
print(f"Current price of {ticker}: {current_price}")
155159

156160
asset_info = asset_collection.find_one({'symbol': ticker})
@@ -199,6 +203,7 @@ def main():
199203
print(f"buy_coeff: {buy_coeff}, quantity: {quantity}, ticker: {ticker}")
200204

201205
order = place_order(trading_client, ticker, OrderSide.BUY, qty=quantity, mongo_url=mongo_url) # Place order using helper
206+
202207
logging.info(f"Executed BUY order for {ticker}: {order}")
203208

204209
trading_client = TradingClient(API_KEY, API_SECRET)

0 commit comments

Comments
 (0)