ROOT_Application
2.0
C++ Core modules and GUIStock
|
Use a policy PolicyChronologic, default VecNoChronologic. More...
#include <ListDataStock.h>
Public Member Functions | |
void | PrintData (const unsigned int verbose=0) const |
Nice formatting output on console. More... | |
Constructors and destructor | |
ListDataStock () | |
ListDataStock (std::string iname, ETime itmscl, Utils::firstlast_dates idates=Utils::get_fldate_default()) | |
ListDataStock (std::string iname, ETime itmscl, unsigned int size) | |
Reserve size for the vector, default DataStock constructor is called (dates and values are set to zero) More... | |
ListDataStock (std::string iname, ETime itmscl, const std::vector< T > &vec_data) | |
Constructor accepting a std::vector<DataStock> More... | |
~ListDataStock () | |
Destructor. More... | |
Wrappers to the internal std::vector | |
unsigned int | GetSize () const |
Return the size of the vector. More... | |
unsigned int | Capacity () const |
Return the capacity of the vector. More... | |
void | Reserve (const unsigned int new_size) |
Reserve new_size elements. More... | |
void | Clear () |
Clear the vector and reinitialize data members to default values. More... | |
void | Swap () |
Reduce the capacity of the internal vector to fit its size. More... | |
Access to the DataStock elements | |
const T & | ChronologicAt (const unsigned int offset) const |
Get the nth element in a chronological order. More... | |
const T & | NoChronologicAt (const unsigned int offset) const |
Get nth element in a non chronological order. More... | |
T & | operator[] (const unsigned int offset) |
Access nth element, do not check for the policy chronology. More... | |
Update of the list | |
void | AddData (DataStock &data) |
Add a copy of the DataStock into the ListDataStock. More... | |
int | AddToList (const ListDataStockBase *new_list) |
Append all data from a new list ( coming from an Update or ReadCSV normally ) to an existing list. More... | |
void | Replace (const ListDataStockBase *ldata_in) |
Replace all DataStock's of the list with ldata_in.data, without checking for update. More... | |
Transform to/from C-Array | |
unsigned int | GetCArray (var_types arraydata_c, const EPChrono b_order, const unsigned int no=0) const |
Extract the data into a one dimensional C-array. More... | |
unsigned int | GetCArray (var_types2 arraydata_c, const EPChrono b_order, std::initializer_list< unsigned int > list_no) const |
Overload version with an initilizer_list, fill a 2 dimensional C-array. More... | |
int | PutCArray (const ListDataStockBase &ldata_date, const unsigned int nb_data, const unsigned size_indic, var_types arraydata_c, const unsigned int offset_begin, const unsigned int offset_end=0, const EPChrono b_chrono=EPChrono::CHRONO, bool full_array=false) |
Fill a ListDataStock<T> from a 2 dimensional C-array. More... | |
Functions related to the policy of the list | |
std::string | policy () const |
Return a string of the chronology policy. More... | |
EPChrono | bpolicy () const |
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO. More... | |
time_t | LastUpdate () const |
Get the date of the last data (always chronological meaning) More... | |
time_t | GetFirstTime () const |
Get the date of the first data (always chronological meaning) More... | |
void | Order (const EPChrono b_chronologic=EPChrono::CHRONO) |
Function to reverse the internal vector in its original policy. More... | |
void | SetDates () |
Set the correct first/last dates from the DataStock in the vector. More... | |
void | SetDates (time_t first, time_t last) |
Set dates, 2 arguments. More... | |
Public Member Functions inherited from ListDataStockBase | |
ListDataStockBase () | |
Default constructor, set empty names, timescale ETime::not_a_time, dates are zero. More... | |
ListDataStockBase (std::string iname, ETime itmscl, Utils::firstlast_dates idates=Utils::get_fldate_default()) | |
Constructor sets name, timescale and optionaly dates. More... | |
virtual | ~ListDataStockBase () |
Destructor. More... | |
std::string | GetName () const |
virtual std::string | GetFullName () const |
virtual ETime | GetTimeScale () const |
virtual void | SetTimeScale (const ETime new_tmscl) |
void | SetName (const std::string iname) |
virtual void | SetFullName (std::string fname) |
virtual Utils::firstlast_dates | GetDates () const |
Return the structure Utils::firstlast_dates of the private data member, not from the data. More... | |
time_t | GetFirstDate () const |
Get first date from the private data member dates. More... | |
time_t | GetLastDate () const |
Get last date from the private data member dates. More... | |
virtual void | SetDates (const Utils::firstlast_dates &new_date) |
Set dates with a structure Utils::firstlast_dates. More... | |
virtual void | GetVectorData (std::vector< DataCSV > &, const EPChrono) const |
virtual void | GetVectorData (std::vector< SimpleData > &, const EPChrono) const |
virtual void | GetVectorData (std::vector< MultiData > &, const EPChrono) const |
Protected Member Functions | |
void | GetVectorData (std::vector< T > &res, const EPChrono chrono) const |
Private Member Functions | |
ListDataStock (const ListDataStock &src)=delete | |
Deleted copy constructor. More... | |
ListDataStock & | operator= (const ListDataStockBase &rhs)=delete |
Deleted assignment operator. More... | |
Private Attributes | |
std::vector< T > | ListData |
internal vector of objects DataStock More... | |
Additional Inherited Members | |
Public Types inherited from ListDataStockBase | |
typedef boost::variant< float **, double **, int ** > | var_types |
typedef boost::variant< float ***, double ***, int *** > | var_types2 |
Protected Attributes inherited from ListDataStockBase | |
std::string | name |
name stores the indicator label with the parameters, it corresponds to its ShortName More... | |
ETime | tmscl |
TimeScale of the List. More... | |
Utils::firstlast_dates | dates |
Store the first and last dates of the list Redondant with dates from DataStock, added first for reading header of files, selecting a range.. but not easy to keep synchronized and not sure it is really necessary. More... | |
std::string | fullname |
fullname seems necessary (convenient) for GUI, never set by constructors More... | |
Use a policy PolicyChronologic, default VecNoChronologic.
This class uses ChronologicalAt or NoChronologicalAt() to loop over elements in a specific order,
whatever the order they are stored internally
Most functions to add elements will take care internally the policy is respected (not AddData).
Order() is used to reoder elements in the correct policy. It aims to be called in every specific algorithms, where one of the policy is easier to implement.
Typedefs are defined in typedef.h, to simplify the definition of often used types of list.
Definition at line 529 of file ListDataStock.h.
|
inline |
Definition at line 538 of file ListDataStock.h.
|
inline |
Definition at line 540 of file ListDataStock.h.
|
inline |
Reserve size for the vector, default DataStock constructor is called (dates and values are set to zero)
Definition at line 544 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inline |
Constructor accepting a std::vector<DataStock>
Definition at line 547 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inline |
Destructor.
Definition at line 554 of file ListDataStock.h.
|
privatedelete |
Deleted copy constructor.
|
inlinevirtual |
Add a copy of the DataStock into the ListDataStock.
The policy is not checked here, always insert to the end of the vector(with a push_back())
Dates are not updated
Correct order can later be changed in calling Order( EPChrono chrono_data )
maybe insert first, insert last option, order or chronology ? add order best, but inefficient to insert first every time
should use T in derived class, does not make sense otherwise. More flexible ? certainly can use GetX
data | : DataStock to insert |
Implements ListDataStockBase.
Definition at line 588 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by GetListDataFromPyList(), and ListDataStock_Utils::TransformTimeScale().
|
virtual |
Append all data from a new list ( coming from an Update or ReadCSV normally ) to an existing list.
Effect expected:
new_list | list to append |
Implements ListDataStockBase.
Definition at line 80 of file ListDataStock_timpl.h.
References ListDataStockBase::ChronologicAt(), DataStock::GetDate(), ListDataStockBase::GetFirstDate(), ListDataStockBase::GetFirstTime(), ListDataStockBase::GetLastDate(), ListDataStockBase::GetSize(), ListDataStockBase::GetVectorData(), ListDataStockBase::LastUpdate(), and Utils::Time_tToString().
|
inlinevirtual |
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO.
Implements ListDataStockBase.
Definition at line 624 of file ListDataStock.h.
Referenced by ListDataStock< T, PolicyChronologic >::GetVectorData().
|
inlinevirtual |
Return the capacity of the vector.
Implements ListDataStockBase.
Definition at line 561 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inlinevirtual |
Get the nth element in a chronological order.
Because the full DataStock object is stored (not a pointer or a base class),
it returns a reference to the exact type (SimpleData, MultiData, DataCSV).
ChronologicAt :
offset | nth element [0,GetSize()-1] |
Implements ListDataStockBase.
Definition at line 570 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by THStock::GetDateFromBin(), ListDataStock< T, PolicyChronologic >::SetDates(), and Stock::WriteCSV().
|
virtual |
Clear the vector and reinitialize data members to default values.
Call std::vector.clear(), size is set to 0 but capacity is not modified
Reset name and fullname to "" timescale is set to ETime::not_a_time
Implements ListDataStockBase.
Definition at line 25 of file ListDataStock_timpl.h.
References Utils::get_fldate_default(), and not_a_time.
|
virtual |
Extract the data into a one dimensional C-array.
Extract only the data, as float or double, not the dates.
The C-array is allocated inside the function and filled in the order given by b_order
With type of DataStock containing more than one data, the user can specify which one to extract.
Example to create a single dimensional array with the close values:
Example to create and fill a multi-dimensional array with CLOSE and Volume:
This second example shows that any combination of data could be append into a c-array.
Then this array could be used to fill a ListDataStock<MultiData> for instance
arraydata_c | pointer on a one dimensional array |
b_order | if the data must be in a chronological or not chronological order |
no | indicates which field to extract. It is possible to use the enumaration EDS::ECSV |
Implements ListDataStockBase.
Definition at line 269 of file ListDataStock_timpl.h.
References CHRONO.
|
virtual |
Overload version with an initilizer_list, fill a 2 dimensional C-array.
Allocates and fills a 2-dimensional array
Example of usage:
arraydata_c | pointer on a 2 dimensional array |
b_order | if the data must be in a chronological or non-chronological order |
list | of data to extract, e.g., {0,2,3} or {ECSV::OPEN, ECVS::CLOSE} |
Implements ListDataStockBase.
Definition at line 311 of file ListDataStock_timpl.h.
|
inlinevirtual |
Get the date of the first data (always chronological meaning)
Implements ListDataStockBase.
Definition at line 628 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inlinevirtual |
Return the size of the vector.
Implements ListDataStockBase.
Definition at line 560 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by ListDataStock< T, PolicyChronologic >::SetDates(), ListDataStock_Utils::TransformTimeScale(), and Stock::UpdateCSVFromWeb().
|
inlineprotected |
Definition at line 647 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::bpolicy(), and ListDataStock< T, PolicyChronologic >::ListData.
|
inlinevirtual |
Get the date of the last data (always chronological meaning)
Implements ListDataStockBase.
Definition at line 626 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inlinevirtual |
Get nth element in a non chronological order.
Because the full DataStock object is stored (not a pointer or a base class),
it returns a reference to the exact type (SimpleData, MultiData, DataCSV).
offset | nth element [0,GetSize()-1] |
Implements ListDataStockBase.
Definition at line 573 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by ListDataStock< T, PolicyChronologic >::SetDates(), ListDataStock_Utils::TransformTimeScale(), and Stock::WriteCSV().
|
privatedelete |
Deleted assignment operator.
|
inlinevirtual |
Access nth element, do not check for the policy chronology.
Implements ListDataStockBase.
Definition at line 578 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
|
inlinevirtual |
Function to reverse the internal vector in its original policy.
Need to know the order the data have been added (order_data) using AddData (AddToList should be correct now) Then the call to Order( order_data ), will modify the internal vector order to respect the policy of the list.
If the order is already correct, nothing will be done (known at compile-time).
It allows to use any convenient order in a specific algorithm, and correct only at the end.
Even if the list is created outside the function which implements the algorithm.
Default true from TAlib, indicates if order is chronologic or not
b_chronologic, indicates if the data have been inserted chronologicaly or not |
Implements ListDataStockBase.
Definition at line 629 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by ListDataStock_Utils::TransformTimeScale(), Stock::UpdateCSVFromWeb(), and wrapUpdateCSV().
|
inlinevirtual |
Return a string of the chronology policy.
Implements ListDataStockBase.
Definition at line 623 of file ListDataStock.h.
|
virtual |
Nice formatting output on console.
verbose :
verbose | : add more information, value = 0 (default) or 1 |
Implements ListDataStockBase.
Definition at line 469 of file ListDataStock_timpl.h.
References FullName::GetTimeScale(), and Utils::Time_tToString().
Referenced by wrapUpdateCSV().
|
virtual |
Fill a ListDataStock<T> from a 2 dimensional C-array.
Insert all the data of the C-array into the list.
If the indicator has multiple values (MACD), all data are inserted at once with a ListDataStock<MultiData>.
The ldata_date parameter is necessary to set the dates after a computation,
Normally, it is the same List used as input for the computation (allow correct offsets)
Because some indicators may be shorter than the input, e.g. a moving average of X data, TALib uses the concept of offsets.
When putting the data into a List, it should be specified a offset_begin of X.
The algorithm is independent of the policy order of ldata_date or this.
The only important parameter is the order of the c-array: last parameter b_chrono.
Maybe later, a shift for size_indic: extract only relevant columns
ldata_date | a list which will be used to set the correct dates |
nb_data | the number of time data to include, should be smaller or equal to the nb_data_c |
size_indic | number of values for each data, e.g. for MACD = 3 |
arraydata_c | c-array[size_indic][nb_data_c] as input with nb_data_c == nb_data at the moment |
offset_begin | offset with the beginning of ldata_date (considered chronological) |
offset_end | offset with the end of ldata_date (consider chronological) |
b_chrono | EPChrono enumeration, indicates in which order the data are stored in the C-array |
full_array | boolean true : a full c-array is used, or false : offset(s) are not present |
Implements ListDataStockBase.
Definition at line 375 of file ListDataStock_timpl.h.
References CHRONO, ListDataStockBase::ChronologicAt(), DataStock::GetDate(), ListDataStockBase::GetSize(), ListDataStockBase::GetTimeScale(), NO_CHRONO, ListDataStockBase::NoChronologicAt(), and not_a_time.
|
virtual |
Replace all DataStock's of the list with ldata_in.data, without checking for update.
Copy explicitly the data of new_list into this and set the new dates.
=> Pointers to this are still valid.
Insert data respecting the policy of this.
Used by TAlib indicators, always replace the listdata by default
to see later, avoid this expensive copy, try more real update
ldata_in | list with new DataStock |
Implements ListDataStockBase.
Definition at line 205 of file ListDataStock_timpl.h.
References ListDataStockBase::GetVectorData().
|
inlinevirtual |
Reserve new_size elements.
Allocate enough memory to store new_size objects without reallocating memory
new_size | of the vector |
Implements ListDataStockBase.
Definition at line 562 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by GetListDataFromPyList(), and ListDataStock_Utils::TransformTimeScale().
|
inlinevirtual |
Set the correct first/last dates from the DataStock in the vector.
to call only after loading the data
Implements ListDataStockBase.
Definition at line 633 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ChronologicAt(), ListDataStockBase::dates, Utils::firstlast_dates::first, ListDataStock< T, PolicyChronologic >::GetSize(), Utils::firstlast_dates::last, and ListDataStock< T, PolicyChronologic >::NoChronologicAt().
Referenced by ListDataStock_Utils::TransformTimeScale(), Stock::UpdateCSVFromWeb(), and wrapUpdateCSV().
|
inlinevirtual |
Set dates, 2 arguments.
Reimplemented from ListDataStockBase.
Definition at line 640 of file ListDataStock.h.
References ListDataStockBase::SetDates().
|
inlinevirtual |
Reduce the capacity of the internal vector to fit its size.
Implements ListDataStockBase.
Definition at line 564 of file ListDataStock.h.
References ListDataStock< T, PolicyChronologic >::ListData.
Referenced by ListDataStock_Utils::TransformTimeScale().
|
private |
internal vector of objects DataStock
Definition at line 656 of file ListDataStock.h.
Referenced by ListDataStock< T, PolicyChronologic >::AddData(), ListDataStock< T, PolicyChronologic >::Capacity(), ListDataStock< T, PolicyChronologic >::ChronologicAt(), ListDataStock< T, PolicyChronologic >::GetFirstTime(), ListDataStock< T, PolicyChronologic >::GetSize(), ListDataStock< T, PolicyChronologic >::GetVectorData(), ListDataStock< T, PolicyChronologic >::LastUpdate(), ListDataStock< T, PolicyChronologic >::ListDataStock(), ListDataStock< T, PolicyChronologic >::NoChronologicAt(), ListDataStock< T, PolicyChronologic >::operator[](), ListDataStock< T, PolicyChronologic >::Order(), ListDataStock< T, PolicyChronologic >::Reserve(), and ListDataStock< T, PolicyChronologic >::Swap().