Uploaded April 2023 | Updated November 2026, 2 hours ago
The video shows how I used chatGPT + Python to calculate the support and resistance levels of the SPDR S&P 500 ETF Trust. The video provides a simple code on how to read historical price data and use Python libraries to calculate these levels. It is a useful resource for those interested in using Python for financial market analysis.
import yfinance as yf
# historical data from yahoo finance
df = yf.download("SPY", period="1d")
# Calculate Fibonacci levels
high = df['High'].max()
low = df['Low'].min()
range_ = high - low
fib_0 = low
fib_23_6 = low + 0.236 * range_
fib_38_2 = low + 0.382 * range_
fib_50 = low + 0.5 * range_
fib_61_8 = low + 0.618 * range_
fib_100 = high
# Determine support and resistance levels based on current price
current_price = df['Close'][-1]
if current_price fib_50:
resistance = fib_100
support = fib_61_8
else:
resistance = fib_38_2
support = fib_0
# support/resistance levels
print(f"The support level is {support:.2f}.")
print(f"The resistance level is {resistance:.2f}.")
print("")
print(f"Fibonacci levels:\n0%: {fib_0:.2f}\n23.6%: {fib_23_6:.2f}\n38.2%: {fib_38_2:.2f}\n50%: {fib_50:.2f}\n61.8%: {fib_61_8:.2f}\n100%: {fib_100:.2f}")
The video shows how I used chatGPT + Python to calculate the support and resistance levels of the SPDR S&P 500 ETF Trust. The video provides a simple code on how to read historical price data and use Python libraries to calculate these levels. It is a useful resource for those interested in using Python for financial market analysis.
import yfinance as yf
# historical data from yahoo finance
df = yf.download("SPY", period="1d")
# Calculate Fibonacci levels
high = df['High'].max()
low = df['Low'].min()
range_ = high - low
fib_0 = low
fib_23_6 = low + 0.236 * range_
fib_38_2 = low + 0.382 * range_
fib_50 = low + 0.5 * range_
fib_61_8 = low + 0.618 * range_
fib_100 = high
# Determine support and resistance levels based on current price
current_price = df['Close'][-1]
if current_price fib_50:
resistance = fib_100
support = fib_61_8
else:
resistance = fib_38_2
support = fib_0
# support/resistance levels
print(f"The support level is {support:.2f}.")
print(f"The resistance level is {resistance:.2f}.")
print("")
print(f"Fibonacci levels:\n0%: {fib_0:.2f}\n23.6%: {fib_23_6:.2f}\n38.2%: {fib_38_2:.2f}\n50%: {fib_50:.2f}\n61.8%: {fib_61_8:.2f}\n100%: {fib_100:.2f}")










