ROOT_Application
2.0
C++ Core modules and GUIStock
|
Main class to deal with one stock. More...
#include <Stock.h>
Public Member Functions | |
Constructors, destructor | |
Stock () | |
Default constructor. More... | |
Stock (const std::string iname, const std::string isymbol, const std::string ipath) | |
to delete More... | |
Stock (const std::string iname, const std::string ipath=Utils::GetPathData()) | |
Set the name (symbol == name), optionally the path of the data. More... | |
virtual | ~Stock () |
Getters/Setters to private data | |
std::string | GetName () const |
std::string | GetSymbol () const |
std::string | GetPath () const |
Check / Retrieve content of the Stock | |
bool | CheckLoaded (const ETime &tmscl) const |
bool | CheckLoaded (const ETime &tmscl, const Indicator &indic, const std::vector< int > ¶m=std::vector< int >()) const |
Check with a TimeScale and an indicator. More... | |
bool | CheckLoaded (const ETime &tmscl, const std::string &sname) const |
Check with a TimeScale and the shortname. More... | |
bool | IsEmpty () const |
Test if some ListData are still present, whatever the timescale. More... | |
ListDataStockBase * | GetListData (const ETime &tmscl, const Indicator &indic, const std::vector< int > param=std::vector< int >()) const |
Get the ListDataStock from a TimeScale, Indicator and vector of parameters. More... | |
ListDataStockBase * | GetListData (const ETime &tmscl, const std::string &sname) const |
Get the ListDataStock from a TimeScale and a string with the shortname format: "Indicator_params". More... | |
Load/Compute new indicators | |
int | LoadListData (const ETime &tmscl, const Indicator &indic=Indicator::StockCSV, const std::vector< int > ¶m=std::vector< int >(), Utils::firstlast_dates dates=Utils::get_fldate_default()) throw (StockException) |
Load or/and compute an indicator in the Stock. More... | |
Delete List data from the Stock | |
void | DeleteListData (const ETime &tmscl, const Indicator &indic, std::vector< int > param=std::vector< int >()) |
Delete a list given the TimeScale, Indicator and param. More... | |
void | DeleteListData (const ETime &tmscl, const std::string &sname) |
Delete a list given the TimeScale and the ShortName "indic_params". More... | |
void | DeleteAllListData (const ETime &tmscl) |
Delete all data of the given TimeScale. More... | |
Update the List(s) | |
int | AddListDataToMap (const ETime &tmscl, ListDataStockBase *p_listdata) |
Insert a ListDataStock to the map. More... | |
void | Updated (const ETime tmscl) |
Return the last available date of historical data. More... | |
void | UpdateAllTimeScale (const ETime tmscl, Utils::firstlast_dates opt_dates=Utils::get_fldate_default(), bool b_readfile=true) |
Update all indicators of the given TimeScale. More... | |
int | UpdateCSVFromFile (const ETime tmscl) |
Load the last historical data from the filesystem into a List in memory. More... | |
int | UpdateCSVFromWeb (const std::string &source, Utils::firstlast_dates opt_dates=Utils::get_fldate_default()) throw (StockException) |
Update data from the Python parser (and save into the filesystem). More... | |
void | MergeStock (const Stock *new_stock, bool) |
Merge entries with an other stock. More... | |
Nice output to console | |
void | PrintMapChrono (const unsigned int verbose=0) const |
Print map content to the console. More... | |
Python embedded functions, access ServerPortfolio classes and methods | |
int | LoadDictionary (std::string dict="") |
Load the dictionary of Stock, see ServerPortfolio. More... | |
int | TestwrapPython (std::string source) |
int | TestwrapPython2 (std::string source) |
Private Types | |
iterator typedefs for the map | |
typedef std::map< ETime, std::vector< ListDataStockBase * > >::iterator | it_map |
typedef std::map< ETime, std::vector< ListDataStockBase * > >::const_iterator | cit_map |
typedef std::vector < ListDataStockBase * > ::iterator | it_listdata |
typedef std::vector < ListDataStockBase * > ::const_iterator | cit_listdata |
Private Member Functions | |
void | SetLDataFullName (ListDataStockBase *p_listdata) const |
Function to complete the fullname of a listdatastock. More... | |
Internal methods function to access iterators to ListDataStock from the map | |
| |
cit_listdata | GetItList (cit_map &it_m, const Indicator &indic, const std::vector< int > ¶m=std::vector< int >()) const |
cit_listdata | GetItList (cit_map &it_m, const std::string &sname) const |
it_listdata | GetItList (it_map &it_m, const Indicator &indic, const std::vector< int > ¶m=std::vector< int >()) |
version non-const More... | |
it_listdata | GetItList (it_map &it_m, const std::string &sname) |
version non-const More... | |
Helper methods for loading and computing indicators | |
void | LoadCSVData (const ETime &tmscl, Utils::firstlast_dates &dates) throw (StockException) |
Get Indicator::StockCSV or StockdCSV with the correct TimeScale Call functions to read and load data from file ReadCSV, day or dcsv. More... | |
int | Transform_TimeScale (const ETime &new_tmscl) |
Transform history values dcsv or DAY to M5,M10..H1 or WEEK, MONTH..YEAR. More... | |
int | ComputeTA (const ETime &tmscl, const std::string &name_indic) throw (TALibException) |
Compute an indicator using the TAlib library. More... | |
Static Private Member Functions | |
Helper (static) methods to Read/Write headers files | |
static int | ReadLineHeader (const std::string &line, Utils::firstlast_dates &dates) |
Extract dates from the header of the historic data files. More... | |
static void | WriteLineHeader (const ETime &tmscl, const Utils::firstlast_dates &dates, std::ostringstream &ss_header) |
Write the header in a stream. More... | |
Private Attributes | |
std::string | name |
Name of the stock. More... | |
std::string | symbol |
symbol refers to the code, i.e., CAC40 More... | |
const std::string | path |
File path for the data directory. More... | |
TAlibAPI * | p_talib |
pointer to TA-lib API object, use a lazy initialization of the library More... | |
std::map< ETime, std::vector < ListDataStockBase * > > | mapTime_ListData |
map TimeScale : vector of ListDataStockBase pointers More... | |
Related to file I/O | |
unsigned int | ReadCSV (const ETime tmscl, Utils::firstlast_dates dates=Utils::get_fldate_default()) throw ( StockFileError ) |
Read DAY or INST file depending on the TimeScale. More... | |
void | WriteCSV (const ETime tmscl, bool opt_tmp=false) const throw ( StockException ) |
Write historical data into files. More... | |
int | SaveCSV (const ETime tmscl, bool opt_tmp=false) const |
Save Historical data to file. More... | |
int | Read_HeaderCSV (ETime tmscl, Utils::firstlast_dates &dates) const throw ( StockFileError ) |
Read the dates from the header file. More... | |
static int | Read_HeaderCSV_static (std::string namestock, ETime tmscl, Utils::firstlast_dates &dates) throw ( StockFileError ) |
Static version of Read_HeaderCSV. More... | |
static int | UpdateCSV_Inst (std::string namestock, DataStock &inst_value, DataStock &inst_volume, ETime tmscl, bool opt_tmp=false) throw ( StockFileError ) |
Update file with TimeScale INST. More... | |
Main class to deal with one stock.
Object defined for each stock (e.g. DJ, FP, CAC40 )
Store ListDataStock's for historic values and indicators at all TimeScale.
Usage:
Implementation details:
For each key (TimeScale enumeration ETime) a list of pointer on a ListDataStock :
|
private |
|
private |
|
private |
|
private |
|
inline |
Stock::Stock | ( | const std::string | iname, |
const std::string | isymbol, | ||
const std::string | ipath | ||
) |
Stock::Stock | ( | const std::string | iname, |
const std::string | ipath = Utils::GetPathData() |
||
) |
|
virtual |
int Stock::AddListDataToMap | ( | const ETime & | tmscl, |
ListDataStockBase * | p_listdata | ||
) |
Insert a ListDataStock to the map.
Check if one already exists:
Return value :
code example with return value and delete
tmscl | TimeScale of the list |
p_listdata | pointer on the list data to insert |
Definition at line 622 of file Stock.cpp.
References ListDataStockBase::AddToList(), ListDataStockBase::GetFullName(), ShortName::GetIndicator(), GetListData(), ListDataStockBase::GetName(), ListDataStockBase::GetSize(), mapTime_ListData, ListDataStockBase::Replace(), SetLDataFullName(), Indicator::StockCSV, Indicator::StockInst, and Indicator::Volume.
Referenced by MergeStock(), SaveCSV(), StockManager::SendDatadCSV(), Transform_TimeScale(), and wrapUpdateCSV().
bool Stock::CheckLoaded | ( | const ETime & | tmscl | ) | const |
Definition at line 529 of file Stock.cpp.
References mapTime_ListData.
Referenced by StockManager::Load(), and UpdateCSVFromFile().
bool Stock::CheckLoaded | ( | const ETime & | tmscl, |
const Indicator & | indic, | ||
const std::vector< int > & | param = std::vector<int>() |
||
) | const |
Check with a TimeScale and an indicator.
Definition at line 539 of file Stock.cpp.
References GetItList(), and mapTime_ListData.
bool Stock::CheckLoaded | ( | const ETime & | tmscl, |
const std::string & | sname | ||
) | const |
Check with a TimeScale and the shortname.
Definition at line 553 of file Stock.cpp.
References GetItList(), and mapTime_ListData.
|
private |
Compute an indicator using the TAlib library.
tmscl | : timescale |
name_indic | : shortname of the indicator, e.g. "SMA_3" |
TALibException |
Definition at line 352 of file Stock.cpp.
References Indicator::AD, INST, Indicator::label(), Indicator::nb_output(), Indicator::nb_param(), Indicator::Null, Indicator::Set(), Indicator::StockCSV, Indicator::StockInst, Utils::toString(), Indicator::Volume, and TALibException::what().
Referenced by UpdateAllTimeScale().
void Stock::DeleteAllListData | ( | const ETime & | tmscl | ) |
Delete all data of the given TimeScale.
Definition at line 916 of file Stock.cpp.
References mapTime_ListData, and PrintMapChrono().
Referenced by StockManager::DeleteAllListDataFromTimeScale().
void Stock::DeleteListData | ( | const ETime & | tmscl, |
const Indicator & | indic, | ||
std::vector< int > | param = std::vector<int>() |
||
) |
Delete a list given the TimeScale, Indicator and param.
Definition at line 872 of file Stock.cpp.
References Indicator::label(), and ShortName::MakeShortName().
Referenced by StockManager::DeleteListData().
void Stock::DeleteListData | ( | const ETime & | tmscl, |
const std::string & | sname | ||
) |
Delete a list given the TimeScale and the ShortName "indic_params".
Definition at line 885 of file Stock.cpp.
References GetItList(), and mapTime_ListData.
|
private |
Definition at line 72 of file Stock.cpp.
References ShortName::MakeShortName().
Referenced by CheckLoaded(), DeleteListData(), GetItList(), and GetListData().
|
private |
|
private |
version non-const
Definition at line 94 of file Stock.cpp.
References GetItList(), and ShortName::MakeShortName().
|
private |
ListDataStockBase * Stock::GetListData | ( | const ETime & | tmscl, |
const Indicator & | indic, | ||
const std::vector< int > | param = std::vector<int>() |
||
) | const |
Get the ListDataStock from a TimeScale, Indicator and vector of parameters.
tmscl | TimeScale, e.g., ETime::DAY, ETime::YEAR |
indic | Indicator, e.g., Indicator::StockCSV, Indicator::Volume |
param | vector of int to set optional parameters |
Definition at line 581 of file Stock.cpp.
References GetItList(), and mapTime_ListData.
Referenced by AddListDataToMap(), StockManager::GetListData(), SaveCSV(), StockManager::SendDatadCSV(), Transform_TimeScale(), and UpdateCSVFromFile().
ListDataStockBase * Stock::GetListData | ( | const ETime & | tmscl, |
const std::string & | sname | ||
) | const |
Get the ListDataStock from a TimeScale and a string with the shortname format: "Indicator_params".
The string can be constructed with Utils::MakeShortName( Indicator, vec_params )
tmscl | TimeScale, e.g., ETime::DAY, ETime::YEAR |
sname | describes fully a list in ShortName format, e.g., "SMA_15","MACD_12_9_26" |
Definition at line 597 of file Stock.cpp.
References GetItList(), and mapTime_ListData.
|
inline |
Definition at line 210 of file Stock.h.
References name.
Referenced by StockManager::AddStock(), StockManager::DeleteAllListDataFromTimeScale(), StockManager::DeleteListData(), MergeStock(), PrintMapChrono(), and SetLDataFullName().
|
inline |
|
inline |
bool Stock::IsEmpty | ( | ) | const |
Test if some ListData are still present, whatever the timescale.
Definition at line 567 of file Stock.cpp.
References mapTime_ListData, and name.
Referenced by StockManager::DeleteAllListDataFromTimeScale(), and StockManager::DeleteListData().
|
private |
Get Indicator::StockCSV or StockdCSV with the correct TimeScale Call functions to read and load data from file ReadCSV, day or dcsv.
And transform the TimeScale if needed.
Check than both StockCSV/StockInst and Volume are present before TransformTimeScale is called.
Otherwise, force to re-read the file (existing Lists should be "replaced")
tmscl | TimeScale to load |
dates | range of dates when reading the data. Default use all. |
StockException |
Definition at line 177 of file Stock.cpp.
References DAY, INST, Indicator::StockCSV, Indicator::StockInst, Indicator::Volume, and StockFileError::what().
int Stock::LoadListData | ( | const ETime & | tmscl, |
const Indicator & | indic = Indicator::StockCSV , |
||
const std::vector< int > & | param = std::vector<int>() , |
||
Utils::firstlast_dates | dates = Utils::get_fldate_default() |
||
) | |||
throw | ( | StockException | |
) |
Load or/and compute an indicator in the Stock.
If an indicator is already present (whatever the initial dates range), the function return 1, it does not try to update.
Update can be done by calling again ReadCSV (with some limitations about dates) for DAY or INST
or call method UpdateAllTimeScale for Indicators
By default the historical data at the same TimeScale are loaded before the indicator are computed,
so that it is possible to ask for a SMA 3 directly.
Example of usage:
tmscl | TimeScale |
indic | Indicator, default StockCSV, the function loads the historical data from files |
param | an optional vector containing the parameters of the indicator. (Some indicators have a default values (see Indicator.h), but not used here) |
dates | optional dates to limit the range. Apply only when reading the file (DAY and INST), other TimeScale are transformed from them. Default use all available (in memory or in file) |
StockException | error in filesystem or cannot compute the indicator |
Definition at line 801 of file Stock.cpp.
References TimeScale::GetTimeScaleName(), ShortName::MakeShortName(), Indicator::Null, Utils::Time_tToString(), and TALibException::what().
Referenced by StockManager::Load(), SaveCSV(), and TransDateBox::Valid().
void Stock::MergeStock | ( | const Stock * | new_stock, |
bool | |||
) |
Merge entries with an other stock.
The calling object will insert new entries and replace or discard existing ones
new_stock | stock to merge into this |
to_replace | if true the new entries will replace the existing ones, otherwise they are discarded. Partly implemented |
Definition at line 730 of file Stock.cpp.
References AddListDataToMap(), GetName(), and mapTime_ListData.
Referenced by StockManager::AddStock().
void Stock::PrintMapChrono | ( | const unsigned int | verbose = 0 | ) | const |
Print map content to the console.
verbose similar to ListDataStock::PrintData() :
verbose | : level of detail 0 or 1 |
Definition at line 2127 of file Stock.cpp.
References GetName(), and mapTime_ListData.
Referenced by DeleteAllListData(), MainControllerIndicatorTHStock::Validation(), and wrapUpdateCSV().
int Stock::Read_HeaderCSV | ( | ETime | tmscl, |
Utils::firstlast_dates & | dates | ||
) | const | ||
throw | ( | StockFileError | |
) |
Read the dates from the header file.
Open and read header of namestock.DAY/INST.csv
will assign first/last date called before stock created in gui, want to call static Stock::Read_Header
tmscl | TimeScale, will read DA> or INST |
dates | structure will contain first and last dates after execution |
StockFileError | cannot be open, or missing header |
Definition at line 1487 of file Stock.cpp.
References TimeScale::GetTimeScaleName(), path, and Indicator::StockCSV.
Referenced by SaveCSV(), UpdateCSVFromFile(), and MainControllerIndicatorTHStock::Validation().
|
static |
Static version of Read_HeaderCSV.
Read file : "Utils::GetPathData()/historical/namestock.tmscl.csv"
Test version
path is taken from Utils::GetPathData()
namestock | name of the stock, considered similar as symbol |
tmscl | TimeScale to read |
dates | structure will contain first and last dates after execution |
StockFileError | cannot be open, or missing header |
Definition at line 1519 of file Stock.cpp.
References Utils::GetPathData(), TimeScale::GetTimeScaleName(), and Indicator::StockCSV.
Referenced by wrapLastCSVUpdate().
unsigned int Stock::ReadCSV | ( | const ETime | tmscl, |
Utils::firstlast_dates | dates = Utils::get_fldate_default() |
||
) | |||
throw | ( | StockFileError | |
) |
Read DAY or INST file depending on the TimeScale.
Create a ListDataStock with TimeScale ETime::DAY or ETime::INST (Indicator::StockCSV or Indicator::StockInst) and insert to the map.
Files are read from the data member path, setup by default to Utils::GetPathData().
Theses files are in the subdirectory "historical_data"
If dates.first only is specified (dates.last = 0), load all data from dates.first to last in file
If dates.last only (dates.first = 0), load all data from first in file to dates.last
This function can be called 2 times for an update if :
tmscl | Timescale |
dates | optional structure (Utils::firstlast_dates), range of dates to load, default (0,0) all. |
StockFileError |
Definition at line 957 of file Stock.cpp.
References ListDataStockBase::AddData(), CHRONO, DAY, Utils::firstlast_dates::first, DataStock::GetDate(), ListDataStockBase::GetSize(), TimeScale::GetTimeScaleName(), INST, Utils::firstlast_dates::last, NO_CHRONO, not_a_time, ListDataStockBase::Order(), path, SimpleData::SetData(), ListDataStockBase::SetDates(), Utils::splitline(), Indicator::StockCSV, Utils::StringToTime_t(), and Utils::Time_tToString().
Referenced by UpdateCSVFromFile().
|
staticprivate |
Extract dates from the header of the historic data files.
line | string input, header format 4 or 6 fields |
dates | fill the Utils::firstlast_dates structure with dates read from the line |
Definition at line 116 of file Stock.cpp.
References Utils::ERROR_StrToTime, Utils::firstlast_dates::first, Utils::firstlast_dates::last, Utils::splitline(), Utils::StringToTime_t(), and Utils::Time_tToString().
int Stock::SaveCSV | ( | const ETime | tmscl, |
bool | opt_tmp = false |
||
) | const |
Save Historical data to file.
This method assures than no data are lost when writing to file.
It should be preferred to WriteCSV in this sense
tmscl | TimeScale to save |
opt_tmp | if true will write to PATH_DATA/historical_data_tmp directory, for tests (to not overwrite original) |
StockException | throw by WriteCSV |
Definition at line 1357 of file Stock.cpp.
References AddListDataToMap(), Utils::firstlast_dates::first, Utils::get_fldate_default(), ListDataStockBase::GetFirstTime(), GetListData(), INST, Utils::firstlast_dates::last, ListDataStockBase::LastUpdate(), LoadListData(), M5, name, not_a_time, Read_HeaderCSV(), Stock(), Indicator::StockCSV, Indicator::StockInst, Indicator::Volume, and WriteCSV().
Referenced by wrapUpdateCSV().
|
private |
Function to complete the fullname of a listdatastock.
Done automaticaly when new data are inserted
ListDataStockBase | pointer on the List to modify |
Definition at line 258 of file Stock.cpp.
References ListDataStockBase::GetName(), GetName(), ListDataStockBase::GetTimeScale(), TimeScale::GetTimeScaleName(), and ListDataStockBase::SetFullName().
Referenced by AddListDataToMap().
|
private |
Transform history values dcsv or DAY to M5,M10..H1 or WEEK, MONTH..YEAR.
Always try
new_tmscl | new timescale to compute, different of dcsv or DAY (assert) |
Definition at line 273 of file Stock.cpp.
References AddListDataToMap(), DAY, GetListData(), INST, not_a_time, Indicator::StockCSV, Indicator::StockInst, ListDataStock_Utils::TransformTimeScale(), and Indicator::Volume.
Referenced by main(), and UpdateAllTimeScale().
void Stock::UpdateAllTimeScale | ( | const ETime | tmscl, |
Utils::firstlast_dates | opt_dates = Utils::get_fldate_default() , |
||
bool | b_readfile = true |
||
) |
Update all indicators of the given TimeScale.
DAY, call to UpdateCSVFromWeb (query Yahoo), and save data to file if new ones available. INST (normally updated by Server), but could call UpdateCSVFromFile (argument or check dates)
Then transform to the correct TimeScale and recompute ta-lib Indicators
tmscl | TimeScale to update |
opt_dates | optional, specify a range of dates for the update |
b_readfile |
Definition at line 1892 of file Stock.cpp.
References ComputeTA(), DAY, FullName::GetNameStock(), INST, Utils::firstlast_dates::last, mapTime_ListData, Indicator::Null, Indicator::Set(), Transform_TimeScale(), UpdateCSVFromFile(), and UpdateCSVFromWeb().
Referenced by Updated().
|
static |
Update file with TimeScale INST.
Append the new data (instantaneous value and volume) to the file and update the header.
Creates the file if it does not exist.
Implemented for wrapPyStock, python modules can update the file with a correct format of string and modify the header.
Files at timescale ETime::INST are in a chronological order. Faster to append data than reading all previous data.
namestock | necessary if want to keep as static function |
inst_value,inst_volume | DataStocks for instantaneous value and volume |
tmscl | should only be ETime::INST. Maybe later follow same logic for writing M5, M10 because often updated |
StockFileError | problem in opening or writing into the file |
Definition at line 1555 of file Stock.cpp.
References Utils::firstlast_dates::first, Utils::get_fldate_default(), Utils::GetPathData(), TimeScale::GetTimeScaleName(), INST, Utils::firstlast_dates::last, not_a_time, and Indicator::StockCSV.
Referenced by wrap_SaveInst().
int Stock::UpdateCSVFromFile | ( | const ETime | tmscl | ) |
Load the last historical data from the filesystem into a List in memory.
Original use with INST data, ServerPortfolio always writes the new data to files, and the List was not updated by the Server.
With DAY works the same, when update from Yahoo is asked by an other process.
Assume the file has been updated (not a precondition), the function will make a call to ReadCSV to add the new data.
If the List contains more data than the file (updated by other way: ServerSM), return -1 (or special code CANNOT_UPDATE)
If only a range of the initial data have been loaded all the new data will be added. (maybe not expected with GUI use)
If the List is empty (call from a script), load all the data.
tmscl | ETime::INST or ETime::DAY (assert to release later) |
StockFileError | may be throw by ReadCSV |
Definition at line 2068 of file Stock.cpp.
References CheckLoaded(), Utils::firstlast_dates::first, Utils::get_fldate_default(), GetListData(), INST, Utils::firstlast_dates::last, ListDataStockBase::LastUpdate(), Indicator::Null, Read_HeaderCSV(), ReadCSV(), Indicator::StockCSV, Indicator::StockInst, and Utils::Time_tToString().
Referenced by UpdateAllTimeScale().
void Stock::Updated | ( | const ETime | tmscl | ) |
Return the last available date of historical data.
First read the last date form the header.
If already loaded in-memory use the last date of it.
If load_list and not in-memory force to load the list in Stock, should be the same date as header.
Check than date in header is not larger than date in-memory. It means only a range has been loaded and update may cause problems. What's about the first date ? If not in memory will need to take care when saving to file.
Before, always load the data in memory, some calling function need this
But could only read the header by default (see LastCSVUpdateFromFile)
tmscl | timescale query, should be ETime::DAY or ETime::INST |
bool | load_list force to load the ListDataStock if not in memory, default read only the header |
StockException |
Indicate than data at tmscl have updated, will recompute all (historical data and indicators) for larger TimeScale.
Call by StockManger when a new TCP message has been received and new data have been added.
Inform than new data have been provided ( dcsv for now, later can be CSV as well ) and call UpdateAllTimeScale, specifying Data must not been read from file. All other update, recompuation similar
Should not use LoadListData for this purpose
tmscl | will recompute all indicators at this TimeScale |
Definition at line 1799 of file Stock.cpp.
References TimeScale::as_uint(), DAY, Utils::get_fldate_default(), INST, M5, mapTime_ListData, not_a_time, and UpdateAllTimeScale().
Referenced by StockManager::SendDatadCSV().
void Stock::WriteCSV | ( | const ETime | tmscl, |
bool | opt_tmp = false |
||
) | const | ||
throw | ( | StockException | |
) |
Write historical data into files.
Write the values and the volume at a specified TimeScale, do not check for previous data in file.
Only DAY is used (INST files are normally written by python ServerPortfolio, now by UpdateCSV_Inst),
other are implemented and unit-tested, but not used at the moment inside the library.
tmscl | TimeScale to write |
opt_tmp | if true will write to PATH_DATA/historical_data_tmp directory for tests (not overwrite original) |
StockException |
Definition at line 1247 of file Stock.cpp.
References ListDataStockBase::ChronologicAt(), ListDataStock< T, PolicyChronologic >::ChronologicAt(), ListDataStockBase::GetDates(), ListDataStockBase::GetSize(), TimeScale::GetTimeScaleName(), INST, ListDataStockBase::NoChronologicAt(), ListDataStock< T, PolicyChronologic >::NoChronologicAt(), not_a_time, path, Indicator::StockCSV, Indicator::StockInst, and Indicator::Volume.
Referenced by main(), and SaveCSV().
|
staticprivate |
Write the header in a stream.
include version number(fixed not used) include TimeScale in string format include dates of first and last data
tmscl | TimeScale |
dates | |
ss_header | filled with correct infos |
Definition at line 159 of file Stock.cpp.
References DAY, Utils::firstlast_dates::first, Utils::firstlast_dates::last, and Utils::Time_tToString().
|
private |
map TimeScale : vector of ListDataStockBase pointers
Definition at line 92 of file Stock.h.
Referenced by AddListDataToMap(), CheckLoaded(), DeleteAllListData(), DeleteListData(), GetListData(), IsEmpty(), MergeStock(), PrintMapChrono(), UpdateAllTimeScale(), Updated(), and ~Stock().
|
private |
|
private |
|
private |
File path for the data directory.
Definition at line 86 of file Stock.h.
Referenced by GetPath().
|
private |
symbol refers to the code, i.e., CAC40
Definition at line 77 of file Stock.h.
Referenced by GetSymbol(), Stock(), and ~Stock().