|
|
import io |
|
|
import requests |
|
|
import pandas as pd |
|
|
import yfinance as yf |
|
|
from datetime import datetime, timedelta |
|
|
|
|
|
from common import html_card, wrap_html |
|
|
from ta_indi_pat import talib_df |
|
|
import datetime |
|
|
|
|
|
date = datetime.date(2025, 11, 27) |
|
|
|
|
|
df = nse_preopen_df("NIFTY") |
|
|
df_bhav, act_date = fetch_bhavcopy_df(date) |
|
|
df_ce, df_pe = fetch_option_chain_df("NIFTY") |
|
|
df_m, df_a, df_meta, df_data = nse_index_df("NIFTY 50") |
|
|
|
|
|
fno = nse_fno_df("RELIANCE") |
|
|
|
|
|
def fetch_index(max_rows=200): |
|
|
""" |
|
|
Fetch NIFTY 50 (^NSEI) 1-year OHLCV data from Yahoo Finance, |
|
|
add TA-Lib indicators + candlestick patterns, |
|
|
return HTML table inside a scrollable container. |
|
|
""" |
|
|
|
|
|
try: |
|
|
|
|
|
|
|
|
|
|
|
df = yf.download("^NSEI", period="1y", interval="1d").round(2) |
|
|
|
|
|
if df.empty: |
|
|
return html_card("Error", "No data found for NIFTY 50 (^NSEI).") |
|
|
|
|
|
|
|
|
df.columns = ["Close", "High", "Low", "Open", "Volume"] |
|
|
df.reset_index(inplace=True) |
|
|
|
|
|
|
|
|
df_display = df.head(max_rows) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
combined_df = talib_df(df_display) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table_html = combined_df.to_html( |
|
|
classes="table table-striped table-bordered", |
|
|
index=False |
|
|
) |
|
|
|
|
|
scrollable_html = f""" |
|
|
<div style="overflow-x:auto; overflow-y:auto; max-height:650px; border:1px solid #ccc; padding:8px;"> |
|
|
{table_html} |
|
|
</div> |
|
|
""" |
|
|
|
|
|
content = f""" |
|
|
<h2>NIFTY 50 (^NSEI) β Daily (OHLCV + Indicators + Patterns)</h2> |
|
|
{html_card("Technical Analysis Table", scrollable_html)} |
|
|
""" |
|
|
|
|
|
return wrap_html(content, title="NIFTY 50 Daily Data") |
|
|
|
|
|
except Exception as e: |
|
|
return html_card("Error", str(e)) |
|
|
|