Updated
Browse filesThis version is capable of capturing real-time stock images, detecting patterns in them, and generating a video and an Excel file containing annotated or predicted images with labels and timestamps.
README.md
CHANGED
@@ -7,14 +7,14 @@ tags:
|
|
7 |
- vision
|
8 |
- object-detection
|
9 |
- pytorch
|
10 |
-
- finance
|
11 |
- stock market
|
12 |
- candlesticks
|
13 |
- pattern recognition
|
14 |
- option trading
|
15 |
- chart reader
|
16 |
library_name: ultralytics
|
17 |
-
library_version: 8.
|
18 |
inference: false
|
19 |
model-index:
|
20 |
- name: foduucom/stockmarket-pattern-detection-yolov8
|
@@ -34,26 +34,24 @@ pipeline_tag: object-detection
|
|
34 |
<img width="500" alt="foduucom/stockmarket-pattern-detection-yolov8" src="https://huggingface.co/foduucom/stockmarket-pattern-detection-yolov8/resolve/main/thumbnail.jpg">
|
35 |
</div>
|
36 |
|
37 |
-
# Model Card for YOLOv8s Stock Market Pattern Detection
|
38 |
|
39 |
## Model Summary
|
40 |
|
41 |
-
The YOLOv8s Stock Market Pattern Detection model is an object detection model based on the YOLO (You Only Look Once) framework. It is designed to detect various chart patterns in real-time stock market trading
|
42 |
|
43 |
## Model Details
|
44 |
|
45 |
### Model Description
|
46 |
-
The YOLOv8s Stock Market Pattern Detection model
|
47 |
|
48 |
-
The model
|
49 |
|
50 |
-
To
|
51 |
|
52 |
- **Developed by:** FODUU AI
|
53 |
- **Model type:** Object Detection
|
54 |
-
- **Task:** Stock Market Pattern Detection
|
55 |
-
|
56 |
-
The YOLOv8s Stock Market Pattern Detection model is designed to adapt to the fast-paced nature of live trading environments. Its ability to operate on real-time video data allows traders and investors to harness pattern-based insights without delay.
|
57 |
|
58 |
### Supported Labels
|
59 |
|
@@ -64,126 +62,111 @@ The YOLOv8s Stock Market Pattern Detection model is designed to adapt to the fas
|
|
64 |
## Uses
|
65 |
|
66 |
### Direct Use
|
67 |
-
|
68 |
-
The YOLOv8s Stock Market Pattern Detection model can be directly integrated into live trading systems to provide real-time detection and classification of chart patterns. Traders can utilize the model's insights for timely decision-making.
|
69 |
|
70 |
### Downstream Use
|
71 |
-
|
72 |
The model's real-time capabilities can be leveraged to automate trading strategies, generate alerts for specific patterns, and enhance overall trading performance.
|
73 |
|
74 |
-
### Training
|
75 |
-
The
|
76 |
-
|
77 |
|
78 |
### Out-of-Scope Use
|
79 |
-
|
80 |
-
The model is not designed for unrelated object detection tasks or scenarios outside the scope of stock market pattern detection in live trading video data.
|
81 |
|
82 |
## Bias, Risks, and Limitations
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
-
|
87 |
-
- Rapid market fluctuations and noise in video data may impact the model's accuracy and responsiveness.
|
88 |
-
- Market-specific patterns or anomalies not well-represented in the training data may pose challenges for detection.
|
89 |
|
90 |
### Recommendations
|
91 |
-
|
92 |
-
Users should be aware of the model's limitations and potential biases. Thorough testing and validation within live trading simulations are advised before deploying the model in real trading environments.
|
93 |
|
94 |
## How to Get Started with the Model
|
95 |
|
96 |
-
To begin using the YOLOv8s Stock Market Pattern Detection model
|
97 |
```bash
|
98 |
-
pip install
|
99 |
```
|
100 |
|
101 |
-
|
102 |
-
|
103 |
```python
|
104 |
-
|
|
|
105 |
import cv2
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
model = YOLO('foduucom/stockmarket-pattern-detection-yolov8')
|
109 |
|
110 |
-
#
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
```
|
147 |
|
148 |
-
##
|
149 |
-
|
150 |
-
### Training Data
|
151 |
-
|
152 |
-
The model is trained on a diverse dataset containing stock market chart images with various chart patterns, capturing different market conditions and scenarios.
|
153 |
-
|
154 |
-
### Training Procedure
|
155 |
-
|
156 |
-
The training process involves extensive computation and is conducted over multiple epochs. The model's weights are adjusted to minimize detection loss and optimize performance for stock market pattern detection.
|
157 |
-
|
158 |
-
#### Metrics
|
159 |
-
|
160 |
-
- [email protected] (box):
|
161 |
-
- All patterns: 0.932
|
162 |
-
- Individual patterns: Varies based on pattern type
|
163 |
-
|
164 |
-
### Model Architecture and Objective
|
165 |
-
|
166 |
-
The YOLOv8s architecture incorporates modifications tailored to stock market pattern detection. It features a specialized backbone network, self-attention mechanisms, and pattern-specific feature extraction modules.
|
167 |
-
|
168 |
-
### Compute Infrastructure
|
169 |
-
|
170 |
-
#### Hardware
|
171 |
-
|
172 |
-
NVIDIA GeForce RTX 3060 card
|
173 |
-
|
174 |
-
#### Software
|
175 |
-
|
176 |
-
The model was trained and fine-tuned using a Jupyter Notebook environment.
|
177 |
-
|
178 |
-
## Model Card Contact
|
179 |
-
|
180 |
For inquiries and contributions, please contact us at [email protected].
|
181 |
|
182 |
```bibtex
|
183 |
@ModelCard{
|
184 |
-
author = {Nehul Agrawal
|
185 |
-
Pranjal Singh Thakur},
|
186 |
-
title = {YOLOv8s Stock Market Pattern Detection
|
187 |
year = {2023}
|
188 |
}
|
189 |
-
```
|
|
|
|
7 |
- vision
|
8 |
- object-detection
|
9 |
- pytorch
|
10 |
+
- finance
|
11 |
- stock market
|
12 |
- candlesticks
|
13 |
- pattern recognition
|
14 |
- option trading
|
15 |
- chart reader
|
16 |
library_name: ultralytics
|
17 |
+
library_version: 8.3.94
|
18 |
inference: false
|
19 |
model-index:
|
20 |
- name: foduucom/stockmarket-pattern-detection-yolov8
|
|
|
34 |
<img width="500" alt="foduucom/stockmarket-pattern-detection-yolov8" src="https://huggingface.co/foduucom/stockmarket-pattern-detection-yolov8/resolve/main/thumbnail.jpg">
|
35 |
</div>
|
36 |
|
37 |
+
# Model Card for YOLOv8s Stock Market Pattern Detection from Live Screen Capture
|
38 |
|
39 |
## Model Summary
|
40 |
|
41 |
+
The YOLOv8s Stock Market Pattern Detection model is an object detection model based on the YOLO (You Only Look Once) framework. It is designed to detect various chart patterns in real-time from screen-captured stock market trading data. The model aids traders and investors by automating the analysis of chart patterns, providing timely insights for informed decision-making. The model has been fine-tuned on a diverse dataset and achieves high accuracy in detecting and classifying stock market patterns in live trading scenarios.
|
42 |
|
43 |
## Model Details
|
44 |
|
45 |
### Model Description
|
46 |
+
The YOLOv8s Stock Market Pattern Detection model enables real-time detection of crucial chart patterns within stock market screen captures. As stock markets evolve rapidly, this model's capabilities empower users with timely insights, allowing them to make informed decisions with speed and accuracy.
|
47 |
|
48 |
+
The model is designed to work with screen capture of stock market trading charts. It can detect patterns such as 'Head and shoulders bottom,' 'Head and shoulders top,' 'M_Head,' 'StockLine,' 'Triangle,' and 'W_Bottom.' Traders can optimize their strategies, automate trading decisions, and respond to market trends in real-time.
|
49 |
|
50 |
+
To integrate this model into live trading systems or for customization inquiries, please contact us at [email protected].
|
51 |
|
52 |
- **Developed by:** FODUU AI
|
53 |
- **Model type:** Object Detection
|
54 |
+
- **Task:** Stock Market Pattern Detection from Screen Capture
|
|
|
|
|
55 |
|
56 |
### Supported Labels
|
57 |
|
|
|
62 |
## Uses
|
63 |
|
64 |
### Direct Use
|
65 |
+
The model can be used for real-time pattern detection on screen-captured stock market charts. It can log detected patterns, annotate detected images, save results in an Excel file, and generate a video of detected patterns over time.
|
|
|
66 |
|
67 |
### Downstream Use
|
|
|
68 |
The model's real-time capabilities can be leveraged to automate trading strategies, generate alerts for specific patterns, and enhance overall trading performance.
|
69 |
|
70 |
+
### Training Data
|
71 |
+
The Stock Market model was trained on a custom dataset consisting of 9000 training images and 800 validation images.
|
|
|
72 |
|
73 |
### Out-of-Scope Use
|
74 |
+
The model is not designed for unrelated object detection tasks or scenarios outside the scope of stock market pattern detection from screen-captured data.
|
|
|
75 |
|
76 |
## Bias, Risks, and Limitations
|
77 |
|
78 |
+
- Performance may be affected by variations in chart styles, screen resolution, and market conditions.
|
79 |
+
- Rapid market fluctuations and noise in trading data may impact accuracy.
|
80 |
+
- Market-specific patterns not well-represented in the training data may pose challenges for detection.
|
|
|
|
|
81 |
|
82 |
### Recommendations
|
83 |
+
Users should be aware of the model's limitations and potential biases. Testing and validation with historical data and live market conditions are advised before deploying the model for real trading decisions.
|
|
|
84 |
|
85 |
## How to Get Started with the Model
|
86 |
|
87 |
+
To begin using the YOLOv8s Stock Market Pattern Detection model, install the necessary libraries:
|
88 |
```bash
|
89 |
+
pip install opencv-python==4.11.0.86 numpy==2.1.3 mss==10.0.0 ultralytics==8.3.94 openpyxl==3.1.5
|
90 |
```
|
91 |
|
92 |
+
### Screen Capture and Pattern Detection Implementation
|
|
|
93 |
```python
|
94 |
+
import os
|
95 |
+
import mss
|
96 |
import cv2
|
97 |
+
import numpy as np
|
98 |
+
import time
|
99 |
+
import glob
|
100 |
+
from ultralytics import YOLO
|
101 |
+
from openpyxl import Workbook
|
102 |
+
|
103 |
+
# Define paths
|
104 |
+
home_dir = os.path.expanduser("~")
|
105 |
+
save_path = os.path.join(home_dir, "yolo_detection")
|
106 |
+
screenshots_path = os.path.join(save_path, "screenshots")
|
107 |
+
detect_path = os.path.join(save_path, "runs", "detect")
|
108 |
+
os.makedirs(screenshots_path, exist_ok=True)
|
109 |
+
os.makedirs(detect_path, exist_ok=True)
|
110 |
+
|
111 |
+
# Define pattern classes
|
112 |
+
classes = ['Head and shoulders bottom', 'Head and shoulders top', 'M_Head', 'StockLine', 'Triangle', 'W_Bottom']
|
113 |
+
|
114 |
+
# Load YOLOv8 model
|
115 |
model = YOLO('foduucom/stockmarket-pattern-detection-yolov8')
|
116 |
|
117 |
+
# Define screen capture region
|
118 |
+
monitor = {"top": 0, "left": 683, "width": 683, "height": 768}
|
119 |
+
|
120 |
+
# Create Excel file
|
121 |
+
excel_file = os.path.join(save_path, "classification_results.xlsx")
|
122 |
+
wb = Workbook()
|
123 |
+
ws = wb.active
|
124 |
+
ws.append(["Timestamp", "Predicted Image Path", "Label"])
|
125 |
+
|
126 |
+
# Initialize video writer
|
127 |
+
video_path = os.path.join(save_path, "annotated_video.mp4")
|
128 |
+
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
|
129 |
+
fps = 0.5
|
130 |
+
video_writer = None
|
131 |
+
|
132 |
+
# Start capturing
|
133 |
+
with mss.mss() as sct:
|
134 |
+
start_time = time.time()
|
135 |
+
frame_count = 0
|
136 |
+
|
137 |
+
while time.time() - start_time < 60:
|
138 |
+
sct_img = sct.grab(monitor)
|
139 |
+
img = np.array(sct_img)
|
140 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
|
141 |
+
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
142 |
+
image_name = f"predicted_images_{timestamp}_{frame_count}.png"
|
143 |
+
image_path = os.path.join(screenshots_path, image_name)
|
144 |
+
cv2.imwrite(image_path, img)
|
145 |
+
|
146 |
+
results = model(image_path, save=True)
|
147 |
+
predict_path = results[0].save_dir if results else None
|
148 |
+
annotated_images = sorted(glob.glob(os.path.join(predict_path, "*.jpg")), key=os.path.getmtime, reverse=True) if predict_path else []
|
149 |
+
final_image_path = annotated_images[0] if annotated_images else image_path
|
150 |
+
|
151 |
+
predicted_label = classes[int(results[0].boxes.cls.tolist()[0])] if results and results[0].boxes else "No pattern detected"
|
152 |
+
ws.append([timestamp, final_image_path, predicted_label])
|
153 |
+
wb.save(excel_file)
|
154 |
+
|
155 |
+
frame_count += 1
|
156 |
+
time.sleep(5)
|
157 |
+
|
158 |
+
print(f"Results saved to {excel_file}")
|
159 |
```
|
160 |
|
161 |
+
## Model Contact
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
For inquiries and contributions, please contact us at [email protected].
|
163 |
|
164 |
```bibtex
|
165 |
@ModelCard{
|
166 |
+
author = {Nehul Agrawal,
|
167 |
+
Pranjal Singh Thakur, Arjun Singh},
|
168 |
+
title = {YOLOv8s Stock Market Pattern Detection from Live Screen Capture},
|
169 |
year = {2023}
|
170 |
}
|
171 |
+
```
|
172 |
+
|