Stockmarket Pattern Detection Yolov8
基于YOLOv8的目标检测模型,专为实时检测股市交易图表中的关键模式而设计
下载量 6,746
发布时间 : 8/10/2023
模型简介
该模型能够从屏幕捕获的股市交易数据中实时检测各类图表模式,包括头肩底、头肩顶等6种常见形态,为交易决策提供自动化分析支持
模型特点
实时模式检测
能够实时处理股市屏幕截图,快速识别关键图表模式
多模式识别
支持检测6种常见股市图表模式,包括头肩形态、趋势线等
自动化交易支持
检测结果可直接用于自动化交易策略或生成交易警报
模型能力
股市图表模式检测
实时屏幕截图分析
多类别目标识别
自动化交易决策支持
使用案例
金融交易
实时交易决策
在交易过程中自动识别图表形态,为买卖决策提供依据
检测准确率mAP@0.5达到61.35%
交易策略优化
通过历史数据分析特定模式的成功率,优化交易策略
金融教育
图表模式教学
作为教学工具展示各类图表模式的识别方法
🚀 YOLOv8s股票市场实时图案检测模型
该模型基于YOLO(You Only Look Once)框架,能够从屏幕捕获的股票市场交易数据中实时检测各种图表模式。它通过自动分析图表模式,为交易者和投资者提供及时的见解,辅助他们做出明智的决策。该模型在多样化的数据集上进行了微调,在实时交易场景中能够高精度地检测和分类股票市场模式。
🚀 快速开始
要开始使用YOLOv8s股票市场实时图案检测模型,你需要安装必要的库:
pip install mss==10.0.0 opencv-python==4.11.0.86 numpy ultralytics==8.3.94 openpyxl==3.1.5
💻 使用示例
基础用法
import os
import mss # type: ignore
import cv2
import numpy as np
import time
import glob
from ultralytics import YOLO
from openpyxl import Workbook
# Get the user's home directory
home_dir = os.path.expanduser("~")
# Define dynamic paths
save_path = os.path.join(home_dir, "yolo_detection")
screenshots_path = os.path.join(save_path, "screenshots")
detect_path = os.path.join(save_path, "runs", "detect")
# Ensure necessary directories exist
os.makedirs(screenshots_path, exist_ok=True)
os.makedirs(detect_path, exist_ok=True)
# Define pattern classes
classes = ['Head and shoulders bottom', 'Head and shoulders top', 'M_Head', 'StockLine', 'Triangle', 'W_Bottom']
# Load YOLOv8 model
model_path = "model.pt"
if not os.path.exists(model_path):
raise FileNotFoundError(f"Model file not found: {model_path}")
model = YOLO(model_path)
# Define screen capture region
monitor = {"top": 0, "left": 683, "width": 683, "height": 768}
# Create an Excel file
excel_file = os.path.join(save_path, "classification_results.xlsx")
wb = Workbook()
ws = wb.active
ws.append(["Timestamp", "Predicted Image Path", "Label"]) # Headers
# Initialize video writer
video_path = os.path.join(save_path, "annotated_video.mp4")
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
fps = 0.5 # Adjust frames per second as needed
video_writer = None
with mss.mss() as sct:
start_time = time.time()
last_capture_time = start_time # Track the last capture time
frame_count = 0
while True:
# Continuously capture the screen
sct_img = sct.grab(monitor)
img = np.array(sct_img)
img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
# Check if 60 seconds have passed since last YOLO prediction
current_time = time.time()
if current_time - last_capture_time >= 60:
# Take screenshot for YOLO prediction
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
image_name = f"predicted_images_{timestamp}_{frame_count}.png"
image_path = os.path.join(screenshots_path, image_name)
cv2.imwrite(image_path, img)
# Run YOLO model and get save directory
results = model(image_path, save=True)
predict_path = results[0].save_dir if results else None
# Find the latest annotated image inside predict_path
if predict_path and os.path.exists(predict_path):
annotated_images = sorted(glob.glob(os.path.join(predict_path, "*.jpg")), key=os.path.getmtime, reverse=True)
final_image_path = annotated_images[0] if annotated_images else image_path
else:
final_image_path = image_path # Fallback to original image
# Determine predicted label
if results and results[0].boxes:
class_indices = results[0].boxes.cls.tolist()
predicted_label = classes[int(class_indices[0])]
else:
predicted_label = "No pattern detected"
# Insert data into Excel (store path instead of image)
ws.append([timestamp, final_image_path, predicted_label])
# Read the image for video processing
annotated_img = cv2.imread(final_image_path)
if annotated_img is not None:
# Add timestamp and label text to the image
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(annotated_img, f"{timestamp}", (10, 30), font, 0.7, (0, 255, 0), 2, cv2.LINE_AA)
cv2.putText(annotated_img, f"{predicted_label}", (10, 60), font, 0.7, (0, 255, 255), 2, cv2.LINE_AA)
# Initialize video writer if not already initialized
if video_writer is None:
height, width, layers = annotated_img.shape
video_writer = cv2.VideoWriter(video_path, fourcc, fps, (width, height))
video_writer.write(annotated_img)
print(f"Frame {frame_count}: {final_image_path} -> {predicted_label}")
frame_count += 1
# Update the last capture time
last_capture_time = current_time
# Save the Excel file periodically
wb.save(excel_file)
# If you want to continuously display the screen, you can add this line
cv2.imshow("Screen Capture", img)
# Break if 'q' is pressed (you can exit the loop this way)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release video writer
if video_writer is not None:
video_writer.release()
print(f"Video saved at {video_path}")
# Remove all files in screenshots directory
for file in os.scandir(screenshots_path):
os.remove(file.path)
os.rmdir(screenshots_path)
print(f"Results saved to {excel_file}")
# Close OpenCV window
cv2.destroyAllWindows()
📚 详细文档
模型详情
模型描述
YOLOv8s股票市场图案检测模型能够实时检测股票市场屏幕截图中的关键图表模式。由于股票市场变化迅速,该模型的功能使用户能够及时获取信息,从而快速准确地做出明智决策。
该模型旨在处理股票市场交易图表的屏幕截图,能够检测诸如“头肩底”、“头肩顶”、“M头”、“股票线”、“三角形”和“W底”等模式。交易者可以优化他们的策略,自动做出交易决策,并实时响应市场趋势。
若要将此模型集成到实时交易系统或进行定制咨询,请通过info@foduu.com与我们联系。
属性 | 详情 |
---|---|
开发者 | FODUU AI |
模型类型 | 目标检测 |
任务 | 从屏幕截图中进行股票市场图案检测 |
支持的标签
['Head and shoulders bottom', 'Head and shoulders top', 'M_Head', 'StockLine', 'Triangle', 'W_Bottom']
用途
- 直接使用:该模型可用于对屏幕捕获的股票市场图表进行实时图案检测。它可以记录检测到的图案,对检测到的图像进行注释,将结果保存到Excel文件中,并生成一段时间内检测到的图案的视频。
- 下游使用:该模型的实时功能可用于自动化交易策略,为特定图案生成警报,并提高整体交易表现。
- 训练数据:该股票市场模型在一个自定义数据集上进行训练,该数据集包含9000张训练图像和800张验证图像。
- 适用范围外的使用:该模型不适用于与股票市场图案检测无关的目标检测任务或场景。
偏差、风险和局限性
- 性能可能会受到图表样式、屏幕分辨率和市场条件变化的影响。
- 快速的市场波动和交易数据中的噪声可能会影响准确性。
- 训练数据中未充分体现的特定市场模式可能会给检测带来挑战。
建议
用户应了解该模型的局限性和潜在偏差。在将模型用于实际交易决策之前,建议使用历史数据和实时市场条件进行测试和验证。
📄 许可证
文档中未提及相关许可证信息。
📞 模型联系信息
如有咨询和贡献需求,请通过info@foduu.com与我们联系。
引用信息
@ModelCard{
author = {Nehul Agrawal,
Pranjal Singh Thakur, Priyal Mehta and Arjun Singh},
title = {YOLOv8s Stock Market Pattern Detection from Live Screen Capture},
year = {2023}
}

Table Transformer Detection
MIT
基于DETR架构的表格检测模型,专门用于从非结构化文档中提取表格
目标检测
Transformers

T
microsoft
2.6M
349
Grounding Dino Base
Apache-2.0
Grounding DINO是一个开放集目标检测模型,通过结合DINO检测器与文本编码器实现零样本目标检测能力。
目标检测
Transformers

G
IDEA-Research
1.1M
87
Grounding Dino Tiny
Apache-2.0
Grounding DINO是一个结合DINO检测器与接地预训练的开放集目标检测模型,能够实现零样本目标检测。
目标检测
Transformers

G
IDEA-Research
771.67k
74
Detr Resnet 50
Apache-2.0
DETR是一个基于Transformer架构的端到端目标检测模型,使用ResNet-50作为骨干网络,在COCO数据集上训练。
目标检测
Transformers

D
facebook
505.27k
857
Detr Resnet 101
Apache-2.0
DETR是一个使用Transformer架构的端到端目标检测模型,采用ResNet-101作为骨干网络,在COCO数据集上训练。
目标检测
Transformers

D
facebook
262.94k
119
Detr Doc Table Detection
Apache-2.0
基于DETR架构的文档表格检测模型,用于检测文档中的有边框和无边框表格
目标检测
Transformers

D
TahaDouaji
233.45k
59
Yolos Small
Apache-2.0
基于视觉Transformer(ViT)的目标检测模型,使用DETR损失函数训练,在COCO数据集上表现优异。
目标检测
Transformers

Y
hustvl
154.46k
63
Yolos Tiny
Apache-2.0
基于COCO 2017目标检测数据集微调的YOLOS模型,使用视觉Transformer架构实现高效目标检测。
目标检测
Transformers

Y
hustvl
144.58k
266
Rtdetr R50vd Coco O365
Apache-2.0
RT-DETR是首个实时端到端目标检测器,通过高效混合编码器和不确定性最小化查询选择机制,在COCO数据集上达到53.1% AP,108 FPS的性能。
目标检测
Transformers 英语

R
PekingU
111.17k
11
Rtdetr R101vd Coco O365
Apache-2.0
首个实时端到端目标检测器,基于Transformer架构,消除非极大值抑制需求,在速度与精度上超越YOLO系列
目标检测
Transformers 英语

R
PekingU
106.81k
7
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98