예제 #1
0
 private void OnReceiveMsg(object sender, _DKHOpenAPIEvents_OnReceiveMsgEvent e)
 {
     if (!e.sMsg.Contains("신규주문"))
     {
         SendConfirm?.Invoke(this, new EventHandler.Identify(e.sMsg.Substring(8)));
     }
 }
예제 #2
0
        private void OnReceiveChejanData(object sender, _DKHOpenAPIEvents_OnReceiveChejanDataEvent e)
        {
            sb = new StringBuilder(256);

            if (e.sGubun.Equals("0"))
            {
                foreach (int fid in new 주문체결())
                {
                    sb.Append(axAPI.GetChejanData(fid)).Append(',');
                }

                string[] arr = sb.ToString().Split(',');

                if (!arr[18].Equals(string.Empty))
                {
                    Box.Show(string.Concat("Conclusion ", arr[17].Contains("-") ? string.Concat("Sell ", arr[17].Substring(1)) : string.Concat("Buy ", arr[17]), "\n", "Commission ₩", (int.Parse(arr[18]) * (arr[3].Substring(0, 3).Equals("101") ? tm : ktm) * commission * double.Parse(arr[17].Contains("-") ? arr[17].Substring(1) : arr[17])).ToString("N0")), DateTime.ParseExact(arr[15], "HHmmss", null).ToString("HH시 mm분 ss초"), waiting / 3);
                }

                return;
            }
            if (e.sGubun.Equals("4"))
            {
                foreach (int fid in new  생잔고())
                {
                    sb.Append(axAPI.GetChejanData(fid)).Append(',');
                }

                string[] arr = sb.ToString().Split(',');

                Quantity      = arr[9].Equals("1") ? -int.Parse(arr[4]) : int.Parse(arr[4]);
                PurchasePrice = double.Parse(arr[5].Contains("-") ? arr[5].Substring(1) : arr[5]);
                SendConfirm?.Invoke(this, new EventHandler.Identify(string.Concat(confirm, " holds ", arr[9].Equals("1") ? "Sell " : "Buy ", arr[4], " Contracts for ", arr[2], ".")));
            }
        }
예제 #3
0
        private void OnReceiveChejanData(object sender, _DKHOpenAPIEvents_OnReceiveChejanDataEvent e)
        {
            sb = new StringBuilder(256);

            foreach (int fid in type.Catalog[int.Parse(e.sGubun)])
            {
                sb.Append(axAPI.GetChejanData(fid)).Append(';');
            }

            if (e.sGubun.Equals("4"))
            {
                string[] param = sb.ToString().Split(';');

                if (param[1].Substring(0, 3).Equals("101"))
                {
                    Quantity = param[9].Equals("1") ? -int.Parse(param[4]) : int.Parse(param[4]);
                }

                SendConfirm?.Invoke(this, new Identify(string.Concat(" holds ", param[9].Equals("1") ? "Sell " : "Buy ", param[4], " Contracts for ", param[2], ".")));

                return;
            }
            if (e.sGubun.Equals("0"))
            {
                LookUpTheDeposit(Account, OnReceiveBalance = GetConclusion(sb.ToString().Split(';')));
            }
        }
예제 #4
0
        private void Request(string code)
        {
            if (code.Substring(0, 3).Equals("101") && code.Length < 9)
            {
                request.RequestTrData(new Task(() => InputValueRqData(new Opt50028 {
                    Value = code, RQName = string.Concat(code, Retention(code)), PrevNext = 0
                })));

                return;
            }
            foreach (KeyValuePair <int, string> kv in Code)
            {
                if (kv.Value.Substring(0, 8).Equals(code.Substring(0, 8)))
                {
                    if (Code.Last().Key.Equals(kv.Key))
                    {
                        SendConfirm?.Invoke(this, new Identify("The latest Data Collection is Complete."));
                    }

                    request.RequestTrData(new Task(() => InputValueRqData(new Opt50066 {
                        Value = Code[kv.Key + 1].Substring(0, 8), RQName = string.Concat(Code[kv.Key + 1].Substring(0, 8), Retention(Code[kv.Key + 1].Substring(0, 8))).Substring(0, 20), PrevNext = 0
                    })));
                    SendConfirm?.Invoke(this, new Identify("Continues to look up " + Code[kv.Key + 1].Substring(0, 8) + "\nChart for the " + kv.Key + " Time."));
                }
            }
        }
예제 #5
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            int           i;
            string        exclusion, date = GetDistinctDate(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday) - CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now.AddDays(1 - DateTime.Now.Day), CalendarWeekRule.FirstDay, DayOfWeek.Sunday) + 1);
            List <string> code = new List <string>
            {
                axAPI.GetFutureCodeByIndex(e.nErrCode)
            };

            for (i = 2; i < 4; i++)
            {
                foreach (var om in axAPI.GetActPriceList().Split(';'))
                {
                    exclusion = axAPI.GetOptionCode(om.Insert(3, "."), i, date);

                    if (code.Exists(o => o.Equals(exclusion)))
                    {
                        continue;
                    }

                    code.Add(exclusion);
                }
            }
            if (TimerBox.Show("Are You using Automatic Login??\n\nIf You aren't using It,\nClick No.\n\nAfter 5 Seconds,\nIt's Regarded as an Automatic Mode and Proceeds.", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 5617).Equals((DialogResult)7))
            {
                axAPI.KOA_Functions("ShowAccountWindow", "");
            }

            SendAccount?.Invoke(this, new Account(axAPI.GetLoginInfo("ACCLIST"), axAPI.GetLoginInfo("USER_ID"), axAPI.GetLoginInfo("USER_NAME"), axAPI.GetLoginInfo("GetServerGubun")));
            code.RemoveAt(1);
            var absence = Sql.GetSchema("Tables");

            Delay.delay = 615;

            foreach (KeyValuePair <string, string> kv in table)
            {
                if (absence.AsEnumerable().Where(o => o.ItemArray.Contains(kv.Key)).Any() == false)
                {
                    var sql = Sql.CreateCommand();
                    sql.CommandText    = kv.Value;
                    sql.CommandTimeout = 0;
                    sql.CommandType    = CommandType.Text;
                    sql.BeginExecuteNonQuery();
                }
            }
            foreach (string output in code)
            {
                RemainingDay(output);
            }

            if (TimerBox.Show("Do You Want to Retrieve Recent Data?\n\nPress 'YES' after 35 Seconds to Receive Data.\n\nDo Not Receive while the Market is Operating.\n\nWarning\n\nReceiving Information for Trading.\n\nIf You have Access to Trading,\nPlease don't Click.\n\nWhen Reception is Complete,\nProceed to the Next Step.", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (uint)code.Count * 743).Equals((DialogResult)6))
            {
                Delay.delay = 4150;
                Request(code[0]);

                return;
            }
            SendConfirm?.Invoke(this, new Identify("It is valid until ", DateTime.ParseExact(Code[0].Substring(18, 8), "yyyyMMdd", null)));
            Delay.delay = 205;
        }
예제 #6
0
        private void FixUp(string[] param, string code)
        {
            Code[Squence++] = string.Concat(code, ";", param[72], ";", param[63], ";", param[45]);
            SendConfirm?.Invoke(this, new Identify(string.Concat(param[72], "\nis Receiving Data for Trading.")));

            if (code.Contains("101") && param[63].Equals(DateTime.Now.ToString("yyyyMMdd")))
            {
                Remaining = true;
            }
        }
예제 #7
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (!axAPI.GetLoginInfo("GetServerGubun").Equals("1") && e.nErrCode == 0 && confirm.Identify(axAPI.GetLoginInfo("USER_ID"), axAPI.GetLoginInfo("USER_NAME")) && !ErrorCode.Equals(915))
            {
                if (DialogResult.Yes == MessageBox.Show("Do You Want to Retrieve Recent Data?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    Delay.delay = 4150;
                    Request();
                }
                SendConfirm?.Invoke(this, new Identify("The Remaining Validity Period is ", CallBasicInformation(e.nErrCode)));

                return;
            }
            else if (ErrorCode.Equals(915) && e.nErrCode.Equals(0))
            {
                CallBasicInformation(e.nErrCode);

                return;
            }
            Box.Show("등록되지 않은 사용자이거나 모의투자로 접속하셨습니다.\n\n프로그램을 종료합니다.", "오류", waiting);
            SendExit?.Invoke(this, new ForceQuit(end));
        }