Skip to content

roscasend/yahoo-finance

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yahoo-finance

C++ library to get stock data from Yahoo Finance.

Support Yahoo Finance Novembrer 2017 API change.

Dependencies

  • cmake >= 3.6.1
  • boost
  • curl

Build

mkdir build
cd build
cmake ..
make

Unit Tests

Boost Unit Tests:

make test

Usage

Use the following header to import Quote class.

#include "quote.hpp"

Code sample:

// S&P 500
Quote *snp500 = new Quote("^GSPC");

// Get the historical spots from Yahoo Finance
snp500->getHistoricalSpots("2017-12-01", "2017-12-31", "1d");

// Print the spots
snp500->printSpots();

// Print a spot
try {
  Spot spot = snp500->getSpot("2017-12-01");
  spot.printSpot();
} catch(const std::exception &e) {
  std::cerr << e.what() << std::endl;
}

// Get the historical EUR/USD rates
Quote *eurusd = new Quote("EURUSD=X");
eurusd->getHistoricalSpots("2018-01-01", "2018-01-10", "1d");
eurusd->printSpots();

// Get the historical EUR/AUD rates
Quote *euraud = new Quote("EURAUD=X");
euraud->getHistoricalSpots("2018-01-01", "2018-01-10", "1d");
euraud->printSpots();

// Free memory
delete snp500;
delete eurusd;
delete euraud;

About

C++ library to get stock data from Yahoo Finance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 95.2%
  • CMake 4.8%