A little modification

This commit is contained in:
fasiondog 2019-12-30 00:20:21 +08:00
parent 1868afd766
commit 5321cebb29
2 changed files with 14 additions and 18 deletions

View File

@ -24,7 +24,7 @@ namespace hku {
shared_ptr<StockManager> StockManager::m_sm; shared_ptr<StockManager> StockManager::m_sm;
StockManager::~StockManager() { StockManager::~StockManager() {
std::cout << "Quit Hikyuu system!" << std::endl; std::cout << "Quit Hikyuu system!\n" << std::endl;
// Cannot use log output when exiting! // Cannot use log output when exiting!
// HKU_TRACE("Quit Hikyuu system!\n"); // HKU_TRACE("Quit Hikyuu system!\n");
} }
@ -59,9 +59,8 @@ Parameter default_other_param() {
return param; return param;
} }
void StockManager::init(const Parameter& baseInfoParam, const Parameter& blockParam, void StockManager::init(const Parameter& baseInfoParam, const Parameter& blockParam, const Parameter& kdataParam,
const Parameter& kdataParam, const Parameter& preloadParam, const Parameter& preloadParam, const Parameter& hikyuuParam) {
const Parameter& hikyuuParam) {
m_baseInfoDriverParam = baseInfoParam; m_baseInfoDriverParam = baseInfoParam;
m_blockDriverParam = blockParam; m_blockDriverParam = blockParam;
m_kdataDriverParam = kdataParam; m_kdataDriverParam = kdataParam;
@ -113,8 +112,7 @@ void StockManager::init(const Parameter& baseInfoParam, const Parameter& blockPa
setKDataDriver(kdata_driver); setKDataDriver(kdata_driver);
// add special Market, for temp csv file // add special Market, for temp csv file
m_marketInfoDict["TMP"] = m_marketInfoDict["TMP"] = MarketInfo("TMP", "Temp Csv file", "temp load from csv file", "000001", Null<Datetime>());
MarketInfo("TMP", "Temp Csv file", "temp load from csv file", "000001", Null<Datetime>());
std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_time; std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_time;
HKU_INFO("{:<.2f}s Loaded Data.", sec.count()); HKU_INFO("{:<.2f}s Loaded Data.", sec.count());
@ -339,13 +337,13 @@ DatetimeList StockManager::getTradingCalendar(const KQuery& query, const string&
return result; return result;
} }
Stock StockManager::addTempCsvStock(const string& code, const string& day_filename, Stock StockManager::addTempCsvStock(const string& code, const string& day_filename, const string& min_filename,
const string& min_filename, price_t tick, price_t tickValue, price_t tick, price_t tickValue, int precision, size_t minTradeNumber,
int precision, size_t minTradeNumber, size_t maxTradeNumber) { size_t maxTradeNumber) {
string new_code(code); string new_code(code);
to_upper(new_code); to_upper(new_code);
Stock result("TMP", new_code, day_filename, STOCKTYPE_TMP, true, Datetime(199901010000), Stock result("TMP", new_code, day_filename, STOCKTYPE_TMP, true, Datetime(199901010000), Null<Datetime>(), tick,
Null<Datetime>(), tick, tickValue, precision, minTradeNumber, maxTradeNumber); tickValue, precision, minTradeNumber, maxTradeNumber);
KDataTempCsvDriver* p = new KDataTempCsvDriver(day_filename, min_filename); KDataTempCsvDriver* p = new KDataTempCsvDriver(day_filename, min_filename);
result.setKDataDriver(KDataDriverPtr(p)); result.setKDataDriver(KDataDriverPtr(p));

View File

@ -62,17 +62,16 @@ namespace hku {
#define SPEND_TIME(id) \ #define SPEND_TIME(id) \
std::stringstream sptmsg_buf_##id(std::stringstream::out); \ std::stringstream sptmsg_buf_##id(std::stringstream::out); \
sptmsg_buf_##id << #id << " (" << __FILE__ << ":" << __LINE__ << ")"; \ sptmsg_buf_##id << #id << " (" << __FILE__ << ":" << __LINE__ << ")"; \
SpendTimer test_spend_timer_##id(sptmsg_buf_##id.str()); hku::SpendTimer test_spend_timer_##id(sptmsg_buf_##id.str());
/** /**
* *
* @param id id * @param id id
* @param ... fmt::format * @param ... fmt::format
*/ */
#define SPEND_TIME_MSG(id, ...) \ #define SPEND_TIME_MSG(id, ...) \
string msg_##id = fmt::format(__VA_ARGS__); \ std::string msg_##id = fmt::format(__VA_ARGS__); \
SpendTimer test_spend_timer_##id( \ hku::SpendTimer test_spend_timer_##id(fmt::format("{} {} ({}:{})", #id, msg_##id, __FILE__, __LINE__));
fmt::format("{} {} ({}:{})", #id, msg_##id, __FILE__, __LINE__));
/** /**
* *
@ -95,8 +94,7 @@ public:
* *
* @param msg * @param msg
*/ */
explicit SpendTimer(const std::string& msg) explicit SpendTimer(const std::string& msg) : m_msg(msg), m_start_time(std::chrono::steady_clock::now()) {}
: m_msg(msg), m_start_time(std::chrono::steady_clock::now()) {}
/** 析构函数,计算从构造至析构所消耗的时间,并打印输出 */ /** 析构函数,计算从构造至析构所消耗的时间,并打印输出 */
virtual ~SpendTimer() { virtual ~SpendTimer() {