コード例 #1
0
        public void test()
        {
            ManualResetEvent processSignaller = new ManualResetEvent(false);

            //BizDomain equityDomain;
            equityDomain = new BizDomain("Equity Domain", new string[] { "MSFT", "BAC", "GE", "WFC" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Salt Futures", new string[] { "MSFT", "BAC", "GE", "WFC" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();
            equityMatchingLogic.updateClearingCorp();



            equityDomain.checkMargin();



            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 17, 1, 2, 2));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 17, 1, 50, 50));
            //Console.ReadLine();
            //equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Market", "B", 20, 2, 2));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 18, 1, 3, 3));


            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Stop", "B", 20, 5, 13, 13));

            processSignaller.WaitOne(2000, false);
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 5, 4, 4));
            //equityDomain.UpdateOrder(new FuturesOrder("MSFT", "Regular", "B", 19, 10, 8), new FuturesOrder("MSFT", "Regular", "B", 20, 5, 4));

            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 29, 7, 5, 5));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", .1, 8, 6, 6));


            processSignaller.WaitOne(2000, false);
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 1, 11, 11));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 25, 6, 12, 12));
            //equityDomain.PriceQuote("MSFT", "B");
            //equityDomain.PriceQuote("MSFT", "S");


            Console.ReadLine();
            Console.WriteLine("Press any key to stop");
            Console.ReadLine();

            return;
        }
コード例 #3
0
        public static void Start()
        {
            ManualResetEvent exchangeOpen     = new ManualResetEvent(false);
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Salt Futures", new string[] { "RSXH", "RSXM", "RSXU", "RSXZ" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();

            //starts listening for orders
            Task.Factory.StartNew(() => SynchronousSocketListener.StartListening(equityDomain));


            while (true)
            {
                if (DateTime.Now > startTime + stagingTime)
                {
                    //equityDomain.findOpenPrice();
                    open = true;
                    break;
                }
                else
                {
                    exchangeOpen.WaitOne(10);
                }
            }


            Console.WriteLine("Press any key to stop");
            Console.ReadLine();

            return;
        }
コード例 #4
0
        static void Main(string[] args)
        {
            BizDomain equityDomain;

            //Create equity domain with 3 order processor dedicated to process
            //MSFT, IBM and GE orders
            equityDomain = new BizDomain("Equity Domain", new string[] { "MSFT", "IBM", "GE" });
            //Assign the order ranking logic
            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();
            //Assign the business component
            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            //Start the matching engine
            equityDomain.Start();
            //Submit buy order
            equityDomain.SubmitOrder("MSFT", new EquityOrder("MSFT", "Regular", "B", 20, 3));
            //Submit sell order
            //this will also generate a trade because
            //there is a matching counter buy order
            equityDomain.SubmitOrder("MSFT", new EquityOrder("MSFT", "Regular", "S", 20, 2));
            Console.WriteLine("Press any key to Stop");
            Console.ReadLine();
        }
コード例 #5
0
        //Mutex syncExchange = new Mutex(false, "SyncExchange");
        //[STAThread]
        public static void Start()
        {
            LeafContainer.openPriceFound.Set();
            EquityMatchingEngine.OMEHost.open    = false;
            EquityMatchingEngine.OMEHost.running = true;

            EquityMatchingEngine.OMEHost.startTime = DateTime.Now;
            ManualResetEvent exchangeOpen     = new ManualResetEvent(false);
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Salt Futures", new string[] { "RSXH", "RSXM", "RSXU", "RSXZ" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();

            //starts listening for orders
            Task.Factory.StartNew(() => SynchronousSocketListener.StartListening(equityDomain));


            while (true)
            {
                if (DateTime.Now > startTime + stagingTime)
                {
                    //equityDomain.findOpenPrice();
                    open = true;
                    break;
                }
                else
                {
                    exchangeOpen.WaitOne(10);
                }
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            // ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain equityDomain;

            equityDomain = new BizDomain("Equity Domain", new string[] { "MSFT", "BAC", "GE", "WFC" });

            equityDomain.OrderBook.OrderPriority          = new PriceTimePriority();
            equityDomain.OrderBook.OrderPriorityForMarket = new TimePriorityForMarket();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            // HandleStop handleStop=new HandleStop(equityDomain);
            //       equityDomain.OrderBook.StopToMarketEvent += new OrderEventHandler(equityMatchingLogic.OrderBook_StopToMarket);
            equityDomain.Start();

            //test Market order
            // equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Market", "B", 20, 3, "Trader1","new"));
            //   equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Market", "S", 16, 5, "Trader1","new"));

            //test limit order
            // equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 25, 3, "Trader1","new"));
            //   equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 10, 5, "Trader1","new"));

            //test cancel order; orderID should be send by client

            /*
             * FuturesOrder OriOrder = new FuturesOrder("MSFT", "Limit", "B", 25, 3, "Trader1", "New");
             * FuturesOrder testDelete = new FuturesOrder("MSFT", "Limit", "B", 25, 3, "Trader1", "Cancel");
             * testDelete.OrderID = OriOrder.OrderID;
             *
             * equityDomain.SubmitOrder("MSFT", OriOrder);
             * equityDomain.SubmitOrder("MSFT", testDelete);
             *
             * //test update order;orderID should be send by client
             *
             * FuturesOrder UOrder = new FuturesOrder("MSFT", "Limit", "B", 25, 3, "Trader1", "New");
             * FuturesOrder testUpdate = new FuturesOrder("MSFT", "Limit", "B", 20, 5, "Trader1", "Update");
             * testUpdate.OrderID = UOrder.OrderID;
             * equityDomain.SubmitOrder("MSFT", UOrder);
             * equityDomain.SubmitOrder("MSFT", testUpdate);
             *
             * FuturesOrder UOrder = new FuturesOrder("MSFT", "Market", "B", 25, 3, "Trader1", "New");
             * FuturesOrder testUpdate = new FuturesOrder("MSFT", "Market", "B", 20, 5, "Trader1", "Update");
             * testUpdate.OrderID = UOrder.OrderID;
             * equityDomain.SubmitOrder("MSFT", UOrder);
             * equityDomain.SubmitOrder("MSFT", testUpdate);
             */
            FuturesOrder SOrder = new FuturesOrder("MSFT", "Stop", "S", 15, 3, "Trader1", "New");

            equityDomain.SubmitOrder("MSFT", SOrder);

            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 10, 5, "Trader1", "New"));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 25, 3, "Trader1", "New"));



            Console.ReadLine();

            return;
        }
コード例 #7
0
        public void Starter()
        {
            ManualResetEvent processSignaller = new ManualResetEvent(false);
            BizDomain        equityDomain;

            equityDomain = new BizDomain("Equity Domain", new string[] { "MSFT", "BAC", "GE", "WFC" });

            equityDomain.OrderBook.OrderPriority = new PriceTimePriority();

            EquityMatchingLogic equityMatchingLogic = new EquityMatchingLogic(equityDomain);

            equityDomain.Start();
            //TcpClient tcp = new TcpClient(AddressFamily.InterNetwork);
            //tcp.Connect(IPAddress.Loopback, 12345);
            //TcpListener tcpListener = null;

            //try
            //{
            //    tcpListener = new TcpListener(IPAddress.Loopback, 12345);
            //    tcpListener.Start();
            //    Console.WriteLine("Waiting for a connection...");
            //}
            //catch (Exception e)
            //{
            //    string output;
            //    output = "Error: " + e.ToString();
            //    Console.WriteLine(output);
            //}
            //TcpClient tcp = tcpListener.AcceptTcpClient( );
            ////Socket tcp = tcpListener.AcceptSocket();
            //StreamReader data_in = new StreamReader(tcp.GetStream());

            //string myxml = data_in.ReadToEnd();
            //Console.WriteLine(myxml);
            //EquityOrder[] order = LoadFromXMLString(myxml);
            //data_in.Close();
            //tcp.Close();

            //foreach (EquityOrder curOrder in order)
            //{
            //    equityDomain.SubmitOrder(curOrder.Instrument, curOrder);
            //}



            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 17, 1, 2));
            //Console.ReadLine();
            //equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Market", "B", 20, 2, 2));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 18, 1, 3));


            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Stop", "B", 20, 5, 13));


            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 5, 4));
            //equityDomain.UpdateOrder(new FuturesOrder("MSFT", "Regular", "B", 19, 10, 8), new FuturesOrder("MSFT", "Regular", "B", 20, 5, 4));

            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 29, 7, 5));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", .1, 8, 6));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 8, 7));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 8, 8));
            equityDomain.DeleteOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 8, 6));

            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 45, 8, 9));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "S", 30, 8, 10));

            processSignaller.WaitOne(1000, false);
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 20, 1, 11));
            equityDomain.SubmitOrder("MSFT", new FuturesOrder("MSFT", "Limit", "B", 25, 6, 12));
            //equityDomain.PriceQuote("MSFT", "B");
            //equityDomain.PriceQuote("MSFT", "S");


            Console.ReadLine();
            Console.WriteLine("Press any key to stop");
            Console.ReadLine();

            return;
        }