Company Tracker is a database of companies and their key financial
ratios. It’s compatible with Reuter’s Kobra data exported in tab
delimited format and also with Google Finance.
14. Sorting Companies 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 // creates a list view item comparer CListViewItemComparer^ lviComparer = gcnew CListViewItemComparer(e- >Column); // set the order and apply it to the listview control if(e->Column == lastColSorted){…… } //apply the comparer to the listview listView1->ListViewItemSorter = lviComparer ; //set flags lastColSorted = e->Column; lastSortOrder = lviComparer->Order; //apply row colors to list view AlternateRowColorListView();
15.
16. Searching a Company 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 /* get item from listview */ ListViewItem^ resultLvItem = listView1-> FindItemWithText(ticker); if(resultLvItem != nullptr){ /* select item and ensure is visible */ resultLvItem->Selected = true; listView1->EnsureVisible(resultLvItem->Index); }
17.
18.
19. Adding a Company to the DB 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 frmAddCompany^ FAddCompany = gcnew frmAddCompany(); CCompany^ newCompany = FAddCompany->GetNewCompany(); /* if the company object received is not null save it*/ if(newCompany != nullptr){ /* check if the company exists*/ if(CompaniesDB->CompanyExists(newCompany)){ MessageBox::Show("The company " + newCompany- >Ticker + " already exists.","Company Already Exists"); }else{ /*adding company*/ CompaniesDB->AddCompany(newCompany); /* update list view*/ UpdateListView(); } }
25. SendToCompanyDetails(Ccompany) 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 // make sure the detail's form for that company is closed if(!IsCompanyDetailsOpen(someCompany->Ticker)){ // initialize and show child form /*setting child window*/ FCompanyDetails = gcnew frmCompanyDetails(); FCompanyDetails->MdiParent = this->MdiParent; FCompanyDetails->Text = someCompany->Ticker + " - Company Details"; /* setting position */ FCompanyDetails->StartPosition = FormStartPosition::CenterParent; /*send company to form */ FCompanyDetails->DisplayCompany(someCompany); FCompanyDetails->Show();
26.
27.
28. Downloading Quotes 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 ticker = ticker->ToUpper(); String^ downloadFolder = "C://files//FINA//PRICEDATA//"+ ticker +".csv"; String^ website = "http://www.google.com/finance/historical?q=" + ticker + "&output=csv"; try{ /* creates a new WebClient object */ WebClient^ wc = gcnew WebClient(); /* download file to assign download folder */ wc->DownloadFile(website,downloadFolder); /* if file downloaded successfully */ MessageBox::Show("Company data for " + ticker + " downloaded successfully.", "Data Downloaded"); /* get a company object from the label ticker and redraw a chart*/ DrawChart(someCompany); }catch(WebException^ e ){/* File could not be downloaded */...}
29. Program Design: Sectors and Historical Data 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 /* load companies from file into memory */ CompaniesDB->LoadCompanies(); /* get a list of companies by sector */ List<CCompany^>^ companiesBySectorList = CompaniesDB->GetCompaniesBySector(someCompany->Sector); /* get historical data */ List<COHLC^>^ ohlcList = someCompany->GetHistoricalData();
30. Charting Data 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 if(someCompany->HistoricalDataExists()) { /* setting chart style */ chart1->Series["Prices"]->ChartType = SeriesChartType::Line; /* enable chart options */ groubBxChartOptions->Enabled = true; rdbtnLine->Checked = true; /*Historical Data Status */ lblHistoricalDataStatus->Text += " was last updated on: " + someCompany->HistoricaDataLastUpdated(); /* set series to be drawn in the chart*/ for each(COHLC^ item in ohlcList){ chart1->Series["Prices"]->Points->AddXY( item->Date,item->Open, item->High,item->Low, item->Close); }…}
39. Adding Events 10/10/10 Jaime Moran - CIS 4100 - Spring 2009 ListViewItem^ lvitem = gcnew ListViewItem(dtpDate->Value.ToShortDateString()); lvitem->SubItems->Add(txtTicker->Text->ToUpper()); lvitem->SubItems->Add(txtEvent->Text); lvEvents->Items->Add(lvitem); EventsDB->SaveEvents(); /*initialize Events DB */ EventsDB = gcnew CCalendarEvents(); /* link the DB to a list view control */ EventsDB->LinkToListView = lvEvents; /* load all data into the liked listview*/ EventsDB->FillEvents();