diff --git a/hikyuu_cpp/hikyuu/MarketInfo.cpp b/hikyuu_cpp/hikyuu/MarketInfo.cpp index 33097e73..aca04cbe 100644 --- a/hikyuu_cpp/hikyuu/MarketInfo.cpp +++ b/hikyuu_cpp/hikyuu/MarketInfo.cpp @@ -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; } diff --git a/hikyuu_cpp/hikyuu/Stock.cpp b/hikyuu_cpp/hikyuu/Stock.cpp index 61066064..4cbb6e31 100644 --- a/hikyuu_cpp/hikyuu/Stock.cpp +++ b/hikyuu_cpp/hikyuu/Stock.cpp @@ -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; } diff --git a/hikyuu_cpp/hikyuu/StockTypeInfo.cpp b/hikyuu_cpp/hikyuu/StockTypeInfo.cpp index 4724a38f..dccd2a25 100644 --- a/hikyuu_cpp/hikyuu/StockTypeInfo.cpp +++ b/hikyuu_cpp/hikyuu/StockTypeInfo.cpp @@ -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() << ")"; diff --git a/hikyuu_cpp/hikyuu/data_driver/KDataTempCsvDriver.cpp b/hikyuu_cpp/hikyuu/data_driver/KDataTempCsvDriver.cpp index c1c87c12..dc77e8d7 100644 --- a/hikyuu_cpp/hikyuu/data_driver/KDataTempCsvDriver.cpp +++ b/hikyuu_cpp/hikyuu/data_driver/KDataTempCsvDriver.cpp @@ -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; } } diff --git a/hikyuu_cpp/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.cpp b/hikyuu_cpp/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.cpp index b1bb411b..f590aaf0 100644 --- a/hikyuu_cpp/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.cpp +++ b/hikyuu_cpp/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.cpp @@ -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(row[0]); try { StockTypeInfo stkTypeInfo( - type, HKU_STR(row[1]), boost::lexical_cast(row[2]), + type, row[1], boost::lexical_cast(row[2]), boost::lexical_cast(row[3]), boost::lexical_cast(row[4]), boost::lexical_cast(row[5]), boost::lexical_cast(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(row[4]), // type boost::lexical_cast(row[5]), // valid; start_date, // startDate diff --git a/hikyuu_cpp/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp b/hikyuu_cpp/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp index 6d6d17fe..6bbd9784 100644 --- a/hikyuu_cpp/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp +++ b/hikyuu_cpp/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.cpp @@ -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 @@ -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)) { diff --git a/hikyuu_cpp/hikyuu/indicator/IndicatorImp.h b/hikyuu_cpp/hikyuu/indicator/IndicatorImp.h index e860c183..acf0f6d3 100644 --- a/hikyuu_cpp/hikyuu/indicator/IndicatorImp.h +++ b/hikyuu_cpp/hikyuu/indicator/IndicatorImp.h @@ -204,8 +204,7 @@ private: template void save(Archive& ar, const unsigned int version) const { namespace bs = boost::serialization; - string name_str(GBToUTF8(m_name)); - ar& bs::make_nvp("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); diff --git a/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h b/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h index 89a15b95..4d376e18 100644 --- a/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h +++ b/hikyuu_cpp/hikyuu/serialization/MarketInfo_serialization.h @@ -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 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 diff --git a/hikyuu_cpp/hikyuu/serialization/StockTypeInfo_serialization.h b/hikyuu_cpp/hikyuu/serialization/StockTypeInfo_serialization.h index c6b71d07..2ed76208 100644 --- a/hikyuu_cpp/hikyuu/serialization/StockTypeInfo_serialization.h +++ b/hikyuu_cpp/hikyuu/serialization/StockTypeInfo_serialization.h @@ -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 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 diff --git a/hikyuu_cpp/hikyuu/serialization/Stock_serialization.h b/hikyuu_cpp/hikyuu/serialization/Stock_serialization.h index 8e50ca5c..b46b896f 100644 --- a/hikyuu_cpp/hikyuu/serialization/Stock_serialization.h +++ b/hikyuu_cpp/hikyuu/serialization/Stock_serialization.h @@ -26,29 +26,10 @@ namespace boost { namespace serialization { template -//防止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); } diff --git a/hikyuu_cpp/hikyuu/trade_manage/PositionRecord.cpp b/hikyuu_cpp/hikyuu/trade_manage/PositionRecord.cpp index c3b7c42b..48c43c0d 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/PositionRecord.cpp +++ b/hikyuu_cpp/hikyuu/trade_manage/PositionRecord.cpp @@ -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(); } diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp index 94877f5f..38ea6147 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.cpp @@ -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); diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.h b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.h index a255feec..21f4392b 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeManager.h +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeManager.h @@ -559,8 +559,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_manage/TradeRecord.cpp b/hikyuu_cpp/hikyuu/trade_manage/TradeRecord.cpp index 440e7a3d..5d59765a 100644 --- a/hikyuu_cpp/hikyuu/trade_manage/TradeRecord.cpp +++ b/hikyuu_cpp/hikyuu/trade_manage/TradeRecord.cpp @@ -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(", "); diff --git a/hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h b/hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h index 49752086..04a565a0 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h @@ -130,8 +130,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_sys/condition/ConditionBase.h b/hikyuu_cpp/hikyuu/trade_sys/condition/ConditionBase.h index aa0b9ff6..278e6b8b 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/condition/ConditionBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/condition/ConditionBase.h @@ -106,8 +106,7 @@ private: friend class boost::serialization::access; template 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 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是系统运行时临时设置,不需要序列化 diff --git a/hikyuu_cpp/hikyuu/trade_sys/environment/EnvironmentBase.h b/hikyuu_cpp/hikyuu/trade_sys/environment/EnvironmentBase.h index cbff767d..5e9e8ba9 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/environment/EnvironmentBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/environment/EnvironmentBase.h @@ -104,8 +104,7 @@ private: friend class boost::serialization::access; template 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 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); } diff --git a/hikyuu_cpp/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h b/hikyuu_cpp/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h index c4c29460..921ffb74 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h @@ -160,8 +160,7 @@ private: friend class boost::serialization::access; template 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 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); } diff --git a/hikyuu_cpp/hikyuu/trade_sys/portfolio/Portfolio.h b/hikyuu_cpp/hikyuu/trade_sys/portfolio/Portfolio.h index 2a9353e9..8e94af28 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/portfolio/Portfolio.h +++ b/hikyuu_cpp/hikyuu/trade_sys/portfolio/Portfolio.h @@ -153,8 +153,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h b/hikyuu_cpp/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h index 473e48e4..888fd91a 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h @@ -100,16 +100,13 @@ private: friend class boost::serialization::access; template 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 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); } diff --git a/hikyuu_cpp/hikyuu/trade_sys/selector/SelectorBase.h b/hikyuu_cpp/hikyuu/trade_sys/selector/SelectorBase.h index 60db26c8..8ef32f86 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/selector/SelectorBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/selector/SelectorBase.h @@ -94,8 +94,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.h b/hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.h index bc725675..41f47c38 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.h @@ -117,8 +117,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_sys/slippage/SlippageBase.h b/hikyuu_cpp/hikyuu/trade_sys/slippage/SlippageBase.h index 880df4bb..26115540 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/slippage/SlippageBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/slippage/SlippageBase.h @@ -89,16 +89,13 @@ private: friend class boost::serialization::access; template 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 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); } diff --git a/hikyuu_cpp/hikyuu/trade_sys/stoploss/StoplossBase.h b/hikyuu_cpp/hikyuu/trade_sys/stoploss/StoplossBase.h index 501daade..d30c6de3 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/stoploss/StoplossBase.h +++ b/hikyuu_cpp/hikyuu/trade_sys/stoploss/StoplossBase.h @@ -104,8 +104,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/trade_sys/system/System.h b/hikyuu_cpp/hikyuu/trade_sys/system/System.h index 6dda5e66..24a30682 100644 --- a/hikyuu_cpp/hikyuu/trade_sys/system/System.h +++ b/hikyuu_cpp/hikyuu/trade_sys/system/System.h @@ -263,8 +263,7 @@ private: friend class boost::serialization::access; template 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 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); diff --git a/hikyuu_cpp/hikyuu/utilities/util.h b/hikyuu_cpp/hikyuu/utilities/util.h index a5b46423..c1a0b198 100644 --- a/hikyuu_cpp/hikyuu/utilities/util.h +++ b/hikyuu_cpp/hikyuu/utilities/util.h @@ -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 银行家舍入法 diff --git a/hikyuu_cpp/hikyuu/xmake.lua b/hikyuu_cpp/hikyuu/xmake.lua index 367f16fb..23a4b428 100644 --- a/hikyuu_cpp/hikyuu/xmake.lua +++ b/hikyuu_cpp/hikyuu/xmake.lua @@ -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 diff --git a/hikyuu_cpp/unit_test/hikyuu/hikyuu/test_StockManager.cpp b/hikyuu_cpp/unit_test/hikyuu/hikyuu/test_StockManager.cpp index 2b2e1c1d..e314ef91 100644 --- a/hikyuu_cpp/unit_test/hikyuu/hikyuu/test_StockManager.cpp +++ b/hikyuu_cpp/unit_test/hikyuu/hikyuu/test_StockManager.cpp @@ -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()); 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()); 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()); 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()); 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); diff --git a/hikyuu_cpp/unit_test/hikyuu/test_main.cpp b/hikyuu_cpp/unit_test/hikyuu/test_main.cpp index 352c6b79..895375d1 100644 --- a/hikyuu_cpp/unit_test/hikyuu/test_main.cpp +++ b/hikyuu_cpp/unit_test/hikyuu/test_main.cpp @@ -16,6 +16,10 @@ using namespace boost::filesystem; using namespace std::filesystem; #endif +#if defined(_WIN32) +#include +#endif + #include #include 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 !!! diff --git a/hikyuu_cpp/unit_test/xmake.lua b/hikyuu_cpp/unit_test/xmake.lua index 1b7109d6..6215777f 100644 --- a/hikyuu_cpp/unit_test/xmake.lua +++ b/hikyuu_cpp/unit_test/xmake.lua @@ -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")