コード例 #1
0
        private void button_CollectData_Click(object sender, EventArgs e)
        {
            OpenApi.Clear();

            const string end        = "수집 종료";
            var          collecting = button_CollectData.Text != end;

            button_CollectData.Text = collecting ? end : "데이터 수집";
            EnableTradeControls(!collecting);
            button_Start.Enabled = !collecting;

            if (!collecting)
            {
                return;
            }

            var etfs = OpenApi.GetETFs();

            string[] names =
            {
                "KODEX 200",
                "TIGER 200",
                "KBSTAR 200",
                "KODEX 인버스",
                "KODEX 코스닥 150",
                "TIGER 코스닥150",
                "KODEX 코스닥150선물인버스"
            };

            var stocks = etfs.Where(x => names.Contains(x.Name));

            OpenApi.SetRealReg(stocks.Select(x => x.Code));
        }
コード例 #2
0
        private void button_Start_Click(object sender, EventArgs e)
        {
            var stocks = new[]
            {
                comboBox_Stock1.SelectedItem as Stock,
                comboBox_Stock2.SelectedItem as Stock,
                comboBox_Stock3.SelectedItem as Stock,
            };

            if (_trader == null)
            {
                float margin = textBox_Margin.Text.ToFloat();
                margin /= 100;
                margin += 1.0f;

                _trader = new Trader(GetAccount(), textBox_Quantity.Text.ToInt(), margin,
                                     stocks[0], stocks[1], stocks[2]);
            }
            else
            {
                _trader = null;
            }

            // 현재 시작여부
            var started = _trader != null;

            button_Start.Text = started ? "거래 종료" : "거래 시작";
            EnableTradeControls(!started);
            button_CollectData.Enabled = !started;

            OpenApi.Clear();

            if (_trader == null)
            {
                return;
            }

            OpenApi.SetRealReg(stocks.Select(x => x.Code));
            OpenApi.RegisterAction(1000, delegate()
            {
                _trader.Process();
            });
        }