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['Avg_Volume'] = df['Volume'].rolling(window=lookback).mean()
# Get the recent high and low recent_high = df['High'].max() recent_low = df['Low'].min()
# Last row data (current day) last_row = df.iloc[-1]
# Check for Price Breakout (above recent high or below recent low) price_breakout_up = last_row['Close'] >= recent_high * price_breakout_pct price_breakout_down = last_row['Close'] <= recent_low * (2 - price_breakout_pct) # A breakout below recent low
# Check for Volume Breakout (above average volume threshold) volume_breakout = last_row['Volume'] >= df['Avg_Volume'].iloc[-1] * volume_mult
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.