public StockStrategyScannerDlg(StockDictionary stockDictionary, StockSerie.Groups stockGroup, StockSerie.StockBarDuration barDuration, string strategyName) { InitializeComponent(); this.stockDictionary = stockDictionary; this.barDuration = barDuration; // Initialise group combo box groupComboBox.Items.AddRange(this.stockDictionary.GetValidGroupNames().ToArray()); groupComboBox.SelectedItem = stockGroup.ToString(); groupComboBox.SelectedValueChanged += new EventHandler(groupComboBox_SelectedValueChanged); // Initialise Strategy Combo box this.strategyComboBox.Items.Clear(); List<string> strategyList = StrategyManager.GetStrategyList(); foreach (string name in strategyList) { this.strategyComboBox.Items.Add(name); } this.strategyComboBox.SelectedItem = strategyName; this.strategyComboBox.SelectedValueChanged += new EventHandler(strategyComboBox_SelectedValueChanged); periodComboBox.SelectedIndex = 0; OnBarDurationChanged(barDuration); }
public StockScannerDlg(StockDictionary stockDictionary, StockSerie.Groups stockGroup, StockSerie.StockBarDuration barDuration, Dictionary<string, List<string>> theme) { InitializeComponent(); this.stockDictionary = stockDictionary; this.barDuration = barDuration; // Initialise group combo box groupComboBox.Items.AddRange(this.stockDictionary.GetValidGroupNames().ToArray()); groupComboBox.SelectedItem = stockGroup.ToString(); groupComboBox.SelectedValueChanged += new EventHandler(groupComboBox_SelectedValueChanged); periodComboBox.SelectedIndex = 0; completeBarCheckBox.Checked = true; OnThemeChanged(theme); OnBarDurationChanged(barDuration); oneRadioButton.Checked = true; }
public PalmaresDlg(StockDictionary stockDico, List<StockWatchList> watchLists, StockSerie.Groups selectedGroup, ToolStripProgressBar progressBar) { InitializeComponent(); // Initialize dico StockDico = stockDico; WatchLists = watchLists; this.progressBar = progressBar; this.groupComboBox.Items.Clear(); this.groupComboBox.Items.AddRange(stockDico.GetValidGroupNames().ToArray()); this.groupComboBox.SelectedItem = selectedGroup.ToString(); this.indicatorTextBox.Text = Settings.Default.MomentumIndicator; // Create an instance of a ListView column sorter and assign it to the ListView control. lvwColumnSorter = new ListViewColumnSorter(); this.palmaresView.ListViewItemSorter = (IComparer)lvwColumnSorter; // Select default values this.untilCheckBox.Checked = false; this.untilDateTimePicker.Enabled = this.untilCheckBox.Checked; var stockList = stockDico.Values.Where(s => s.BelongsToGroup(selectedGroup)); if (stockList.Count() > 0 && stockList.ElementAt(0).Initialise()) { this.fromDateTimePicker.MaxDate = stockList.ElementAt(0).Keys.Last(); DateTime fromDate =new DateTime(stockList.ElementAt(0).Keys.ElementAt(stockList.ElementAt(0).Keys.Count - 2).Year,1,1); this.fromDateTimePicker.Value = fromDate; this.untilDateTimePicker.Value = stockList.ElementAt(0).Keys.Last(); } else { this.fromDateTimePicker.Value = System.DateTime.Today.AddYears(-1); this.fromDateTimePicker.MaxDate = System.DateTime.Today.AddDays(-1); this.untilDateTimePicker.Value = System.DateTime.Today; } previousFromDate = fromDateTimePicker.Value; previousUntilDate = untilDateTimePicker.Value; // InitializeListView(); // Activate handlers this.fromDateTimePicker.CloseUp += new System.EventHandler(this.fromDateTimePicker_ValueChanged); this.fromDateTimePicker.LostFocus += new System.EventHandler(this.fromDateTimePicker_ValueChanged); this.untilDateTimePicker.CloseUp += new System.EventHandler(this.untilDateTimePicker_ValueChanged); this.untilDateTimePicker.LostFocus += new System.EventHandler(this.untilDateTimePicker_ValueChanged); this.groupComboBox.SelectedIndexChanged += new System.EventHandler(this.groupComboBox_SelectedIndexChanged); this.TopLevel = true; }
private bool DownloadLibelleFromABC(string destFolder, string groupName, StockSerie.Groups group) { bool success = true; if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { string fileName = destFolder + @"\" + group.ToString() + ".txt"; if (File.Exists(fileName)) { if (File.GetLastWriteTime(fileName) > DateTime.Now.AddDays(-7)) // File has been updated during the last 7 days return true; } try { // Send POST request string url = "http://www.abcbourse.com/download/libelles.aspx"; if (dailyViewState == string.Empty) { // Get ViewState using (WebClient webClient = new WebClient()) { webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"); byte[] response = webClient.DownloadData(url); string htmlContent = Encoding.ASCII.GetString(response); dailyViewState = ExtractValue(htmlContent, "__VIEWSTATE"); dailyViewStateGenerator = ExtractValue(htmlContent, "__VIEWSTATEGENERATOR"); dailyEventValidation = ExtractValue(htmlContent, "__EVENTVALIDATION"); } } string postData = "ctl00_BodyABC_ToolkitScriptManager1_HiddenField=%3B%3BAjaxControlToolkit%2C+Version%3D3.0.20229.20843%2C+Culture%3Dneutral%2C+PublicKeyToken%3D28f01b0e84b6d53e%3Afr-FR%3A3b7d1b28-161f-426a-ab77-b345f2c428f5%3A865923e8%3A9b7907bc%3A411fea1c%3Ae7c87f07%3A91bd373d%3Abbfda34c%3A30a78ec5%3A9349f837%3Ad4245214%3A77c58d20%3A14b56adc%3A8e72a662%3Aacd642d2%3A596d588c%3A269a19ae&" + "__EVENTTARGET=&" + "__EVENTARGUMENT=&" + "__VIEWSTATE=" + dailyViewState + "&" + "__VIEWSTATEGENERATOR=" + dailyViewStateGenerator + "&" + "__EVENTVALIDATION=" + dailyEventValidation + "&" + "ctl00%24BodyABC%24$GROUPNAME=on&" + "ctl00%24BodyABC%24Button1=T%C3%A9l%C3%A9charger"; // POST /download/libelles.aspx HTTP/1.1 //Host: www.abcbourse.com //Connection: keep-alive //Content-Length: 2780 //Cache-Control: max-age=0 //Origin: http://www.abcbourse.com //Upgrade-Insecure-Requests: 1 //User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36 //Content-Type: application/x-www-form-urlencoded //Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 //Referer: http://www.abcbourse.com/download/libelles.aspx //Accept-Encoding: gzip, deflate //Accept-Language: en-US,en;q=0.8,fr;q=0.6 //Cookie: ABCUser=72F2F42219E37B3033A28A8570D79EFF5F8FC6FB812B0801C3537E62EA3B2EF5A14C073D6D2881DFC20DE83147927543E6ED8445B178BED0DDE815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1%2F0GGZDF0VWO2oYTcspg%2FQJIEo7yz4CR037atiIVgEYIzEhkb9KlYZmye7%2FnJk8Wqab3FraRKRA4NH4SMkbr0ssfhDNp48vrt1aToLK%2FxuYkxeDUJ2jyEChuCcZNAzb5On4rHEP9HywghYEYPSSOqNVqe2KgYnr%2BNJRx9At%2BumCzYS2uPoXq%2FdVJByyB7RsbMXUq2lzc8dt95PO%2BkCFfVa1MgDkVN3T3jY%2FKQIBPK12FXYyMGO0%2F5KPgqmM77ItwinSXDlQBQcTHG5JyTAMHmjunt2bP%2Fj%2FgPFOe%2F%2Baf%2FiQDbqNtvcnRfkH2ohjdh6dUQ5m%2B2VTNYWkGxattRg9EKKE5vey1FPRlCqZyDgvrv9lvrlshrlzdNlGwotAGLfLMcs2vyw1rETiNehQSuxs4fVNVenj9bBwNMtd92XoZ0fgAFx0VYRpgUubx6SaFj1P1ns1k7saP20CtOv40Vh1fIBS7G3r7SNtlzk3C0A%2F4Rmw2%2BXo6xnkHUnscHL5GCzjGbRjxavMDrnvi92ihmau6VuJALuZvH2%2BXItM49krxVbbQbx%2BrvmYdNFMYrxrqfXKoG%2FeBbQYV684ncHXIr7RWAGAEkKq%2FpI3%2Bjw0KrRp1bA%3D%3D&ctl00%24txtAutoComplete=&ctl00%24BodyABC%24$GROUPNAME=on&ctl00%24BodyABC%24Button1=T%C3%A9l%C3%A9charger"; postData = postData.Replace("$GROUPNAME", groupName); byte[] data = Encoding.ASCII.GetBytes(postData); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.CookieContainer = new CookieContainer(); req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = data.Length; req.Method = "POST"; req.AllowAutoRedirect = false; req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; req.Headers.Add("Accept-Language", "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3"); req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"; req.Referer = url; Stream newStream = req.GetRequestStream(); // Send the data. newStream.Write(data, 0, data.Length); newStream.Close(); success = SaveResponseToFile(fileName, req); } catch (System.Exception ex) { StockLog.Write(ex); System.Windows.Forms.MessageBox.Show(ex.Message, "Connection failed"); success = false; } } return success; }