From b73efaad90c01b44b083e81c6e053678c899c511 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Fri, 5 Apr 2019 17:43:35 +0800 Subject: [PATCH] update --- LICENSE.996 | 23 ------------------- README.rst | 4 ---- .../data_driver/HistoryFinanceReader.cpp | 22 +++++++++++------- .../hikyuu/data_driver/HistoryFinanceReader.h | 5 ++-- .../libs/hikyuu/hikyuu/test_temp.cpp | 2 +- 5 files changed, 17 insertions(+), 39 deletions(-) delete mode 100644 LICENSE.996 diff --git a/LICENSE.996 b/LICENSE.996 deleted file mode 100644 index 7f417044e..000000000 --- a/LICENSE.996 +++ /dev/null @@ -1,23 +0,0 @@ -版权所有(c)2019 fasiondog - -反996许可证版本1.0 - -在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下 -统称为“授权作品”)的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但 -不限于使用、复制,修改,衍生利用、散布,发布和再许可: - -1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修 -改。 -2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地 -(以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖 -区没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国 -际劳工标准的核心公约。 -3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意直接或 -间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利或补救 -措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该等个人或法人实体也不得以任何方法 -限制其雇员或独立承包人向版权持有人或监督许可证合规情况的有关当局报告或投诉上述违反许可证的行为 -的权利。 - -该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵 -权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或 -本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。 \ No newline at end of file diff --git a/README.rst b/README.rst index 6cb691174..0efe226e0 100644 --- a/README.rst +++ b/README.rst @@ -9,10 +9,6 @@ .. image:: https://img.shields.io/github/license/mashape/apistatus.svg :target: https://github.com/fasiondog/hikyuu/blob/master/LICENSE.txt :alt: GitHub - -.. image:: https://img.shields.io/badge/link-996.icu-red.svg - :target: https://996.icu - :alt: 996.icu ----------- diff --git a/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.cpp b/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.cpp index 022fdb811..b65ebd9f1 100644 --- a/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.cpp +++ b/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.cpp @@ -9,6 +9,7 @@ #include #include +#include "../StockTypeInfo.h" #include "HistoryFinanceReader.h" namespace hku { @@ -23,16 +24,20 @@ HistoryFinanceReader::~HistoryFinanceReader() { } PriceList HistoryFinanceReader -::getHistoryFinanceInfo(Datetime date, - const string& market, const string& code) { +::getHistoryFinanceInfo(Datetime date, const Stock& stock) { PriceList result; + if (stock.type() != STOCKTYPE_A) { + return result; + } + string filename(m_dir + "/gpcw" + boost::lexical_cast(date.number() / 10000) + ".dat"); std::cout << filename << std::endl; std::ifstream file(filename.c_str(), std::ifstream::binary); if( !file ) { - std::cout << "error!" << std::endl; + HKU_INFO("Can't found " << filename + << " [HistoryFinanceReader::getHistoryFinanceInfo]"); return result; } @@ -53,19 +58,20 @@ ::getHistoryFinanceInfo(Datetime date, file.read(stock_item_buf, 11); memcpy(stock_code, stock_item_buf, 6); stock_code[6] = '\0'; - if (string(stock_code) == code) { + if (string(stock_code) == stock.code()) { memcpy(&address, stock_item_buf + 7, 4); break; } } - float result_buffer[500]; + const int MAX_COL_NUM = 350; + float result_buffer[MAX_COL_NUM]; if (address != 0) { std::cout << address << std::endl; int report_fields_count = int(report_size / 4); - if (report_fields_count >= 500) { - HKU_WARN("Over buffer! [HistoryFinanceReader::getHistoryFinanceInfo]"); - report_fields_count = 500; + if (report_fields_count >= MAX_COL_NUM) { + HKU_WARN("Over MAX_COL_NUM! [HistoryFinanceReader::getHistoryFinanceInfo]"); + report_fields_count = MAX_COL_NUM; report_size = report_fields_count * 4; } file.seekg(address); diff --git a/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.h b/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.h index ee79ac192..339ecc838 100644 --- a/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.h +++ b/hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.h @@ -10,7 +10,7 @@ #ifndef HISTORYFINANCEREADER_H_ #define HISTORYFINANCEREADER_H_ -#include "../DataType.h" +#include "../Stock.h" namespace hku { @@ -24,8 +24,7 @@ class HKU_API HistoryFinanceReader { HistoryFinanceReader(const string& dir); virtual ~HistoryFinanceReader(); - PriceList getHistoryFinanceInfo(Datetime date, - const string& market, const string& code); + PriceList getHistoryFinanceInfo(Datetime date, const Stock& stock); private: string m_dir; //历史财务信息文件存放目录 diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/hikyuu/test_temp.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/hikyuu/test_temp.cpp index 5163efc47..4ba8519f0 100644 --- a/hikyuu_cpp/unit_test/libs/hikyuu/hikyuu/test_temp.cpp +++ b/hikyuu_cpp/unit_test/libs/hikyuu/hikyuu/test_temp.cpp @@ -17,7 +17,7 @@ BOOST_AUTO_TEST_CASE( test_temp ) { std::cout << "**************************" << std::endl; HistoryFinanceReader rd = HistoryFinanceReader(dirname); - PriceList result = rd.getHistoryFinanceInfo(Datetime(201109300000), "SH", "600000"); + PriceList result = rd.getHistoryFinanceInfo(Datetime(201109300000), getStock("sh600000")); BOOST_CHECK(result.size() == 286); float x = 0xf8f8f8f8;