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; }
public void OrderTests() { // no orders yet Assert.That(orders == 0, orders.ToString()); // no fill requests yet Assert.That(fillrequest == 0, fillrequest.ToString()); // client wants to buy 100 TST at market Order o = new Order("TST", 100); // if it works it'll return zero int error = c.SendOrder(o); Assert.That(error == 0, error.ToString()); // client should have received notification that an order entered his account Assert.That(orders == 1, orders.ToString()); // server should have gotten a request to fill an order Assert.That(fillrequest == 1, fillrequest.ToString()); }