kaganseyda commited on
Commit
91c96e5
·
verified ·
1 Parent(s): 57c6132

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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("Veri temizlendikten sonra boş kaldı (OHLC yok).")
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: Hisse sembolü boş olamaz."
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: Başlangıç tarihi bitişten önce olmalı."
241
  except Exception:
242
- return None, "Error: Tarih formatı geçersiz. YYYY-MM-DD şeklinde girin."
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, "Grafik başarıyla oluşturuldu!"
296
  except Exception as e:
297
- return None, f"Grafik çiziminde hata: {e}"
298
 
299
  # Gradio arayüzü
300
  iface = gr.Interface(
301
  fn=plot_stock_with_patterns,
302
  inputs=[
303
- gr.Textbox(label="Hisse Sembolü (örn: MSFT, AAPL, ^GSPC)", value="MSFT"),
304
- gr.Textbox(label="Başlangıç Tarihi (YYYY-MM-DD)", value="2024-01-01"),
305
- gr.Textbox(label="Bitiş Tarihi (YYYY-MM-DD)", value=date.today().strftime("%Y-%m-%d")),
306
  gr.CheckboxGroup(
307
- label="Formasyon Seç (TALib Destekli)",
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 Formasyon Tespit Aracı",
317
- description="Seçtiğin mum formasyonlarını grafikte yeşil (boğa) ve kırmızı (ayı) işaretlerle gösterir."
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__":