반응형

https://freeprog.tistory.com/376


기본적인 세팅은 위의 블로그에 잘 정리 되어있다.


나는 저기서 조건검색(전략) 결과를 가져오는 것을 추가 해 보겠다.


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
 
namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        private CPUTILLib.CpCybos _cpCybos;
        private CPSYSDIBLib.MarketEye _marketEye;
        private DSCBO1Lib.StockCur _stockCur;
        private CPSYSDIBLib.CssStgFind _CssStgFind;
        private CPSYSDIBLib.CssStgList _CssStgList;
        private CPSYSDIBLib.MarketEye _MarketEye;
        private ArrayList _arrCode;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            _cpCybos = new CPUTILLib.CpCybos();
 
            if(_cpCybos.IsConnect == 1)
            {
                Console.WriteLine("크레온 플러스 접속 성공");
            }
            else
            {
                Console.WriteLine("크레온 플러스 접속 실패");
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            _CssStgList = new CPSYSDIBLib.CssStgList(); //클래스 생성
            _CssStgList.SetInputValue(01); //나의 전략( '0' : 예제전략, '1': 나의전략)
            int result = _CssStgList.BlockRequest(); // 요청
            Console.WriteLine(_CssStgList.GetDataValue(10)); // 첫번째전략 ID 출력
 
            _CssStgFind = new CPSYSDIBLib.CssStgFind(); //클래스 생성
            _CssStgFind.SetInputValue(0, _CssStgList.GetDataValue(10)); //첫번째전략 종목
            result = _CssStgFind.BlockRequest(); // 요청
            _arrCode = new ArrayList(); //종목코드 저장할 array 생성
            _arrCode.Clear(); // 초기화
            for (int i = 0; i <= Convert.ToInt32(_CssStgFind.GetHeaderValue(0).ToString()) - 1; i++)
            {
                _arrCode.Add(_CssStgFind.GetDataValue(0, i)); //array에 종목코드 추가
            }
 
            _marketEye = new CPSYSDIBLib.MarketEye(); // 클래스 생성
 
            int[] items = { 01234567101117 }; //marketeye에서 불러올 정보들
            _marketEye.SetInputValue(0, items); 
 
            String[] sCodes = new String[_arrCode.Count]; 
 
            for (int i = 0; i <= _arrCode.Count - 1; i++)
                sCodes[i] = _arrCode[i].ToString(); // ArrayList 를 String 으로 바꿈
 
            _marketEye.SetInputValue(1, sCodes); //종목코드를 이용해 종목정보를 가져옴
 
            int resultMarketEye = _marketEye.BlockRequest(); //요청
 
 
            if (resultMarketEye == 0)
            {
                for (int j = 0; j <= Convert.ToInt32(_marketEye.GetHeaderValue(2).ToString()) - 1; j++)
                {
                    Console.WriteLine(_marketEye.GetDataValue(0, j)+" " + _marketEye.GetDataValue(10, j)); //
 
                }
            }
 
        }
 
 
 
    }
}
 
cs

(자세한 설명은 생략한다. 크레온플러스 도움말을 참조하자)

버튼2를 추가해 버튼 2를 누르면 조건검색된 종목들의 종목코드와 이름을 출력하게 만들었다.


나의 전략 리스트를 받아온뒤

첫번째 전략에 포함된 종목들의 종목코드를 가져와서

마켓아이를 이용해 종목명을 가져와서 출력한다. 


일단 크레온에서 할것들은 이거면 거의 된것 같고 전략선택하는 부분만 나중에 수정하면 될 듯하다.


반응형

+ Recent posts