예제 #1
0
 void OnCollectingData(string[] markets)
 {
     Temporary.SetConnection(OpenAPI);
     SetScreenNumber(8900, 9050);
     new Task(() => SetScreenNumber(1000, 8900)).Start();
     SetPasswordWhileCollectingData(markets.Length);
     CodeList = RequestCodeList(new List <string>(32), markets);
     SendMemorize?.Invoke(this, new Memorize("Clear"));
     Delay.Milliseconds = 4315;
     Request(GetRandomCode(new Random().Next(0, CodeList.Count)));
 }
예제 #2
0
        void OnReceiveMsg(object sender, _DKHOpenAPIEvents_OnReceiveMsgEvent e)
        {
            if (Array.Exists(basic, o => o.Equals(e.sMsg.Substring(9))))
            {
                var temp = e.sMsg.Substring(9);

                if ((temp.Equals(basic[2]) || temp.Equals(basic[6]) || temp.Equals(basic[8])) && OnReceiveBalance == false)
                {
                    OnReceiveBalance = request.QueueCount == 0 ? true : false;
                }

                if (e.sMsg.Contains("모의투자"))
                {
                    temp = temp.Replace("모의투자 ", string.Empty);
                }

                if (e.sMsg.Last().Equals('다') || e.sMsg.Last().Equals('요'))
                {
                    temp = string.Concat(temp, ".");
                }

                SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber));
                SendCount?.Invoke(this, new NotifyIconText(temp));

                return;
            }
            if (e.sMsg.Equals(TR))
            {
                SendMemorize?.Invoke(this, new Memorize("Clear"));
                Request(GetRandomCode(new Random().Next(0, CodeList.Count)));

                return;
            }
            if (e.sMsg.Equals(Failure))
            {
                Process.Start("shutdown.exe", "-r");
                Dispose();

                return;
            }
            if (e.sMsg.Contains(Response) && TimerBox.Show(string.Concat(Response, "."), GoblinBat, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, 1375).Equals(DialogResult.OK))
            {
                return;
            }

            if (e.sMsg.Substring(9).Equals(LookUp))
            {
                return;
            }

            new ExceptionMessage(e.sMsg);
        }
예제 #3
0
        public void StartProgress(int delay)
        {
            if (Delay.Milliseconds == 3605)
            {
                return;
            }

            DeadLine           = true;
            Delay.Milliseconds = delay;
            CodeList           = RequestCodeList(new List <string>(32)).Result;
            SendMemorize?.Invoke(this, new Memorize("Clear"));
            Request(GetRandomCode(new Random().Next(0, CodeList.Count)));
        }
예제 #4
0
        public void StartProgress(string transfer)
        {
            if (transfer != null)
            {
                foreach (string temp in new Transfer(transfer, KeyDecoder.GetWindowsProductKeyFromRegistry()))
                {
                    if (!temp.Contains(","))
                    {
                        string code = temp.Equals("Tick") || temp.Equals("Day") ? "101Q3000" : temp;
                        SendMemorize?.Invoke(this, new Memorize(temp.Equals("Day") ? "day" : temp, code));

                        continue;
                    }
                    SendMemorize?.Invoke(this, new Memorize(temp.Split(',')));
                }
            }
        }
예제 #5
0
        void SendErrorMessage(int error)
        {
            if (error < 0)
            {
                new ExceptionMessage(this.error.GetErrorMessage(error));

                switch (error)
                {
                case -100:
                case -101:
                case -102:
                case -200:
                    Process.Start("shutdown.exe", "-r");
                    Dispose();
                    return;

                case -106:
                    SendCount?.Invoke(this, new NotifyIconText(error));
                    break;

                case -300:
                    SendMemorize?.Invoke(this, new Memorize("Clear"));
                    Request(GetRandomCode(new Random().Next(0, CodeList.Count)));
                    return;

                default:
                    return;
                }
                if (API != null)
                {
                    API = null;
                }

                if (OpenAPI != null)
                {
                    OpenAPI = null;
                }
            }
        }
예제 #6
0
        private void OnReceiveTrData(object sender, _DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            var temp = axAPI.GetCommDataEx(e.sTrCode, e.sRQName);

            if (temp != null)
            {
                string[,] ts = new string[((object[, ])temp).GetUpperBound(0) + 1, ((object[, ])temp).GetUpperBound(1) + 1];
                int x, y, lx = ((object[, ])temp).GetUpperBound(0), ly = ((object[, ])temp).GetUpperBound(1);

                for (x = 0; x <= lx; x++)
                {
                    sb = new StringBuilder(64);

                    for (y = 0; y <= ly; y++)
                    {
                        ts[x, y] = (string)((object[, ])temp)[x, y];

                        if (ts[x, y].Length > 13 && !e.sTrCode.Equals("opt50001") && Retention.Equals(ts[x, y].Substring(2)))
                        {
                            sb          = new StringBuilder(it);
                            e.sPrevNext = "0";

                            break;
                        }
                        sb.Append(ts[x, y]);

                        if (y != ly)
                        {
                            sb.Append(",");
                        }
                    }
                    if (!e.sTrCode.Equals("opt50001") && sb.ToString() != it)
                    {
                        SendMemorize?.Invoke(this, new Memorize(sb));

                        continue;
                    }
                    if (sb.ToString() == it)
                    {
                        break;
                    }

                    if (e.sTrCode.Equals("opt50001"))
                    {
                        Remaining = axAPI.GetCommData(e.sTrCode, e.sRQName, 0, "잔존일수").Trim();

                        return;
                    }
                }
                if (e.sPrevNext.Equals("2") && !e.sTrCode.Equals("opt50001"))
                {
                    request.RequestTrData(new Task(() => InputValueRqData(new Opt50028 {
                        Value = Code, RQName = Code + Retention, PrevNext = 2
                    })));

                    return;
                }
                if (e.sPrevNext.Equals("0") && !e.sTrCode.Equals("opt50001"))
                {
                    SendMemorize?.Invoke(this, new Memorize(e.sPrevNext));
                }
            }
        }
예제 #7
0
        private void OnReceiveTrData(object sender, _DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            if (e.sTrCode.Equals("opt50028") || e.sTrCode.Equals("opt50066"))
            {
                var temp = axAPI.GetCommDataEx(e.sTrCode, e.sRQName);

                if (temp != null)
                {
                    string[,] ts = new string[((object[, ])temp).GetUpperBound(0) + 1, ((object[, ])temp).GetUpperBound(1) + 1];
                    int x, y, lx = ((object[, ])temp).GetUpperBound(0), ly = ((object[, ])temp).GetUpperBound(1);

                    for (x = 0; x <= lx; x++)
                    {
                        sb = new StringBuilder(64);

                        for (y = 0; y <= ly; y++)
                        {
                            ts[x, y] = (string)((object[, ])temp)[x, y];

                            if (ts[x, y].Length > 13 && e.sRQName.Substring(8).Equals(ts[x, y].Substring(2)))
                            {
                                sb          = new StringBuilder(it);
                                e.sPrevNext = "0";

                                break;
                            }
                            sb.Append(ts[x, y]).Append(';');
                        }
                        if (!it.Equals(sb.ToString()))
                        {
                            SendMemorize?.Invoke(this, new Memorize(sb));

                            continue;
                        }
                        if (it.Equals(sb.ToString()))
                        {
                            break;
                        }
                    }
                    if (e.sRQName.Substring(0, 3).Equals("101") && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50028 {
                            Value = e.sRQName.Substring(0, 8), RQName = e.sRQName, PrevNext = 2
                        })));

                        return;
                    }
                    if (e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50066 {
                            Value = e.sRQName.Substring(0, 8), RQName = e.sRQName, PrevNext = 2
                        })));

                        return;
                    }
                    if (e.sPrevNext.Equals("0"))
                    {
                        SendMemorize?.Invoke(this, new Memorize(e.sPrevNext, e.sRQName.Substring(0, 8)));
                    }
                }
                Request(e.sRQName);
                return;
            }
            if (e.sTrCode.Contains("KOA"))
            {
                return;
            }

            sb = new StringBuilder(512);
            int i, cnt = axAPI.GetRepeatCnt(e.sTrCode, e.sRQName);

            for (i = 0; i < (cnt > 0 ? cnt : cnt + 1); i++)
            {
                foreach (string item in Array.Find(catalog, o => o.ToString().Contains(e.sTrCode.Substring(1))))
                {
                    sb.Append(axAPI.GetCommData(e.sTrCode, e.sRQName, i, item).Trim()).Append(';');
                }

                if (cnt > 0)
                {
                    sb.Append("*");

                    if (DeadLine && sb.ToString().Substring(0, 3).Equals("101"))
                    {
                        string[] temp = sb.ToString().Split(';');
                        Quantity = temp[2].Equals("1") ? -int.Parse(temp[3]) : int.Parse(temp[3]);
                        DeadLine = false;
                    }
                }
            }
            switch (Array.FindIndex(catalog, o => o.ToString().Contains(e.sTrCode.Substring(1))))
            {
            case 0:
                FixUp(sb.ToString().Split(';'), e.sRQName);
                break;

            case 1:
                SendDeposit?.Invoke(this, new Deposit(sb));
                break;

            case 2:
                SendHolding?.Invoke(this, new Holding(sb.ToString()));
                break;
            }
        }
예제 #8
0
        void OnReceiveTrData(object sender, _DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            int index = Array.FindIndex(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1)));

            if (index < 1)
            {
                new ExceptionMessage(e.sTrCode);

                return;
            }
            if (index < 5 && index > 0)
            {
                var temp = API.GetCommDataEx(e.sTrCode, e.sRQName);

                if (temp != null)
                {
                    string[,] ts = new string[((object[, ])temp).GetUpperBound(0) + 1, ((object[, ])temp).GetUpperBound(1) + 1];
                    int x, y, lx = ((object[, ])temp).GetUpperBound(0), ly = ((object[, ])temp).GetUpperBound(1);

                    for (x = 0; x <= lx; x++)
                    {
                        var sb = new StringBuilder(64);

                        for (y = 0; y <= ly; y++)
                        {
                            ts[x, y] = (string)((object[, ])temp)[x, y];

                            if (ts[x, y].Length > 13 && e.sRQName.Split(';')[1].Equals(ts[x, y].Substring(2)))
                            {
                                sb          = Exists;
                                e.sPrevNext = "0";

                                break;
                            }
                            sb.Append(ts[x, y]).Append(';');
                        }
                        if (Exists.Equals(sb) == false)
                        {
                            SendMemorize?.Invoke(this, new Memorize(sb));

                            continue;
                        }
                        if (Exists.Equals(sb))
                        {
                            break;
                        }
                    }
                    if (DeadLine && (e.sRQName.Split(';')[1].Length == 8 || e.sRQName.Split(';')[1].Equals("DoesNotExist")) && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt10081
                        {
                            Value    = e.sRQName.Split(';')[0],
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Split(';')[0].Length == 6 && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt10079
                        {
                            Value    = e.sRQName.Split(';')[0],
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Substring(5, 3).Equals("000") && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50028
                        {
                            Value    = e.sRQName.Substring(0, 8),
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (DeadLine == false && e.sRQName.Split(';')[0].Length == 8 && e.sPrevNext.Equals("2"))
                    {
                        request.RequestTrData(new Task(() => InputValueRqData(new Opt50066
                        {
                            Value    = e.sRQName.Substring(0, 8),
                            RQName   = e.sRQName,
                            PrevNext = 2
                        })));
                        return;
                    }
                    if (e.sPrevNext.Equals("0"))
                    {
                        SendMemorize?.Invoke(this, new Memorize(e.sPrevNext, e.sRQName.Split(';')[0]));
                    }
                }
                SetScreenNumber(9000, 9031);
                SendMemorize?.Invoke(this, new Memorize("Clear"));
                Request(GetRandomCode(new Random().Next(0, CodeList.Count)));

                return;
            }
            var str = new StringBuilder(512);
            int i, cnt = API.GetRepeatCnt(e.sTrCode, e.sRQName);

            for (i = 0; i < (cnt > 0 ? cnt : cnt + 1); i++)
            {
                foreach (string item in Array.Find(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1))))
                {
                    str.Append(API.GetCommData(e.sTrCode, e.sRQName, i, item).Trim()).Append(';');
                }

                if (cnt > 0)
                {
                    str.Append("*");
                }
            }
            switch (Array.FindIndex(catalogTR, o => o.ToString().Contains(e.sTrCode.Substring(1))))
            {
            case 5:
                FixUp(str.ToString().Split(';'), e.sRQName);
                return;

            case 6:
                foreach (string info in str.ToString().Split('*'))
                {
                    FixUp(info.Split(';'));
                }

                return;

            case 7:
            case 8:
                if (str.Length > 1 && e.sRQName.Equals("DoNotRollOver") == false)
                {
                    if (e.sScrNo.Substring(0, 1).Equals("1"))
                    {
                        SellOrder[str.ToString().Split(';')[0]] = double.Parse(e.sRQName.Split(';')[0]);
                    }

                    else if (e.sScrNo.Substring(0, 1).Equals("2"))
                    {
                        BuyOrder[str.ToString().Split(';')[0]] = double.Parse(e.sRQName.Split(';')[0]);
                    }
                }
                SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber));
                return;

            case 9:
                SendState?.Invoke(this, new State(OnReceiveBalance, SellOrder.Count, Quantity, BuyOrder.Count, ScreenNumber));
                return;

            case 10:
                SendDeposit?.Invoke(this, new Deposit(str.ToString().Split(';')));
                break;

            case 11:
                new Task(() =>
                {
                    var temporary = str.ToString().Split('*');

                    for (i = 0; i < temporary.Length; i++)
                    {
                        if (temporary[i].Length > 0 && temporary[i].Substring(0, 8).Equals(API.GetFutureCodeByIndex(0)))
                        {
                            var quantity = temporary[i].Split(';');
                            Quantity     = quantity[2].Equals("1") ? -int.Parse(quantity[3]) : int.Parse(quantity[3]);
                            AvgPurchase  = (double.Parse(quantity[4]) / 100).ToString("F2");
                        }
                    }
                    SendBalance?.Invoke(this, new Balance(temporary));
                }).Start();
                break;
            }
        }