43
Company Tracker | CIS 4100 May 18, 2009 06/18/22 Jaime Moran - CIS 4100 - Spring 2009

Company Tracker

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

Page 1: Company Tracker

Company Tracker | CIS 4100May 18, 2009

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 2: Company Tracker

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

Page 3: Company Tracker

Program DesignClasses

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 4: Company Tracker

Importing Data

Reuters Data Compatible through Excel tab delimited files

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 5: Company Tracker

Importing Data

Tab Delimited Files

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 6: Company Tracker

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

Page 7: Company Tracker

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;

}

Page 8: Company Tracker

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

Page 9: Company Tracker

Importing Data

Text files must have twelve columns of data.Data consistency and program stability.04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 10: Company Tracker

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{…….}

Page 11: Company Tracker

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

Page 12: Company Tracker

Program Design:Company Management Classes

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 13: Company Tracker

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

Page 14: Company Tracker

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();

Page 15: Company Tracker

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

Page 16: Company Tracker

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);

}

Page 17: Company Tracker

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

Page 18: Company Tracker

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

Page 19: Company Tracker

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();

} }

Page 20: Company Tracker

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

Page 21: Company Tracker

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();

Page 22: Company Tracker

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

Page 23: Company Tracker

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();

}

Page 24: Company Tracker

Company Details

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 25: Company Tracker

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();

Page 26: Company Tracker

Company Details:Overview

Displays Fundamentals, competitors and a chart to visualize historical quotes.

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 27: Company Tracker

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

Page 28: Company Tracker

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 */...}

Page 29: Company Tracker

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();

Page 30: Company Tracker

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);

}…}

Page 31: Company Tracker

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

Page 32: Company Tracker

Company DetailsChart Options

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 33: Company Tracker

Company DetailsChart Options

• Line chart, last three months04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 34: Company Tracker

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Company DetailsChart Options

• Stock chart, last three months

Page 35: Company Tracker

Company DetailsChart Options

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

•Candlestick style and three months back.

Page 36: Company Tracker

Viewing Multiple Companies

• MDI Applications: Multiple Document Interface04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 37: Company Tracker

Program Design:Tracking Events Class

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 38: Company Tracker

Tracking Events:Adding Events

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 39: Company Tracker

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();

Page 40: Company Tracker

Tracking Events:Viewing and Deleting Events

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 41: Company Tracker

Program Design:Other Classes

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Page 42: Company Tracker

File Structure

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

Directory

Companies.txt

events.txt

Page 43: Company Tracker

File Structure:Historical Quotes

04/12/23 Jaime Moran - CIS 4100 - Spring 2009

GOOG.csv