2015-01-07 01:26:14 +08:00
|
|
|
/*
|
|
|
|
* StockManager.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2011-11-9
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
2020-05-01 18:49:36 +08:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif
|
|
|
|
|
2020-04-03 02:05:27 +08:00
|
|
|
#include "GlobalInitializer.h"
|
2018-09-10 01:14:42 +08:00
|
|
|
#include <chrono>
|
2020-04-20 23:59:47 +08:00
|
|
|
#include <fmt/format.h>
|
2015-01-07 01:26:14 +08:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
2019-12-31 23:18:30 +08:00
|
|
|
#include "utilities/IniParser.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
#include "utilities/util.h"
|
|
|
|
#include "StockManager.h"
|
2020-04-20 23:59:47 +08:00
|
|
|
#include "GlobalTaskGroup.h"
|
2020-10-01 00:06:58 +08:00
|
|
|
#include "data_driver/kdata/cvs/KDataTempCsvDriver.h"
|
2019-08-16 01:17:24 +08:00
|
|
|
#include "data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h"
|
2018-04-16 03:46:43 +08:00
|
|
|
#include "data_driver/base_info/mysql/MySQLBaseInfoDriver.h"
|
2017-10-13 01:50:11 +08:00
|
|
|
#include "data_driver/block_info/qianlong/QLBlockInfoDriver.h"
|
2017-10-12 01:58:08 +08:00
|
|
|
#include "data_driver/kdata/hdf5/H5KDataDriver.h"
|
2017-10-13 01:50:11 +08:00
|
|
|
#include "data_driver/kdata/tdx/TdxKDataDriver.h"
|
2018-04-16 03:46:43 +08:00
|
|
|
#include "data_driver/kdata/mysql/MySQLKDataDriver.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
2020-04-03 02:05:27 +08:00
|
|
|
StockManager* StockManager::m_sm = nullptr;
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-03-01 01:24:55 +08:00
|
|
|
void StockManager::quit() {
|
2020-12-27 19:11:18 +08:00
|
|
|
releaseThreadPool();
|
2020-03-01 03:00:48 +08:00
|
|
|
if (m_sm) {
|
2020-04-03 02:05:27 +08:00
|
|
|
delete m_sm;
|
|
|
|
m_sm = nullptr;
|
2020-03-01 01:24:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-20 23:59:47 +08:00
|
|
|
StockManager::StockManager() {}
|
|
|
|
StockManager::~StockManager() {
|
2020-12-27 19:11:18 +08:00
|
|
|
releaseThreadPool();
|
2020-04-20 23:59:47 +08:00
|
|
|
fmt::print("Quit Hikyuu system!\n\n");
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
StockManager& StockManager::instance() {
|
2019-11-10 19:45:57 +08:00
|
|
|
if (!m_sm) {
|
2020-04-03 02:05:27 +08:00
|
|
|
m_sm = new StockManager();
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
return (*m_sm);
|
|
|
|
}
|
|
|
|
|
2017-10-13 01:50:11 +08:00
|
|
|
Parameter default_preload_param() {
|
|
|
|
Parameter param;
|
|
|
|
param.set<bool>("day", true);
|
|
|
|
param.set<bool>("week", false);
|
|
|
|
param.set<bool>("month", false);
|
|
|
|
param.set<bool>("quarter", false);
|
|
|
|
param.set<bool>("halfyear", false);
|
|
|
|
param.set<bool>("year", false);
|
|
|
|
param.set<bool>("min", false);
|
|
|
|
param.set<bool>("min5", false);
|
|
|
|
param.set<bool>("min15", false);
|
|
|
|
param.set<bool>("min30", false);
|
|
|
|
param.set<bool>("min60", false);
|
2020-12-26 18:33:57 +08:00
|
|
|
param.set<bool>("ticks", false);
|
|
|
|
param.set<int>("day_max", 100000);
|
|
|
|
param.set<int>("week_max", 100000);
|
|
|
|
param.set<int>("month_max", 100000);
|
|
|
|
param.set<int>("quarter_max", 100000);
|
|
|
|
param.set<int>("halfyear_max", 100000);
|
|
|
|
param.set<int>("year_max", 100000);
|
|
|
|
param.set<int>("min_max", 5120);
|
|
|
|
param.set<int>("min5_max", 5120);
|
|
|
|
param.set<int>("min15_max", 5120);
|
|
|
|
param.set<int>("min30_max", 5120);
|
|
|
|
param.set<int>("min60_max", 5120);
|
|
|
|
param.set<int>("ticks_max", 5120);
|
2017-10-13 01:50:11 +08:00
|
|
|
return param;
|
|
|
|
}
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
Parameter default_other_param() {
|
|
|
|
Parameter param;
|
|
|
|
param.set<string>("tmpdir", ".");
|
2019-11-10 19:45:57 +08:00
|
|
|
param.set<string>("logger", "");
|
2017-10-14 03:08:49 +08:00
|
|
|
return param;
|
|
|
|
}
|
|
|
|
|
2020-04-20 23:59:47 +08:00
|
|
|
void StockManager::init(const Parameter& baseInfoParam, const Parameter& blockParam,
|
|
|
|
const Parameter& kdataParam, const Parameter& preloadParam,
|
|
|
|
const Parameter& hikyuuParam) {
|
2017-10-26 02:02:32 +08:00
|
|
|
m_baseInfoDriverParam = baseInfoParam;
|
|
|
|
m_blockDriverParam = blockParam;
|
|
|
|
m_kdataDriverParam = kdataParam;
|
|
|
|
m_preloadParam = preloadParam;
|
|
|
|
m_hikyuuParam = hikyuuParam;
|
|
|
|
|
2020-04-20 23:59:47 +08:00
|
|
|
// 创建内部线程池
|
|
|
|
// 不能同过 GlobalInitializer 初始化全局线程池
|
|
|
|
// 原因是 std::thread 无法在 dllmain 中创建使用,会造成死锁
|
2020-12-27 19:11:18 +08:00
|
|
|
initThreadPool();
|
2020-04-20 23:59:47 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
// 获取路径信息
|
|
|
|
m_tmpdir = hikyuuParam.tryGet<string>("tmpdir", ".");
|
|
|
|
m_datadir = hikyuuParam.tryGet<string>("datadir", ".");
|
2019-04-03 22:31:55 +08:00
|
|
|
|
2018-08-19 16:51:10 +08:00
|
|
|
m_stockDict.clear();
|
|
|
|
m_marketInfoDict.clear();
|
|
|
|
m_stockTypeInfo.clear();
|
|
|
|
|
|
|
|
string funcname(" [StockManager::init]");
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
//加载证券基本信息
|
2020-10-29 00:03:25 +08:00
|
|
|
m_baseInfoDriver = DataDriverFactory::getBaseInfoDriver(baseInfoParam);
|
|
|
|
HKU_CHECK(m_baseInfoDriver, "Failed get base info driver!");
|
|
|
|
m_baseInfoDriver->loadBaseInfo();
|
2017-10-13 01:50:11 +08:00
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
//获取板块驱动
|
|
|
|
m_blockDriver = DataDriverFactory::getBlockDriver(blockParam);
|
2017-10-13 01:50:11 +08:00
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
//获取K线数据驱动并预加载指定的数据
|
2018-08-30 02:38:13 +08:00
|
|
|
HKU_INFO("Loading KData...");
|
2018-09-10 01:14:42 +08:00
|
|
|
std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now();
|
2017-10-13 01:50:11 +08:00
|
|
|
|
2020-04-05 02:02:05 +08:00
|
|
|
KDataDriverPtr kdata_driver = DataDriverFactory::getKDataDriver(m_kdataDriverParam);
|
2017-10-26 02:02:32 +08:00
|
|
|
setKDataDriver(kdata_driver);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
2019-11-10 19:45:57 +08:00
|
|
|
// add special Market, for temp csv file
|
2020-04-20 23:59:47 +08:00
|
|
|
m_marketInfoDict["TMP"] =
|
2020-10-31 00:07:18 +08:00
|
|
|
MarketInfo("TMP", "Temp Csv file", "temp load from csv file", "000001", Null<Datetime>(),
|
|
|
|
TimeDelta(0), TimeDelta(0), TimeDelta(0), TimeDelta(0));
|
2017-10-13 01:50:11 +08:00
|
|
|
|
2018-09-10 01:14:42 +08:00
|
|
|
std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_time;
|
2019-06-16 17:56:34 +08:00
|
|
|
HKU_INFO("{:<.2f}s Loaded Data.", sec.count());
|
2017-10-26 02:02:32 +08:00
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
void StockManager::setKDataDriver(const KDataDriverPtr& driver) {
|
2020-11-22 00:12:09 +08:00
|
|
|
HKU_ERROR_IF_RETURN(!driver, void(), "kdata driver is null!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
if (m_kdataDriverParam != driver->getParameter()) {
|
2017-10-26 02:02:32 +08:00
|
|
|
m_kdataDriverParam = driver->getParameter();
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_day = m_preloadParam.tryGet<bool>("day", false);
|
|
|
|
HKU_INFO_IF(preload_day, "Preloading all day kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_week = m_preloadParam.tryGet<bool>("week", false);
|
|
|
|
HKU_INFO_IF(preload_week, "Preloading all week kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_month = m_preloadParam.tryGet<bool>("month", false);
|
|
|
|
HKU_INFO_IF(preload_week, "Preloading all month kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_quarter = m_preloadParam.tryGet<bool>("quarter", false);
|
|
|
|
HKU_INFO_IF(preload_quarter, "Preloading all quarter kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_halfyear = m_preloadParam.tryGet<bool>("halfyear", false);
|
|
|
|
HKU_INFO_IF(preload_halfyear, "Preloading all halfyear kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_year = m_preloadParam.tryGet<bool>("year", false);
|
|
|
|
HKU_INFO_IF(preload_year, "Preloading all year kdata to buffer!");
|
2017-10-12 01:58:08 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_min = m_preloadParam.tryGet<bool>("min", false);
|
|
|
|
HKU_INFO_IF(preload_min, "Preloading all 1 min kdata to buffer!");
|
2017-10-26 02:02:32 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_min5 = m_preloadParam.tryGet<bool>("min5", false);
|
|
|
|
HKU_INFO_IF(preload_min5, "Preloading all 5 min kdata to buffer!");
|
2017-10-26 02:02:32 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_min15 = m_preloadParam.tryGet<bool>("min15", false);
|
|
|
|
HKU_INFO_IF(preload_min15, "Preloading all 15 min kdata to buffer!");
|
2017-10-26 02:02:32 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_min30 = m_preloadParam.tryGet<bool>("min30", false);
|
|
|
|
HKU_INFO_IF(preload_min30, "Preloading all 30 min kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-11-22 00:12:09 +08:00
|
|
|
bool preload_min60 = m_preloadParam.tryGet<bool>("min60", false);
|
|
|
|
HKU_INFO_IF(preload_min60, "Preloading all 60 min kdata to buffer!");
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2020-12-27 19:11:18 +08:00
|
|
|
if (!driver->canParallelLoad()) {
|
|
|
|
for (auto iter = m_stockDict.begin(); iter != m_stockDict.end(); ++iter) {
|
|
|
|
if (iter->second.market() == "TMP")
|
|
|
|
continue;
|
|
|
|
iter->second.setKDataDriver(driver);
|
|
|
|
if (preload_day)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::DAY);
|
|
|
|
if (preload_week)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::WEEK);
|
|
|
|
if (preload_month)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MONTH);
|
|
|
|
if (preload_quarter)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::QUARTER);
|
|
|
|
if (preload_halfyear)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::HALFYEAR);
|
|
|
|
if (preload_year)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::YEAR);
|
|
|
|
if (preload_min)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN);
|
|
|
|
if (preload_min5)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN5);
|
|
|
|
if (preload_min15)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN15);
|
|
|
|
if (preload_min30)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN30);
|
|
|
|
if (preload_min60)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN60);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// 异步并行加载
|
|
|
|
list<std::future<void>> task_list;
|
|
|
|
for (auto iter = m_stockDict.begin(); iter != m_stockDict.end(); ++iter) {
|
|
|
|
if (iter->second.market() == "TMP")
|
|
|
|
continue;
|
|
|
|
Stock stk = iter->second;
|
|
|
|
stk.setKDataDriver(driver);
|
|
|
|
if (preload_day)
|
|
|
|
// iter->second.loadKDataToBuffer(KQuery::DAY);
|
|
|
|
task_list.push_back(addTask([=]() mutable { stk.loadKDataToBuffer(KQuery::DAY); }));
|
|
|
|
if (preload_week)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::WEEK);
|
|
|
|
if (preload_month)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MONTH);
|
|
|
|
if (preload_quarter)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::QUARTER);
|
|
|
|
if (preload_halfyear)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::HALFYEAR);
|
|
|
|
if (preload_year)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::YEAR);
|
|
|
|
if (preload_min)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN);
|
|
|
|
if (preload_min5)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN5);
|
|
|
|
if (preload_min15)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN15);
|
|
|
|
if (preload_min30)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN30);
|
|
|
|
if (preload_min60)
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN60);
|
|
|
|
}
|
|
|
|
for (auto& task : task_list) {
|
|
|
|
task.get();
|
|
|
|
}
|
2017-10-26 02:02:32 +08:00
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string StockManager::tmpdir() const {
|
2017-10-13 01:50:11 +08:00
|
|
|
return m_tmpdir;
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 22:31:55 +08:00
|
|
|
string StockManager::datadir() const {
|
|
|
|
return m_datadir;
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
Stock StockManager::getStock(const string& querystr) const {
|
|
|
|
Stock result;
|
|
|
|
string query_str = querystr;
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(query_str);
|
2016-04-03 00:08:31 +08:00
|
|
|
auto iter = m_stockDict.find(query_str);
|
2020-11-22 00:12:09 +08:00
|
|
|
return (iter != m_stockDict.end()) ? iter->second : result;
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MarketInfo StockManager::getMarketInfo(const string& market) const {
|
|
|
|
string market_tmp = market;
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(market_tmp);
|
2016-04-03 00:08:31 +08:00
|
|
|
auto iter = m_marketInfoDict.find(market_tmp);
|
2020-11-22 00:12:09 +08:00
|
|
|
return (iter != m_marketInfoDict.end()) ? iter->second : Null<MarketInfo>();
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
2020-10-01 22:52:50 +08:00
|
|
|
StockTypeInfo StockManager::getStockTypeInfo(uint32_t type) const {
|
2016-04-03 00:08:31 +08:00
|
|
|
auto iter = m_stockTypeInfo.find(type);
|
2020-11-22 00:12:09 +08:00
|
|
|
return (iter != m_stockTypeInfo.end()) ? iter->second : Null<StockTypeInfo>();
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MarketList StockManager::getAllMarket() const {
|
|
|
|
MarketList result;
|
2016-04-03 00:08:31 +08:00
|
|
|
auto iter = m_marketInfoDict.begin();
|
2019-11-10 19:45:57 +08:00
|
|
|
for (; iter != m_marketInfoDict.end(); ++iter) {
|
2015-01-07 01:26:14 +08:00
|
|
|
result.push_back(iter->first);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-04-03 00:08:31 +08:00
|
|
|
Block StockManager::getBlock(const string& category, const string& name) {
|
2019-11-10 19:45:57 +08:00
|
|
|
return m_blockDriver ? m_blockDriver->getBlock(category, name) : Block();
|
2016-04-03 00:08:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BlockList StockManager::getBlockList(const string& category) {
|
2017-10-14 03:08:49 +08:00
|
|
|
return m_blockDriver ? m_blockDriver->getBlockList(category) : BlockList();
|
2016-04-03 00:08:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BlockList StockManager::getBlockList() {
|
2017-10-14 03:08:49 +08:00
|
|
|
return m_blockDriver ? m_blockDriver->getBlockList() : BlockList();
|
2016-04-03 00:08:31 +08:00
|
|
|
}
|
|
|
|
|
2019-11-10 19:45:57 +08:00
|
|
|
DatetimeList StockManager::getTradingCalendar(const KQuery& query, const string& market) {
|
2020-11-22 00:12:09 +08:00
|
|
|
auto marketinfo = getMarketInfo(market);
|
|
|
|
return getStock(fmt::format("{}{}", marketinfo.market(), marketinfo.code()))
|
|
|
|
.getDatetimeList(query);
|
2016-04-03 00:08:31 +08:00
|
|
|
}
|
|
|
|
|
2020-04-20 23:59:47 +08:00
|
|
|
Stock StockManager::addTempCsvStock(const string& code, const string& day_filename,
|
|
|
|
const string& min_filename, price_t tick, price_t tickValue,
|
|
|
|
int precision, size_t minTradeNumber, size_t maxTradeNumber) {
|
2017-08-01 02:16:51 +08:00
|
|
|
string new_code(code);
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(new_code);
|
2020-04-20 23:59:47 +08:00
|
|
|
Stock result("TMP", new_code, day_filename, STOCKTYPE_TMP, true, Datetime(199901010000),
|
|
|
|
Null<Datetime>(), tick, tickValue, precision, minTradeNumber, maxTradeNumber);
|
2017-09-20 02:29:53 +08:00
|
|
|
|
2019-11-10 19:45:57 +08:00
|
|
|
KDataTempCsvDriver* p = new KDataTempCsvDriver(day_filename, min_filename);
|
2017-07-31 02:26:10 +08:00
|
|
|
result.setKDataDriver(KDataDriverPtr(p));
|
2020-12-27 00:23:58 +08:00
|
|
|
const auto& preload_param = getPreloadParameter();
|
|
|
|
if (preload_param.tryGet<bool>("day", true)) {
|
|
|
|
result.loadKDataToBuffer(KQuery::DAY);
|
|
|
|
}
|
|
|
|
if (preload_param.tryGet<bool>("min", false)) {
|
|
|
|
result.loadKDataToBuffer(KQuery::MIN);
|
|
|
|
}
|
2020-11-22 00:12:09 +08:00
|
|
|
return loadStock(result) ? result : Null<Stock>();
|
2017-07-31 02:26:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StockManager::removeTempCsvStock(const string& code) {
|
|
|
|
string query_str = "TMP" + code;
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(query_str);
|
2017-07-31 02:26:10 +08:00
|
|
|
auto iter = m_stockDict.find(query_str);
|
2019-11-10 19:45:57 +08:00
|
|
|
if (iter != m_stockDict.end()) {
|
2017-07-31 02:26:10 +08:00
|
|
|
m_stockDict.erase(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-15 21:00:00 +08:00
|
|
|
bool StockManager::loadStock(const Stock& stock) {
|
2017-10-09 02:25:02 +08:00
|
|
|
string market_code(stock.market_code());
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(market_code);
|
2020-11-22 00:12:09 +08:00
|
|
|
HKU_ERROR_IF_RETURN(m_stockDict.find(market_code) != m_stockDict.end(), false,
|
|
|
|
"The stock had exist! {}", market_code);
|
2017-10-09 02:25:02 +08:00
|
|
|
m_stockDict[market_code] = stock;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-13 23:29:15 +08:00
|
|
|
bool StockManager::loadMarketInfo(const MarketInfo& marketInfo) {
|
2017-10-09 02:25:02 +08:00
|
|
|
string market = marketInfo.market();
|
2019-08-03 01:44:57 +08:00
|
|
|
to_upper(market);
|
2020-11-22 00:12:09 +08:00
|
|
|
HKU_ERROR_IF_RETURN(m_marketInfoDict.find(market) != m_marketInfoDict.end(), false,
|
|
|
|
"The marketInfo had exist! {}", market);
|
2017-10-09 02:25:02 +08:00
|
|
|
m_marketInfoDict[market] = marketInfo;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-13 23:29:15 +08:00
|
|
|
bool StockManager::loadStockTypeInfo(const StockTypeInfo& stkTypeInfo) {
|
2020-11-22 00:12:09 +08:00
|
|
|
HKU_ERROR_IF_RETURN(m_stockTypeInfo.find(stkTypeInfo.type()) != m_stockTypeInfo.end(), false,
|
|
|
|
"The stockTypeInfo had exist! {}", stkTypeInfo.type());
|
2017-10-09 02:25:02 +08:00
|
|
|
m_stockTypeInfo[stkTypeInfo.type()] = stkTypeInfo;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-10 19:45:57 +08:00
|
|
|
} // namespace hku
|