2015-01-07 01:26:14 +08:00
|
|
|
|
/*
|
|
|
|
|
* StockManager.cpp
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2011-11-9
|
|
|
|
|
* Author: fasiondog
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
#include <boost/chrono.hpp>
|
|
|
|
|
|
|
|
|
|
#include "utilities/util.h"
|
|
|
|
|
#include "StockManager.h"
|
|
|
|
|
#include "data_driver/DataDriverFactory.h"
|
2017-07-31 02:26:10 +08:00
|
|
|
|
#include "data_driver/KDataTempCsvDriver.h"
|
2017-10-13 01:50:11 +08:00
|
|
|
|
#include "data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h"
|
|
|
|
|
#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"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
namespace hku {
|
|
|
|
|
|
|
|
|
|
shared_ptr<StockManager> StockManager::m_sm;
|
|
|
|
|
|
|
|
|
|
StockManager::~StockManager() {
|
|
|
|
|
HKU_TRACE("Quit Hikyuu system!\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StockManager& StockManager::instance() {
|
|
|
|
|
if( !m_sm ) {
|
|
|
|
|
m_sm = shared_ptr<StockManager>(new StockManager());
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
return param;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
|
Parameter default_other_param() {
|
|
|
|
|
Parameter param;
|
|
|
|
|
param.set<string>("tmpdir", ".");
|
|
|
|
|
param.set<string>("logger","");
|
|
|
|
|
return param;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-13 01:50:11 +08:00
|
|
|
|
void StockManager::init(
|
|
|
|
|
const Parameter& baseInfoParam,
|
|
|
|
|
const Parameter& blockParam,
|
|
|
|
|
const Parameter& kdataParam,
|
2017-10-14 03:08:49 +08:00
|
|
|
|
const Parameter& preloadParam,
|
|
|
|
|
const Parameter& hikyuuParam) {
|
2017-10-13 01:50:11 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
m_baseInfoDriverParam = baseInfoParam;
|
|
|
|
|
m_blockDriverParam = blockParam;
|
|
|
|
|
m_kdataDriverParam = kdataParam;
|
|
|
|
|
m_preloadParam = preloadParam;
|
|
|
|
|
m_hikyuuParam = hikyuuParam;
|
|
|
|
|
|
|
|
|
|
m_stockDict.clear();
|
|
|
|
|
m_marketInfoDict.clear();
|
|
|
|
|
m_stockTypeInfo.clear();
|
|
|
|
|
|
|
|
|
|
string funcname(" [StockManager::init]");
|
|
|
|
|
|
2017-10-13 01:50:11 +08:00
|
|
|
|
//初始化注册默认支持的数据驱动
|
|
|
|
|
DataDriverFactory::regBaseInfoDriver(BaseInfoDriverPtr(new SQLiteBaseInfoDriver));
|
|
|
|
|
DataDriverFactory::regBlockDriver(BlockInfoDriverPtr(new QLBlockInfoDriver));
|
|
|
|
|
DataDriverFactory::regKDataDriver(KDataDriverPtr(new TdxKDataDriver));
|
|
|
|
|
DataDriverFactory::regKDataDriver(KDataDriverPtr(new H5KDataDriver));
|
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
|
//获取临时路径信息
|
2017-10-13 01:50:11 +08:00
|
|
|
|
try {
|
|
|
|
|
m_tmpdir = hikyuuParam.get<string>("tmpdir");
|
|
|
|
|
} catch (...) {
|
|
|
|
|
m_tmpdir = "";
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
|
//获取log4cplus配置文件信息
|
2017-10-13 01:50:11 +08:00
|
|
|
|
try {
|
|
|
|
|
string logger = hikyuuParam.get<string>("logger");
|
|
|
|
|
init_logger(logger);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
init_logger("");
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
|
//加载证券基本信息
|
2017-10-13 01:50:11 +08:00
|
|
|
|
BaseInfoDriverPtr base_info = DataDriverFactory::getBaseInfoDriver(baseInfoParam);
|
|
|
|
|
base_info->loadBaseInfo();
|
|
|
|
|
|
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线数据驱动并预加载指定的数据
|
|
|
|
|
HKU_TRACE("Loading KData...");
|
|
|
|
|
boost::chrono::system_clock::time_point start_time = boost::chrono::system_clock::now();
|
2017-10-13 01:50:11 +08:00
|
|
|
|
|
2017-10-14 03:08:49 +08:00
|
|
|
|
KDataDriverPtr kdata_driver = DataDriverFactory::getKDataDriver(kdataParam);
|
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
setKDataDriver(kdata_driver);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
//add special Market, for temp csv file
|
|
|
|
|
m_marketInfoDict["TMP"] = MarketInfo("TMP", "Temp Csv file",
|
|
|
|
|
"temp load from csv file",
|
|
|
|
|
"000001", Null<Datetime>());
|
2017-10-13 01:50:11 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
boost::chrono::duration<double> sec = boost::chrono::system_clock::now() - start_time;
|
|
|
|
|
HKU_TRACE(sec << " Loaded Data.");
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
void StockManager::setKDataDriver(const KDataDriverPtr& driver) {
|
|
|
|
|
string funcname(" [StockManager::setKDataDriver]");
|
|
|
|
|
if (!driver) {
|
|
|
|
|
HKU_ERROR("kdata driver is null!" << funcname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (m_kdataDriverParam == driver->getParameter()) {
|
2017-10-13 01:50:11 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
} else {
|
|
|
|
|
m_kdataDriverParam = driver->getParameter();
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_day = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_day = m_preloadParam.get<bool>("day");
|
|
|
|
|
if (preload_day)
|
|
|
|
|
HKU_TRACE("Preload all day kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_day = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_week = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_week = m_preloadParam.get<bool>("week");
|
|
|
|
|
if (preload_week)
|
|
|
|
|
HKU_TRACE("Preload all week kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_week = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_month = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_month = m_preloadParam.get<bool>("month");
|
|
|
|
|
if (preload_week)
|
|
|
|
|
HKU_TRACE("Preload all month kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_month = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_quarter = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_quarter = m_preloadParam.get<bool>("quarter");
|
|
|
|
|
if (preload_quarter)
|
|
|
|
|
HKU_TRACE("Preload all quarter kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_quarter = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_halfyear = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_halfyear = m_preloadParam.get<bool>("halfyear");
|
|
|
|
|
if (preload_halfyear)
|
|
|
|
|
HKU_TRACE("Preload all halfyear kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_halfyear = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_year = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_year = m_preloadParam.get<bool>("year");
|
|
|
|
|
if (preload_year)
|
|
|
|
|
HKU_TRACE("Preload all year kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_year = false;
|
|
|
|
|
}
|
2017-10-12 01:58:08 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_min = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_min = m_preloadParam.get<bool>("min");
|
|
|
|
|
if (preload_min)
|
|
|
|
|
HKU_TRACE("Preload all 1 min kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_min = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool preload_min5 = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_min5 = m_preloadParam.get<bool>("min5");
|
|
|
|
|
if (preload_min5)
|
|
|
|
|
HKU_TRACE("Preload all 5 min kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_min5 = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool preload_min15 = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_min15 = m_preloadParam.get<bool>("min15");
|
|
|
|
|
if (preload_min15)
|
|
|
|
|
HKU_TRACE("Preload all 15 min kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_min15 = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool preload_min30 = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_min30 = m_preloadParam.get<bool>("min30");
|
|
|
|
|
if (preload_min30)
|
|
|
|
|
HKU_TRACE("Preload all 30 min kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_min30 = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
bool preload_min60 = false;
|
|
|
|
|
try {
|
|
|
|
|
preload_min60 = m_preloadParam.get<bool>("min60");
|
|
|
|
|
if (preload_min60)
|
|
|
|
|
HKU_TRACE("Preload all 60 min kdata to buffer!" << funcname);
|
|
|
|
|
} catch(...) {
|
|
|
|
|
preload_min60 = false;
|
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
for(auto iter = m_stockDict.begin(); iter != m_stockDict.end(); ++iter) {
|
|
|
|
|
if (iter->second.market() == "TMP")
|
|
|
|
|
continue;
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
iter->second.setKDataDriver(driver);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_day)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::DAY);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_week)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::WEEK);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_month)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MONTH);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_quarter)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::QUARTER);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_halfyear)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::HALFYEAR);
|
2017-10-14 03:08:49 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_year)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::YEAR);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
if (preload_min)
|
|
|
|
|
iter->second.loadKDataToBuffer(KQuery::MIN);
|
2017-07-31 02:26:10 +08:00
|
|
|
|
|
2017-10-26 02:02:32 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stock StockManager::getStock(const string& querystr) const {
|
|
|
|
|
Stock result;
|
|
|
|
|
string query_str = querystr;
|
|
|
|
|
boost::to_upper(query_str);
|
2016-04-03 00:08:31 +08:00
|
|
|
|
auto iter = m_stockDict.find(query_str);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
if(iter != m_stockDict.end()) {
|
|
|
|
|
return iter->second;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MarketInfo StockManager::getMarketInfo(const string& market) const {
|
|
|
|
|
string market_tmp = market;
|
|
|
|
|
boost::to_upper(market_tmp);
|
2016-04-03 00:08:31 +08:00
|
|
|
|
auto iter = m_marketInfoDict.find(market_tmp);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
if(iter != m_marketInfoDict.end()) {
|
|
|
|
|
return iter->second;
|
|
|
|
|
}
|
|
|
|
|
return Null<MarketInfo>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StockTypeInfo StockManager::getStockTypeInfo(hku_uint32 type) const {
|
2016-04-03 00:08:31 +08:00
|
|
|
|
auto iter = m_stockTypeInfo.find(type);
|
2015-01-07 01:26:14 +08:00
|
|
|
|
if( iter != m_stockTypeInfo.end() ){
|
|
|
|
|
return iter->second;
|
|
|
|
|
}
|
|
|
|
|
return Null<StockTypeInfo>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MarketList StockManager::getAllMarket() const {
|
|
|
|
|
MarketList result;
|
2016-04-03 00:08:31 +08:00
|
|
|
|
auto iter = m_marketInfoDict.begin();
|
2015-01-07 01:26:14 +08:00
|
|
|
|
for(; iter != m_marketInfoDict.end(); ++iter) {
|
|
|
|
|
result.push_back(iter->first);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-04-03 00:08:31 +08:00
|
|
|
|
Block StockManager::getBlock(const string& category, const string& name) {
|
2017-10-14 03:08:49 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DatetimeList StockManager::
|
|
|
|
|
getTradingCalendar(const KQuery& query, const string& market) {
|
|
|
|
|
Stock stock = getStock("SH000001");
|
|
|
|
|
size_t start_ix = 0, end_ix = 0;
|
|
|
|
|
DatetimeList result;
|
|
|
|
|
if (stock.getIndexRange(query, start_ix, end_ix)) {
|
2016-04-11 23:48:47 +08:00
|
|
|
|
result = stock.getDatetimeList(start_ix, end_ix, query.kType());
|
2016-04-03 00:08:31 +08:00
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-31 02:26:10 +08:00
|
|
|
|
Stock StockManager::addTempCsvStock(
|
|
|
|
|
const string& code,
|
|
|
|
|
const string& day_filename,
|
|
|
|
|
const string& min_filename,
|
2017-09-20 02:29:53 +08:00
|
|
|
|
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);
|
|
|
|
|
boost::to_upper(new_code);
|
2017-09-20 02:29:53 +08:00
|
|
|
|
Stock result("TMP", new_code, day_filename, STOCKTYPE_TMP, true,
|
|
|
|
|
Datetime(199901010000), Null<Datetime>(),
|
|
|
|
|
tick, tickValue, precision, minTradeNumber, maxTradeNumber);
|
|
|
|
|
|
2017-07-31 02:26:10 +08:00
|
|
|
|
KDataTempCsvDriver *p = new KDataTempCsvDriver(day_filename, min_filename);
|
|
|
|
|
result.setKDataDriver(KDataDriverPtr(p));
|
|
|
|
|
result.loadKDataToBuffer(KQuery::DAY);
|
|
|
|
|
result.loadKDataToBuffer(KQuery::MIN);
|
2017-09-20 02:29:53 +08:00
|
|
|
|
|
|
|
|
|
if (!addStock(result)){
|
|
|
|
|
//加入失败,返回Null<Stock>
|
|
|
|
|
return Null<Stock>();
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-31 02:26:10 +08:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StockManager::removeTempCsvStock(const string& code) {
|
|
|
|
|
string query_str = "TMP" + code;
|
|
|
|
|
boost::to_upper(query_str);
|
|
|
|
|
auto iter = m_stockDict.find(query_str);
|
|
|
|
|
if(iter != m_stockDict.end()) {
|
|
|
|
|
m_stockDict.erase(iter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 02:25:02 +08:00
|
|
|
|
|
|
|
|
|
bool StockManager::addStock(const Stock& stock) {
|
|
|
|
|
string market_code(stock.market_code());
|
|
|
|
|
boost::to_upper(market_code);
|
|
|
|
|
if(m_stockDict.find(market_code) != m_stockDict.end()) {
|
|
|
|
|
HKU_ERROR("The stock had exist! "
|
|
|
|
|
<< market_code
|
|
|
|
|
<< " [StockManager::addStock]");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_stockDict[market_code] = stock;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool StockManager::addMarketInfo(const MarketInfo& marketInfo) {
|
|
|
|
|
string market = marketInfo.market();
|
|
|
|
|
boost::to_upper(market);
|
|
|
|
|
if (m_marketInfoDict.find(market) != m_marketInfoDict.end()) {
|
|
|
|
|
HKU_ERROR("The marketInfo had exist! "
|
|
|
|
|
<< market
|
|
|
|
|
<< " [StockManager::addMarketInfo]");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_marketInfoDict[market] = marketInfo;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StockManager::addStockTypeInfo(const StockTypeInfo& stkTypeInfo) {
|
|
|
|
|
if (m_stockTypeInfo.find(stkTypeInfo.type()) != m_stockTypeInfo.end()) {
|
|
|
|
|
HKU_ERROR("The stockTypeInfo had exist! "
|
|
|
|
|
<< stkTypeInfo.type()
|
|
|
|
|
<< " [StockManager::addStockTypeInfo]");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_stockTypeInfo[stkTypeInfo.type()] = stkTypeInfo;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
|
} /* namespace */
|