//public System.Threading.AutoResetEvent get_ReEval()
        //{
        //    return ReEval;
        //}


        public SysMan(Contract contract)
        {
            _Counter = 0;

            _StartUp = true;

            _instr = new Instrument(contract);

            //Ticklist = new List<TagValue>();
            BidPriList  = new Queue <double>();
            BidSizeList = new Queue <int>();
            AskPriList  = new Queue <double>();
            AskSizeList = new Queue <int>();
            LastPrice   = new Queue <double>();

            m_Matcher = new TradeMatcher(RoundTurnMethod.LIFO, 0.01);

            _instr.PriceUpdate += OnInstrUpdate;
            _instr.FillUpdate  += OnInstrumentFill;

            DecisionTimer           = new System.Timers.Timer(15000);
            DecisionTimer.Elapsed  += OnTimedEvent;
            DecisionTimer.AutoReset = true;
            DecisionTimer.Enabled   = true;
            DecisionTimer.Start();
        }
 public PositionManager(TradeMatcher t)
 {
     positions = new Dictionary<Product, int>();
     orderToFillMap = new Dictionary<Order, List<Fill>>();
     unmatchedOrders = new List<Fill>();
     matchedTrades = new List<Trade>();
     brokers = new List<BrokerManager>();
     tradeMatcher = t;
 }
Example #3
0
        public Instrument()
        {
            //Trade matcher below set at FIFO, AvgCost
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);
            //dataGridView1.DataSource = m_Matcher.BuyTable;
            //dataGridView2.DataSource = m_Matcher.SellTable;
            //dataGridView3.DataSource = m_Matcher.RoundTurns;

            // Create a new InstrObjClass object
            //Making Calls to Trader API
            m_Instr = new InstrObjClass("CME", "ES", InstrObjClass.ProdType.FUTURE, "Sep16", 125000);

            // Create a new InstrNotifyClass object from the InstrObjClass object.
            //subscribe to the observer
            m_Notify = ( InstrNotifyClass )m_Instr.CreateNotifyObj;

            // Enable price updates.
            m_Notify.EnablePriceUpdates = true;
            // Set UpdateFilter so event will fire anytime any one of these changes in the
            // associated InstrObjClass object.

            m_Notify.UpdateFilter = "LAST,LASTQTY";
            // Subscribe to the OnNotifyUpdate event.
            m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate);
            // Set the exchange, product, contract and product type.


            // Open m_Instr.
            m_Instr.Open(true);

            // Create a new OrderSetClass object.
            m_OrderSet = new OrderSetClass();
            // Set the limits accordingly.  If any of these limits is reached,
            // trading through the API will be shut down automatically.
            m_OrderSet.set_Set("MAXORDERS", 1000);
            m_OrderSet.set_Set("MAXORDERQTY", 1000);
            m_OrderSet.set_Set("MAXWORKING", 1000);
            m_OrderSet.set_Set("MAXPOSITION", 1000);
            // Enable deleting of orders.  Enable the OnOrderFillData event.  Enable order sending.
            m_OrderSet.EnableOrderAutoDelete = true;
            m_OrderSet.EnableOrderFillData   = true;
            m_OrderSet.EnableOrderSend       = true;
            // Subscribe to the OnOrderFillData event.
            m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData);
            // Open the m_OrderSet.
            m_OrderSet.Open(true);
            // Associate m_OrderSet with m_Instr.
            m_Instr.OrderSet = m_OrderSet;
        }
Example #4
0
        // public event FillEventHandler OnFill;

        public SystemManager04()
        {
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);

            // Create a new Instrument object.
            m_Instrument = new Instrument();
            m_Instrument.OnInstrumentUpdate += new OnInstrumentUpdateEventHandler(OnInstrumentUpdate);
            m_Instrument.OnInstrumentFill   += new OnInstrumentFillEventHandler(OnInstrumentFill);

            // Create a new SortedList to hold the Tick objects.
            m_TickList = new List <Tick>();

            m_Position = 0;
            m_Go       = false;
            m_Qty      = 1;
        }
Example #5
0
        // public event FillEventHandler OnFill;

        public SystemManager04()
        {
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);

            // Create a new Instrument object.
            m_Instrument = new Instrument("ES", "201406", Instrument.InstrumentType.FUTURE);
            m_Instrument.BidAskUpdate += new DataUpdateEventHandler(OnInstrumentUpdate);
            m_Instrument.FillUpdate   += new FillEventHandler(OnInstrumentFill);

            // Create a new SortedList to hold the Tick objects.
            m_TickList = new List <Tick>();

            m_Position = 0;
            m_Go       = false;
            m_Qty      = 0;
        }
Example #6
0
        // public event FillEventHandler OnFill;
        public SystemManager03()
        {
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);

            // Create a new Instrument object.
            m_Instrument = new Instrument();
            m_Instrument.OnInstrumentUpdate += new InstrumentUpdateEventHandler(OnInstrumentUpdate);
            m_Instrument.OnFill += new FillEventHandler(OnInstrumentFill);

            // Create a new SortedList to hold the Tick objects.
            m_TickList = new List<Tick>();

            m_Position = 0;
            m_Go = false;
            m_Qty = 0;
        }
Example #7
0
        public Instrument()
        {
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);


            // Create a new InstrObjClass object
            m_Instr = new InstrObjClass();

            // Create a new InstrNotifyClass object from the InstrObjectClass object.
            m_Notify = (InstrNotifyClass)m_Instr.CreateNotifyObj;
            // Enable price updates.
            m_Notify.EnablePriceUpdates = true;
            // Set UpdateFilter so event will fire anytime any one of these changes in the
            // associated InstrObjClass object.
            m_Notify.UpdateFilter = "LAST, LASTQTY";
            // Subscribe to the OnNotifyUpdate event.
            m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate);
            // Set the exchange, product, contract and product type.
            m_Instr.Exchange = "CME";
            m_Instr.Product  = "ES";
            m_Instr.Contract = "Sep12";
            m_Instr.ProdType = "FUTURE";
            // Open m_Instr.
            m_Instr.Open(true);

            // Create a new OrderSetClass object.
            m_OrderSet = new OrderSetClass();
            // Set the limits accordingly. If any of these limits is reached,
            // trading through the API will be shut down automatically.
            m_OrderSet.set_Set("MAXORDERS", 1000);
            m_OrderSet.set_Set("MAXORDERQTY", 1000);
            m_OrderSet.set_Set("MAXWORKING", 1000);
            m_OrderSet.set_Set("MAXPOSITION", 1000);
            // Enable deleting of orders. Enable the OnOrderFillData event. Enable order sending.
            m_OrderSet.EnableOrderAutoDelete = true;
            m_OrderSet.EnableOrderFillData   = true;
            m_OrderSet.EnableOrderSend       = true;
            // Subscribe to the OnOrderFillData event.
            m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData);
            // Open the m_OrderSet.
            m_OrderSet.Open(true);
            // Associate m_OrderSet with m_Instr.
            m_Instr.OrderSet = m_OrderSet;
        }
Example #8
0
        public Instrument()
        {
            m_Matcher = new TradeMatcher(RoundTurnMethod.FIFO);

            // Create a new InstrObjClass object
            m_Instr = new InstrObjClass();

            // Create a new InstrNotifyClass object from the InstrObjectClass object.
            m_Notify = (InstrNotifyClass)m_Instr.CreateNotifyObj;
            // Enable price updates.
            m_Notify.EnablePriceUpdates = true;
            // Set UpdateFilter so event will fire anytime any one of these changes in the
            // associated InstrObjClass object.
            m_Notify.UpdateFilter = "LAST, LASTQTY";
            // Subscribe to the OnNotifyUpdate event.
            m_Notify.OnNotifyUpdate += new InstrNotifyClass.OnNotifyUpdateEventHandler(OnNotifyUpdate);
            // Set the exchange, product, contract and product type.
            m_Instr.Exchange = "CME";
            m_Instr.Product = "ES";
            m_Instr.Contract = "Sep12";
            m_Instr.ProdType = "FUTURE";
            // Open m_Instr.
            m_Instr.Open(true);

            // Create a new OrderSetClass object.
            m_OrderSet = new OrderSetClass();
            // Set the limits accordingly. If any of these limits is reached,
            // trading through the API will be shut down automatically.
            m_OrderSet.set_Set("MAXORDERS", 1000);
            m_OrderSet.set_Set("MAXORDERQTY", 1000);
            m_OrderSet.set_Set("MAXWORKING", 1000);
            m_OrderSet.set_Set("MAXPOSITION", 1000);
            // Enable deleting of orders. Enable the OnOrderFillData event. Enable order sending.
            m_OrderSet.EnableOrderAutoDelete = true;
            m_OrderSet.EnableOrderFillData = true;
            m_OrderSet.EnableOrderSend = true;
            // Subscribe to the OnOrderFillData event.
            m_OrderSet.OnOrderFillData += new OrderSetClass.OnOrderFillDataEventHandler(OnOrderFillData);
            // Open the m_OrderSet.
            m_OrderSet.Open(true);
            // Associate m_OrderSet with m_Instr.
            m_Instr.OrderSet = m_OrderSet;
        }