Exemplo n.º 1
0
 public void Basics()
 {
     Broker broker = new Broker();
     broker.GotFill += new FillDelegate(broker_GotFill);
     broker.GotOrder += new OrderDelegate(broker_GotOrder);
     broker.GotWarning += new DebugDelegate(broker_GotWarning);
     Order o = new Order();
     uint failsoninvalid= broker.sendOrder(o);
     Assert.That(failsoninvalid==0);
     Assert.That(warn == 1);
     Assert.That(orders == 0);
     Assert.That(fills == 0);
     o = new BuyMarket(s, 100);
     Assert.That(broker.sendOrder(o)>0);
     Assert.That(orders == 1);
     Assert.That(fills == 0);
     Assert.That(broker.Execute(Tick.NewTrade(s,10,200)) == 1);
     Assert.That(fills == 1);
     // no warnings since first warning
     Assert.That(warn == 1);
 }
Exemplo n.º 2
0
 public void MultiAccount()
 {
     const string sym = "TST";
     Order o = new BuyMarket(sym,100);
     const string me = "tester";
     const string other = "anotherguy";
     Account a = new Account(me);
     Account b = new Account(other);
     Account c = new Account("sleeper");
     // send order to account for jfranta
     Assert.That(broker.sendOrder(o, a)>0);
     Assert.That(broker.sendOrder(o, b)>0);
     Tick t = new Tick(sym);
     t.trade = 100m;
     t.size = 200;
     Assert.That(broker.Execute(t)==2);
     Position apos = broker.GetOpenPosition(sym,a);
     Position bpos = broker.GetOpenPosition(sym,b);
     Position cpos = broker.GetOpenPosition(sym, c);
     Assert.That(apos.Side && (apos.Size == 100));
     Assert.That(bpos.Side && (bpos.Size == 100));
     Assert.That(cpos.Flat);
     // make sure that default account doesn't register
     // any trades
     Assert.That(broker.GetOpenPosition(sym).Flat);
 }