eshan6704 commited on
Commit
bfbc38e
·
verified ·
1 Parent(s): da08f9b

Delete index.py

Browse files
Files changed (1) hide show
  1. index.py +0 -116
index.py DELETED
@@ -1,116 +0,0 @@
1
- '''import io
2
- import requests
3
- import pandas as pd
4
- import yfinance as yf
5
- from datetime import datetime, timedelta
6
-
7
- from common import html_card, wrap_html
8
- from ta_indi_pat import talib_df
9
- import datetime
10
- from nse import nse_index_df
11
-
12
-
13
- def fetch_index(max_rows=200):
14
- """
15
- Fetch NIFTY 50 (^NSEI) 1-year OHLCV data from Yahoo Finance,
16
- add TA-Lib indicators + candlestick patterns,
17
- return HTML table inside a scrollable container.
18
- """
19
-
20
- try:
21
- # ----------------------------------
22
- # Fetch NIFTY 50 data
23
- # ----------------------------------
24
- df = nse_index_df(index_name="NIFTY 50")
25
-
26
- print(df)
27
- if df.empty:
28
- return html_card("Error", "No data found for NIFTY 50 (^NSEI).")
29
-
30
-
31
- # ----------------------------------
32
- # Convert to HTML
33
- # ----------------------------------
34
- table_html = df.to_html(
35
- classes="table table-striped table-bordered",
36
- index=False
37
- )
38
-
39
- scrollable_html = f"""
40
- <div style="overflow-x:auto; overflow-y:auto; max-height:650px; border:1px solid #ccc; padding:8px;">
41
- {table_html}
42
- </div>
43
- """
44
-
45
- content = f"""
46
- <h2>NIFTY 50 </h2>
47
- {html_card("Technical Analysis Table", scrollable_html)}
48
- """
49
-
50
- return wrap_html(content, title="NIFTY 50 Daily Data")
51
-
52
- except Exception as e:
53
- return html_card("Error", str(e))
54
- '''
55
- import io
56
- import requests
57
- import pandas as pd
58
- import yfinance as yf
59
- from datetime import datetime, timedelta
60
-
61
- from common import html_card, wrap_html
62
- from ta_indi_pat import talib_df
63
- import datetime
64
- from nse import nse_index_df
65
-
66
-
67
- def fetch_index(max_rows=200):
68
- """
69
- Fetch NIFTY 50 data using nse_index_df(),
70
- format each returned DataFrame into its own HTML table.
71
- """
72
-
73
- try:
74
- # ------------------------------------------------
75
- # Fetch NIFTY 50 → 4 dataframes
76
- # ------------------------------------------------
77
- df_market, df_adv, df_meta, df_data = nse_index_df(index_name="NIFTY 50")
78
-
79
- # Debug print
80
- print("MARKET DF:", df_market.shape)
81
- print("ADVANCE DECLINE DF:", df_adv.shape)
82
- print("META DF:", df_meta.shape)
83
- print("DATA DF:", df_data.shape)
84
-
85
- # ------------------------------------------------
86
- # Helper for HTML conversion
87
- # ------------------------------------------------
88
- def make_table(df):
89
- return f"""
90
- <div style="overflow-x:auto; overflow-y:auto; max-height:450px; border:1px solid #ccc; padding:8px; margin-bottom:18px;">
91
- {df.to_html(classes='table table-striped table-bordered', index=False)}
92
- </div>
93
- """
94
-
95
- # Convert all tables
96
- html_market = make_table(df_market)
97
- html_adv = make_table(df_adv)
98
- html_meta = make_table(df_meta)
99
- html_data = make_table(df_data)
100
-
101
- # ------------------------------------------------
102
- # Final HTML layout
103
- # ------------------------------------------------
104
- content = f"""
105
- <h2>NIFTY 50 - Index Report</h2>
106
-
107
- {html_card("Market Overview", html_market)}
108
- {html_card("Advance / Decline", html_adv)}
109
- {html_card("Index Meta Information", html_meta)}
110
- {html_card("Daily OHLCV + Calculated Indicators", html_data)}
111
- """
112
-
113
- return wrap_html(content, title="NIFTY 50 Index Data")
114
-
115
- except Exception as e:
116
- return html_card("Error", str(e))