Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,7 +141,7 @@ def clean_ohlc(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 141 |
df_sel = df_sel.dropna(subset=['Open', 'High', 'Low', 'Close']).copy()
|
| 142 |
|
| 143 |
if df_sel.empty:
|
| 144 |
-
raise ValueError("
|
| 145 |
|
| 146 |
# ensure ordering ascending by date
|
| 147 |
df_sel = df_sel.sort_index()
|
|
@@ -231,15 +231,15 @@ def plot_stock_with_patterns(ticker_symbol: str, start_date: str, end_date: str,
|
|
| 231 |
Main handler for Gradio. Returns (image_filepath or None, status_message).
|
| 232 |
"""
|
| 233 |
if not ticker_symbol:
|
| 234 |
-
return None, "Error:
|
| 235 |
|
| 236 |
try:
|
| 237 |
start = pd.to_datetime(start_date)
|
| 238 |
end = pd.to_datetime(end_date)
|
| 239 |
if start >= end:
|
| 240 |
-
return None, "Error:
|
| 241 |
except Exception:
|
| 242 |
-
return None, "Error:
|
| 243 |
|
| 244 |
# download
|
| 245 |
try:
|
|
@@ -292,19 +292,19 @@ def plot_stock_with_patterns(ticker_symbol: str, start_date: str, end_date: str,
|
|
| 292 |
figscale=1.5
|
| 293 |
)
|
| 294 |
fig.savefig(fig_path, dpi=150, bbox_inches='tight')
|
| 295 |
-
return fig_path, "
|
| 296 |
except Exception as e:
|
| 297 |
-
return None, f"
|
| 298 |
|
| 299 |
# Gradio arayüzü
|
| 300 |
iface = gr.Interface(
|
| 301 |
fn=plot_stock_with_patterns,
|
| 302 |
inputs=[
|
| 303 |
-
gr.Textbox(label="
|
| 304 |
-
gr.Textbox(label="
|
| 305 |
-
gr.Textbox(label="
|
| 306 |
gr.CheckboxGroup(
|
| 307 |
-
label="
|
| 308 |
choices=TALIB_PATTERNS,
|
| 309 |
value=["CDLHAMMER", "CDLSHOOTINGSTAR"]
|
| 310 |
)
|
|
@@ -313,8 +313,8 @@ iface = gr.Interface(
|
|
| 313 |
gr.Image(type="filepath", label="Hisse Grafiği"),
|
| 314 |
gr.Textbox(label="Durum")
|
| 315 |
],
|
| 316 |
-
title="TALib
|
| 317 |
-
description="
|
| 318 |
)
|
| 319 |
|
| 320 |
if __name__ == "__main__":
|
|
|
|
| 141 |
df_sel = df_sel.dropna(subset=['Open', 'High', 'Low', 'Close']).copy()
|
| 142 |
|
| 143 |
if df_sel.empty:
|
| 144 |
+
raise ValueError("value error.")
|
| 145 |
|
| 146 |
# ensure ordering ascending by date
|
| 147 |
df_sel = df_sel.sort_index()
|
|
|
|
| 231 |
Main handler for Gradio. Returns (image_filepath or None, status_message).
|
| 232 |
"""
|
| 233 |
if not ticker_symbol:
|
| 234 |
+
return None, "Error: stock symbol could not empty."
|
| 235 |
|
| 236 |
try:
|
| 237 |
start = pd.to_datetime(start_date)
|
| 238 |
end = pd.to_datetime(end_date)
|
| 239 |
if start >= end:
|
| 240 |
+
return None, "Error: date error."
|
| 241 |
except Exception:
|
| 242 |
+
return None, "Error: invalid date format"
|
| 243 |
|
| 244 |
# download
|
| 245 |
try:
|
|
|
|
| 292 |
figscale=1.5
|
| 293 |
)
|
| 294 |
fig.savefig(fig_path, dpi=150, bbox_inches='tight')
|
| 295 |
+
return fig_path, "Successfully created!"
|
| 296 |
except Exception as e:
|
| 297 |
+
return None, f"error: {e}"
|
| 298 |
|
| 299 |
# Gradio arayüzü
|
| 300 |
iface = gr.Interface(
|
| 301 |
fn=plot_stock_with_patterns,
|
| 302 |
inputs=[
|
| 303 |
+
gr.Textbox(label="Stock Symbol (örn: MSFT, AAPL, ^GSPC)", value="MSFT"),
|
| 304 |
+
gr.Textbox(label="Starting Date (YYYY-MM-DD)", value="2024-01-01"),
|
| 305 |
+
gr.Textbox(label="End Date (YYYY-MM-DD)", value=date.today().strftime("%Y-%m-%d")),
|
| 306 |
gr.CheckboxGroup(
|
| 307 |
+
label="Select one (TALib)",
|
| 308 |
choices=TALIB_PATTERNS,
|
| 309 |
value=["CDLHAMMER", "CDLSHOOTINGSTAR"]
|
| 310 |
)
|
|
|
|
| 313 |
gr.Image(type="filepath", label="Hisse Grafiği"),
|
| 314 |
gr.Textbox(label="Durum")
|
| 315 |
],
|
| 316 |
+
title="TALib Tool",
|
| 317 |
+
description="bullish green, bearish red"
|
| 318 |
)
|
| 319 |
|
| 320 |
if __name__ == "__main__":
|