The project is currently splitted into two parts:
Python modules for retrieving financial market data from two websites:
These modules are used to query those websites directly to get instantaneous data or to update periodically (e.g. 30 sec.) the values of a predefined list of stocks/devises (see the [Usage] page).
C++ application divided into modules and subdirectories:
The model consists of the storage of time series of market quotes, its update through the ServerPortfolio modules and the computation of techinal indicators. All classes are defined in libstock.so
A vector (StockManager::vec_stock) stores all Stock in memory. The class StockManager is defined as a singleton class and conveniently implements the most used functionnalities on the stocks (Loading/getting stocks, updating data and computing indicators) as wrapper functions to Stock member functions. It can be easily retrieved and used by an other application linked with libstock.so with the static function:
StockManager *fstockmanager = StockManager::getInstance(Utils::PATH_DATA);
It also owns a TCPServer object used for receiving data update from the ServerPortfolio Python modules in real-time mode.
This class represents the main dependency between the graphical interface and the model.
Stock is the main class for dealing with the financial data. To each object is associated a quote: a share, an indice or a devise. The time-series data (values of the quotes and indicators) are stored in a map with the TimeScale as key and a vector of ListDataStock as value.
The timescale (Utils/TimeScale.h) data consists of an enumeration for the time representation: intantaneous, 5 minutes, 10 minutes, daily, weekly... Only instantaneous (dCSV) or daily data (CSV) are stored on the filesystem (in data/csv or dcsv), other timescales are computed from them with Stock::Transform_TimeScale.
Values of the stocks and indicators are stored in a vector defined in the ListDataStock class.
The first requirement was to store different data types:
Then ListDataStock is defined as a template instantiated for each data type, e.g. ListDataStock<DataCSV>
To Store ListDataStocks as a value of the Stock's map (stored as pointer in a vector), all ListDataStock<> derive from a base class: ListDataStockBase
An arbitrary choice concerns the chronological ordering of the data in the vector. CSV format is usually presented from the newest to the oldest data (non-chronological), the TA-lib library expects input data in the chronological order, other algorithms are easier to implement either in a chronological or non-chronological order.
To solve this problem, a class template policy has been implemented for ListDataStock.
PolicyChronologic.h defines 2 class templates: VecChronologic and VecNoChronologic, which will indicate which ordering scheme has been chosen. Theses classes provide specific implementations for functions like:
By default the storage order is non-chronologic for daily (weekly, monthly) data and chronologic for intantaneous data.
2 forms of binding between Python and C++ are used: