Beispiel #1
0
        private void 매수완료처리(StockOrder order)
        {
            log.Info("매수완료처리 new : " + JsonConvert.SerializeObject(order));

            StockTarget target = dacStock.당일대상조회(order.inqDate, order.stockCode)[0];

            log.Info("매수완료처리 변경전:" + JsonConvert.SerializeObject(target));

            // tbl_stock_target 업데이트
            dacStock.주식상태매수완료처리로변경(order.inqDate, order.stockCode
                                   , Util.GetInt(order.ConfirmQty), Util.GetInt(order.ConfirmPrice), "추가매수".Equals(order.OrderOption) ? "Y" : "");

            target = dacStock.당일대상조회(order.inqDate, order.stockCode)[0];

            log.Info("매수완료처리 변경후:" + JsonConvert.SerializeObject(target));

            if ("추가매수".Equals(order.OrderOption))
            {
                log.Info("추가매수");

                List <StockOrder> listOrders = dacStock.tbl_stock_order_주문조회(order.inqDate, order.stockCode, "매도", "요청중");

                if (listOrders != null && listOrders.Count > 0)
                {
                    StockOrder 매도요청중주문 = listOrders[0];

                    int resultCode = OpenAPI.매도취소요청(Biz.AccountNo, 매도요청중주문.Seq, 매도요청중주문.orderNo, 매도요청중주문.stockCode, 매도요청중주문.stockName
                                                    , 매도요청중주문.Qty, 매도요청중주문.Price);

                    if (resultCode == 0)
                    {
                        dacStock.주문상태변경(매도요청중주문.Seq, "취소완료");
                    }
                    else
                    {
                        dacStock.주문상태변경(매도요청중주문.Seq, "취소중오류");
                    }
                }
            }

            log.Info("매수완료처리 new end ");
        }
Beispiel #2
0
        public void 종목현재가조회()
        {
            string 요일 = DateTime.Now.ToString("ddd");

            //if (요일.Equals("토") || 요일.Equals("일")) return;

            // 09시부터 15시 30분까지 실행
            //if (DateTime.Now.ToString("HHmm").CompareTo("0830") < 0 ||
            //    DateTime.Now.ToString("HHmm").CompareTo("1530") > 0) return;

            if (최종현재가조회시간 == DateTime.MinValue)
            {
                최종현재가조회시간 = DateTime.Now;
            }
            else if (DateTime.Now.AddSeconds(-3) <= 최종현재가조회시간)
            {
                return;
            }
            else
            {
                최종현재가조회시간 = DateTime.Now;
            }

            List <StockTarget> list = dacStock.당일대상조회(inqDate, "");

            int pageSize = 100;

            if (list.Count <= pageSize)
            {
                string stockCodeAr = string.Join(";", list.Select(i => i.stockCode).ToArray());
                OpenAPI.CommKwRqData(stockCodeAr, 0, list.Count, 0, "종목현재가조회", "1111");
            }
            else
            {
                int page     = list.Count / pageSize;
                int remainer = list.Count % pageSize;

                if (remainer > 0)
                {
                    page += 1;
                }

                List <StockTarget> tempList = null;

                for (int i = 0; i < page; i++)
                {
                    if (i < page - 1)
                    {
                        tempList = list.Skip(i * pageSize).Take(pageSize).ToList();
                    }
                    else
                    {
                        tempList = list.Skip(i * pageSize).Take(remainer).ToList();
                    }

                    string stockCodeAr = string.Join(";", tempList.Select(k => k.stockCode).ToArray());
                    OpenAPI.CommKwRqData(stockCodeAr, 0, tempList.Count, 0, "종목현재가조회", "1111");
                }
            }

            log.Info("loop CommKwRqData finished");

            Thread.Sleep(2000);
        }
Beispiel #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                string 요일 = DateTime.Now.ToString("ddd");

                if (요일.Equals("토") || 요일.Equals("일"))
                {
                    return;
                }

                // 09시부터 15시 30분까지 실행
                if (DateTime.Now.ToString("HHmm").CompareTo("0900") < 0 ||
                    DateTime.Now.ToString("HHmm").CompareTo("1830") > 0)
                {
                    return;
                }


                List <StockTarget> list = dacStock.당일대상조회("20200709", "");

                int pageSize = 50;

                if (list.Count <= pageSize)
                {
                    string stockCodeAr = string.Join(";", list.Select(i => i.stockCode).ToArray());
                    OpenAPI.CommKwRqData(stockCodeAr, 0, list.Count, 0, "종목현재가조회", "1111");

                    Thread.Sleep(500);
                }
                else
                {
                    int page     = list.Count / pageSize;
                    int remainer = list.Count % pageSize;

                    if (remainer > 0)
                    {
                        page += 1;
                    }

                    List <StockTarget> tempList = null;

                    for (int i = 0; i < page; i++)
                    {
                        if (i < page - 1)
                        {
                            tempList = list.Skip(i * pageSize).Take(pageSize).ToList();
                        }
                        else
                        {
                            tempList = list.Skip(i * pageSize).Take(remainer).ToList();
                        }

                        string stockCodeAr = string.Join(";", tempList.Select(k => k.stockCode).ToArray());
                        OpenAPI.CommKwRqData(stockCodeAr, 0, tempList.Count, 0, "종목현재가조회", "1111");

                        Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }