Extras

Extras image











In this section you will find the documentation for everything that is not directly related to algotrading but that is also offered by the Quotek SDK.

Time Functions

As the name suggests, these are all the function related to the manipulation of time data.

Note about time functions: For most of them, user has to provide the current
timestamp instead of just having an internal time(0) call inside. It is because these functions
must support backtesting, which implies decorelated real time and backtest time.


SaaS Users: To use these functions, all you have to do is to call them this->t as timestamp argument, eg: is_time(“10:00”, this->t);


std::string quotek::core::time::timestr(long timestamp)

timestr takes an epoch timestamp and returns an “HH:MM:SS” string corresponding.

Return
hour string with the form “HH:MM:SS”
Parameters
  • timestamp -

    epoch timestamp to get hour string from.

std::vector<int> quotek::core::time::timeint(long timestamp)

timeint takes an epoch timestamp and returns a vector of int representing the hours, minutes and seconds of timestamp. vect[0] is hours, vect[1] is minutes, vect[2] is seconds

Return
an int vector of 3 elements.
Parameters
  • timestamp -

    epoch timestamp to get time ints from.

bool quotek::core::time::is_time(std::string time_string, long timestamp)

is_time tells if a time string matches with the epoch timestamp provided as an argument.

Return
true if time_string is current time, false otherwise.
Parameters
  • time_string -

    string representing time, can be under the form “HH:MM:SS” or “HH:MM”

std::string quotek::core::time::week_day(long timestamp)

week_day returns the long day name according to a provided epoch timestamp.

Return
day of week as a string (“monday” or “tuesday”, etc..)
Parameters
  • timestamp -

    epoch timestamp

int quotek::core::time::month_day(long timestamp)

month_day provids the number of the day of the month according to provided timestamp.

std::string quotek::core::time::datestr(std::time_t timestamp, std::string format)

datestr() converts an epoch timestamp to the corresponding date string, given a user-defined format.

Return
the date string of the timestamp provided as argument.
Parameters
  • timestamp -

    epoch timestamp to convert to date string.

  • format -

    format of the date string, following the usual date formatting (“%Y-%m-%d %H:%M:%S”)

String Functions

String functions are extending the set of C++ string manipulators, So that the users of the Quotek SDK doesn’t have to code them.

std::vector<std::string> quotek::core::utils::split(const std::string &s, char delim)

Splits a string into multiple parts, given a delimiter character.

Return
a vector of strings containing the splitted parts of the string.
Parameters
  • s -

    String to split.

  • delim -

    Delimiter character.

std::vector<std::string> quotek::core::utils::tokenise(std::string const &s)

Tokenise a string by making use of C++ std::istream_iterator. It is useful to split the words inside a sentence, for instance.

Return
a vector of strings containing the tokens.
Parameters
  • s -

    String to tokenise.

std::string &quotek::core::utils::ltrim(std::string &s)

Removes the non-alphanum characters at the left of a string.

Return
reference to the left-trimed string.
Parameters
  • s -

    String to left-trim.

std::string &quotek::core::utils::rtrim(std::string &s)

Removes the non-alphanum characters at the right of a string.

Return
reference to the right-trimed string.
Parameters
  • s -

    String to right-trim.

std::string &quotek::core::utils::trim(std::string &s)

Removes the non-alphanum characters at both ends of a string.

Return
reference to the trimed string.
Parameters
  • s -

    String to trim.

HTTP

The HTTP Class allows the users of the Quotek SDK to perform raw HTTP queries and fetch their result.

class quotek::http

HTTP is a simple HTTP client that will allow your strategies to remotely fetch data. Also note that this class supports https.

Public Functions

http()

http class constructor.

~http()

http class destructor.

void destroy()

alternative destructor.

std::string get(std::string url)

Performs an HTTP GET QUERY on provided URL and returns result as a string.

Return
the HTTP server response, as a string.
Parameters
  • url -

    HTTP URL to perform query on.

std::string get(std::string url, std::map<std::string, std::string> &get_params)

Performs an HTTP GET QUERY on provided URL with provided params, and returns result as a string.

Return
the HTTP server response, as a string.
Parameters
  • url -

    HTTP URL to perform query on.

  • get_params -

    key/values map corresponding to paramter/value.

std::string post(std::string url, std::string &post_data)

Performs an HTTP POST query on provided URL and returns result as a string.

Return
the HTTP server response, as a string.
Parameters
  • url -

    HTTP URL to perform query on.

  • post_data -

    POST data string having the form “field1=data2&field2=data2..&fieldn=datan”.

std::string post(std::string url, std::map<std::string, std::string> &post_data)

Performs an HTTP POST query on provided URL and returns result as a string.

Return
the HTTP server response, as a string.
Parameters
  • url -

    HTTP URL to perform query on.

  • post_data -

    std::map containing the post data (eg post_data[“name”] = “john” will send “name=john” as POST data).

std::string del(std::string url)

Performs an HTTP DELETE QUERY on provided URL and returns result as a string.

Return
the HTTP server response, as a string.
Parameters
  • url -

    HTTP URL to perform query on.

void add_header(std::string header)

Adds an header value prior to an HTTP request.

Parameters
  • header -

    header data to add. Header string is usually of the form: “Header_name: Value”.

std::string escape(std::string to_escape)

Escapes characters in a string to pass it as a valid URL/ post data.

Return
HTTP Escaped string.
Parameters
  • to_escape -

    String to escape.

Private Members

CURL *ch

Internal curl object handler.

struct curl_slist *headers

Internal headers list.