주식 챠트 패턴 분석
DB CAFE
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
관련 링크[편집]
https://analyzingalpha.com/algorithmic-chart-pattern-detection
https://github.com/CharlesLoo/stock-pattern-recorginition
import numpy as np
from sklearn.metrics import pairwise_distances
def find_similar_patterns(target_pattern, candidate_patterns, threshold):
# 패턴 간 유사도를 계산하기 위해 유클리드 거리를 활용합니다.
distances = pairwise_distances(target_pattern, candidate_patterns, metric='euclidean')
# 유사도가 임계값 이하인 패턴을 찾습니다.
similar_patterns_indices = np.where(distances <= threshold)[1]
return similar_patterns_indices
# 삼성전자 주가 패턴 예시
samsung_pattern = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
# 유사한 패턴 후보들 예시
candidate_patterns = np.array([
[1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.1],
[0.9, 2.0, 3.1, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8, 10.0],
[1.0, 2.1, 3.2, 4.4, 5.5, 6.7, 7.8, 8.9, 9.9, 10.2]
])
# 유사도 임계값 설정
similarity_threshold = 0.5
# 유사한 패턴 찾기
similar_patterns = find_similar_patterns(samsung_pattern, candidate_patterns, similarity_threshold)
print("유사한 패턴 인덱스:", similar_patterns)