mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 10:59:43 +08:00
refactor crypto support
This commit is contained in:
parent
1632d7ae2d
commit
a729dc9f37
@ -93,10 +93,7 @@ Stock::Data::Data(const string& market, const string& code, const string& name,
|
||||
}
|
||||
|
||||
to_upper(m_market);
|
||||
if (m_type == STOCKTYPE_CRYPTO)
|
||||
m_market_code = m_market + "/" + m_code;
|
||||
else
|
||||
m_market_code = m_market + m_code;
|
||||
m_market_code = marketCode();
|
||||
|
||||
const auto& ktype_list = KQuery::getAllKType();
|
||||
for (const auto& ktype : ktype_list) {
|
||||
@ -105,6 +102,12 @@ Stock::Data::Data(const string& market, const string& code, const string& name,
|
||||
}
|
||||
}
|
||||
|
||||
string Stock::Data::marketCode() const {
|
||||
if (m_type == STOCKTYPE_CRYPTO)
|
||||
return m_market + "/" + m_code;
|
||||
return m_market + m_code;
|
||||
}
|
||||
|
||||
Stock::Data::~Data() {
|
||||
for (auto iter = pKData.begin(); iter != pKData.end(); ++iter) {
|
||||
if (iter->second) {
|
||||
|
@ -259,7 +259,7 @@ struct HKU_API Stock::Data {
|
||||
Data(const string& market, const string& code, const string& name, uint32_t type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate, price_t tick, price_t tickValue,
|
||||
int precision, double minTradeNumber, double maxTradeNumber);
|
||||
|
||||
string marketCode() const;
|
||||
virtual ~Data();
|
||||
};
|
||||
|
||||
|
@ -469,19 +469,14 @@ void StockManager::loadAllStocks() {
|
||||
} catch (...) {
|
||||
endDate = Null<Datetime>();
|
||||
}
|
||||
string market_code;
|
||||
if (info.type == STOCKTYPE_CRYPTO)
|
||||
market_code = format("{}/{}", info.market, info.code);
|
||||
else
|
||||
market_code = format("{}{}", info.market, info.code);
|
||||
Stock _stock(info.market, info.code, info.name, info.type, info.valid, startDate,
|
||||
endDate, info.tick, info.tickValue, info.precision, info.minTradeNumber,
|
||||
info.maxTradeNumber);
|
||||
string market_code = _stock.market_code();;
|
||||
to_upper(market_code);
|
||||
auto iter = m_stockDict.find(market_code);
|
||||
if (iter == m_stockDict.end()) {
|
||||
Stock stock(info.market, info.code, info.name, info.type, info.valid, startDate,
|
||||
endDate, info.tick, info.tickValue, info.precision, info.minTradeNumber,
|
||||
info.maxTradeNumber);
|
||||
m_stockDict[market_code] = stock;
|
||||
|
||||
m_stockDict[market_code] = _stock;
|
||||
} else {
|
||||
Stock& stock = iter->second;
|
||||
if (!stock.m_data) {
|
||||
|
Loading…
Reference in New Issue
Block a user