Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            securityList1 = ConfigurationManager.AppSettings["securities1"].Split(',').Select(s => s.Trim()).ToArray();
            securityList2 = ConfigurationManager.AppSettings["securities2"].Split(',').Select(s => s.Trim()).ToArray();
            currencyList1 = ConfigurationManager.AppSettings["currencies1"].Split(',').Select(s => s.Trim()).ToArray();
            currencyList2 = ConfigurationManager.AppSettings["currencies2"].Split(',').Select(s => s.Trim()).ToArray();
            baseCurrency = ConfigurationManager.AppSettings["baseCurrency"];
            sendTransactions = Convert.ToBoolean(ConfigurationManager.AppSettings["sendTransaction"]);
            tc = new TransactionComputer
                (securityList1, securityList2, currencyList1, currencyList2, baseCurrency);
            ts = new TransactionSender();
            SessionOptions sessionOptions = new SessionOptions();
            sessionOptions.ServerHost = "localhost";
            sessionOptions.ServerPort = 8194;
            Session session = new Session(sessionOptions, new EventHandler(ProcessEvent));
            session.StartAsync();

            //Invoke(new Action(() => richTextBox1.AppendText("moi\n");
            Invoke(new Action(() => richTextBox1.AppendText("end\n")));
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            securityList1    = ConfigurationManager.AppSettings["securities1"].Split(',').Select(s => s.Trim()).ToArray();
            securityList2    = ConfigurationManager.AppSettings["securities2"].Split(',').Select(s => s.Trim()).ToArray();
            currencyList1    = ConfigurationManager.AppSettings["currencies1"].Split(',').Select(s => s.Trim()).ToArray();
            currencyList2    = ConfigurationManager.AppSettings["currencies2"].Split(',').Select(s => s.Trim()).ToArray();
            baseCurrency     = ConfigurationManager.AppSettings["baseCurrency"];
            sendTransactions = Convert.ToBoolean(ConfigurationManager.AppSettings["sendTransaction"]);
            tc = new TransactionComputer
                     (securityList1, securityList2, currencyList1, currencyList2, baseCurrency);
            ts = new TransactionSender();
            SessionOptions sessionOptions = new SessionOptions();

            sessionOptions.ServerHost = "localhost";
            sessionOptions.ServerPort = 8194;
            Session session = new Session(sessionOptions, new EventHandler(ProcessEvent));

            session.StartAsync();

            //Invoke(new Action(() => richTextBox1.AppendText("moi\n");
            Invoke(new Action(() => richTextBox1.AppendText("end\n")));
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Lgr.Start();
            int _securities;

            try
            {
                _securities = get_Securities();
            }
            catch (CsvHelper.CsvMissingFieldException)
            {
                Invoke(new Action(() => richTextBox1.AppendText("Malformed securities.csv.\nSee that the header line is security1,security2,currency1,currency2,security1scale,security2scale,arbidir\n")));
                return;
            }
            catch (System.IO.FileNotFoundException)
            {
                Invoke(new Action(() => richTextBox1.AppendText("Could not find securities.csv\n")));
                return;
            }

            Invoke(new Action(() => richTextBox1.AppendText(String.Format("Found {0} securities\n", _securities))));
            if (_securities == 0)
            {
                Invoke(new Action(() => richTextBox1.AppendText("No valid securities found. Not starting.\n")));
                return;
            }

            baseCurrency = ConfigurationManager.AppSettings["baseCurrency"];
            profitThresholdEur = Convert.ToInt32(ConfigurationManager.AppSettings["profitThresholdEur"]);
            sendTransactions = Convert.ToBoolean(ConfigurationManager.AppSettings["sendTransaction"]);
            tc = new TransactionComputer
                (securityList1, securityList2,
                 currencyList1, currencyList2,
                 securityScale1, securityScale2,
                 baseCurrency, profitThresholdEur);
            ts = new TransactionSender();
            if (running == false)
            {
                running = true;

                SessionOptions sessionOptions = new SessionOptions();
                sessionOptions.ServerHost = "localhost";
                sessionOptions.ServerPort = 8194;

                //pullInitial(sessionOptions);

                sessionCurr = new Session(sessionOptions, new EventHandler(ProcessEventCurr));
                sessionCurr.StartAsync();

                sessionSec = new Session(sessionOptions, new EventHandler(ProcessEventSec));
                sessionSec.StartAsync();

                Invoke(new Action(() => richTextBox1.AppendText("started\n")));
                this.button1.Text = "Stop";
            }
            else
            {
                // FIXME: Any danger in stopping, eg. to transactions?
                running = false;
                sessionCurr.Stop();
                sessionSec.Stop();
                Invoke(new Action(() => richTextBox1.AppendText("stopped\n")));
                this.button1.Text = "Start";
            }
        }