curl_stocks
Loading...
Searching...
No Matches
Classes | Functions
API

Classes

class  Api
 Wraps alphavantage API. Fetches stock data using curl. More...
 

Functions

size_t callback (void *contents, size_t size, size_t nmemb, std::string *s)
 A call back function to be used with curl.
 
 Api::Api ()
 Default constructor.
 
 Api::Api (std::string apikey, std::string cert_path)
 Constructor.
 
void Api::fetch (std::string const &function, std::string const &symbol, std::string &stock_data)
 Fetch stock data.
 
 Api::~Api ()
 Destructor cleans up curl objects.
 

Detailed Description

Function Documentation

◆ Api() [1/2]

Api::Api ( )

Default constructor.

◆ Api() [2/2]

Api::Api ( std::string  apikey,
std::string  cert_path 
)

Constructor.

Parameters
apikey
cert_path

◆ callback()

size_t callback ( void *  contents,
size_t  size,
size_t  nmemb,
std::string *  s 
)

A call back function to be used with curl.

Curl needs a function pointer as an argument which writes data to a string. Unfortunately, a pointer pointing to a member function is of a different type than a pointer pointing to a normal function. Curl needs a pointer to a normal function. Therefore this function cannot be a member function of the class Api and is declared separately.

Parameters
contents
size
nmemb
s
Returns
Here is the caller graph for this function:

◆ fetch()

void Api::fetch ( std::string const &  function,
std::string const &  symbol,
std::string &  stock_data 
)

Fetch stock data.

Parameters
functionDaily / weekly / monthly data
symbolStock symbol
stock_dataFetched data is stored here
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Api()

Api::~Api ( )

Destructor cleans up curl objects.