File size: 1,649 Bytes
155145b
2cdf938
 
 
155145b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cdf938
155145b
 
2cdf938
155145b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import yfinance as yf
import streamlit as st
import pandas as pd

# Hàm phân tích VSA và xác suất tăng, giảm ngày hôm sau (kết hợp)
def combined_vsa_probability(ticker):
    data = yf.download(ticker, period='5d', interval='1d')

    latest_day = data.iloc[-1]
    open_price = latest_day['Open'].item()
    current_price = latest_day['Close'].item() if latest_day.name.time().strftime('%H:%M') >= '16:00' else yf.Ticker(ticker).history(period="1d", interval="1m").iloc[-1]['Close'].item()
    volume = latest_day['Volume'].item()
    avg_volume = data['Volume'].iloc[-4:-1].mean().item()

    spread = latest_day['High'].item() - latest_day['Low'].item()
    close_position = (current_price - latest_day['Low'].item()) / spread

    # Điều kiện kết hợp VSA & xác suất
    if (current_price > open_price) and (volume > avg_volume) and close_position > 0.7:
        probability = "Bullish (Strength): Xác suất ~75-80% tăng tiếp"
    elif (current_price >= open_price) and close_position > 0.5 and volume >= avg_volume:
        probability = "Bullish (Possible Strength): Xác suất ~60-65% tăng tiếp"
    elif (current_price < open_price) and close_position < 0.3 and volume >= avg_volume:
        probability = "Bearish (Weakness): Xác suất cao giảm hôm sau"
    else:
        probability = "Sideway hoặc chưa rõ tín hiệu: Quan sát thêm"

    return probability

# Streamlit app
st.title("Dự đoán xác suất tăng/giảm hôm sau (Kết hợp VSA) cho SPY & QQQ")

for ticker in ["QQQ", "SPY"]:
    probability = combined_vsa_probability(ticker)
    st.subheader(f"{ticker}: {probability}")