Skip to content

Commit

Permalink
fix: 🐛 fix for CQRS and changes to stock data analysis.
Browse files Browse the repository at this point in the history
fix for CQRS and changes to stock data analysis.
  • Loading branch information
adhilabu committed Aug 31, 2024
1 parent 732ebab commit f70e7db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/analysis/stock_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def find_support_resistance(request: GetLevelsRequest):
if data.empty or len(data) < 2 or data.iloc[-1]['Close'] < 50:
continue # Skip this symbol

# # Calculate percentage movement over a rolling window of 15 trading days
# data['Pct_Change'] = data['Close'].pct_change(periods=15) * 100

# # Check if the maximum percentage movement within 15 days exceeds 10%
# max_pct_change = data['Pct_Change'].abs().max()
# if max_pct_change <= 10:
# continue # Skip this symbol if the movement is not significant

# Calculate support and resistance levels
data['Support'] = data['Low'].rolling(window=20).min()
data['Resistance'] = data['High'].rolling(window=20).max()
Expand Down Expand Up @@ -87,16 +95,10 @@ def find_support_resistance(request: GetLevelsRequest):

def create_ranges(levels):
def get_range_diff(value):
if value < 50:
return 2
elif value < 100:
return 5
elif value < 1000:
return 20
elif value < 10000:
return 50
else:
return 100
base_diff = 2
increment_per_50 = 0.04 # Define how much the range should increase per 50-point increase in value
multiplier = value // 50
return base_diff + (increment_per_50 * multiplier * 50)

ranges = []
for level in levels:
Expand Down
1 change: 1 addition & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"http://localhost",
"http://localhost:8080",
"http://localhost:3000",
"http://www.aksyo.in"
]

app.add_middleware(
Expand Down

0 comments on commit f70e7db

Please sign in to comment.