Пример #1
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        public TestMarket()
        {
            InitializeComponent();

            // Set application information - do this before hubs are instantiated.
            string  basePath = UV.Lib.IO.FilesIO.GetPathToDirName(System.IO.Directory.GetCurrentDirectory(), "Ambre", true);
            AppInfo info     = AppInfo.GetInstance();

            info.BasePath     = basePath;
            info.LogDirectory = string.Format("{0}{1}", info.LogDirectory, UV.Lib.IO.FilesIO.GetTodaysLogDirAndClean(info.LogPath));


            // Instantiate the API.
            m_TTServices = TTApiService.GetInstance();
            m_TTServices.ServiceStateChanged += new EventHandler(TTServices_ServiceStateChanged);


            // Instantiate hubs
            //  but do not Connect until the user name/pw has been authenticated.
            m_Market = new Markets.MarketTTAPI();
            m_Market.Start();
            //m_Market.MarketStatusChanged += new EventHandler<UVLib.MarketHubs.MarketStatusChangedEventArg>(Market_MarketStatusChanged);
            //m_Market.FoundServiceResource += new EventHandler<MarketFoundServiceResource>(Market_MarketFoundServiceResource);
            m_Market.MarketStatusChanged += new EventHandler(Market_MarketStatusChanged);
            m_Market.FoundResource       += new EventHandler(Market_MarketFoundServiceResource);

            timer1.Tick    += new EventHandler(timer1_Tick);
            timer1.Interval = 1000;
        }
Пример #2
0
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// After constructing the drop rules, one can load a previous file or change
        /// parameters before writing.  The writers are created only after calling "Start()".
        /// </summary>
        /// <param name="fillHub"></param>
        public DropRules(FillHub fillHub)
        {
            // Create the unique user name.
            // UserLoginID + FillHubName (usually acct#)
            //
            TTApiService api = TTApiService.GetInstance();

            this.UniqueUserName = string.Format("{0}_{1}", api.LoginUserName, fillHub.Name);
            //this.UniqueUserName = fillHub.Name;
            this.m_FillHub             = fillHub;
            this.DropFileStartDateTime = fillHub.Log.GetTime();               // time stamp "label" used for archiving current drop file.

            m_StringifyOverrideTable = new Dictionary <Type, string[]>();
            m_StringifyOverrideTable.Add(m_FillHub.GetType(), new string[] { string.Empty, "GetAttributesDrop", "GetElementsDrop" });


            //#if (DEBUG)
            //BookDropPeriod = new TimeSpan(0, 5, 0);
            //PushToRepository = false;
            //#endif

            this.LastBookDrop    = fillHub.Log.GetTime().Subtract(this.BookDropPeriod).AddMinutes(5.0);
            this.m_LocalTimeLast = this.LastBookDrop;
            //this.NextResetDateTime = this.NextResetDateTime.Subtract(this.NextResetDateTime.TimeOfDay).Add(ResetTimeOfDay);
        }
Пример #3
0
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// Immediately starts the thread.  A TT Session must already exist when this is created.
        /// </summary>
        /// <param name="listenerName"></param>
        /// <param name="aLog"></param>
        public OrderListener(string listenerName, Hub parentHub)
        {
            m_ParentHub = parentHub;
            this.Log    = m_ParentHub.Log;
            this.m_Name = listenerName;
            m_TTService = TTApiService.GetInstance();
        }
Пример #4
0
        //
        //
        #endregion//Private Event Handlers


        #region Form Event Handlers
        // *****************************************************************
        // ****                     Event Handlers                     ****
        // *****************************************************************
        //
        //
        private void button_Click(object sender, EventArgs e)
        {
            // Validate
            if (!(sender is Button))
            {
                return;
            }
            Button button = (Button)sender;

            //
            // Process button click
            //
            if (button == buttonStart)
            {
                TTApiService service = TTApiService.GetInstance();
                service.Start(this.checkBoxUseXTraderFollowLogin.Checked);
            }
            else if (button == buttonGetProducts)
            {
                int selectedIndex = listBoxMarkets.SelectedIndex;
                if (selectedIndex >= 0 && selectedIndex < listBoxMarkets.Items.Count)
                {
                    listBoxProducts.ClearSelected();                               // deselect any selected products.
                    listBoxProducts.Items.Clear();                                 // remove products from list.
                    m_Market.RequestProducts((string)listBoxMarkets.SelectedItem); // Request new products.
                }
            }
            else if (button == buttonGetInstruments)
            {
                int selectedIndex = listBoxProducts.SelectedIndex;
                if (selectedIndex >= 0 && selectedIndex < listBoxProducts.Items.Count)
                {
                    listBoxInstruments.ClearSelected();                                 // deselect any selected products.
                    listBoxInstruments.Items.Clear();                                   // remove products from list.
                    string  productUniqueName = ((string)listBoxProducts.SelectedItem); // Request new products.
                    Product product;
                    if (m_Products.TryGetValue(productUniqueName, out product))
                    {
                        m_Market.RequestInstruments(product);
                    }
                }
            }
            else if (button == buttonStop)
            {
            }
            else if (button == buttonExit)
            {
                Shutdown();
                this.Close();
            }
            else if (button == buttonUpdate)
            {
                ToggleUpdateState();
                //UpdateMarket();
            }
            else
            {   // unknown button
                return;
            }
        }
Пример #5
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        //
        public HedgeOptionsDatabaseWriterTest()
        {
            m_Log = new LogHub("BRELibLog", string.Format("{0}{1}", UV.Lib.Application.AppInfo.GetInstance().BasePath,
                                                          UV.Lib.Application.AppInfo.GetInstance().LogDirectory), true, LogLevel.ShowAllMessages);
            InitializeComponent();
            m_UIDispatcher = Dispatcher.CurrentDispatcher;

            DatabaseInfo dbInfo = DatabaseInfo.Create(DatabaseInfo.DatabaseLocation.bredev);

            dbInfo.UserName        = "******";
            dbInfo.UserPW          = "test";
            m_DatabaseReaderWriter = new DatabaseReaderWriter(dbInfo);
            m_DatabaseReaderWriter.QueryResponse += new EventHandler(DatabaseReaderWriter_QueryResponse);

            this.textBoxExchangeName.Text = "CME";
            this.textBoxProductName.Text  = "GE";
            this.textBoxProductType.Text  = "Spread";

            m_TTAPIService = TTApiService.GetInstance();
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTApiService_ServiceStateChanged);
            m_TTAPIService.Start(true);

            m_Market = new MarketTTAPI();
            m_Market.MarketStatusChanged += new EventHandler(MarketTTAPI_MarketStatusChanged);
            m_Market.FoundResource       += new EventHandler(MarketTTAPI_MarketFoundServiceResource);
            m_Market.Start();
            m_Market.Connect();                             // initialize connection to API.
        }
Пример #6
0
 //
 //
 public override void Start()
 {
     // Locate required services
     Misty.Lib.Application.AppServices appServices = Misty.Lib.Application.AppServices.GetInstance();
     foreach (Misty.Lib.Application.IService service in appServices.GetServices(typeof(Markets.MarketTTAPI)))
     {
         this.AddHub((Markets.MarketTTAPI)service);
         break;
     }
     //foreach (Misty.Lib.Application.IService service in appServices.Services.Values)
     //    if (service is Markets.MarketTTAPI)
     //    {
     //        this.AddHub((Markets.MarketTTAPI)service);
     //        break;
     //    }
     if (m_Market == null)
     {
         throw new Exception("Failed to find required service.");
     }
     // Subscribe to TTApi
     if (m_TTService == null)
     {
         m_TTService = TTApiService.GetInstance();
         m_TTService.ServiceStateChanged += new EventHandler(TTService_ServiceStatusChanged);
     }
     base.Start();
 }//Start()
        /// <summary>
        /// GUI constructor to have both of the paths as members and log as well as drop file player, audit trail player.
        /// </summary>
        public AmbreRecoveryViewer()
        {
            InitializeComponent();
            typeof(MarketTTAPI).ToString();

            // Create log viewer.
            bool isLogViewerVisible = true;

            Log = new LogHub(ApplicationName, AppInfo.GetInstance().LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);

            // Create app service and get useful paths.
            AppServices appAmbreMaintenanceServices = AppServices.GetInstance(ApplicationName, true);

            m_RepositoryDropFilePath = appAmbreMaintenanceServices.Info.DropPath;
            m_AuditTrailFilePath     = appAmbreMaintenanceServices.Info.DropPath;
            if (m_DebugMode)
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, ReferenceApplicationName);
            }
            else
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(string.Format("\\{0}", ApplicationName), "");
            }

            Log.NewEntry(LogLevel.Minor, "The default paths to operate are {0} and {1}.", m_RepositoryDropFilePath, m_ReferenceDropFilePath);
            if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, "Ambre");
                Log.NewEntry(LogLevel.Major, "The default path for reference Ambre system does not exist, and the operating path becomes {0}.", m_ReferenceDropFilePath);
                if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
                {
                    Log.NewEntry(LogLevel.Major, "The changed path still does not exist. and the program can not proceed.");
                    return;
                }
            }

            // Create market tt api service and tt api service.
            m_MarketTTAPIService = new MarketTTAPI();
            m_MarketTTAPIService.Start();
            m_TTAPIService     = TTApiService.GetInstance();
            m_TTAPIService.Log = this.Log;
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTAPIService_ServiceStateChanged);
            m_TTAPIService.Start();

            // Sample for the user login name and fill hub name.
            textBoxUserName.Text    = "BETSIM";
            textBoxFillHubName.Text = "2014";
            m_UserName = textBoxUserName.Text;
            m_FillHubOrFillManagerName = textBoxFillHubName.Text;

            // Create file players.
            m_DropFilePlayer = new DropFilePlayer(m_ReferenceDropFilePath, Log);

            // Add closing form event trigger.
            this.FormClosing += new FormClosingEventHandler(AmbreRecoveryViewer_Closing);

            // Find all existing audit trail files. Also in this block, toggle the earliest and latest date time to the GUI.
            m_RepoFileList = new List <string>();
            LoadAllAuditTrailFiles();
        }//AmbreRecoveryViewer()
Пример #8
0
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// After constructing the drop rules, one can load a previous file or change
        /// parameters before writing.  The writers are created only after calling "Start()".
        /// </summary>
        /// <param name="fillHub"></param>
        public DropSimple(FillHub fillHub)
        {
            // Create the unique user name.
            TTApiService api = TTApiService.GetInstance();

            this.UniqueUserName        = string.Format("{0}_{1}", api.LoginUserName, fillHub.Name);
            this.m_FillHub             = fillHub;
            this.DropFileStartDateTime = fillHub.Log.GetTime();               // time stamp "label" used for archiving current drop file.

            m_StringifyOverrideTable = new Dictionary <Type, string[]>();
            m_StringifyOverrideTable.Add(m_FillHub.GetType(), new string[] { string.Empty, "GetAttributesDrop", "GetElementsDrop" });

            this.LastBookDrop    = fillHub.Log.GetTime().Subtract(this.BookDropPeriod).AddMinutes(5.0);
            this.m_LocalTimeLast = this.LastBookDrop;
        }
Пример #9
0
        //
        //
        //
        #endregion//Constructors



        #region no Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        //
        //
        //
        #endregion//Public Methods


        #region Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        //
        // ****             Shutdown()              ****
        //
        /// <summary>
        /// Complete shutdown of all hubs and their threads.
        /// </summary>
        private void Shutdown()
        {
            if (m_Market != null)
            {
                m_Market.RequestStop();
            }
            TTApiService ttService = TTApiService.GetInstance();

            if (ttService != null)
            {
                ttService.Dispose();
            }
            if (timer1 != null)
            {
                timer1.Stop();
                timer1.Enabled = false;
                timer1.Dispose();
            }
        }// Shutdown()
Пример #10
0
 public FillListener()
 {
     this.Name   = "FillListener";
     m_TTService = TTApiService.GetInstance();
 }
Пример #11
0
        public FilterType m_FilterType;                       // The filter type in the last recent book.
        #endregion                                            // members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// Immediately starts the thread.  A TT Session must already exist when this is created.
        /// </summary>
        /// <param name="listenerName"></param>
        /// <param name="aLog"></param>
        public FillListener(string listenerName)
        {
            this.Name   = listenerName;
            m_TTService = TTApiService.GetInstance();
        }
Пример #12
0
        private ConcurrentQueue <Job> m_InQueue = new ConcurrentQueue <Job>();  // In-Out queue, Jobs pushed from outsider threads.

        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public PriceListener(string priceListenerName, LogHub aLog)
        {
            this.Log     = aLog;
            m_TTServices = TTApiService.GetInstance();
            m_Name       = priceListenerName;
        }
Пример #13
0
        }     //TryGetProduct()

        //
        // *****************************************************************
        // ****                     Start()                             ****
        // *****************************************************************
        /// <summary>
        /// This is called after all services exist, but before any services is connected.
        /// </summary>
        public override void Start()
        {
            m_TTService = TTApiService.GetInstance();
            m_TTService.ServiceStateChanged += new EventHandler(this.HubEventEnqueue); // Once TTAPI is connected, I can connect automatically.
            base.Start();
        }//Start().
Пример #14
0
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// Immediately starts the thread.  A TT Session must already exist when this is created.
        /// </summary>
        /// <param name="listenerName"></param>
        /// <param name="aLog"></param>
        public OrderListenerMsgr(string listenerName, LogHub aLog)
        {
            this.Log    = aLog;
            this.m_Name = listenerName;
            m_TTService = TTApiService.GetInstance();
        }