Пример #1
0
        private void MainStockTab_StockList_listbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            stockDetailHistoricalInfo = null;
            stockDetailHistoricalInfo = new DataTable();
            stockDetailHistoricalInfo.Columns.Add(new DataColumn("Resolução"));
            stockDetailHistoricalInfo.Columns.Add(new DataColumn("Início"));
            stockDetailHistoricalInfo.Columns.Add(new DataColumn("Fim"));
            stockDetailHistoricalInfo.Columns.Add(new DataColumn("N. Períodos"));
            MainStockDetail_historicalData_dg.Height = MainStockDetail_historicalData_dg.RowTemplate.Height;

            Stock stock = app.stockManager.Get(MainStockTab_StockList_listbox.SelectedItem.ToString());

            MainStockDetail_name_lb.Text   = stock.Name;
            MainStockDetail_ticker_lb.Text = stock.Ticker;



            Image tmpImage;

            logos.TryGetValue(stock.Id, out tmpImage);
            if (tmpImage == null)
            {
                tmpImage = Image.FromFile(app.config.AppSettings.Settings["logoDir"].Value + "/" + Regex.Replace(stock.Ticker, "[0-9]", "") + ".png");
                logos.Add(stock.Id, tmpImage);
            }

            MainStockDetailLogo_pb.Image = tmpImage;

            foreach (KeyValuePair <string, bool> resolution in app.historicalDataResolutions)
            {
                List <Candle> candleList = stock.HistoricalData(AppData.HistoricalDataResolutionStringToSeconds(resolution.Key));
                DateTime      temp;

                string start    = "Não disponível";
                string end      = "Não disponível";
                int    dataSize = 0;

                if (candleList != null)
                {
                    temp  = new DateTime(1970, 1, 1, 0, 0, 0);
                    start = temp.AddSeconds(candleList[0].Timestamp).ToString();
                    end   = temp.AddSeconds(candleList.Last().Timestamp).ToString();

                    dataSize = candleList.Count;
                    //start = candleList[0].Timestamp.ToString();
                    //end = candleList.Last().Timestamp.ToString();
                }


                stockDetailHistoricalInfo.Rows.Add(new Object[] { resolution.Key, start, end, dataSize });
                MainStockDetail_historicalData_dg.Height += MainStockDetail_historicalData_dg.RowTemplate.Height;
            }
            MainStockDetail_historicalData_dg.DataSource = stockDetailHistoricalInfo;

            MainStockDetail_gb.Show();
        }
Пример #2
0
        public MainForm(AppData app)
        {
            this.app = app;
            InitializeComponent();

            logos = new Dictionary <int, Image>();


            this.MainConfig_RTDDefaultUser_text.Text = ConfigurationManager.AppSettings["RTDDefaultUser"];

            MainStockTab_StockList_listbox.Items.Clear();
            foreach (string item in app.streamerClient.Items)
            {
                MainStockTab_StockList_listbox.Items.Add(item);
            }

            /*   bool RTDStreamAutostart = false;
             * if (ConfigurationManager.AppSettings["RTDStreamAutostart"].Equals("1"))
             *     RTDStreamAutostart = true;
             */
            //RTDStreamAutostart_cb.Checked = RTDStreamAutostart;

            MainStartegyCheckList_treeView.Nodes.Clear();
            strategyIndentifiers = new List <string>();
            int currentSize = 0;

            foreach (iStrategy strategy in app.strategyManager.All)
            {
                MainStartegyCheckList_treeView.Nodes.Add(strategy.Name);
                strategyIndentifiers.Add(strategy.Identifier);
                MainStartegyCheckList_treeView.Nodes[currentSize].Checked = strategy.Active;

                currentSize++;
            }

            StrategyDetails_gb.Hide();
            MainStockDetail_gb.Hide();


            //sobre dados históricos.
            string defaultHDPIdentifier = "";

            if (app.historicalDataManager.Config.AppSettings.Settings["historicalDataProvider"] != null)
            {
                defaultHDPIdentifier = app.historicalDataManager.Config.AppSettings.Settings["historicalDataProvider"].Value;
            }
            foreach (HistoricalDataProvider hdp in app.historicalDataManager.All)
            {
                if (defaultHDPIdentifier.Equals(hdp.Identifier))
                {
                    HDDefaultProvider_cb.SelectedIndex = HDDefaultProvider_cb.Items.Add(hdp.Name);
                }
                else
                {
                    HDDefaultProvider_cb.Items.Add(hdp.Name);
                }
            }

            HistoricalDataAutoUpdate_check.Checked =
                app.historicalDataManager.Config.AppSettings.Settings["historicalDataAutoUpdate"] != null &&
                app.historicalDataManager.Config.AppSettings.Settings["historicalDataAutoUpdate"].Value == "1" ? true : false;
        }