๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import numpy as np | |
from datetime import datetime, timedelta | |
from scipy.interpolate import RegularGridInterpolator | |
sample_json_data = '''[ | |
{ | |
"timestamp": "2025-08-25T16:50:00Z", | |
"underlying_symbol": "NIFTY", | |
"underlying_price": 24967.75, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yfinance as yf | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Function to calculate the Stochastic Oscillator | |
def calculate_stochastic(data, n=14, smoothing=3): | |
""" | |
Calculate the Stochastic Oscillator (%K and %D). | |
- n: Lookback period for the high-low range. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import yfinance as yf | |
import matplotlib.pyplot as plt | |
# Define stocks and time period | |
stocks = ['AAPL', 'GOOGL', 'MSFT'] | |
start_date = '2020-01-01' | |
end_date = '2023-01-01' | |
# Download historical adjusted close prices |