eshan6704 commited on
Commit
97cd7bd
·
verified ·
1 Parent(s): a4d29b7

Update daily.py

Browse files
Files changed (1) hide show
  1. daily.py +14 -27
daily.py CHANGED
@@ -1,11 +1,13 @@
1
  # daily.py
2
  import yfinance as yf
3
  import pandas as pd
4
- from indicater import calculate_indicators
5
- from chart_builder import build_chart
6
- from common import html_card, make_table, wrap_html
7
 
8
- def fetch_daily(symbol):
 
 
 
9
  try:
10
  # --- Fetch historical data ---
11
  df = yf.download(symbol + ".NS", period="6mo", interval="1d")
@@ -13,34 +15,19 @@ def fetch_daily(symbol):
13
  return html_card("Error", f"No daily data found for {symbol}")
14
  df.reset_index(inplace=True)
15
 
16
- # --- Calculate indicators ---
17
- indicators = calculate_indicators(df)
 
18
 
19
- # --- Build chart with injected checkbox script ---
20
- chart_html = build_chart(df, indicators)
21
 
22
- # --- Format table ---
23
- table_html = make_table(df)
24
 
25
- # --- Combine everything in HTML ---
26
  content = f"""
27
  <h2>{symbol} - Daily Data</h2>
28
-
29
- <div>
30
- <b>Select Indicators to Display:</b><br>
31
- <input type="checkbox" class="indicator-toggle" data-trace="1" checked> SMA20
32
- <input type="checkbox" class="indicator-toggle" data-trace="2" checked> SMA50
33
- <input type="checkbox" class="indicator-toggle" data-trace="3"> EMA20
34
- <input type="checkbox" class="indicator-toggle" data-trace="4"> EMA50
35
- <input type="checkbox" class="indicator-toggle" data-trace="5"> MACD
36
- <input type="checkbox" class="indicator-toggle" data-trace="6"> RSI
37
- <input type="checkbox" class="indicator-toggle" data-trace="7"> Stochastic
38
- <button onclick="applyIndicators()">Apply</button>
39
- </div>
40
- <br>
41
-
42
- {chart_html}
43
- <br>
44
  {html_card("Data Table", table_html)}
45
  """
46
 
 
1
  # daily.py
2
  import yfinance as yf
3
  import pandas as pd
4
+ from ta_indi_pat import patterns, indicators
5
+ from common import html_card, wrap_html
 
6
 
7
+ def fetch_daily_full_table(symbol):
8
+ """
9
+ Fetch daily OHLCV data, calculate indicators + patterns, return as HTML table.
10
+ """
11
  try:
12
  # --- Fetch historical data ---
13
  df = yf.download(symbol + ".NS", period="6mo", interval="1d")
 
15
  return html_card("Error", f"No daily data found for {symbol}")
16
  df.reset_index(inplace=True)
17
 
18
+ # --- Calculate indicators and patterns ---
19
+ indicator_df = indicators(df)
20
+ pattern_df = patterns(df)
21
 
22
+ # --- Combine OHLCV + indicators + patterns ---
23
+ combined_df = pd.concat([df, indicator_df, pattern_df], axis=1)
24
 
25
+ # --- Convert to HTML table ---
26
+ table_html = combined_df.to_html(classes="table table-striped table-bordered", border=0, index=False)
27
 
28
+ # --- Wrap in card and full HTML ---
29
  content = f"""
30
  <h2>{symbol} - Daily Data</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  {html_card("Data Table", table_html)}
32
  """
33