Exemplo n.º 1
0
 private string getExchange(OrderDirections directions)
 {
     if (directions.Cbo)
     {
         WriteLine("Am placing order {0} on Cbo", directions.Symbol);
         return("CBO");
     }
     if (directions.Box)
     {
         WriteLine("Am placing order {0} on Box", directions.Symbol);
         return("Box");
     }
     if (directions.Ise)
     {
         WriteLine("Am placing order {0} on Ise", directions.Symbol);
         return("Ise");
     }
     if (directions.Ase)
     {
         WriteLine("Am placing order {0} on Ase", directions.Symbol);
         return("Ase");
     }
     if (directions.Phs)
     {
         WriteLine("Am placing order {0} on Phs", directions.Symbol);
         return("Phs");
     }
     WriteLine("don't know what exhange to send order for {0}", directions.Symbol);
     return("Uknown");
 }
Exemplo n.º 2
0
        public void autobid(OrderDirections directions)
        {
            WriteLog("autobid on directions {0} " + directions.ToString());
            this.directions = directions;
            this.state      = State.Watching;
            string tql = querytable.TqlForBidAskTrade(directions.Symbol, null, "A", "B", "C", "D", "E", "I", "J", "K", "M", "N", "P", "Q", "W", "X", "Y");

            querytable.WantData(tql, true, true);
            querytable.OnRegional += new EventHandler <DataEventArgs <RegionalRecord> >(OnData);
            querytable.OnDead     += new EventHandler <EventArgs>(OnConnectionDead);
            if (!querytable.Connected)
            {
                WriteLog("!querytable.Connected, querytable.Start()");
                querytable.Start();
            }
        }
Exemplo n.º 3
0
        private void autobidButton_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Autobid Button Clicked ");
              Console.WriteLine("Configuration.getValue(test): " + Configuration.getValue("Configuration/Account/Branch"));
              OrderManager.Rules rules = new OrderManager.Rules();
              rules.MinTotalBidSizeTenCent = Convert.ToInt32(minTotalBidSizeTenCentTextBox.Text );
              rules.MinTotalBidSizeFiveCent = Convert.ToInt32(minTotalBidSizeFiveCentTextBox.Text);
              rules.MaxAskSizeBuyTriggerFiveCent = Convert.ToInt32(maxAskSizeBuyFiveCentTriggerTextBox.Text);
              rules.MaxAskSizeBuyTriggerTenCent = Convert.ToInt32(maxAskSizeBuyTenCentTriggerTextBox.Text);
              rules.MaxAskPrice = Convert.ToDouble(maxAskPriceTextBox.Text);
              rules.MinCoreExchangeBidSize = Convert.ToInt32(MinCoreExchangeBidSizeTextBox.Text);
              orderManager.rules = rules;

              orderManager.AddWriteLineListeners(Terminal.OnWriteLine);
              Terminal.Clear();
              OrderDirections directions = new OrderDirections();
              XmlDataProvider xml = (XmlDataProvider)FindName("Rule");
              Simulated = Convert.ToBoolean(xml.Document.SelectSingleNode("Rule/Simulated").InnerText);
              directions.Simulated = Simulated;
              directions.Symbol = optionSymbolComboBox.Text;
              directions.Route = routeComboBox.Text;
              directions.Size = Convert.ToInt32( sizeTextBox.Text );
              directions.Box = boxCheckBox.IsChecked.Value;
              directions.Cbo = cboCheckBox.IsChecked.Value;
              directions.Ise = iseCheckBox.IsChecked.Value;
              directions.Ase = aseCheckBox.IsChecked.Value;
              directions.Phs = phsCheckBox.IsChecked.Value;

              orderManager.autobid(directions);

              orderManager.AutobidStatusListeners += UpdateTableStatus;
              recentSymbols.Add(optionSymbolComboBox.Text);
              optionSymbolComboBox.Items.Refresh();
        }
Exemplo n.º 4
0
        public void placeOrder(OrderDirections directions)
        {
            cancelOrder();
            cache           = new OrderCache(app);
            this.directions = directions;
            OrderBuilder bld = new OrderBuilder(cache);

            state = State.ConnectionPending;
            using (OrderWatcher watch = new OrderWatcher(cache, bld.OrderTag)) {
                cache.Start();
                while (state != State.ConnectionDead && state != State.OrderFinished)
                {
                    if (!WaitAny(10000, watch.WaitHandles))
                    {
                        WriteLine("TIMED OUT WaitAny(10000) WAITING FOR RESPONSE");
                        break;
                    }
                    OrderWatcher.Action action;
                    while (watch.GetNext(out action, out ord))
                    {
                        switch (action)
                        {
                        case OrderWatcher.Action.Live:
                            if (state == State.ConnectionPending)
                            {
                                WriteLine("SUBMITTING ORDER");
                                state = State.OrderPending;
                                bld.SetAccount(Configuration.getValue("Configuration/Account/Bank"),
                                               Configuration.getValue("Configuration/Account/Branch"),
                                               Configuration.getValue("Configuration/Account/Customer"),
                                               Configuration.getValue("Configuration/Account/Deposit"));
                                bld.SetBuySell(OrderBuilder.BuySell.BUY);
                                bld.SetExpiration(OrderBuilder.Expiration.DAY);
                                bld.SetRoute(directions.Route);
                                bld.SetSymbol(directions.Symbol, getExchange(directions), OrderBuilder.SecurityType.STOCKOPT);
                                bld.SetVolume(directions.Size);
                                bld.SetPriceLimit(directions.LimitPrice);
                                if (directions.Simulated)
                                {
                                    WriteLine("Am sending simulated order");
                                }
                                else
                                {
                                    WriteLine("Am sending real order");
                                    cache.SubmitOrder(bld);
                                }
                            }
                            break;

                        case OrderWatcher.Action.Dead:
                            WriteLine("CONNECTION FAILED");
                            state = State.ConnectionDead;
                            break;

                        case OrderWatcher.Action.Order:
                            DisplayOrder(ord);
                            if (state == State.OrderPending && ord.Type == "UserSubmitOrder")
                            {
                                if (ord.CurrentStatus == "COMPLETED")
                                {
                                    WriteLine("Order Completed");
                                    state = State.OrderFinished;
                                }
                                else
                                {
                                    WriteLine("Order UNEXPECTEDLY FINISHED");
                                    state = State.OrderFinished;
                                }
                            }
                            else if (state == State.CancelPending)
                            {
                                if (ord.CurrentStatus == "COMPLETED" || ord.CurrentStatus == "DELETED")
                                {
                                    state = State.OrderFinished;
                                }
                            }

                            if (ord.Type == "ExchangeTradeOrder")
                            {
                                WriteLine("GOT FILL FOR {0} {1} AT {2}", ord.Buyorsell, ord.Volume, ord.Price);
                            }
                            if (ord.Type == "ExchangeKillOrder")
                            {
                                WriteLine("GOT KILL");
                            }

                            break;
                        } // end switch
                    }     // end while getNext
                }         // end while state
            }             // end using watch
            WriteLine("DONE PLACING ORDER");
        }
Exemplo n.º 5
0
        public void placeOrder(OrderDirections directions)
        {
            cancelOrder();
              cache = new OrderCache(app);
              this.directions = directions;
              OrderBuilder bld = new OrderBuilder(cache);
              state = State.ConnectionPending;
              using (OrderWatcher watch = new OrderWatcher(cache, bld.OrderTag)) {
            cache.Start();
            while (state != State.ConnectionDead && state != State.OrderFinished) {
              if (!WaitAny(10000, watch.WaitHandles) ) {
            WriteLine("TIMED OUT WaitAny(10000) WAITING FOR RESPONSE");
            break;
              }
              OrderWatcher.Action action;
              while (watch.GetNext(out action, out ord)) {
            switch (action) {
            case OrderWatcher.Action.Live:
              if (state == State.ConnectionPending) {
            WriteLine("SUBMITTING ORDER");
            state = State.OrderPending;
            bld.SetAccount(Configuration.getValue("Configuration/Account/Bank"),
                   Configuration.getValue("Configuration/Account/Branch"),
                   Configuration.getValue("Configuration/Account/Customer"),
                   Configuration.getValue("Configuration/Account/Deposit"));
            bld.SetBuySell(OrderBuilder.BuySell.BUY);
            bld.SetExpiration(OrderBuilder.Expiration.DAY);
            bld.SetRoute(directions.Route);
            bld.SetSymbol(directions.Symbol, getExchange(directions), OrderBuilder.SecurityType.STOCKOPT);
            bld.SetVolume(directions.Size);
            bld.SetPriceLimit(directions.LimitPrice);
            if (directions.Simulated) {
              WriteLine("Am sending simulated order");
            }
            else {
              WriteLine("Am sending real order");
              cache.SubmitOrder(bld);
            }
              }
              break;
            case OrderWatcher.Action.Dead:
              WriteLine("CONNECTION FAILED");
              state = State.ConnectionDead;
              break;
            case OrderWatcher.Action.Order:
              DisplayOrder(ord);
              if( state==State.OrderPending && ord.Type=="UserSubmitOrder" ) {
            if( ord.CurrentStatus=="COMPLETED") {
            WriteLine("Order Completed");
            state = State.OrderFinished;
            }
            else {
              WriteLine("Order UNEXPECTEDLY FINISHED" );
              state = State.OrderFinished;
            }
              }
              else if (state == State.CancelPending) {
            if( ord.CurrentStatus=="COMPLETED" || ord.CurrentStatus=="DELETED" )
              state = State.OrderFinished;
              }

              if (ord.Type == "ExchangeTradeOrder")
            WriteLine("GOT FILL FOR {0} {1} AT {2}", ord.Buyorsell, ord.Volume, ord.Price);
              if (ord.Type == "ExchangeKillOrder")
            WriteLine("GOT KILL");

              break;
            } // end switch
              } // end while getNext
            } // end while state
              } // end using watch
              WriteLine("DONE PLACING ORDER");
        }
Exemplo n.º 6
0
 private string getExchange(OrderDirections directions)
 {
     if (directions.Cbo) {
     WriteLine("Am placing order {0} on Cbo", directions.Symbol);
     return "CBO";
       }
       if (directions.Box) {
     WriteLine("Am placing order {0} on Box", directions.Symbol);
     return "Box";
       }
       if (directions.Ise) {
     WriteLine("Am placing order {0} on Ise", directions.Symbol);
     return "Ise";
       }
       if (directions.Ase) {
     WriteLine("Am placing order {0} on Ase", directions.Symbol);
     return "Ase";
       }
       if (directions.Phs) {
     WriteLine("Am placing order {0} on Phs", directions.Symbol);
     return "Phs";
       }
       WriteLine("don't know what exhange to send order for {0}", directions.Symbol);
       return "Uknown";
 }