investment in mutual funds at 2.3pm after running this script. first get the values.
- Get link
- X
- Other Apps
provide, chatgtp suggest pytoncode, by modify various other paramters to take decision? in pyton code?
ChatGPT said:
Great — let's extend your Colab Python code to accept and process multiple decision parameters for better mutual fund investment decisions.
✅ Enhanced Decision Parameters for Investment
We'll consider the following parameters in the model:
Parameter | Type | Example Value | Weight in Decision |
---|---|---|---|
Nifty % change till 2 PM | Market trend | +0.62% | 30% |
FII net inflow (3-day avg) | Institutional | ₹1,102 Cr | 20% |
DII net inflow (3-day avg) | Institutional | ₹3,968 Cr | 20% |
India VIX (volatility) | Risk factor | 12.4 | 15% (inverse) |
USD/INR trend | Macro | ₹83.2 → ₹83.0 | 10% |
Crude oil price trend | Macro | $84 → $82 | 5% |
📊 Final Score Formula
textFinal Score = (0.3 × Nifty_scaled) + (0.2 × FII_scaled) + (0.2 × DII_scaled) + (0.15 × (20 - VIX)) + (0.1 × USDINR_change_scaled) + (0.05 × Crude_change_scaled)
🐍 Python Code (Enhanced with Custom Parameters)
python# User Inputs
nifty_pct_change = 0.62 # Nifty 50 % till 2 PM
fii_3day_avg = 1102.77 # In crores
dii_3day_avg = 3968.4 # In crores
india_vix = 12.4 # VIX: Lower = Better
usd_inr_change = -0.2 # INR appreciation is +ve
crude_change = -2.0 # Oil price down = positive
total_capital = 10_00_000 # ₹10 lakh
# Normalization Functions
def scale_flow(x): return max(min(x / 500.0, 10), -10)
def scale_nifty(x): return max(min(x * 20, 10), -10)
def scale_macro(x): return max(min(x * 5, 10), -10)
# Scaled values
nifty_scaled = scale_nifty(nifty_pct_change)
fii_scaled = scale_flow(fii_3day_avg)
dii_scaled = scale_flow(dii_3day_avg)
vix_scaled = 20 - india_vix # lower VIX is better
usd_inr_scaled = scale_macro(usd_inr_change)
crude_scaled = scale_macro(crude_change)
# Score Calculation with weights
score = (
0.3 * nifty_scaled +
0.2 * fii_scaled +
0.2 * dii_scaled +
0.15 * vix_scaled +
0.1 * usd_inr_scaled +
0.05 * crude_scaled
)
# Investment Strategy
if score > 8:
invest_pct = 0.5
comment = "📈 Strong market sentiment"
elif score > 5:
invest_pct = 0.3
comment = "🔄 Stable to positive trend"
elif score > 2:
invest_pct = 0.15
comment = "⚠️ Cautious approach advised"
else:
invest_pct = 0.0
comment = "🛑 Avoid investing today"
invest_amount = int(invest_pct * total_capital)
# Output
print(f"🔢 Final Score: {round(score, 2)}")
print(f"💡 Decision: {comment}")
print(f"💰 Recommended Investment: ₹{invest_amount} ({int(invest_pct*100)}%)")
🛠 How to Use This Code:
-
Run daily between 1:30 PM – 2:30 PM IST
-
Update input values manually (can automate later via APIs)
-
Decision is printed as per current scenario
✅ Future Enhancements Possible:
-
Pull Nifty/VIX/Crude/USD-INR data live via:
-
Yahoo Finance API
-
NSE/BSE endpoints
-
-
Save results to Google Sheets or Excel
-
Track total investment history + balance
Would you like me to add any automation (API, web-scraping) or save the output to a file so you can keep a daily log?
You said:
ChatGPT said:
Great question! These 3 parameters — India VIX, USD/INR change, and Crude Oil change — are freely available online from financial websites. Here's how and where you can find them:
✅ 1. India VIX (Volatility Index)
🔗 Live URL:
📍 How to find:
-
Visit NSE Homepage → Scroll to Indices section.
-
Look for “India VIX” (near Nifty/Sensex)
-
It shows a value like
12.40
(lower = less fear)
🔄 Refresh time:
-
Updates every few minutes during market hours
✅ 2. USD/INR Exchange Rate Change
🔗 Reliable sources:
📍 How to calculate change:
Let’s say:
-
Previous Close = ₹83.20
-
Current = ₹83.00
Then:
pythonusd_inr_change = (83.00 - 83.20) = -0.20
Means INR appreciated → positive for India.
✅ 3. Crude Oil (Brent) Price Change
🔗 Sources:
📍 How to calculate change:
If:
-
Previous = $84
-
Current = $82
Then:
pythoncrude_change = (82 - 84) = -2.0
Means oil price is falling → good for India (importer)
✅ Summary Table
Parameter | Where to Find | What to Note |
---|---|---|
India VIX | nseindia.com | Under “Market Indices” |
USD/INR | Investing.com | Look at current vs previous close |
Crude Oil | Investing.com | Brent Crude; compare daily prices |
✅ Optional: Automate Using Python APIs
Would you like a version of your Python code that:
-
Automatically scrapes these values using
requests + BeautifulSoup
or -
Uses financial APIs like Yahoo Finance (
yfinance
)? ----------------------
- Get link
- X
- Other Apps