Vidu

Vidu

import yfinance as yf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Function to check for price and volume breakouts
def breakout_scanner(ticker, price_breakout_pct=1.05, volume_mult=1.5, lookback=20):
# Download historical data (6 months of daily data)
df = yf.download(ticker, period="6mo", interval="1d")

# Calculate moving averages for volume
df = df .rolling(window=lookback).mean()

# Get the recent high and low
recent_high = df .max()
recent_low = df .min()

# Last row data (current day)
last_row = df.iloc

# Check for Price Breakout (above recent high or below recent low)
price_breakout_up = last_row >= recent_high * price_breakout_pct
price_breakout_down = last_row = df .iloc * volume_mult

# Print scanner results
if price_breakout_up:
print(f"{ticker}: Price Breakout Up! (Price above {recent_high * price_breakout_pct})")
if price_breakout_down:
print(f"{ticker}: Price Breakout Down! (Price below {recent_low * (2 - price_breakout_pct)})")

if volume_breakout:
print(f"{ticker}: Volume Breakout! (Volume above {df .iloc * volume_mult})")

# Optional: Plot stock chart for visual inspection
df [ ].plot(figsize=(10,6), subplots=True)
plt.suptitle(f'{ticker} - Price and Volume Breakout')
plt.show()

# List of stocks to scan
stocks =

for stock in stocks:
breakout_scanner(stock)

Read More

Share:

Latest News