Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Apr 5, 2019
1 parent 1acd781 commit b73efaa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 39 deletions.
23 changes: 0 additions & 23 deletions LICENSE.996

This file was deleted.

4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


-----------
Expand Down
22 changes: 14 additions & 8 deletions hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <fstream>
#include <boost/lexical_cast.hpp>
#include "../StockTypeInfo.h"
#include "HistoryFinanceReader.h"

namespace hku {
Expand All @@ -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<string>(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;
}

Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions hikyuu_cpp/hikyuu/data_driver/HistoryFinanceReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef HISTORYFINANCEREADER_H_
#define HISTORYFINANCEREADER_H_

#include "../DataType.h"
#include "../Stock.h"

namespace hku {

Expand All @@ -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; //历史财务信息文件存放目录
Expand Down
2 changes: 1 addition & 1 deletion hikyuu_cpp/unit_test/libs/hikyuu/hikyuu/test_temp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b73efaa

Please sign in to comment.