예제 #1
0
        private void main_Load_1(object sender, EventArgs e)
        {
            {
                mainUpdater = new MainUpdater(sAPI_Key, sAPI_Secret);

                coinList = mainUpdater.getUpdateList();
                if (coinList.Count < 1)
                {
                    MessageBox.Show("Init error due to API error, try again.");
                    Close();
                    return;
                }
                mainUpdater.updateHoldList();
                holdList = mainUpdater.holdList.Copy();

                for (int i = 0; i < coinList.Count; i++)
                {
                    list_coinName.Items.Add(coinList[i]);
                }

                showHoldList = new DataTable();
                showHoldList.Columns.Add("Name", typeof(string));
                showHoldList.Columns.Add("Units", typeof(double));
                showHoldList.Columns.Add("Value", typeof(double));
                showHoldList.Columns.Add("Total", typeof(double));
            }

            {
                tradeHistory = new TradeHistory(sAPI_Key, sAPI_Secret);
                if (tradeHistory.loadFile() < 0)
                {
                    Close();
                    return;
                }
            }

            {
                macro = new MacroSetting(sAPI_Key, sAPI_Secret, coinList);
                macro.setLastKrw();

                if (macro.loadFile() < 0)
                {
                    Close();
                    return;
                }
            }

            {
                thread_updater      = new Thread(() => executeMainUpdater());
                thread_tradeHistory = new Thread(() => executeTradeHistoryUpdate());
                thread_macro        = new Thread(() => executeMacro());

                thread_updater.Start();
                thread_tradeHistory.Start();
                thread_macro.Start();
            }

            isInit = true;
        }
예제 #2
0
        private void executeMacro()
        {
            while (!AllStop)
            {
                if (macro.setting.Count > 0)
                {
                    lock (lock_macro)
                        macro.setLastPrice();
                    for (int i = 0; i < macro.setting.Count; i++)
                    {
                        lock (lock_macro)
                        {
                            if (i >= macro.setting.Count)
                            {
                                continue;
                            }

                            macro.setLastKrw();
                            macro.setCandleData(i);
                            macro.executeMacro(i);

                            for (int j = 0; j < macro.order.Rows.Count; j++)
                            {
                                macro.executeCheckResult(j);
                            }

                            for (int j = 0; j < macro.executionStr.Count; j++)
                            {
                                logIn(macro.executionStr[j].str);
                                if (macro.executionStr[j].level == 1)
                                {
                                    notifyIcon.BalloonTipTitle = "Macro Execution";
                                    notifyIcon.BalloonTipText  = macro.executionStr[j].str;
                                    notifyIcon.ShowBalloonTip(1000);
                                }
                            }
                            macro.executionStr.Clear();
                            macro.saveFile();
                        }

                        for (int j = 0; j < 10; j++)
                        {
                            if (AllStop)
                            {
                                break;
                            }
                            Thread.Sleep(100);
                        }
                        if (AllStop)
                        {
                            break;
                        }
                    }
                }

                Thread.Sleep(100);
            }
        }