검색결과 리스트
금융에 해당되는 글 39건
- 2024.02.17 2024.2.19일 기준 인공지능 주가 예측
- 2024.02.13 홍콩 ELS 사태에 대한 분석 보고서
- 2024.02.13 NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom
- 2024.02.13 PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드
- 2024.02.13 PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드
- 2016.09.23 나만의 로보 어드바이저(robo-advisor) 만들기 [5]
- 2016.09.05 나만의 로보 어드바이저(robo-advisor) 만들기 [4]
- 2016.08.30 나만의 로보 어드바이저(robo-advisor) 만들기 [2]
- 2016.08.18 딥러닝 for 트레이딩
글
자세한 설명은 도움말 참고
RANK | 종목코드 | 종목명 | 기준일 | 예측 변동률(%) | 이견도 |
1 | 166480 | 코아스템켐온- | 20240219 | 24.124 | 4.238 |
2 | 007810 | 코리아써키트 | 20240219 | 21.008 | 0.724 |
3 | 281820 | 케이씨텍 | 20240219 | 20.994 | 4.415 |
4 | 001685 | 대상우 | 20240219 | 20.804 | 2.069 |
5 | 286750 | 나노브릭- | 20240219 | 19.683 | 4.017 |
6 | 087010 | 펩트론- | 20240219 | 18.902 | 0.927 |
7 | 340930 | 유일에너테크- | 20240219 | 18.663 | 0.085 |
8 | 035150 | 백산 | 20240219 | 17.456 | 3.811 |
9 | 094170 | 동운아나텍- | 20240219 | 17.405 | 1.990 |
10 | 067390 | 아스트- | 20240219 | 17.324 | 3.813 |
11 | 007660 | 이수페타시스 | 20240219 | 16.515 | 4.785 |
12 | 001570 | 금양 | 20240219 | 16.302 | 1.906 |
13 | 038110 | 에코플라스틱- | 20240219 | 15.914 | 0.422 |
14 | 051360 | 토비스- | 20240219 | 15.740 | 1.918 |
15 | 102370 | 케이옥션- | 20240219 | 15.609 | 3.455 |
16 | 114840 | 아이패밀리에스씨- | 20240219 | 15.538 | 1.470 |
17 | 203650 | 드림시큐리티- | 20240219 | 15.467 | 4.187 |
18 | 005420 | 코스모화학 | 20240219 | 14.917 | 3.090 |
19 | 900250 | 크리스탈신소재- | 20240219 | 14.840 | 0.754 |
20 | 035760 | CJ ENM- | 20240219 | 14.653 | 1.129 |
21 | 402340 | SK스퀘어 | 20240219 | 14.577 | 4.579 |
22 | 291650 | 압타머사이언스- | 20240219 | 14.558 | 1.375 |
23 | 259630 | 엠플러스- | 20240219 | 14.543 | 1.311 |
24 | 051905 | LG생활건강우 | 20240219 | 14.535 | 2.638 |
25 | 013990 | 아가방컴퍼니- | 20240219 | 14.528 | 3.176 |
26 | 079980 | 휴비스 | 20240219 | 14.354 | 0.194 |
27 | 073240 | 금호타이어 | 20240219 | 13.954 | 4.492 |
28 | 005110 | 한창 | 20240219 | 13.784 | 0.846 |
29 | 086820 | 바이오솔루션- | 20240219 | 13.501 | 4.191 |
30 | 105560 | KB금융 | 20240219 | 13.246 | 4.350 |
전체보기:
http://bigdata-trader.com/index.jsp?month=3&version=20140101-56565656
'금융' 카테고리의 다른 글
2024.2.19 기관+외인 매수 증가 시작 (0) | 2024.02.17 |
---|---|
2024.2.19 눌림목 세력주 (20일선, 5일선, 60일선 이평선) (0) | 2024.02.17 |
홍콩 ELS 사태에 대한 분석 보고서 (0) | 2024.02.13 |
NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom (0) | 2024.02.13 |
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
글
홍콩 연계 ELS 위기: 한국 투자자들의 손실 확대와 그 원인
1. 홍콩 ELS란 무엇인가?
홍콩 ELS(Equity-Linked Securities)는 홍콩의 항셍 중국 기업 지수(HSCEI)와 같은 주가 지수에 연계된 파생상품입니다. 이는 투자자에게 지수의 상승 또는 하락에 따른 변동 수익을 제공하는 금융 상품입니다.
2. 사태의 원인
사태의 근본적인 원인은 HSCEI 지수의 급격한 하락으로, 이로 인해 ELS 상품에 투자한 많은 투자자들이 예상치 못한 큰 손실을 입었습니다. 특히, 2021년 초부터 지수가 급락하기 시작하면서 상황이 악화되었습니다.
3. 무엇이 문제인가?
ELS 상품이 고위험 상품임에도 불구하고 은행과 금융 기관들이 적절한 위험 고지 없이 이를 판매한 것이 문제로 지적되고 있습니다. 많은 투자자들이 상품의 위험성을 충분히 인지하지 못한 채 투자했으며, 결과적으로 큰 손실을 입었습니다.
4. 어떤 논쟁거리들이 있는가
- 투자자 보호 문제: 투자자들은 금융 기관이 제공한 정보의 충분성과 정확성에 대해 의문을 제기하고 있습니다. 특히 고령 투자자들이 고위험 상품에 노출되었다는 점이 큰 문제로 부각되고 있습니다.
- 금융 기관의 책임: 금융 기관들이 고위험 상품을 적극적으로 판매했는지, 그리고 투자자에게 적절한 상품을 권유했는지에 대한 조사가 진행 중입니다. 특히, 투자자의 경험 수준에 따른 맞춤형 상품 권유 여부가 검토되고 있습니다.
- 정부 및 감독 기관의 역할: 이번 사태를 계기로 금융 상품 판매에 대한 감독 기관의 역할과 감독 체계에 대한 재검토 요구가 높아지고 있습니다. 금융 감독 기관이 사전에 위험을 파악하고 적극적인 조치를 취했어야 한다는 지적도 있습니다.
결론
홍콩 ELS 사태는 한국 금융 시장에 큰 충격을 주었으며, 금융기관의 상품 판매 관행, 투자자 보호 메커니즘, 그리고 금융 규제 체계 전반에 대한 심도 있는 검토를 촉발시켰습니다. 금융감독원은 투자자 보호를 위한 보상 기준을 마련하고, 금융기관에 대한 조사를 강화할 방침입니다
'금융' 카테고리의 다른 글
2024.2.19 눌림목 세력주 (20일선, 5일선, 60일선 이평선) (0) | 2024.02.17 |
---|---|
2024.2.19일 기준 인공지능 주가 예측 (0) | 2024.02.17 |
NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom (0) | 2024.02.13 |
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
글
NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom
설정
트랙백
댓글
Subtitle: The Ripple Effect on South Korea's Samsung Electronics and SK Hynix Stocks and Emerging Market Opportunities
The recent meteoric rise in NVIDIA's stock price can be primarily attributed to the rapid advancement in artificial intelligence (AI) technology and the consequent spike in demand for high-performance semiconductors. NVIDIA, holding about 80% of the market share in the graphics processing unit (GPU) sector, is at the forefront of this surge. These GPUs are crucial for efficiently handling the specific mathematical operations required in AI computing. The significant increase in NVIDIA's stock is closely linked to its growth in the AI sector, significantly bolstered by the success of the chatbot technology, ChatGPT.
In January 2023, NVIDIA's stock experienced a 42% surge, primarily driven by investments banking on the potential of ChatGPT, thereby significantly increasing the wealth of NVIDIA's CEO, Jensen Huang. This rally reflects the anticipated demand for NVIDIA's new chip models, designed to meet the burgeoning computing requirements driven by AI advancements.
The impact on South Korean semiconductor giants, Samsung Electronics and SK Hynix, is also noteworthy. Alongside NVIDIA's soaring shares, Samsung Electronics has increased its capital expenditure, despite the current demand-supply gap in the semiconductor industry. This suggests Samsung's optimistic outlook on the semiconductor industry's recovery and indicates a potentially positive impact on other semiconductor companies like SK Hynix.
This shift presents new market opportunities for South Korea's semiconductor firms, laying the groundwork for growth alongside the progression of AI technology. NVIDIA's success could spur innovation and investment across the semiconductor industry, offering Samsung Electronics and SK Hynix the chance to enhance their global competitiveness by actively responding to market changes.
The rise in NVIDIA's stock highlights the positive impact of rapid AI technological advancements and the increased demand for high-performance semiconductors on the semiconductor industry. It is anticipated that South Korean semiconductor companies will capitalize on these market trends to solidify their position in the global market.
'금융' 카테고리의 다른 글
2024.2.19일 기준 인공지능 주가 예측 (0) | 2024.02.17 |
---|---|
홍콩 ELS 사태에 대한 분석 보고서 (0) | 2024.02.13 |
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
글
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드
주식 투자에서 다양한 분석 도구와 지표가 사용되는 가운데, PER(Price to Earnings Ratio, 주가수익비율)은 기업의 수익성과 주가를 연결하는 중요한 지표 중 하나입니다. 이 글에서는 PER의 기본 개념부터 시작해, PER을 활용한 주식 투자 방법, 저PER 종목의 특징 및 투자 시 고려해야 할 장단점에 대해 상세히 알아보겠습니다.
단원 1: PER의 기본 이해
1.1 PER이란?
PER(Price to Earnings Ratio)는 주가를 기업의 주당순이익(Earnings Per Share, EPS)으로 나눈 값으로, 주가가 기업의 이익에 비해 얼마나 평가되고 있는지를 나타내는 지표입니다. PER = 주가 / EPS로 계산됩니다.
1.2 PER의 중요성
PER은 투자자가 주식을 적정 가격에 매입하고 있는지 판단하는 데 도움을 줍니다. 낮은 PER은 주가가 해당 기업의 이익 대비 저평가되어 있을 가능성을, 높은 PER은 주가가 고평가되었을 가능성을 시사합니다. 따라서, PER은 투자 결정에 있어 중요한 참고 지표가 됩니다.
단원 2: PER을 이용한 주식 투자 방법
2.1 저PER 종목의 발굴
저PER 종목은 기업의 이익에 비해 상대적으로 저평가된 종목을 찾는 데 유용합니다. 일반적으로 PER이 업종 평균이나 시장 평균보다 낮은 종목은 투자 가치가 있을 수 있습니다. 그러나, 단순히 PER이 낮다는 이유만으로 투자 결정을 내리기 전에 기업의 재무 건전성, 성장성, 업종의 전망 등을 함께 고려해야 합니다.
2.2 고평가된 종목의 회피
높은 PER을 가진 종목은 시장에서 과대평가된 것일 가능성이 있으므로, 투자 시 신중을 기해야 합니다. 특히, PER이 해당 업종의 평균이나 시장 평균을 크게 초과하는 경우, 주가 조정(하락)의 위험이 있을 수 있습니다.
단원 3: 저PER 종목 투자의 장단점
3.1 장점
- 효율적 가치 평가: 저PER 종목 투자는 시장에서 과소평가된 기업을 발굴하여 투자하는 전략입니다. 이는 장기적으로 주가 상승의 가능성을 내포하고 있습니다.
- 위험 관리: 저PER 종목은 이미 이익 대비 낮은 가격으로 거래되고 있기 때문에, 추가 하락의 리스크가 상대적으로 낮을 수 있습니다.
3.2 단점
- 기업 문제의 가능성: PER이 낮은 이유는 기업의 이익이 감소할 것이라는 시장의 예상 때문일 수 있습니다. 따라서, 저PER 종목에 투자하기 전에는 해당 기업의 이익 감소 원인과 업종의 전반적인 상황을 면밀히 분석해야 합니다.
- 시장 변화에 둔감: 저PER 종목은 시장이나 업종의 긍정적 변화를 반영하는 데 시간이 걸릴 수 있습니다. 따라서, 투자자는 높은 인내심을 가지고 장기적인 관점에서 투자를 접근해야 합니다.
- 분석의 복잡성: 단순히 PER이 낮다고 해서 모든 저PER 종목이 좋은 투자 대상이 되는 것은 아닙니다. 기업의 재무 건전성, 성장 전망, 업종의 사이클 등 다양한 요소를 종합적으로 고려해야 합니다.
단원 4: PER 투자 전략의 실제 적용
4.1 선별 기준 설정
PER을 이용한 투자 결정 시, PER 값만을 고려하는 것이 아니라, 기업의 재무 건전성, 성장성, 업종 평균 PER, 시장 상황 등 다양한 요소를 함께 고려하는 것이 중요합니다. 이를 통해, 투자자는 보다 신중하고 균형 잡힌 투자 결정을 내릴 수 있습니다.
4.2 포트폴리오 다각화
저PER 종목에 투자할 때는 투자 위험을 분산하기 위해 포트폴리오를 다각화하는 전략이 중요합니다. 다양한 업종과 지역의 저PER 종목에 분산 투자함으로써, 특정 기업이나 업종의 위험에 대한 노출을 줄일 수 있습니다.
4.3 장기적 관점
PER을 기반으로 한 투자는 단기적인 시장의 변동성에 영향을 덜 받는 장기적인 전략입니다. 시장의 인식 변화나 기업 가치의 재평가가 일어나기까지 시간이 소요될 수 있으므로, 투자자는 인내심을 가지고 장기적인 관점에서 접근하는 것이 바람직합니다.
결론
PER은 주식 투자에서 기업의 가치를 평가하는 데 중요한 지표 중 하나입니다. 저PER 종목 투자 전략은 시장에서 과소평가된 기업을 발굴하여 투자 기회를 찾는 데 유용할 수 있습니다. 그러나, 이 전략을 성공적으로 실행하기 위해서는 기업 분석에 필요한 다양한 요소들을 종합적으로 고려하고, 장기적인 관점에서 투자를 접근하는 것이 중요합니다. 이러한 접근 방식을 통해 투자자는 주식 시장에서 가치를 발견하고, 장기적인 수익을 실현할 수 있을 것입니다.
'금융' 카테고리의 다른 글
홍콩 ELS 사태에 대한 분석 보고서 (0) | 2024.02.13 |
---|---|
NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom (0) | 2024.02.13 |
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
나만의 로보 어드바이저(robo-advisor) 만들기 [4] (0) | 2016.09.05 |
글
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드
주식 투자에 있어 여러 분석 도구와 지표들이 사용되지만, PBR(Price to Book Ratio, 주가순자산비율)은 특히 투자자들에게 중요한 정보를 제공합니다. 이 글에서는 PBR의 개념부터 시작하여, PBR을 이용한 주식 투자 방법, 저PBR 종목의 원인 및 투자 시 고려해야 할 장단점에 대해 자세히 알아보겠습니다.
단원 1: PBR의 기본 이해
1.1 PBR이란?
PBR(Price to Book Ratio)은 주가순자산비율로, 기업의 주가를 그 기업의 순자산가치(자본총계)에 대해 비교한 값입니다. 계산 방식은 간단하며, 주가를 주당순자산(Book Value per Share)으로 나눈 값으로 표현됩니다. 수식으로는 PBR = 주가 / 주당순자산(BPS) 입니다.
1.2 PBR의 중요성
PBR은 기업 가치 평가에 있어 중요한 지표 중 하나입니다. PBR이 낮다는 것은 주가가 순자산가치에 비해 낮게 평가되어 있음을 의미하며, 이는 해당 주식이 과소평가되었을 가능성이 높다는 신호로 해석될 수 있습니다. 반대로, 높은 PBR은 주가가 순자산가치에 비해 고평가되었을 수 있음을 나타냅니다.
단원 2: PBR을 이용한 주식 투자 방법
2.1 저PBR 종목의 발굴
저PBR 종목은 시장에서 상대적으로 저평가된 종목을 찾는 데 유용합니다. 일반적으로 PBR이 1 미만인 종목은 그 기업의 주가가 순자산가치보다 낮다는 것을 의미하므로, 투자 가치가 있을 수 있습니다. 하지만, 저PBR 투자 전략을 사용할 때는 기업의 재무 상태, 업종의 전망, 시장 환경 등을 종합적으로 고려해야 합니다.
2.2 고평가된 종목의 회피
높은 PBR을 가진 종목은 시장에서 과대평가됐을 가능성이 있으므로, 주의 깊게 접근해야 합니다. 특히, PBR이 업종 평균보다 현저히 높은 종목은 가격 조정(하락)의 리스크가 있을 수 있습니다.
단원 3: 저PBR 종목 투자의 장단점
3.1 장점
- 가치 발굴: 저PBR 종목 투자는 시장에서 과소평가된 기업을 발굴하여 투자하는 전략입니다. 이러한 기업들은 장기적으로 주가 상승 가능성이 높습니다.
- 위험 완화: 저PBR 종목은 이미 낮은 가격으로 거래되고 있기 때문에, 추가 하락의 리스크가 상대적으로 낮습니다.
3.2 단점
- 시장의 오류: 시장이 항상 옳은 것은 아니며, 종종 기업의 진정한가치를 잘못 평가하기도 합니다. 저PBR 종목이 반드시 저평가된 것만은 아니며, 때로는 기업의 기본적인 문제점이나 업종의 구조적 문제로 인해 낮은 PBR을 기록할 수도 있습니다.
- 시간 소요: 저PBR 종목이 시장에 재평가되어 그 가치가 증가하기까지 상당한 시간이 소요될 수 있습니다. 따라서, 단기 수익을 목표로 하는 투자자에게는 적합하지 않을 수 있습니다.
- 분석의 어려움: 저PBR 종목 중에는 숨겨진 가치를 가진 기업도 있지만, 기업의 재무 상태가 실제로 악화되고 있어 저평가된 경우도 있습니다. 따라서, 투자 결정에 앞서 심도 있는 분석과 연구가 필수적입니다.
단원 4: PBR 투자 전략의 실제 적용
4.1 선별 기준 설정
PBR을 통한 투자 결정 시, 단순히 PBR 값만을 기준으로 삼는 것은 위험할 수 있습니다. 시장 평균 PBR, 업종별 평균 PBR, 기업의 재무 상태, 경영진의 질, 시장 상황 등 다양한 요소를 함께 고려해야 합니다.
4.2 포트폴리오 다각화
저PBR 종목에 투자할 때는 포트폴리오를 다각화하여 위험을 분산시키는 것이 중요합니다. 한 업종이나 몇 개의 종목에 과도하게 집중 투자하는 것보다는, 다양한 업종과 지역의 저PBR 종목에 분산 투자함으로써 리스크를 관리할 수 있습니다.
4.3 장기적 관점
저PBR 종목에 투자하는 경우, 투자 수익을 실현하기까지 일정 시간이 필요할 수 있습니다. 시장의 인식 변화, 기업 가치의 재평가, 업종의 사이클 변동 등을 고려할 때, 장기적인 관점에서 접근하는 것이 바람직합니다.
결론
PBR은 주식 투자에서 중요한 지표 중 하나로, 저PBR 종목 투자는 특히 가치 투자자들에게 매력적인 전략입니다. 하지만, 이러한 접근 방식은 심도 있는 분석과 장기적인 관점이 요구됩니다. 투자자는 개별 기업의 가치뿐만 아니라 시장 상황, 업종 동향 등을 종합적으로 고려하여 투자 결정을 내려야 합니다. 저PBR 종목 투자 전략을 잘 활용한다면, 시장에서 과소평가된 기업을 발굴하여 투자의 기회를 넓힐 수 있을 것입니다.
'금융' 카테고리의 다른 글
NVIDIA's Skyward Surge: The Era of High-Performance Semiconductors Ignited by the AI Boom (0) | 2024.02.13 |
---|---|
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
나만의 로보 어드바이저(robo-advisor) 만들기 [4] (0) | 2016.09.05 |
나만의 로보 어드바이저(robo-advisor) 만들기 [2] (0) | 2016.08.30 |
글
오늘은 Python과 CybosPlus를 이용하여 장중 실시간 종목 가격 변동을 모니터링하고 특정 조건(매수 혹은 매도가 도달)만족시 이벤트를 생성하는 방법을 알아보자.
먼저 첨부된 python 코드는, 깔끔하지는 않지만, 장중 정해준 종목을 계속 모니터링하다가 정해진 이벤트(트레이딩)이 발생할 경우 발생한 트레이딩 정보와 변동률을 화면에 뿌려주는 기능을 한다.
이 코드를 조금 수정하면 이벤트가 발생한 경우에 사용자 펑션 호출하여 원하는 조건(매수 혹은 매도 조건 도달, 특정 가격이상 변동, 급작스런 가격변동 탐지등)을 만족하는가를 체크하고 만족하는 경우 특정 행동을 하도록 할 수 있을것이다.
특정 조건 만족시 매수, 혹은 매도를 실행하는 코드를 추가하면 실시간 트레이딩이 가능해지는데 이 부분은 다음 시간에 다루기로 한다.
코드 설명:
__author__ = 'Dr. Deeeep'
import win32com.client
import io
""" Memo
02: change rate
13: currentprice
18: currenttime
"""
activeFlag = [ 1, 1, 0, 0, 0, 0, 0]
itemcode = ['A017680','A052790','A032860', 'A900110', 'A033130']
############### deco, actoz, steel, EAH, cho
crArray = [ '', '', '', '', '', '']
class CpEvent0:
#print("E0: flag=", activeFlag[0])
instance = None
def OnReceived(self):
#print("E0: flag=", activeFlag[0])
if (activeFlag[0]>0):
currentprice = CpEvent0.instance.GetHeaderValue(13)
changeprice = CpEvent0.instance.GetHeaderValue(2)
changerate = round(((changeprice / (currentprice - changeprice)) * 100.0),2)
crArray[0] = changerate
prt_style_all(0, changerate, currentprice, changeprice)
#prt_style(0, changerate, currentprice, changeprice)
#print(itemcode[0], " ", changerate, " E0: ", currentprice, " ", changeprice);
class CpEvent1:
#print("E1: flag=", activeFlag[1])
instance = None
def OnReceived(self):
#print("E1: flag=", activeFlag[1])
if (activeFlag[1]>0):
currentprice = CpEvent1.instance.GetHeaderValue(13)
changeprice = CpEvent1.instance.GetHeaderValue(2)
changerate = round(((changeprice / (currentprice - changeprice)) * 100.0),2)
crArray[1] = changerate
prt_style_all(1, changerate, currentprice, changeprice)
#prt_style(1, changerate, currentprice, changeprice)
#print(itemcode[1], " ", changerate, " E1: ", currentprice, " ", changeprice);
class CpEvent2:
#print("E2: flag=", activeFlag[2])
instance = None
def OnReceived(self):
#print("E2: flag=", activeFlag[2])
if (activeFlag[2]>0):
currentprice = CpEvent2.instance.GetHeaderValue(13)
changeprice = CpEvent2.instance.GetHeaderValue(2)
changerate = round(((changeprice / (currentprice - changeprice)) * 100.0),2)
crArray[2] = changerate
prt_style_all(2, changerate, currentprice, changeprice)
#prt_style(2, changerate, currentprice, changeprice)
#print(itemcode[2], " ", changerate, " E2: ", currentprice, " ", changeprice);
class CpEvent3:
#print("E3: flag=", activeFlag[3])
instance = None
def OnReceived(self):
#print("E3: flag=", activeFlag[3])
if (activeFlag[3]>0):
currentprice = CpEvent3.instance.GetHeaderValue(13)
changeprice = CpEvent3.instance.GetHeaderValue(2)
changerate = round(((changeprice / (currentprice - changeprice)) * 100.0),2)
crArray[3] = changerate
prt_style_all(3, changerate, currentprice, changeprice)
#prt_style(3, changerate, currentprice, changeprice)
#print(itemcode[3], " ", changerate, " E3: ", currentprice, " ", changeprice);
class CpEvent4:
#print("E4: flag=", activeFlag[4])
instance = None
def OnReceived(self):
#print("E4: flag=", activeFlag[4])
if (activeFlag[4]>0):
currentprice = CpEvent4.instance.GetHeaderValue(13)
changeprice = CpEvent4.instance.GetHeaderValue(2)
changerate = round(((changeprice / (currentprice - changeprice)) * 100.0),2)
crArray[4] = changerate
prt_style_all(4, changerate, currentprice, changeprice)
#prt_style(4, changerate, currentprice, changeprice)
#print(itemcode[4], " ", changerate, " E4: ", currentprice, " ", changeprice);
def prt_style_all(classnum, chrate, curprice, chprice):
print(classnum, ", ", enter_crArray(), curprice, ",", chprice)
def prt_style(classnum, chrate, curprice, chprice):
print(classnum, enter_spc(classnum), chrate, ",", exit_spc(classnum), ",", curprice, ",", chprice)
#print(itemcode[classnum], enter_spc(classnum), chrate, ", ", curprice, ", ", chprice)
def enter_crArray():
crnum = len(crArray)
rtnline = ""
for n in range(0, crnum):
rtnline = rtnline + str(crArray[n]) + ","
return rtnline
def enter_spc(classn):
spc = ""
for n in range(0, classn):
spc = spc + " "
return spc
def exit_spc(classn):
spc = ""
rev = 4 - classn
for n in range(0, rev):
spc = spc + " "
return spc
#not working
def sprintf(buf, fmt, args):
buf.write(fmt % args)
inst0 = win32com.client.Dispatch("dscbo1.StockCur")
inst1 = win32com.client.Dispatch("dscbo1.StockCur")
inst2 = win32com.client.Dispatch("dscbo1.StockCur")
inst3 = win32com.client.Dispatch("dscbo1.StockCur")
inst4 = win32com.client.Dispatch("dscbo1.StockCur")
win32com.client.WithEvents(inst0, CpEvent0)
win32com.client.WithEvents(inst1, CpEvent1)
win32com.client.WithEvents(inst2, CpEvent2)
win32com.client.WithEvents(inst3, CpEvent3)
win32com.client.WithEvents(inst4, CpEvent4)
inst0.SetInputValue(0,itemcode[0])
inst1.SetInputValue(0,itemcode[1])
inst2.SetInputValue(0,itemcode[2])
inst3.SetInputValue(0,itemcode[3])
inst4.SetInputValue(0,itemcode[4])
CpEvent0.instance = inst0
CpEvent1.instance = inst1
CpEvent2.instance = inst2
CpEvent3.instance = inst3
CpEvent4.instance = inst4
inst0.Subscribe()
inst1.Subscribe()
inst2.Subscribe()
inst3.Subscribe()
inst4.Subscribe()
이벤트 발생시 해당 종목의 가격을 체크하여 정해진 STOPLOSS 보다 작거나 STOPGAIN보다 큰 경우 적절한 행동을 하도록 하려면 다음과 같은 class를 정해주면 된다.
class CpEvent000:
instance = None
monitoring = 1 # 0 no, 1 yes
def OnReceived(self):
if (monitoring = 1)
value13_cprice = CpEvent1.instance.GetHeaderValue(13)
value18_ctime = CpEvent1.instance.GetHeaderValue(18)
print("E1: ",value18_ctime,", ", value13_cprice)
if (value13_cprice >= stopgain_price)
print("E1: STOPGAIN, Exit")
monitoring = 0 # 정해진 일을 이곳에 코딩
elif (value13_cprice <= stoploss_price)
print("E1: STOPLOASS, Exit")
monitoring = 0 # 정해진 일을 이곳에 코딩
<to be continued..>
'금융' 카테고리의 다른 글
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
---|---|
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [4] (0) | 2016.09.05 |
나만의 로보 어드바이저(robo-advisor) 만들기 [2] (0) | 2016.08.30 |
딥러닝 for 트레이딩 (0) | 2016.08.18 |
글
오늘은 CybosPlus를 이용하여 실제로 나의 계좌를 관리하고 계좌 정보를 가져오는 방법, 그리고 정해진 조건이 만족되었을 때 매수 및 매도가 이루어지도록 프로그램 매을 내는 방법을 알아보자.
'금융' 카테고리의 다른 글
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
---|---|
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
나만의 로보 어드바이저(robo-advisor) 만들기 [2] (0) | 2016.08.30 |
딥러닝 for 트레이딩 (0) | 2016.08.18 |
글
Python을 이용한 주가 데이터 크롤링
기본적으로 로보 어드바이저는 대용량의 주가 및 환경 데이터 + 지능적 트레이딩 알고리즘에 의해 구동된다. 따라서 나만의 로보 어드바이저를 만들기 위해서는 나만의 트레이딩 알고리즘을 구현할 수 있는 프로그램 능력과 대용량 데이터를 분석할 수 있는 분석 능력뿐 아니라 데용량 데이터를 수집할 수 있는 수집 능력이 필수 적이다. 따라서 주가 데이터의 크롤러가 필수적이다. 이 글에서는 주가 데이터의 크롤러 제작에 필요한 기술과 구현 방법에 대해 살펴보겠다.
공학도라면 서론을 길게 말하는것을 싫어한다. 결론 먼저, 설명 나중이므로. 먼저 쿨하게 내가 제작한 주가 데이터 크롤러 소스를 밑에 붙여 놓았다. 바쁜 사람은 그냥 카피해가서 바로 사용하면 된다. 안 바쁜 독자라면 계속 읽어보자.
이 코드는 파이썬으로 제작한 주가 데이터 크롤러이다. 로보 어드바이저는 두가지 크롤러가 필요한데, 롱텀 크롤러와 실시간 크롤러가 그것이다. 롱텀 크롤러는 처음 로보 어드바이저를 기동하기 위해 최초 한번은 몇 년치 주가 데이터를 한꺼번에 크롤링 하는 작업이 필요한데 그때 사용하기 위한 크롤러 이다. 밑에 소스는 롱텀 크롤러 소스이다. 이 후에는 변경(추가)된 데이터만을 매일매일, 혹은 실시간으로, 가져오는 간략화된(속도가 빠른) 실시간 크롤러가 필요한데 그것은 나중에 올리기로 한다. 물론 롱텀 그롤러와 실시간 크롤러는 비슷한 코드로 구성된다. 단지 용도에 맞게 프로그램 흐름도가 조금 다를뿐이다.
이 크롤러는 CybosPlus와 Python으로 구현되었다. CybosPlus는 대신증권에서 제공하는 시스템 트레이딩을 위한 API이다. CybosPlus에 대한 정보는 쉽게 찾아 볼 수 있으므로 생략하기로 한다.
(임시저장...)
#
# Developed by "Dr.Deeeep"
#
# intelligent version of crawler, in this version
# - it check the last day of item in the database and crawling from the last day.
# - the data of last day will be overwritten because they may are not the final value
#
import time
import mysql.connector
import win32com.client
config = {
'user': 'USERID',
'password': 'PASSWORD',
'host': 'yourhost.com',
'database': 'DBNAME',
'raise_on_warnings': True,
}
# Don't forget to change the server setting to arrow remote connection to MySQL.
# mysql examples are available at
# https://dev.mysql.com/doc/connector-python/en/connector-python-examples.html
cnx = mysql.connector.connect(**config)
cursor = cnx.cursor()
cpcybos = win32com.client.Dispatch("CpUtil.CpCybos")
if cpcybos.IsConnect == 1:
print("Cybos connection succeeded")
else:
print("Cybos connection failed")
inStockCode = win32com.client.Dispatch("CpUtil.CpStockCode") # general stock item info
inStockMst = win32com.client.Dispatch("dscbo1.StockMst") # Current data
inStockChart = win32com.client.Dispatch("CpSysdib.StockChart") # Past Data
totalItemNumInCybosPlus = inStockCode.GetCount()
print("Total number of items = ",totalItemNumInCybosPlus)
# print all items in BT format
# Some variables, such as changerate, fortramt, totaltraceprice, should be calculated on the fly, thus filled with dummy '-999.0'
#itemcode
finalpriceArray = [] #inStockChart.SetInputValue(5, 5)
startpriceArray = [] #inStockChart.SetInputValue(5, 2)
highpriceArray = [] #inStockChart.SetInputValue(5, 3)
lowpriceArray = [] #inStockChart.SetInputValue(5, 4)
changerateArray = [] #inStockChart.SetInputValue(5, 6) may need to calculate from (today final / yesterday final)
tramtArray = [] #inStockChart.SetInputValue(5, 8)
orgtramtArray = [] #inStockChart.SetInputValue(5, 20) THIS data is not complete in cybosdb. cannot use..
fortramtArray = [] # -999.0 #inStockChart.SetInputValue(5, ???) may need to cal from (today fortotal - yesterday fortotal)
fortotalArray = [] #inStockChart.SetInputValue(5, 16)
forportionArray = [] #inStockChart.SetInputValue(5, 17)
totaltradepriceArray = [] # -999.0 #inStockChart.SetInputValue(5, 0) may need to cal from (tramt * final price)
#beyond BT Format
circulationrateArray = [] #inStockChart.SetInputValue(5, 25)
totalstocknumArray = [] #inStockChart.SetInputValue(5, 12)
sichongArray = [] #inStockChart.SetInputValue(5, 13)
###################################################
#
# This number represents the number of record to crawl for each cybosplus access
# Must be large enough to cover the gap between the last date in my db and today while keep small enough to prevent the waste of speed of cybosplus access.
numOfCrawling = 200 # n days
#
# This string number is the starting itemcode for the case of resuming suspened, quitted, crawling job
startingItemCode = "000000" # 000000 for new start
#
#
###################################################
currentItemIndex = -1
for aItemcode in range(0, inStockCode.GetCount()): # for each itemcode
currentItemIndex = currentItemIndex + 1
print("### progress = ", ((currentItemIndex * 100) / totalItemNumInCybosPlus), " %")
dateToCrawlArray = [] #inStockChart.SetInputValue(5, 0)
# this line print just the item code and name
# print(inStockCode.GetData(0,i), inStockCode.GetData(1,i), inStockCode.GetData(2,i))
itemcode = inStockCode.GetData(0,aItemcode)
# this can be used for resuming suspended process
# THIS may not necessary for intelligent version of crawler
if itemcode < "A"+startingItemCode:
print("Skipping "+itemcode)
continue
inStockChart.SetInputValue(0, itemcode)
## retrieve LAST DATE in DB of this itemcode ==========================
## if no data for this item, set the last date to 20050101
print ("itemcode = ", itemcode)
shortItemcode = itemcode[1:]
sqlStr = ("select max(date) from datatable where itemcode='"+ shortItemcode+ "'")
#print("sqlStr = ", sqlStr, ", newItemcode = ", shortItemcode)
cursor.execute(sqlStr)
#######################################
# modified source
row = cursor.fetchone()
if row[0]:
lastDateInMyDB = row[0]
else: # Null. number of returned row is 0. no data in DB.
print ("itemcode = ", itemcode, " is added newly... skipping..")
print ("TODO: add code here to handle newly added items. !!!!!!!!!!!!")
continue
#######################################
## retrieving LAST DATE in CybosPlus ========================
inStockChart.SetInputValue(1, '2') # retrieve by num of records
inStockChart.SetInputValue(4, 1) # num of record to retrive is. Just the last one
inStockChart.SetInputValue(5, 0) # field type, tr amt(8), finalprice(5), date(0)
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
lastDateInCybosPlus = inStockChart.GetDataValue(0,0)
print("in itemcode = ", itemcode, ", The latest data in CybosPlus = ", lastDateInCybosPlus)
#TODO:
# dateToCrawlArray = retieve DATE array from lastDateInMyDB to lastDateInCybosPlus
# for aDate in dateArray:
# do the same with other crawlers
## retireve dateToCrawlArray
print("in itemcode = ", itemcode, ", Now retrieving Date2Crawl array...")
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, lastDateInMyDB) # starting date
inStockChart.SetInputValue(2, lastDateInCybosPlus) # ending date
inStockChart.SetInputValue(4, numOfCrawling) # get some data which number is given
inStockChart.SetInputValue(5, 0) # field type, tr amt(8), finalprice(5), date(0)
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.BlockRequest()
numofdate2Crawl = inStockChart.GetHeaderValue(3) # num of rec retrieved
print("in itemcode = ", itemcode, ", Num of DATE to crwal = ", numofdate2Crawl, " From = ", lastDateInMyDB, " to = ", lastDateInCybosPlus)
for i in range(numofdate2Crawl):
volumn = inStockChart.GetDataValue(0,i)
dateToCrawlArray.insert(0, volumn)
if int(volumn) <= int(lastDateInMyDB):
break
print("in itemcode = ", itemcode, ", dateToCrawArray = ", dateToCrawlArray)
for aCrawlDate in dateToCrawlArray:
## retrieving FINALPRICE =========================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 5) # finalprice(5)
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_finalprice = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (FP) = ", numofreturned_finalprice)
if (numofreturned_finalprice > 0):
finalprice = inStockChart.GetDataValue(0,0)
#print(" final price was ", finalprice)
else:
finalprice = '-999.0'
print(itemcode, " No data. default final price: -999.0")
## retrieving STARTPRICE ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 2) # startprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_startprice = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (SP) = ", numofreturned_startprice)
if (numofreturned_startprice > 0):
startprice = inStockChart.GetDataValue(0,0)
#print(" start price was ", startprice)
else:
startprice = '-999.0'
print(itemcode, " No data. default START PRICE : -999.0")
## retrieving HIGHPRICE ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 3) # highprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_highprice = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (HP) = ", numofreturned_highprice)
if (numofreturned_highprice > 0):
highprice = inStockChart.GetDataValue(0,0)
#print(" high price was ", highprice)
else:
highprice = '-999.0'
print(itemcode, " No data. default HIGH PRICE: -999.0")
## retrieving LOWPRICE ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 4) # lowprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_lowprice = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (LowP) = ", numofreturned_lowprice)
if (numofreturned_lowprice > 0):
lowprice = inStockChart.GetDataValue(0,0)
#print(" low price was ", lowprice)
else:
lowprice = '-999.0'
print(itemcode, " No data. default LOW PRICE: -999.0")
## retrieving CHANGERATE ============================
changerate = '-999.0'
#print(" changerate was ", changerate)
## retrieving TRAMT ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 8) # tramt
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_tramt = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (TRAMT) = ", numofreturned_tramt)
if (numofreturned_tramt > 0):
tramt = inStockChart.GetDataValue(0,0)
#print(" tramt was ", tramt)
else:
tramt = '-999.0'
print(itemcode, " No data. default TRAMT: -999.0")
## retrieving ORGTRAMT ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 20) # org tramt
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_orgtramt = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (ORG TRAMT) = ", numofreturned_orgtramt)
if (numofreturned_orgtramt > 0):
orgtramt = inStockChart.GetDataValue(0,0)
#print(" orgtramt was ", orgtramt)
else:
orgtramt = '-999.0'
print(itemcode[1:], " No data. default ORG TRAMT: -999.0")
## retrieving FORTRAMT ============================
fortramt = '-999.0'
#print(" fortramt was ", fortramt)
## retrieving FORTOTAL ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 16) # startprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_fortotal = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (FORTOTAL) = ", numofreturned_fortotal)
if (numofreturned_fortotal > 0):
fortotal = inStockChart.GetDataValue(0,0)
#print(" fortotal was ", fortotal)
else:
fortotal = '-999.0'
print(itemcode, " No data. default FORTOTAL: -999.0")
## retrieving FORPORTION ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 17) # startprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_forportion = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (FORPORTION) = ", numofreturned_forportion)
if (numofreturned_forportion > 0):
forportion = inStockChart.GetDataValue(0,0)
forportion = float("{0:.4f}".format(forportion))
#print(" forportion was ", forportion)
else:
forportion = '-999.0'
print(itemcode, " No data. default FORPORTION: -999.0")
## retrieving TOTALTRADEPRICE ============================
totaltradeprice = '-999.0'
#print(" total trade price was ", totaltradeprice)
## retrieving CIRCULATIONRATE ============================
circulationrate = '-999.0'
#print(" circulation rate was ", circulationrate)
## retrieving TOTALSTOCKNUM ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 12) # startprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_totalstocknum = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (TOTALSTOCKNUM) = ", numofreturned_totalstocknum)
if (numofreturned_totalstocknum > 0):
totalstocknum = inStockChart.GetDataValue(0,0)
#print(" totalstocknum was ", totalstocknum)
else:
totalstocknum = '-999.0'
print(itemcode, " No data. default TOTALSTOCKNUM: -999.0")
## retrieving SICHONG ============================
inStockChart.SetInputValue(1, '1') # retrieve by num of specified date
inStockChart.SetInputValue(3, aCrawlDate) # starting date
inStockChart.SetInputValue(2, aCrawlDate) # ending date
inStockChart.SetInputValue(4, 1) # get a data
inStockChart.SetInputValue(5, 13) # startprice
inStockChart.SetInputValue(6, ord('D')) # chart type, by Day
inStockChart.SetInputValue(9, '0') # modified price? yes. 0 for no
inStockChart.BlockRequest()
numofreturned_sichong = inStockChart.GetHeaderValue(3) # num of rec retrieved
#print(" Num of retrieved record (SICHONG) = ", numofreturned_sichong)
if (numofreturned_sichong > 0):
sichong = inStockChart.GetDataValue(0,0)
#print(" sichong was ", sichong)
else:
sichong = '-999.0'
print(itemcode, " No data. default SICHONG: -999.0")
#sqlStr = ("insert into cybosplus date="+str(aCrawlDate)+", itemcode="+itemcode[1:]+", finalprice="+str(finalprice)+", startprice="+str(startprice))
#print("insert sqlStr = ", sqlStr)
add_record = ("insert into datatable "
"(date, itemcode, finalprice, startprice, highprice, lowprice, changerate, tradeamount, orgtradeamount, fortradeamount, fortotalamount, forportion, totaltradeprice, totalstocknum, sichong) "
"values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) "
"on duplicate key update "
"finalprice=%s, startprice=%s, highprice=%s, lowprice=%s, changerate=%s, tradeamount=%s, orgtradeamount=%s, fortradeamount=%s, fortotalamount=%s, forportion=%s, totaltradeprice=%s, totalstocknum=%s, sichong=%s")
data_record = (aCrawlDate, itemcode[1:], finalprice, startprice, highprice,
lowprice, changerate, tramt, orgtramt, fortramt,
fortotal, forportion, totaltradeprice, totalstocknum, sichong,
finalprice, startprice, highprice,
lowprice, changerate, tramt, orgtramt, fortramt,
fortotal, forportion, totaltradeprice, totalstocknum, sichong)
cursor.execute(add_record, data_record)
cnx.commit()
cursor.close()
cnx.close()
'금융' 카테고리의 다른 글
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
---|---|
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
나만의 로보 어드바이저(robo-advisor) 만들기 [4] (0) | 2016.09.05 |
딥러닝 for 트레이딩 (0) | 2016.08.18 |
글
트래이딩분야에 적용된 딥러닝 기술
그 동안 개인적으로 테스트해 본 트래이딩에서의 딥러닝 알고리즘은 그닥 효과가 좋지 못하다. 트래이딩 알고리즘의 시뮬레이션을 위해 구축한 웹페이지 (http://www.bigdata-trader.com/simulation_preview.jsp?month=00000000)에서 확인할 수도 있는데, 딥러닝 모델(현재 A26부터 A30까지 5개 모델이 딥러닝 모델, 나머지는 전통적 트레이딩 알고리즘)의 단타 매매 성공율은 겨우 60퍼센트 정도에 미치고 있다. 물론 딥러닝 모델은 아직 2개월 정도밖에 운영하지 않았지만 몇 년을 돌려도 크게 바뀔거 같지는 않다. 이 정도의 performance는 전통적 방법의 트래이딩 알고리즘(예를 들면 A14나 A4)보다도 훨씬 뒤쳐지는 성적이다.
참고로 각 알고리즘은 DBN을 이용하여 72개월간 다음 데이터를 학습한며, 매일 10거래일 전 발행한 추천 종목의 성적을 평가한다.
A26: 주가
A27: 주가+인덱스
A28: 주가변동률+인덱스변동률
A29: 주가변동률+거래량+외인거래량
A30: 주가변동률+거래량+외인거래량+외인보유portion
다양한 딥러닝 아키텍춰를 추가해서 LSTM 등을 이용할 계획이긴 하지만 크게 향상될것 같지는 않다. 아키텍춰보다는 데이터나 모델을 바꿔야 할듯.
USC의 Greg Harris 가 트래이딩 분야에 적용된 딥러닝 기술을 잘 정리를 해둔것을 발견하여 정리해본다. 원문은 http://gregharris.info/a-survey-of-deep-learning-techniques-applied-to-trading/
(요약 할것)
1. Limit order book modeling
2. price-based classification models
3. Text-based Classification models
4. Volatility Prediction
5. Portfolio Optimization
각 모델별로 아키텍춰를 달리한 논문들을 소개하고 있는데 내 시스템에 적용 가능한것부터 하나하나 테스트 해볼 생각이다.
========== continued..
일단 위에 열거된 다른 연구자들의 결과를 보고 놀라운 점은 수익 성공률이 53% 정도 밖에 안된다는 것. 내가 구현한 딥러닝 모델보다도 조금 더 나쁘고 A4나 A14보다도 훨씬 안좋다. 하지만 위 요약을 읽으면서 몇가지 새로운 모델에 대한 구상이 떠올라서 구현해보기로 한다.
1. 먼저 리턴(closing price - opening price)이라는 개념. 나의 예측 모델들은 모두 regression problem에 집중한데 반해 리턴이란 개념으로 접근한다면 classification 문제가 된다. + 일것이냐 - 일것이냐의 classification. 사실 class 수를 더 늘려서 regression 처럼 학습할 수 있지만. 어쩄든. 그게 중한게 아니고. return을 계산하기 위해서는 opening price 를 알아야 하는데. 이런식으로 하려면 실시간 시스템이어야 한다. 종가 확인 후 하루 한번 예측을 수행하는 일(daily) 베이스의 bigdata trader 시스템에서는 적용할 수 없다. opening price를 무시한다면 성공률이 50%로 수렴할 것이 뻔하다. 서비스 용도말고 관리자창에 테스트 용도로 장중 opening price를 입력 받아 return을 얻어내는 실험 모듈을 추가해야겠다.
- 조금 더 생각해보니 "종목 상세 보기"에서는 사용자 입력 후 해당 종목에 한 해 실시간 장중가를 가져 올 수 있으니 그날의 리턴을 계산할 수도 있겠다.
2. Text 기반 classification
경제면 headline 들과 개별 종목 등락을 학습한다는 개념. 말그대로 bigdata trader의 기본 개념인데... sns 대신 경제면 headline 을 학습한다는 것.
3. moving box learning
DBN 을 써서 oscillating box를 학습 한다는 것인데. 학습이고 뭐고를 떠나 이 전략은 전략 자체의 validation 이 필요하다고 본다. 박스 바닥 뚫고 진입시 매수, 박스 바닥 뚫고 진출수 매도. 그러나 박스권의 설정 자체가 이미 후행적이고 결과론 적이다. oscillating box 이론이 잘 맞는 종목도 있을테니 선택적으로 적용한다면 시도해볼만 하다. 각 종목이 얼마나 oscillating box 이론에 일치하는가 평가하는 모듈이 먼저 필요하다.
(임시저장)
'금융' 카테고리의 다른 글
PER을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
---|---|
PBR을 활용한 주식투자 전략: 중고급 투자자를 위한 가이드 (0) | 2024.02.13 |
나만의 로보 어드바이저(robo-advisor) 만들기 [5] (0) | 2016.09.23 |
나만의 로보 어드바이저(robo-advisor) 만들기 [4] (0) | 2016.09.05 |
나만의 로보 어드바이저(robo-advisor) 만들기 [2] (0) | 2016.08.30 |
RECENT COMMENT