#include #include #include #include "../../shared/GlobalConfigFile.h" #include "DataFromSpryWare.h" #include "ProcessData.h" #include "ProcessSymbolsUnit.h" #include "CorrelationSymbols.h" typedef std::vector< std::string > StringList; void loadSymbolFile(const std::string &fileName, StringList &symbols) { std::ifstream inFile; std::string symbol; inFile.open(fileName.c_str()); if (!inFile) { std::cerr << "Unable to open file \"" << fileName << '\"' << std::endl; exit(1); } while (inFile >> symbol) { if (!symbol.empty()) symbols.push_back(symbol); } inFile.close(); std::sort(symbols.begin(), symbols.end()); } int main(int argc, char *argv[]) { StringList allSymbols; if (argc == 1) { // Nothing on the command line. We could use all defaults, but it seems // to make more sense to display help here. std::cerr<<"Request History Overnight Process\n" <<"Use the -i / -f syntax to specify values.\n" <<"* symbol_files - A comma separated list of symbol files to read.\n" <<" No default. At least one filename is required\n" <<"* correlation_file - Each symbol will be comprared to these symbols to see\n" <<" if they correlate.\n" <<" default behavior is to skip correlations\n" <<"* data_file - The last section to send to the files.\n" <<" default = OvernightData.csv.\n" <<"* standard_candles_file - Load the requirements for standard candle history.\n" <<" 1st column is the number of minutes per candle.\n" <<" Can optionally have a \"Max Candle Count\" column.\n" <<" no defaut value\n" <<"* dump_candles_db - Set this to the name of the database to dump candles to\n" <<" by default candles are not dumped to the database\n" <<"* days_of_history - Total days of history to dump into the db. Useless if\n" <<" you don't set dump_candles_db.\n" <<" defaults to 21\n" <<"* charts_directory - Directory to place the daily and weekly .gif charts.\n" <<" Trailing slash not required\n" <<" default is to not create charts\n"; exit(1); } // default addConfigItems("data_file=OvernightData.csv"); addConfigItems("days_of_history=21"); if (!addConfigItemsFromCommandLine(argv + 1)) return 1; configItemsComplete(); if (!getConfigItem("symbol_files").empty()) { StringList fileList = explode(",", getConfigItem("symbol_files")); for (StringList::const_iterator it = fileList.begin(); it != fileList.end(); it++) loadSymbolFile(*it, allSymbols); } else { std::cerr << "Parameter symbol_files is required.\n"; exit(1); } if (!getConfigItem("correlation_file").empty()) { StringList correlationSymbols; loadSymbolFile(getConfigItem("correlation_file"), correlationSymbols); loadSymbolFile(getConfigItem("correlation_file"), allSymbols); addCorrelationSymbols(correlationSymbols); } ProcessData processing; if (!getConfigItem("standard_candles_file").empty()) { processing.loadStandardCandles(getConfigItem("standard_candles_file")); } if (!getConfigItem("dump_candles_db").empty()) { processing.setDumpCandles(getConfigItem("dump_candles_db"), strtolDefault(getConfigItem("days_of_history"), 21)); } if (!getConfigItem("charts_directory").empty()) { processing.setChartsDirectory(getConfigItem("charts_directory")); } processing.setOutputFiles(getConfigItem("data_file")); ProcessSymbols(processing, allSymbols); processing.flushOutputFiles(); }