Yahoo! Finance

Yahoo Finance Logo









class quotek::datasource::yahoofinance

yahoofinance is a class which allows to query the Yahoo! Finance API service to fetch historical data on stocks and indices.

Inherits from quotek::datasource::datasource

Public Functions

yahoofinance()

yahoofinance class constructor

~yahoofinance()

yahoofinance class destructor

std::vector<quotek::data::history> history(std::string symbol, std::string from, std::string to)

returns an asset history under the form of a quotek history vector (open,close,high,low).

Return
a vector of quotek history records.
Parameters
  • symbol -

    yahoo! symbol for the asset.

  • from -

    string-formated date with the format “YYYY-MM-DD”.

  • to -

    string-formated date with the format “YYYY-MM-DD”.

quotek::data::records close_history(std::string symbol, std::string from, std::string to)

returns the closing history of an asset defined by symbol. Compared to history, it is a very convenient function to perform moving average, VAR, etc.. computations.

Return
a quotek records structure containing closing prices as value.
Parameters
  • symbol -

    yahoo! symbol for the asset.

  • from -

    string-formated date with the format “YYYY-MM-DD”.

  • to -

    string-formated date with the format “YYYY-MM-DD”.

Example

#include <quotek/quotek.hpp>
#include <quotek/datasources/yahoofinance.hpp>
using namespace quotek::datasource;
using namespace quotek::data;

int main(int argc, char** argv) {

  //We declare a new yahoofinance object.
  yahoofinance yf1;

  //now we will import the DAX EOD data for the first week of July, 2016.
  records r1_dax = yf1.close_history("^GDAXI","2016-07-01","2016-07-9");

  //We check that we got some data in r1_dax.
  assert( r1_dax.size() > 0 );

}