ROOT_Application
2.0
C++ Core modules and GUIStock
|
Abstract base class for the ListDataStock, for storing base pointers in vectors. More...
#include <ListDataStock.h>
Data Structures | |
class | visitor_get_array_allocate |
class | visitor_get_array_set_value |
class | visitor_type_array |
Public Types | |
typedef boost::variant for Put/GetCArray | |
typedef boost::variant< float **, double **, int ** > | var_types |
typedef boost::variant< float ***, double ***, int *** > | var_types2 |
Public Member Functions | |
virtual void | PrintData (const unsigned int verbose=0) const =0 |
Nice formatting output on console. More... | |
Constructors and destructor | |
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... | |
Getters / Setters of private members of the base class | |
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 time_t first, const time_t last) |
Set dates, 2 arguments. More... | |
virtual void | SetDates (const Utils::firstlast_dates &new_date) |
Set dates with a structure Utils::firstlast_dates. More... | |
virtual void | SetDates ()=0 |
Set the correct first/last dates from the DataStock in the vector. More... | |
Wrappers to the internal std::vector | |
virtual unsigned int | GetSize () const =0 |
Return the size of the vector. More... | |
virtual unsigned int | Capacity () const =0 |
Return the capacity of the vector. More... | |
virtual void | Reserve (const unsigned int new_size)=0 |
Reserve new_size elements. More... | |
virtual void | Clear ()=0 |
Clear the vector and reinitialize data members to default values. More... | |
virtual void | Swap ()=0 |
Reduce the capacity of the internal vector to fit its size. More... | |
Get a copy of the internal vector, in the order given by chrono | |
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 |
Functions related to the policy of the list | |
virtual std::string | policy () const =0 |
Return a string of the chronology policy. More... | |
virtual EPChrono | bpolicy () const =0 |
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO. More... | |
virtual void | Order (const EPChrono chrono)=0 |
Function to reverse the internal vector in its original policy. More... | |
virtual time_t | LastUpdate () const =0 |
Get the date of the last data (always chronological meaning) More... | |
virtual time_t | GetFirstTime () const =0 |
Get the date of the first data (always chronological meaning) More... | |
Access to the DataStock elements | |
virtual DataStock & | operator[] (const unsigned int offset)=0 |
Access nth element, do not check for the policy chronology. More... | |
virtual const DataStock & | ChronologicAt (const unsigned int offset) const =0 |
Get the nth element in a chronological order. More... | |
virtual const DataStock & | NoChronologicAt (const unsigned int offset) const =0 |
Get nth element in a non chronological order. More... | |
Update of the list | |
virtual void | AddData (DataStock &)=0 |
Add a copy of the DataStock into the ListDataStock. More... | |
virtual int | AddToList (const ListDataStockBase *)=0 |
Append all data from a new list ( coming from an Update or ReadCSV normally ) to an existing list. More... | |
virtual void | Replace (const ListDataStockBase *)=0 |
Replace all DataStock's of the list with ldata_in.data, without checking for update. More... | |
Transform to/from C-Array | |
virtual unsigned int | GetCArray (var_types arraydata_c, const EPChrono b_order, const unsigned int no=0) const =0 |
Extract the data into a one dimensional C-array. More... | |
virtual unsigned int | GetCArray (var_types2 arraydata_c, const EPChrono b_order, std::initializer_list< unsigned int > list_no) const =0 |
Overload version with an initilizer_list, fill a 2 dimensional C-array. More... | |
virtual 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)=0 |
Fill a ListDataStock<T> from a 2 dimensional C-array. More... | |
Protected Attributes | |
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... | |
Private Member Functions | |
ListDataStockBase (const ListDataStockBase &src) | |
Delete copy constructor. More... | |
ListDataStockBase & | operator= (const ListDataStockBase &rhs) |
Delete assignment operator. More... | |
Abstract base class for the ListDataStock, for storing base pointers in vectors.
Store:
Definition at line 50 of file ListDataStock.h.
typedef boost::variant<float**, double**, int**> ListDataStockBase::var_types |
Definition at line 256 of file ListDataStock.h.
typedef boost::variant<float***, double***, int***> ListDataStockBase::var_types2 |
Definition at line 257 of file ListDataStock.h.
|
inline |
Default constructor, set empty names, timescale ETime::not_a_time, dates are zero.
Definition at line 56 of file ListDataStock.h.
|
inline |
Constructor sets name, timescale and optionaly dates.
fullname is left empty
Definition at line 67 of file ListDataStock.h.
|
inlinevirtual |
Destructor.
Definition at line 71 of file ListDataStock.h.
|
private |
Delete copy constructor.
|
pure virtual |
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 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by Stock::ReadCSV(), and StockManager::SendDatadCSV().
|
pure 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 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by Stock::AddListDataToMap().
|
pure virtual |
Return policy as an enumeration type EPChrono, CHRONO / NO_CHRONO.
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure virtual |
Return the capacity of the vector.
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure virtual |
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] |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList(), ListDataStock< T, PolicyChronologic >::PutCArray(), THistPainterStock::SetLabelXAxis(), and Stock::WriteCSV().
|
pure 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
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure 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 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by TAlibAPI::Compute().
|
pure 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} |
Implemented in ListDataStock< T, PolicyChronologic >.
|
inlinevirtual |
Return the structure Utils::firstlast_dates of the private data member, not from the data.
Definition at line 87 of file ListDataStock.h.
References dates.
Referenced by Stock::WriteCSV().
|
inline |
Get first date from the private data member dates.
Definition at line 89 of file ListDataStock.h.
References dates, and Utils::firstlast_dates::first.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList().
|
pure virtual |
Get the date of the first data (always chronological meaning)
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList(), and Stock::SaveCSV().
|
inlinevirtual |
Definition at line 79 of file ListDataStock.h.
References fullname.
Referenced by Stock::AddListDataToMap().
|
inline |
Get last date from the private data member dates.
Definition at line 91 of file ListDataStock.h.
References dates, and Utils::firstlast_dates::last.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList().
|
inline |
Definition at line 78 of file ListDataStock.h.
References name.
Referenced by ControllerIndicatorTHStock::AddData(), CanvasStock::AddListDataStockToMap(), Stock::AddListDataToMap(), THStock::AddPairToVector(), THStock::GetDateFromBin(), THStock::GetListDataStock(), THStock::SetColor(), THistPainterStock::SetLabelXAxis(), Stock::SetLDataFullName(), THStock::SetObjectStock(), and ListDataStock_Utils::TransformTimeScale().
|
pure virtual |
Return the size of the vector.
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ControllerIndicatorTHStock::AddData(), CanvasStock::AddListDataStockToMap(), Stock::AddListDataToMap(), THStock::AddPairToVector(), ListDataStock< T, PolicyChronologic >::AddToList(), TAlibAPI::Compute(), IndicatorObjectStock::ComputeBinRange(), THistPainterStock::PaintInit(), ListDataStock< T, PolicyChronologic >::PutCArray(), Stock::ReadCSV(), THistPainterStock::SetLabelXAxis(), ListObjectStock< T >::SetObjectStock(), PStockLine::SetObjectStock(), CollectionObjectStock::SetObjectStock(), and Stock::WriteCSV().
|
inlinevirtual |
Definition at line 80 of file ListDataStock.h.
References tmscl.
Referenced by ListDataStock< T, PolicyChronologic >::PutCArray(), THistPainterStock::SetLabelXAxis(), Stock::SetLDataFullName(), and ListDataStock_Utils::TransformTimeScale().
|
inlinevirtual |
Definition at line 133 of file ListDataStock.h.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList(), and ListDataStock< T, PolicyChronologic >::Replace().
|
inlinevirtual |
Definition at line 134 of file ListDataStock.h.
|
inlinevirtual |
Definition at line 135 of file ListDataStock.h.
|
pure virtual |
Get the date of the last data (always chronological meaning)
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ListDataStock< T, PolicyChronologic >::AddToList(), Stock::SaveCSV(), and Stock::UpdateCSVFromFile().
|
pure virtual |
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] |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ListDataStock< T, PolicyChronologic >::PutCArray(), ListObjectStock< T >::SetObjectStock(), PStockLine::SetObjectStock(), CollectionObjectStock::SetObjectStock(), and Stock::WriteCSV().
|
private |
Delete assignment operator.
|
pure virtual |
Access nth element, do not check for the policy chronology.
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure virtual |
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 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by Stock::ReadCSV().
|
pure virtual |
Return a string of the chronology policy.
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure virtual |
Nice formatting output on console.
verbose :
verbose | : add more information, value = 0 (default) or 1 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ControllerIndicatorTHStock::AddData().
|
pure 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 |
Implemented in ListDataStock< T, PolicyChronologic >.
|
pure 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 |
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by Stock::AddListDataToMap().
|
pure virtual |
Reserve new_size elements.
Allocate enough memory to store new_size objects without reallocating memory
new_size | of the vector |
Implemented in ListDataStock< T, PolicyChronologic >.
|
inlinevirtual |
Set dates, 2 arguments.
Reimplemented in ListDataStock< T, PolicyChronologic >.
Definition at line 93 of file ListDataStock.h.
References dates, Utils::firstlast_dates::first, and Utils::firstlast_dates::last.
Referenced by Stock::ReadCSV(), and StockManager::SendDatadCSV().
|
inlinevirtual |
Set dates with a structure Utils::firstlast_dates.
Definition at line 96 of file ListDataStock.h.
References dates.
|
pure virtual |
Set the correct first/last dates from the DataStock in the vector.
to call only after loading the data
Implemented in ListDataStock< T, PolicyChronologic >.
Referenced by ListDataStock< T, PolicyChronologic >::SetDates().
|
inlinevirtual |
Definition at line 83 of file ListDataStock.h.
References fullname.
Referenced by Stock::SetLDataFullName().
|
inline |
Definition at line 82 of file ListDataStock.h.
References name.
Referenced by ListDataStock_Utils::TransformTimeScale().
|
inlinevirtual |
Definition at line 81 of file ListDataStock.h.
References tmscl.
Referenced by ListDataStock_Utils::TransformTimeScale().
|
pure virtual |
Reduce the capacity of the internal vector to fit its size.
Implemented in ListDataStock< T, PolicyChronologic >.
|
protected |
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.
Definition at line 422 of file ListDataStock.h.
Referenced by GetDates(), GetFirstDate(), GetLastDate(), SetDates(), and ListDataStock< T, PolicyChronologic >::SetDates().
|
protected |
fullname seems necessary (convenient) for GUI, never set by constructors
Definition at line 425 of file ListDataStock.h.
Referenced by GetFullName(), and SetFullName().
|
protected |
name stores the indicator label with the parameters, it corresponds to its ShortName
Definition at line 396 of file ListDataStock.h.
|
protected |
TimeScale of the List.
Definition at line 404 of file ListDataStock.h.
Referenced by GetTimeScale(), and SetTimeScale().