Upload
jrmoransv
View
290
Download
2
Tags:
Embed Size (px)
DESCRIPTION
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.
Citation preview
Company Tracker | CIS 4100May 18, 2009
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Overview
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Purposes•Track Company Financial Data
•Compare a fundamentals•PE•EPS•Dividend Yields•ROE•And other ratios
•Evaluate Technical Data•Visualize Historical Data
Program DesignClasses
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Importing Data
Reuters Data Compatible through Excel tab delimited files
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Importing Data
Tab Delimited Files
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Importing Data
Loading data after a compatible file has been loaded. Notice how the RIC from Reuters has been change to a standard ticker, and company name has been formatted to lowercase.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Browse Button
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
/* creating new open file dialog box*/ OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog();
/* setting filters for compatible data*/ openFileDialog1->Filter = "Text File (Tab Delimited)|*.txt"; openFileDialog1->Title = "Select a File";
/*the dialog box is shown automatically*/
/*when the dialog box is closed get the file path*/ if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK){
/*get the path received into the textbox*/ txtPath->Text = openFileDialog1->FileName;
}
/* creating new open file dialog box*/ OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog();
/* setting filters for compatible data*/ openFileDialog1->Filter = "Text File (Tab Delimited)|*.txt"; openFileDialog1->Title = "Select a File";
/*the dialog box is shown automatically*/
/*when the dialog box is closed get the file path*/ if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK){
/*get the path received into the textbox*/ txtPath->Text = openFileDialog1->FileName;
}
Importing Companies
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
companyImportList->Add(gcnew CCompany(columns[0],
columns[1], columns[2], Convert::ToInt64(columns[4]), Convert::ToDouble(columns[5]), Convert::ToDouble(columns[6]), Convert::ToDouble(columns[8]), Convert::ToDouble(columns[9]), Convert::ToDouble(columns[10]),
Convert::ToDouble(columns[11])));
companyImportList->Add(gcnew CCompany(columns[0],
columns[1], columns[2], Convert::ToInt64(columns[4]), Convert::ToDouble(columns[5]), Convert::ToDouble(columns[6]), Convert::ToDouble(columns[8]), Convert::ToDouble(columns[9]), Convert::ToDouble(columns[10]),
Convert::ToDouble(columns[11])));
CompaniesDB->ImportCompanies(companyImportList);CompaniesDB->ImportCompanies(companyImportList);
companyImportList = gcnew List<CCompany^>();companyImportList = gcnew List<CCompany^>();
StreamReader
Importing Data
Text files must have twelve columns of data.Data consistency and program stability.04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Checking Compatibility
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
// read contents of file while(txtIn->Peek() != -1){
// read lines of text String^ row = txtIn->ReadLine();
// split line to find # of columns array<String^>^ columns = row->Split('\t');
/*checks if the file is compatible*/ if(columns->Length!=12){
MessageBox::Show("The selected file is not compatible.", "Error Reading File", MessageBoxButtons::OK ,MessageBoxIcon::Error);
break;}else{…….}
// read contents of file while(txtIn->Peek() != -1){
// read lines of text String^ row = txtIn->ReadLine();
// split line to find # of columns array<String^>^ columns = row->Split('\t');
/*checks if the file is compatible*/ if(columns->Length!=12){
MessageBox::Show("The selected file is not compatible.", "Error Reading File", MessageBoxButtons::OK ,MessageBoxIcon::Error);
break;}else{…….}
Company Management
Mimics a Database using classes to load and save list of company objects into text files
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Program Design:Company Management Classes
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Company Management:Sorting Companies
Using a ListView control and a ListViewItemSorter class, data can be sorted. This allows company performance comparison.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Sorting Companies
04/12/23 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();
// 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();
Company Management: Searching Companies
The user can search for companies using the search box. While text is being entered the possible matches are highlighted in the company list.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Searching a Company
04/12/23 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);
}
/* 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);
}
Company Management: Adding Companies
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
•Dropdown combo box allows easily selection of sectors.•Sectors are loaded using a Sectors object
Company Management: Adding Companies
• Data validation allows data consistency and offers aid to the user when manually adding companies.
• If a company already exists in the database, inform the user and prevent adding the duplicate data.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Adding a Company to the DB
04/12/23 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();
} }
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();
} }
Company Management: Editing Companies
• Companies can be edited by selecting a company from the database and clicking on the edit button.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Editing Companies
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
// get the selected item ListViewItem^ itemSelected = listView1->SelectedItems[0]; CCompany^ selectedCompany =
CompaniesDB->GetCompany(itemSelected->Text);
frmAddCompany^ FEditCompany = gcnew frmAddCompany(); CCompany^ editedCompany =
FEditCompany->EditCompany(selectedCompany);
if(editedCompany != nullptr){ /* replace company */ CompaniesDB->AddCompany(editedCompany); CompaniesDB->RemoveCompany(selectedCompany);
/* update listview*/ UpdateListView();
// get the selected item ListViewItem^ itemSelected = listView1->SelectedItems[0]; CCompany^ selectedCompany =
CompaniesDB->GetCompany(itemSelected->Text);
frmAddCompany^ FEditCompany = gcnew frmAddCompany(); CCompany^ editedCompany =
FEditCompany->EditCompany(selectedCompany);
if(editedCompany != nullptr){ /* replace company */ CompaniesDB->AddCompany(editedCompany); CompaniesDB->RemoveCompany(selectedCompany);
/* update listview*/ UpdateListView();
Company Management: Deleting Companies
• To delete a company from the database just select it and click delete, after the confirmation appears click yes.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Deleting a company
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
// get the selected item ListViewItem^ itemSelected = listView1->SelectedItems[0]; CCompany^ selectedCompany =
CompaniesDB->GetCompany(itemSelected->Text);
if(selectedCompany != nullptr){ // get delete confirmation String^ msg = "Are you sure you want to delete " +
selectedCompany->Ticker + "?"; ::DialogResult button = MessageBox::Show(msg, "Comfirm Delete", MessageBoxButtons::YesNo); if(button == ::DialogResult::Yes){
CompaniesDB->RemoveCompany(selectedCompany); UpdateListView();
}
// get the selected item ListViewItem^ itemSelected = listView1->SelectedItems[0]; CCompany^ selectedCompany =
CompaniesDB->GetCompany(itemSelected->Text);
if(selectedCompany != nullptr){ // get delete confirmation String^ msg = "Are you sure you want to delete " +
selectedCompany->Ticker + "?"; ::DialogResult button = MessageBox::Show(msg, "Comfirm Delete", MessageBoxButtons::YesNo); if(button == ::DialogResult::Yes){
CompaniesDB->RemoveCompany(selectedCompany); UpdateListView();
}
Company Details
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
SendToCompanyDetails(Ccompany)
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
// make sure the detail's form for that company is closedif(!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();
// make sure the detail's form for that company is closedif(!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();
Company Details:Overview
Displays Fundamentals, competitors and a chart to visualize historical quotes.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Company Details:Downloading Quotes
• After clicking the button data is automatically downloaded and stored in the hard drive for future reference.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Downloading Quotes
04/12/23 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 */...}
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 */...}
Program Design:Sectors and Historical Data
04/12/23 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);
/* 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();
/* get historical data */List<COHLC^>^ ohlcList =
someCompany->GetHistoricalData();
Charting Data
04/12/23 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);
}…}
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);
}…}
Company DetailsChart
Company details, displays fundamental data along competitors and a chart of the historical prices for the last year.
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Company DetailsChart Options
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Company DetailsChart Options
• Line chart, last three months04/12/23 Jaime Moran - CIS 4100 - Spring 2009
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Company DetailsChart Options
• Stock chart, last three months
Company DetailsChart Options
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
•Candlestick style and three months back.
Viewing Multiple Companies
• MDI Applications: Multiple Document Interface04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Program Design:Tracking Events Class
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Tracking Events:Adding Events
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Adding Events
04/12/23 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();
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();
/*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();
Tracking Events:Viewing and Deleting Events
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Program Design:Other Classes
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
File Structure
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
Directory
Companies.txt
events.txt
File Structure:Historical Quotes
04/12/23 Jaime Moran - CIS 4100 - Spring 2009
GOOG.csv