예제 #1
0
        public void TickTests()
        {
            // havent' sent any ticks, so shouldn't have any counted
            Assert.That(ticks == 0, ticks.ToString());

            // have to subscribe to a stock to get notified on fills for said stock
            c.Subscribe(new MarketBasket(new Stock("TST")));

            //send a tick from the server
            Tick t = Tick.NewTrade("TST", 10, 100);

            s.newTick(t);

            // make sure the client got it
            Assert.That(ticks == 1, ticks.ToString());
        }
예제 #2
0
        private void Trade_Click(object sender, EventArgs e)
        {
            string sym = stock.Text.ToUpper();

            if (!Stock.isStock(sym))
            {
                status("Please input a stock symbol.");
                return;
            }
            if (Boxes.SelectedIndex == -1)
            {
                status("Please select a box.");
                return;
            }
            Security sec      = Security.Parse(sym);
            string   shortsym = sec.Symbol;
            string   boxcrit  = "Box on " + sym + " with " + (string)Boxes.SelectedItem;

            if (boxlist.ContainsKey(shortsym))
            {
                if (MessageBox.Show("For safety, you're only allowed one box per symbol.  Would you like to replace existing box?", "Confirm box replace", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                {
                    status("flatting symbol " + shortsym);
                    tl.SendOrder(new MarketOrder(shortsym, boxlist[shortsym].PosSize * -1));
                    boxlist[shortsym].Shutdown("user requested shutdown");
                    string name = boxlist[shortsym].Name;
                    boxlist.Remove(shortsym);
                    status("Removed strategy " + name + " from " + shortsym);
                }
                else
                {
                    status("Box activation canceled because of too many boxes.");
                    return;
                }
            }
            mb.Add(new Stock(sym));
            tl.Subscribe(mb);
            workingbox.Symbol = shortsym;
            boxcriteria.Items.Add(workingbox.Name + " [" + shortsym + "]");
            boxlist.Add(shortsym, workingbox);
            seclist.Add(shortsym, sec);
            boxes.Add(workingbox);


            stock.Text = "";
            status("");
            Boxes.SelectedIndex = -1;
        }
예제 #3
0
        private void importbasketbut_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Multiselect     = true;
            od.Filter          = "Basket (*.mb)|*.mb|All files (*.*)|*.*";
            od.AddExtension    = true;
            od.DefaultExt      = ".mb";
            od.CheckFileExists = true;
            od.Title           = "Select the baskets you wish to import to quototpia";
            if (od.ShowDialog() == DialogResult.OK)
            {
                foreach (string f in od.FileNames)
                {
                    StreamReader sr   = new StreamReader(f);
                    string       line = sr.ReadLine();
                    sr.Close();
                    string[] r       = line.Split(',');
                    int      skipped = 0;
                    for (int i = 0; i < r.Length; i++)
                    {
                        bool add = true;
                        if (Stock.isStock(r[i]))
                        {
                            mb.Add(new Stock(r[i]));
                        }
                        else if (Index.isIdx(r[i]))
                        {
                            ib.Add(new Index(r[i]));
                        }
                        else
                        {
                            add = false; skipped++;
                        }
                        if (add)
                        {
                            addsymbol(r[i]);
                        }
                    }
                    status("Imported " + (r.Length - skipped) + " instruments.");
                }
            }
            tl.Subscribe(mb);
            tl.RegIndex(ib);
        }
예제 #4
0
        void refreshlist(int size)
        {
            if (size != (mb.Count + ib.Count))
            {
                tl.RegIndex(ib);
                tl.Subscribe(mb);

                stockslist.Items.Clear();
                for (int i = 0; i < mb.Count; i++)
                {
                    stockslist.Items.Add(mb[i].Name);
                }
                for (int i = 0; i < ib.Count; i++)
                {
                    stockslist.Items.Add(ib[i].Name);
                }
            }
        }