예제 #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 main_Load(object sender, EventArgs e)
        {
            {
                mainUpdater = new MainUpdater(sAPI_Key, sAPI_Secret);

                coinList = new List <string>(mainUpdater.setCoinList());
                if (coinList == null)
                {
                    MessageBox.Show("Init error due to API error, try again.");
                    Close();
                    return;
                }
                mainUpdater.update();
                account = mainUpdater.account;
                ticker  = mainUpdater.ticker;

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

                showAccount = new DataTable();
                showAccount.Columns.Add("Name", typeof(string));
                showAccount.Columns.Add("Units", typeof(double));
                showAccount.Columns.Add("Price", typeof(double));
                showAccount.Columns.Add("Total", typeof(double));

                for (int i = 0; i < account.Count; i++)
                {
                    if (!"USDT".Equals(account[i].coinName.ToUpper()))
                    {
                        DataRow dataRow = showAccount.NewRow();
                        dataRow["Name"]  = account[i].coinName;
                        dataRow["Units"] = account[i].locked + account[i].valid;
                        dataRow["Price"] = account[i].coinName == "KRW" ? 1 : ticker[account[i].coinName].close;
                        dataRow["Total"] = (double)dataRow["Units"] * (double)dataRow["Price"];
                        showAccount.Rows.Add(dataRow);
                    }
                }

                dataGridView_holdList.DataSource = showAccount;
                dataGridView_holdList.Columns["Units"].DefaultCellStyle.Format = "#,0.####";
                dataGridView_holdList.Columns["Price"].DefaultCellStyle.Format = "#,0.##";
                dataGridView_holdList.Columns["Total"].DefaultCellStyle.Format = "#,0.##";
            }

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

            {
                macro = new MacroSetting(sAPI_Key, sAPI_Secret, coinList);
                if (macro.loadFile() < 0)
                {
                    Close();
                    return;
                }
            }

            {
                bot = new BotSetting(sAPI_Key, sAPI_Secret, coinList);
                if (bot.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;
        }