hikyuu2/hikyuu_cpp/hikyuu/data_driver/BaseInfoDriver.cpp

75 lines
1.9 KiB
C++
Raw Normal View History

/*
* BaseInfoDriver.cpp
*
* Created on: 2017-10-8
* Author: fasiondog
*/
#include <boost/algorithm/string.hpp>
2021-01-26 22:58:19 +08:00
#include "../StockManager.h"
2021-02-21 22:52:05 +08:00
#include "../global/GlobalTaskGroup.h"
#include "BaseInfoDriver.h"
namespace hku {
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const BaseInfoDriver& driver) {
2017-10-20 02:11:57 +08:00
os << "BaseInfoDriver(" << driver.name() << ", " << driver.getParameter() << ")";
return os;
}
2019-11-10 23:31:41 +08:00
HKU_API std::ostream& operator<<(std::ostream& os, const BaseInfoDriverPtr& driver) {
2017-10-20 02:11:57 +08:00
if (driver) {
os << *driver;
} else {
os << "BaseInfoDriver(NULL)";
}
return os;
}
2019-11-10 23:31:41 +08:00
BaseInfoDriver::BaseInfoDriver(const string& name) : m_name(name) {
to_upper(m_name);
}
bool BaseInfoDriver::checkType() {
bool result = false;
try {
string type = getParam<string>("type");
to_upper(type);
if (type == m_name) {
result = true;
} else {
result = false;
HKU_WARN("Type of driver mismatch! ({} != {})", type, m_name);
}
2019-11-10 23:31:41 +08:00
} catch (...) {
result = false;
HKU_ERROR("Can't get type of driver!");
}
return result;
}
bool BaseInfoDriver::init(const Parameter& params) {
2020-11-22 18:34:37 +08:00
HKU_IF_RETURN(m_params == params, true);
m_params = params;
2020-11-22 18:34:37 +08:00
HKU_IF_RETURN(!checkType(), false);
2020-11-01 14:01:08 +08:00
HKU_INFO("Using {} BaseInfoDriver", name());
return _init();
}
Parameter BaseInfoDriver::getFinanceInfo(const string& market, const string& code) {
HKU_INFO("The getFinanceInfo method has not been implemented! (BaseInfoDriver: {})", m_name);
return Parameter();
}
StockWeightList BaseInfoDriver::getStockWeightList(const string& market, const string& code,
Datetime start, Datetime end) {
HKU_INFO("The getStockWeightList method has not been implemented! (BaseInfoDriver: {})",
m_name);
return StockWeightList();
}
} /* namespace hku */