mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 20:08:26 +08:00
清理兼容python2导致的内部字符串格式问题
This commit is contained in:
parent
1fce078a6a
commit
e3da64e5eb
@ -17,15 +17,8 @@ HKU_API std::ostream& operator<<(std::ostream& os, const MarketInfo& market) {
|
||||
}
|
||||
|
||||
string split(", ");
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
os << "MarketInfo(" << market.market() << split << utf8_to_gb(market.name()) << split
|
||||
<< utf8_to_gb(market.description()) << split << market.code() << split << market.lastDate()
|
||||
<< ")";
|
||||
|
||||
#else
|
||||
os << "MarketInfo(" << market.market() << split << market.name() << split
|
||||
<< market.description() << split << market.code() << split << market.lastDate() << ")";
|
||||
#endif
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,9 @@ HKU_API std::ostream& operator<<(std::ostream& os, const Stock& stock) {
|
||||
string strip(", ");
|
||||
const StockManager& sm = StockManager::instance();
|
||||
StockTypeInfo typeInfo(sm.getStockTypeInfo(stock.type()));
|
||||
os << "Stock(" << stock.market() << strip << stock.code() << strip
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
<< utf8_to_gb(stock.name()) << strip << utf8_to_gb(typeInfo.description()) << strip
|
||||
#else
|
||||
<< stock.name() << strip << typeInfo.description() << strip
|
||||
#endif
|
||||
<< stock.valid() << strip << stock.startDatetime() << strip << stock.lastDatetime() << ")";
|
||||
os << "Stock(" << stock.market() << strip << stock.code() << strip << stock.name() << strip
|
||||
<< typeInfo.description() << strip << stock.valid() << strip << stock.startDatetime()
|
||||
<< strip << stock.lastDatetime() << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,7 @@ HKU_API std::ostream& operator<<(std::ostream& os, const StockTypeInfo& stockTyp
|
||||
}
|
||||
|
||||
string split(", ");
|
||||
os << "StockTypeInfo(" << stockTypeInfo.type() << split
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
<< utf8_to_gb(stockTypeInfo.description()) << split
|
||||
#else
|
||||
<< stockTypeInfo.description() << split
|
||||
#endif
|
||||
os << "StockTypeInfo(" << stockTypeInfo.type() << split << stockTypeInfo.description() << split
|
||||
<< stockTypeInfo.tick() << split << stockTypeInfo.tickValue() << split
|
||||
<< stockTypeInfo.unit() << split << stockTypeInfo.precision() << split
|
||||
<< stockTypeInfo.minTradeNumber() << split << stockTypeInfo.maxTradeNumber() << ")";
|
||||
|
@ -55,26 +55,25 @@ void KDataTempCsvDriver::_get_title_column(const string& line) {
|
||||
string token = m_token_buf[i];
|
||||
to_upper(token);
|
||||
|
||||
if ("DATE" == token || "DATETIME" == token || HKU_STR("日期") == token) {
|
||||
if ("DATE" == token || "DATETIME" == token || "日期" == token) {
|
||||
m_column[DATE] = i;
|
||||
|
||||
} else if ("OPEN" == token || HKU_STR("开盘价") == token) {
|
||||
} else if ("OPEN" == token || "开盘价" == token) {
|
||||
m_column[OPEN] = i;
|
||||
|
||||
} else if ("HIGH" == token || HKU_STR("最高价") == token) {
|
||||
} else if ("HIGH" == token || "最高价" == token) {
|
||||
m_column[HIGH] = i;
|
||||
|
||||
} else if ("LOW" == token || HKU_STR("最低价") == token) {
|
||||
} else if ("LOW" == token || "最低价" == token) {
|
||||
m_column[LOW] = i;
|
||||
|
||||
} else if ("CLOSE" == token || HKU_STR("收盘价") == token) {
|
||||
} else if ("CLOSE" == token || "收盘价" == token) {
|
||||
m_column[CLOSE] = i;
|
||||
|
||||
} else if ("AMOUNT" == token || HKU_STR("成交金额") == token) {
|
||||
} else if ("AMOUNT" == token || "成交金额" == token) {
|
||||
m_column[AMOUNT] = i;
|
||||
|
||||
} else if ("VOLUME" == token || "COUNT" == token || "VOL" == token ||
|
||||
HKU_STR("成交量") == token) {
|
||||
} else if ("VOLUME" == token || "COUNT" == token || "VOL" == token || "成交量" == token) {
|
||||
m_column[VOLUME] = i;
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ bool MySQLBaseInfoDriver::_loadMarketInfo() {
|
||||
}
|
||||
|
||||
try {
|
||||
MarketInfo marketInfo(market, HKU_STR(row[1]), HKU_STR(row[2]), row[3], last_date);
|
||||
MarketInfo marketInfo(market, row[1], row[2], row[3], last_date);
|
||||
sm.loadMarketInfo(marketInfo);
|
||||
} catch (...) {
|
||||
HKU_ERROR("Can't get MarketInfo {}", market);
|
||||
@ -178,7 +178,7 @@ bool MySQLBaseInfoDriver::_loadStockTypeInfo() {
|
||||
uint32 type = boost::lexical_cast<uint32>(row[0]);
|
||||
try {
|
||||
StockTypeInfo stkTypeInfo(
|
||||
type, HKU_STR(row[1]), boost::lexical_cast<price_t>(row[2]),
|
||||
type, row[1], boost::lexical_cast<price_t>(row[2]),
|
||||
boost::lexical_cast<price_t>(row[3]), boost::lexical_cast<int>(row[4]),
|
||||
boost::lexical_cast<size_t>(row[5]), boost::lexical_cast<size_t>(row[6]));
|
||||
sm.loadStockTypeInfo(stkTypeInfo);
|
||||
@ -312,7 +312,7 @@ bool MySQLBaseInfoDriver::_loadStock() {
|
||||
try {
|
||||
Stock stock(market,
|
||||
row[2], // code
|
||||
HKU_STR(row[3]), // name
|
||||
row[3], // name
|
||||
boost::lexical_cast<uint32>(row[4]), // type
|
||||
boost::lexical_cast<bool>(row[5]), // valid;
|
||||
start_date, // startDate
|
||||
|
@ -143,8 +143,6 @@ bool SQLiteBaseInfoDriver::_loadStock() {
|
||||
StockTypeInfo null_stockTypeInfo;
|
||||
StockManager& sm = StockManager::instance();
|
||||
for (auto& r : table) {
|
||||
// HKU_INFO("stock({},{},{},{},{},{},{},{})",
|
||||
// r.stockid,r.marketid,r.code,HKU_STR(r.name),r.type,r.valid,r.startDate,r.endDate);
|
||||
Datetime startDate, endDate;
|
||||
if (r.startDate > r.endDate || r.startDate == 0 || r.endDate == 0) {
|
||||
//日期非法,置为Null<Datetime>
|
||||
@ -158,14 +156,14 @@ bool SQLiteBaseInfoDriver::_loadStock() {
|
||||
|
||||
stockTypeInfo = sm.getStockTypeInfo(r.type);
|
||||
if (stockTypeInfo != null_stockTypeInfo) {
|
||||
stock = Stock(marketDict[r.marketid], r.code, HKU_STR(r.name), r.type, r.valid,
|
||||
startDate, endDate, stockTypeInfo.tick(), stockTypeInfo.tickValue(),
|
||||
stockTypeInfo.precision(), stockTypeInfo.minTradeNumber(),
|
||||
stockTypeInfo.maxTradeNumber());
|
||||
stock =
|
||||
Stock(marketDict[r.marketid], r.code, r.name, r.type, r.valid, startDate, endDate,
|
||||
stockTypeInfo.tick(), stockTypeInfo.tickValue(), stockTypeInfo.precision(),
|
||||
stockTypeInfo.minTradeNumber(), stockTypeInfo.maxTradeNumber());
|
||||
|
||||
} else {
|
||||
stock = Stock(marketDict[r.marketid], r.code, HKU_STR(r.name), r.type, r.valid,
|
||||
startDate, endDate);
|
||||
stock =
|
||||
Stock(marketDict[r.marketid], r.code, r.name, r.type, r.valid, startDate, endDate);
|
||||
}
|
||||
|
||||
if (sm.loadStock(stock)) {
|
||||
|
@ -204,8 +204,7 @@ private:
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
namespace bs = boost::serialization;
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& bs::make_nvp<string>("m_name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_discard);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_result_num);
|
||||
|
@ -21,30 +21,11 @@
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
//防止boost::serialization某些情况不能在独立的命名空间中
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX < 0x03000000)
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) hku::GBToUTF8(s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) hku::UTF8ToGB(s)
|
||||
#endif
|
||||
#else
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) (s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) (s)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::MarketInfo& record, unsigned int version) {
|
||||
hku::string market = record.market();
|
||||
hku::string name = HKU_GB_TO_UTF8(record.name());
|
||||
hku::string description = HKU_GB_TO_UTF8(record.description());
|
||||
hku::string name = record.name();
|
||||
hku::string description = record.description();
|
||||
hku::string code = record.code();
|
||||
hku::uint64 lastDate = record.lastDate().number();
|
||||
ar& BOOST_SERIALIZATION_NVP(market);
|
||||
@ -63,8 +44,7 @@ void load(Archive& ar, hku::MarketInfo& record, unsigned int version) {
|
||||
ar& BOOST_SERIALIZATION_NVP(description);
|
||||
ar& BOOST_SERIALIZATION_NVP(code);
|
||||
ar& BOOST_SERIALIZATION_NVP(lastDate);
|
||||
record = hku::MarketInfo(market, HKU_UTF8_TO_GB(name), HKU_UTF8_TO_GB(description), code,
|
||||
hku::Datetime(lastDate));
|
||||
record = hku::MarketInfo(market, name, description, code, hku::Datetime(lastDate));
|
||||
}
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
@ -20,29 +20,10 @@
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
//防止boost::serialization某些情况不能在独立的命名空间中
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX < 0x03000000)
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) hku::GBToUTF8(s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) hku::UTF8ToGB(s)
|
||||
#endif
|
||||
#else
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) (s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) (s)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::StockTypeInfo& record, unsigned int version) {
|
||||
hku::uint32 type = record.type();
|
||||
hku::string description = HKU_GB_TO_UTF8(record.description());
|
||||
hku::string description = record.description();
|
||||
hku::price_t tick = record.tick();
|
||||
hku::price_t tickValue = record.tickValue();
|
||||
int precision = record.precision();
|
||||
@ -71,8 +52,8 @@ void load(Archive& ar, hku::StockTypeInfo& record, unsigned int version) {
|
||||
ar& BOOST_SERIALIZATION_NVP(precision);
|
||||
ar& BOOST_SERIALIZATION_NVP(minTradeNumber);
|
||||
ar& BOOST_SERIALIZATION_NVP(maxTradeNumber);
|
||||
record = hku::StockTypeInfo(type, HKU_UTF8_TO_GB(description), tick, tickValue, precision,
|
||||
minTradeNumber, maxTradeNumber);
|
||||
record = hku::StockTypeInfo(type, description, tick, tickValue, precision, minTradeNumber,
|
||||
maxTradeNumber);
|
||||
}
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
@ -26,29 +26,10 @@
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
template <class Archive>
|
||||
//防止boost::serialization某些情况不能在独立的命名空间中
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX < 0x03000000)
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) hku::GBToUTF8(s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) hku::UTF8ToGB(s)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifndef HKU_GB_TO_UTF8
|
||||
#define HKU_GB_TO_UTF8(s) (s)
|
||||
#endif
|
||||
|
||||
#ifndef HKU_UTF8_TO_GB
|
||||
#define HKU_UTF8_TO_GB(s) (s)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void save(Archive& ar, const hku::Stock& stock, unsigned int version) {
|
||||
hku::string market_code = stock.market_code();
|
||||
hku::string name = HKU_GB_TO_UTF8(stock.name());
|
||||
hku::string name = stock.name();
|
||||
ar& BOOST_SERIALIZATION_NVP(market_code);
|
||||
ar& BOOST_SERIALIZATION_NVP(name);
|
||||
}
|
||||
|
@ -43,11 +43,7 @@ HKU_API std::ostream& operator<<(std::ostream& os, const PositionRecord& record)
|
||||
if (!stock.isNull()) {
|
||||
market = stock.market();
|
||||
code = stock.code();
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
name = utf8_to_gb(stock.name());
|
||||
#else
|
||||
name = stock.name();
|
||||
#endif
|
||||
} else {
|
||||
precision = stock.precision();
|
||||
}
|
||||
|
@ -1857,16 +1857,11 @@ void TradeManager::tocsv(const string& path) {
|
||||
<< getSystemPartName(record.from) << std::endl;
|
||||
} else {
|
||||
file << record.datetime << sep << record.stock.market_code() << sep
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
<< utf8_to_gb(record.stock.name()) << sep
|
||||
#else
|
||||
<< record.stock.name() << sep
|
||||
#endif
|
||||
<< getBusinessName(record.business) << sep << record.planPrice << sep
|
||||
<< record.realPrice << sep << record.goalPrice << sep << record.number << sep
|
||||
<< record.cost.commission << sep << record.cost.stamptax << sep
|
||||
<< record.cost.transferfee << sep << record.cost.others << sep << record.cost.total
|
||||
<< sep << record.stoploss << sep << record.cash << sep
|
||||
<< record.stock.name() << sep << getBusinessName(record.business) << sep
|
||||
<< record.planPrice << sep << record.realPrice << sep << record.goalPrice << sep
|
||||
<< record.number << sep << record.cost.commission << sep << record.cost.stamptax
|
||||
<< sep << record.cost.transferfee << sep << record.cost.others << sep
|
||||
<< record.cost.total << sep << record.stoploss << sep << record.cash << sep
|
||||
<< getSystemPartName(record.from) << sep;
|
||||
if (BUSINESS_BUY == record.business || BUSINESS_SELL == record.business) {
|
||||
KRecord kdata = record.stock.getKRecordByDate(record.datetime, KQuery::DAY);
|
||||
@ -1895,12 +1890,7 @@ void TradeManager::tocsv(const string& path) {
|
||||
for (; history_iter != m_position_history.end(); ++history_iter) {
|
||||
const PositionRecord& record = *history_iter;
|
||||
file << record.takeDatetime << sep << record.cleanDatetime << sep
|
||||
<< record.stock.market_code() << sep
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
<< utf8_to_gb(record.stock.name()) << sep
|
||||
#else
|
||||
<< record.stock.name() << sep
|
||||
#endif
|
||||
<< record.stock.market_code() << sep << record.stock.name() << sep
|
||||
<< record.totalNumber << sep << record.buyMoney << sep << record.totalCost << sep
|
||||
<< record.sellMoney << sep << record.sellMoney - record.totalCost - record.buyMoney
|
||||
<< sep << record.totalRisk << std::endl;
|
||||
@ -1922,14 +1912,9 @@ void TradeManager::tocsv(const string& path) {
|
||||
for (; position_iter != m_position.end(); ++position_iter) {
|
||||
const PositionRecord& record = position_iter->second;
|
||||
file << record.takeDatetime << sep << record.cleanDatetime << sep
|
||||
<< record.stock.market_code() << sep
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
<< utf8_to_gb(record.stock.name()) << sep
|
||||
#else
|
||||
<< record.stock.name() << sep
|
||||
#endif
|
||||
<< record.number << sep << record.totalNumber << sep << record.buyMoney << sep
|
||||
<< record.totalCost << sep << record.sellMoney << sep << record.totalRisk << sep;
|
||||
<< record.stock.market_code() << sep << record.stock.name() << sep << record.number
|
||||
<< sep << record.totalNumber << sep << record.buyMoney << sep << record.totalCost
|
||||
<< sep << record.sellMoney << sep << record.totalRisk << sep;
|
||||
size_t pos = record.stock.getCount(KQuery::DAY);
|
||||
if (pos != 0) {
|
||||
KRecord krecord = record.stock.getKRecord(pos - 1, KQuery::DAY);
|
||||
|
@ -559,8 +559,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_init_datetime);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_init_cash);
|
||||
@ -587,9 +586,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_init_datetime);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_init_cash);
|
||||
|
@ -118,11 +118,7 @@ HKU_API std::ostream& operator<<(std::ostream& os, const TradeRecord& record) {
|
||||
string market_code(""), name("");
|
||||
if (!stock.isNull()) {
|
||||
market_code = stock.market_code();
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX >= 0x03000000)
|
||||
name = utf8_to_gb(stock.name());
|
||||
#else
|
||||
name = stock.name();
|
||||
#endif
|
||||
}
|
||||
|
||||
string strip(", ");
|
||||
|
@ -130,8 +130,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_query);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_count);
|
||||
@ -142,7 +141,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
ar& boost::serialization::make_nvp("name", m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_query);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_count);
|
||||
|
@ -106,8 +106,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_valid);
|
||||
// m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
|
||||
@ -115,9 +114,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_valid);
|
||||
// m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
|
||||
|
@ -104,8 +104,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
// ev可能多个系统共享,保留m_query可能用于查错
|
||||
ar& BOOST_SERIALIZATION_NVP(m_query);
|
||||
@ -114,9 +113,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_query);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_valid);
|
||||
}
|
||||
|
@ -160,8 +160,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
// m_query、m_tm都是系统运行时临时设置,不需要序列化
|
||||
// ar & BOOST_SERIALIZATION_NVP(m_query);
|
||||
@ -170,9 +169,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
}
|
||||
|
||||
|
@ -153,8 +153,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_se);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_af);
|
||||
@ -163,9 +162,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string name;
|
||||
ar& boost::serialization::make_nvp("name", name);
|
||||
m_name = UTF8ToGB(name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_se);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_af);
|
||||
|
@ -100,16 +100,13 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_count);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_pre_date);
|
||||
@ -104,7 +103,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
ar& boost::serialization::make_nvp("name", m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_count);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_pre_date);
|
||||
|
@ -117,8 +117,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_hold);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
||||
@ -129,7 +128,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
ar& boost::serialization::make_nvp("name", m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_hold);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
||||
|
@ -89,16 +89,13 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string name_str(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("name", name_str);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
// m_kdata都是系统运行时临时设置,不需要序列化
|
||||
// ar & BOOST_SERIALIZATION_NVP(m_kdata);
|
||||
@ -113,7 +112,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
ar& boost::serialization::make_nvp("name", m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
// m_kdata都是系统运行时临时设置,不需要序列化
|
||||
// ar & BOOST_SERIALIZATION_NVP(m_kdata);
|
||||
|
@ -263,8 +263,7 @@ private:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
string tmp_name(GBToUTF8(m_name));
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
|
||||
ar& BOOST_SERIALIZATION_NVP(m_tm);
|
||||
@ -297,9 +296,7 @@ private:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
string tmp_name;
|
||||
ar& boost::serialization::make_nvp("m_name", tmp_name);
|
||||
m_name = UTF8ToGB(tmp_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_name);
|
||||
ar& BOOST_SERIALIZATION_NVP(m_params);
|
||||
|
||||
ar& BOOST_SERIALIZATION_NVP(m_tm);
|
||||
|
@ -32,22 +32,8 @@ std::string HKU_API utf8_to_gb(const std::string& szinput);
|
||||
std::string HKU_API gb_to_utf8(const std::string& szinput);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Windows平台下将字符串由UTF8转换为GB2312编码,
|
||||
* Linux平台下不做任何事
|
||||
* @note 为跨平台,源代码文件必须使用UTF8编码保存,程序中出现的
|
||||
* 中文字符串,应使用HKU_STR,如:std::cout << HKU_STR("中国")
|
||||
*/
|
||||
#if defined(_MSC_VER) && (PY_VERSION_HEX < 0x03000000)
|
||||
//将utf8编码的字符串转换为GB2312编码
|
||||
#define UTF8ToGB utf8_to_gb
|
||||
#define GBToUTF8 gb_to_utf8
|
||||
#define HKU_STR(s) UTF8ToGB(s)
|
||||
#else
|
||||
#define HKU_STR(s) (s)
|
||||
#define GBToUTF8(s) (s)
|
||||
#define UTF8ToGB(s) (s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 四舍五入,ROUND_HALF_EVEN 银行家舍入法
|
||||
|
@ -30,7 +30,6 @@ target("hikyuu")
|
||||
if is_plat("windows") then
|
||||
add_defines("SQLITE_API=__declspec(dllimport)")
|
||||
add_defines("HKU_API=__declspec(dllexport)")
|
||||
add_defines("PY_VERSION_HEX=0x03000000")
|
||||
add_includedirs("../../hikyuu_extern_libs/src/sqlite3")
|
||||
add_deps("sqlite3")
|
||||
if is_mode("release") then
|
||||
|
@ -44,7 +44,8 @@ TEST_CASE("test_StockManager_getStock") {
|
||||
stock = sm.getStock("sh000001");
|
||||
CHECK_EQ(stock.market(), "SH");
|
||||
CHECK_EQ(stock.code(), "000001");
|
||||
CHECK_EQ(stock.name(), HKU_STR("上证指数"));
|
||||
CHECK_EQ(stock.name(), "上证指数");
|
||||
HKU_INFO("{}", stock.toString());
|
||||
CHECK_EQ(stock.type(), 2);
|
||||
CHECK_EQ(stock.valid(), true);
|
||||
CHECK_EQ(stock.startDatetime(), Datetime(199012190000));
|
||||
@ -71,8 +72,8 @@ TEST_CASE("test_StockManager_getMarketInfo") {
|
||||
CHECK_NE(marketInfo, Null<MarketInfo>());
|
||||
CHECK_EQ(marketInfo.market(), "SH");
|
||||
CHECK_EQ(marketInfo.code(), "000001");
|
||||
CHECK_EQ(marketInfo.name(), HKU_STR("上海证劵交易所"));
|
||||
CHECK_EQ(marketInfo.description(), HKU_STR("上海市场"));
|
||||
CHECK_EQ(marketInfo.name(), "上海证劵交易所");
|
||||
CHECK_EQ(marketInfo.description(), "上海市场");
|
||||
CHECK_EQ(marketInfo.lastDate(), Datetime(201112060000L));
|
||||
|
||||
/** @arg 查询已存在的市场,市场简称全部小写 */
|
||||
@ -98,7 +99,7 @@ TEST_CASE("test_StockManager_getStockTypeInfo") {
|
||||
stockTypeInfo = sm.getStockTypeInfo(0);
|
||||
CHECK_NE(stockTypeInfo, Null<StockTypeInfo>());
|
||||
CHECK_EQ(stockTypeInfo.type(), 0);
|
||||
CHECK_EQ(stockTypeInfo.description(), HKU_STR("Block"));
|
||||
CHECK_EQ(stockTypeInfo.description(), "Block");
|
||||
CHECK_EQ(stockTypeInfo.tick(), 100);
|
||||
CHECK_EQ(stockTypeInfo.precision(), 2);
|
||||
CHECK_EQ(stockTypeInfo.minTradeNumber(), 100);
|
||||
@ -108,10 +109,7 @@ TEST_CASE("test_StockManager_getStockTypeInfo") {
|
||||
stockTypeInfo = sm.getStockTypeInfo(8);
|
||||
CHECK_NE(stockTypeInfo, Null<StockTypeInfo>());
|
||||
CHECK_EQ(stockTypeInfo.type(), 8);
|
||||
#if !defined(_MSC_VER)
|
||||
// msvc中文支持不好,此处无法编译
|
||||
CHECK_EQ(stockTypeInfo.description(), HKU_STR("创业板"));
|
||||
#endif
|
||||
CHECK_EQ(stockTypeInfo.description(), "创业板");
|
||||
CHECK_EQ(stockTypeInfo.tick(), 0.01);
|
||||
CHECK_EQ(stockTypeInfo.precision(), 2);
|
||||
CHECK_EQ(stockTypeInfo.minTradeNumber(), 100);
|
||||
@ -121,7 +119,7 @@ TEST_CASE("test_StockManager_getStockTypeInfo") {
|
||||
stockTypeInfo = sm.getStockTypeInfo(2);
|
||||
CHECK_NE(stockTypeInfo, Null<StockTypeInfo>());
|
||||
CHECK_EQ(stockTypeInfo.type(), 2);
|
||||
CHECK_EQ(stockTypeInfo.description(), HKU_STR("指数"));
|
||||
CHECK_EQ(stockTypeInfo.description(), "指数");
|
||||
CHECK_EQ(stockTypeInfo.tick(), 0.001);
|
||||
CHECK_EQ(stockTypeInfo.precision(), 3);
|
||||
CHECK_EQ(stockTypeInfo.minTradeNumber(), 1);
|
||||
|
@ -16,6 +16,10 @@ using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <hikyuu/hikyuu.h>
|
||||
#include <hikyuu/debug.h>
|
||||
using namespace hku;
|
||||
@ -45,6 +49,11 @@ void init_hikyuu_test() {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
#if defined(_WIN32)
|
||||
// Windows 下设置控制台程序输出代码页为 UTF8
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
#endif
|
||||
|
||||
doctest::Context context;
|
||||
|
||||
// !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!!
|
||||
|
@ -33,7 +33,6 @@ target("unit-test")
|
||||
add_defines("HKU_API=__declspec(dllimport)")
|
||||
end
|
||||
|
||||
add_defines("PY_VERSION_HEX=0x03000000")
|
||||
add_defines("TEST_ALL_IN_ONE")
|
||||
|
||||
add_deps("hikyuu")
|
||||
@ -74,7 +73,6 @@ target("small-test")
|
||||
add_defines("HKU_API=__declspec(dllimport)")
|
||||
end
|
||||
|
||||
add_defines("PY_VERSION_HEX=0x03000000")
|
||||
add_defines("TEST_ALL_IN_ONE")
|
||||
|
||||
add_deps("hikyuu")
|
||||
|
Loading…
Reference in New Issue
Block a user