mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-29 18:39:10 +08:00
int64/int32/int8和c++11保持一致改为int64_t/int32_t/int8_t
This commit is contained in:
parent
b5e2cf89cb
commit
3fe0519bc1
@ -18,11 +18,9 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
//#include <boost/shared_ptr.hpp>
|
||||
//#include <boost/make_shared.hpp>
|
||||
//#include <boost/enable_shared_from_this.hpp>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string_view>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <cmath>
|
||||
@ -52,28 +50,28 @@ namespace hku {
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if !defined(int64)
|
||||
typedef long long int64;
|
||||
#if !defined(int64_t)
|
||||
typedef long long int64_t;
|
||||
#endif
|
||||
|
||||
#if !defined(uint64)
|
||||
typedef unsigned long long uint64;
|
||||
#if !defined(uint64_t)
|
||||
typedef unsigned long long uint64_t;
|
||||
#endif
|
||||
|
||||
#if !defined(int32)
|
||||
typedef int int32;
|
||||
#if !defined(int32_t)
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
|
||||
#if !defined(uint32)
|
||||
typedef unsigned uint32;
|
||||
#if !defined(uint32_t)
|
||||
typedef unsigned uint32_t;
|
||||
#endif
|
||||
|
||||
#if !defined(int8)
|
||||
typedef char int8;
|
||||
#if !defined(int8_t)
|
||||
typedef char int8_t;
|
||||
#endif
|
||||
|
||||
#if !defined(uint8)
|
||||
typedef unsigned char uint8;
|
||||
#if !defined(uint8_t)
|
||||
typedef unsigned char uint8_t;
|
||||
#endif
|
||||
|
||||
#ifndef MAX_DOUBLE
|
||||
|
@ -100,7 +100,7 @@ KData HKU_API getKData(const string& market_code, const Datetime& start, const D
|
||||
return StockManager::instance().getStock(market_code).getKData(query);
|
||||
}
|
||||
|
||||
KData HKU_API getKData(const string& market_code, int64 start, int64 end, KQuery::KType ktype,
|
||||
KData HKU_API getKData(const string& market_code, int64_t start, int64_t end, KQuery::KType ktype,
|
||||
KQuery::RecoverType recoverType) {
|
||||
KQuery query(start, end, ktype, recoverType);
|
||||
return StockManager::instance().getStock(market_code).getKData(query);
|
||||
|
@ -138,7 +138,7 @@ KData HKU_API getKData(const string& market_code, const Datetime& start = Dateti
|
||||
* @param recoverType 复权类型
|
||||
* @ingroup StockManage
|
||||
*/
|
||||
KData HKU_API getKData(const string& market_code, int64 start = 0, int64 end = Null<int64>(),
|
||||
KData HKU_API getKData(const string& market_code, int64_t start = 0, int64_t end = Null<int64_t>(),
|
||||
KQuery::KType ktype = KQuery::DAY,
|
||||
KQuery::RecoverType recoverType = KQuery::NO_RECOVER);
|
||||
|
||||
|
@ -29,9 +29,10 @@ const string KQuery::HOUR12("HOUR12");
|
||||
// const string KQuery::INVALID_KTYPE("Z");
|
||||
|
||||
KQuery::KQuery(Datetime start, Datetime end, KType ktype, RecoverType recoverType)
|
||||
: m_start(start == Null<Datetime>() ? (int64)start.number()
|
||||
: (int64)(start.number() * 100 + start.second())),
|
||||
m_end(end == Null<Datetime>() ? (int64)end.number() : (int64)(end.number() * 100 + end.second())),
|
||||
: m_start(start == Null<Datetime>() ? (int64_t)start.number()
|
||||
: (int64_t)(start.number() * 100 + start.second())),
|
||||
m_end(end == Null<Datetime>() ? (int64_t)end.number()
|
||||
: (int64_t)(end.number() * 100 + end.second())),
|
||||
m_queryType(KQuery::DATE),
|
||||
m_dataType(ktype),
|
||||
m_recoverType(recoverType) {
|
||||
@ -39,21 +40,21 @@ KQuery::KQuery(Datetime start, Datetime end, KType ktype, RecoverType recoverTyp
|
||||
}
|
||||
|
||||
Datetime KQuery::startDatetime() const {
|
||||
if (m_queryType != DATE || (uint64)m_start == Null<uint64>()) {
|
||||
if (m_queryType != DATE || (uint64_t)m_start == Null<uint64_t>()) {
|
||||
return Null<Datetime>();
|
||||
}
|
||||
|
||||
uint64 number = (uint64)(m_start / 100);
|
||||
uint64_t number = (uint64_t)(m_start / 100);
|
||||
Datetime d(number);
|
||||
return Datetime(d.year(), d.month(), d.day(), d.hour(), d.minute(), m_start - number * 100);
|
||||
}
|
||||
|
||||
Datetime KQuery::endDatetime() const {
|
||||
if (m_queryType != DATE || (uint64)m_end == Null<uint64>()) {
|
||||
if (m_queryType != DATE || (uint64_t)m_end == Null<uint64_t>()) {
|
||||
return Null<Datetime>();
|
||||
}
|
||||
|
||||
uint64 number = (uint64)(m_end / 100);
|
||||
uint64_t number = (uint64_t)(m_end / 100);
|
||||
Datetime d(number);
|
||||
return Datetime(d.year(), d.month(), d.day(), d.hour(), d.minute(), m_end - number * 100);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
/** 默认构造,按索引方式查询全部日线数据,不复权 */
|
||||
KQuery()
|
||||
: m_start(0),
|
||||
m_end(Null<int64>()),
|
||||
m_end(Null<int64_t>()),
|
||||
m_queryType(INDEX),
|
||||
m_dataType(DAY),
|
||||
m_recoverType(NO_RECOVER){};
|
||||
@ -98,7 +98,7 @@ public:
|
||||
* @param recoverType 复权类型
|
||||
* @param queryType 默认按索引方式查询
|
||||
*/
|
||||
KQuery(int64 start, int64 end = Null<int64>(), KType dataType = DAY,
|
||||
KQuery(int64_t start, int64_t end = Null<int64_t>(), KType dataType = DAY,
|
||||
RecoverType recoverType = NO_RECOVER, QueryType queryType = INDEX)
|
||||
: m_start(start),
|
||||
m_end(end),
|
||||
@ -119,17 +119,17 @@ public:
|
||||
RecoverType recoverType = NO_RECOVER);
|
||||
|
||||
/**
|
||||
* 按索引方式查询时,返回指定的起始索引,否则返回Null<int64>()
|
||||
* 按索引方式查询时,返回指定的起始索引,否则返回Null<int64_t>()
|
||||
*/
|
||||
int64 start() const {
|
||||
return m_queryType != INDEX ? Null<int64>() : m_start;
|
||||
int64_t start() const {
|
||||
return m_queryType != INDEX ? Null<int64_t>() : m_start;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按索引方式查询时,返回指定的结束索引,否则返回Null<int64>()
|
||||
* 按索引方式查询时,返回指定的结束索引,否则返回Null<int64_t>()
|
||||
*/
|
||||
int64 end() const {
|
||||
return m_queryType != INDEX ? Null<int64>() : m_end;
|
||||
int64_t end() const {
|
||||
return m_queryType != INDEX ? Null<int64_t>() : m_end;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,8 +177,8 @@ public:
|
||||
static RecoverType getRecoverTypeEnum(const string&);
|
||||
|
||||
private:
|
||||
int64 m_start;
|
||||
int64 m_end;
|
||||
int64_t m_start;
|
||||
int64_t m_end;
|
||||
QueryType m_queryType;
|
||||
KType m_dataType;
|
||||
RecoverType m_recoverType;
|
||||
@ -193,11 +193,11 @@ private:
|
||||
* @see KQuery
|
||||
* @ingroup StockManage*
|
||||
*/
|
||||
KQuery HKU_API KQueryByIndex(int64 start = 0, int64 end = Null<int64>(),
|
||||
KQuery HKU_API KQueryByIndex(int64_t start = 0, int64_t end = Null<int64_t>(),
|
||||
KQuery::KType dataType = KQuery::DAY,
|
||||
KQuery::RecoverType recoverType = KQuery::NO_RECOVER);
|
||||
|
||||
inline KQuery KQueryByIndex(int64 start, int64 end, KQuery::KType dataType,
|
||||
inline KQuery KQueryByIndex(int64_t start, int64_t end, KQuery::KType dataType,
|
||||
KQuery::RecoverType recoverType) {
|
||||
return KQuery(start, end, dataType, recoverType, KQuery::INDEX);
|
||||
}
|
||||
@ -259,7 +259,7 @@ class Null<KQuery> {
|
||||
public:
|
||||
Null() {}
|
||||
operator KQuery() {
|
||||
return KQuery(Null<int64>(), Null<int64>(),
|
||||
return KQuery(Null<int64_t>(), Null<int64_t>(),
|
||||
"", // KQuery::INVALID_KTYPE,
|
||||
KQuery::INVALID_RECOVER_TYPE, KQuery::INVALID);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ const string Stock::default_market;
|
||||
const string Stock::default_code;
|
||||
const string Stock::default_market_code;
|
||||
const string Stock::default_name;
|
||||
const uint32 Stock::default_type = Null<uint32>();
|
||||
const uint32_t Stock::default_type = Null<uint32_t>();
|
||||
const bool Stock::default_valid = false;
|
||||
const Datetime Stock::default_startDate; // = Null<Datetime>();
|
||||
const Datetime Stock::default_lastDate; // = Null<Datetime>();
|
||||
@ -69,7 +69,7 @@ Stock::Data::Data()
|
||||
}*/
|
||||
}
|
||||
|
||||
Stock::Data::Data(const string& market, const string& code, const string& name, uint32 type,
|
||||
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, size_t minTradeNumber, size_t maxTradeNumber)
|
||||
: m_market(market),
|
||||
@ -125,16 +125,16 @@ Stock::Stock(const string& market, const string& code, const string& name) {
|
||||
default_precision, default_minTradeNumber, default_maxTradeNumber));
|
||||
}
|
||||
|
||||
Stock::Stock(const string& market, const string& code, const string& name, uint32 type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate) {
|
||||
Stock::Stock(const string& market, const string& code, const string& name, uint32_t type,
|
||||
bool valid, const Datetime& startDate, const Datetime& lastDate) {
|
||||
m_data = shared_ptr<Data>(new Data(market, code, name, type, valid, startDate, lastDate,
|
||||
default_tick, default_tickValue, default_precision,
|
||||
default_minTradeNumber, default_maxTradeNumber));
|
||||
}
|
||||
|
||||
Stock::Stock(const string& market, const string& code, const string& name, uint32 type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate, price_t tick, price_t tickValue,
|
||||
int precision, size_t minTradeNumber, size_t maxTradeNumber)
|
||||
Stock::Stock(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, size_t minTradeNumber, size_t maxTradeNumber)
|
||||
: m_data(make_shared<Data>(market, code, name, type, valid, startDate, lastDate, tick, tickValue,
|
||||
precision, minTradeNumber, maxTradeNumber)) {}
|
||||
|
||||
@ -170,7 +170,7 @@ const string& Stock::name() const {
|
||||
return m_data ? m_data->m_name : default_name;
|
||||
}
|
||||
|
||||
uint32 Stock::type() const {
|
||||
uint32_t Stock::type() const {
|
||||
return m_data ? m_data->m_type : default_type;
|
||||
}
|
||||
|
||||
@ -269,6 +269,8 @@ void Stock::loadKDataToBuffer(KQuery::KType inkType) {
|
||||
releaseKDataBuffer(kType);
|
||||
m_data->pKData[kType] = make_shared<KRecordList>();
|
||||
if (m_kdataDriver) {
|
||||
//*(m_data->pKData[kType]) =
|
||||
// m_kdataDriver->getKRecordList(m_data->m_market, m_data->m_code, KQuery(0));
|
||||
m_kdataDriver->loadKData(m_data->m_market, m_data->m_code, kType, 0, Null<size_t>(),
|
||||
m_data->pKData[kType]);
|
||||
}
|
||||
@ -393,7 +395,7 @@ bool Stock::_getIndexRangeByIndex(const KQuery& query, size_t& out_start, size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
int64 startix, endix;
|
||||
int64_t startix, endix;
|
||||
startix = query.start();
|
||||
if (startix < 0) {
|
||||
startix += total;
|
||||
|
@ -34,7 +34,7 @@ private:
|
||||
static const string default_code;
|
||||
static const string default_market_code;
|
||||
static const string default_name;
|
||||
static const uint32 default_type;
|
||||
static const uint32_t default_type;
|
||||
static const bool default_valid;
|
||||
static const Datetime default_startDate;
|
||||
static const Datetime default_lastDate;
|
||||
@ -51,18 +51,18 @@ public:
|
||||
Stock(const Stock&);
|
||||
Stock(const string& market, const string& code, const string& name);
|
||||
|
||||
Stock(const string& market, const string& code, const string& name, uint32 type, bool valid,
|
||||
Stock(const string& market, const string& code, const string& name, uint32_t type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate);
|
||||
Stock(const string& market, const string& code, const string& name, uint32 type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate, price_t tick, price_t tickValue, int precision,
|
||||
size_t minTradeNumber, size_t maxTradeNumber);
|
||||
Stock(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, size_t minTradeNumber, size_t maxTradeNumber);
|
||||
virtual ~Stock();
|
||||
Stock& operator=(const Stock&);
|
||||
bool operator==(const Stock&) const;
|
||||
bool operator!=(const Stock&) const;
|
||||
|
||||
/** 获取内部id,一般用于作为map的键值使用,该id实质为m_data的内存地址 */
|
||||
uint64 id() const;
|
||||
uint64_t id() const;
|
||||
|
||||
/** 获取所属市场简称,市场简称是市场的唯一标识 */
|
||||
const string& market() const;
|
||||
@ -77,7 +77,7 @@ public:
|
||||
const string& name() const;
|
||||
|
||||
/** 获取证券类型 */
|
||||
uint32 type() const;
|
||||
uint32_t type() const;
|
||||
|
||||
/** 该证券当前是否有效 */
|
||||
bool valid() const;
|
||||
@ -215,7 +215,7 @@ struct HKU_API Stock::Data {
|
||||
string m_code; //证券代码
|
||||
string m_market_code; //市场简称证券代码
|
||||
string m_name; //证券名称
|
||||
uint32 m_type; //证券类型
|
||||
uint32_t m_type; //证券类型
|
||||
bool m_valid; //当前证券是否有效
|
||||
Datetime m_startDate; //证券起始日期
|
||||
Datetime m_lastDate; //证券最后日期
|
||||
@ -233,9 +233,9 @@ struct HKU_API Stock::Data {
|
||||
map<string, KRecordListPtr> pKData;
|
||||
|
||||
Data();
|
||||
Data(const string& market, const string& code, const string& name, uint32 type, bool valid,
|
||||
const Datetime& startDate, const Datetime& lastDate, price_t tick, price_t tickValue, int precision,
|
||||
size_t minTradeNumber, size_t maxTradeNumber);
|
||||
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, size_t minTradeNumber, size_t maxTradeNumber);
|
||||
|
||||
virtual ~Data();
|
||||
};
|
||||
@ -264,8 +264,8 @@ inline bool operator<(const Stock& s1, const Stock& s2) {
|
||||
return s1.id() < s2.id();
|
||||
}
|
||||
|
||||
inline uint64 Stock::id() const {
|
||||
return isNull() ? 0 : (int64)m_data.get();
|
||||
inline uint64_t Stock::id() const {
|
||||
return isNull() ? 0 : (int64_t)m_data.get();
|
||||
}
|
||||
|
||||
inline StockWeightList Stock::getWeight() const {
|
||||
|
@ -315,7 +315,7 @@ MarketInfo StockManager::getMarketInfo(const string& market) const {
|
||||
return Null<MarketInfo>();
|
||||
}
|
||||
|
||||
StockTypeInfo StockManager::getStockTypeInfo(uint32 type) const {
|
||||
StockTypeInfo StockManager::getStockTypeInfo(uint32_t type) const {
|
||||
auto iter = m_stockTypeInfo.find(type);
|
||||
if (iter != m_stockTypeInfo.end()) {
|
||||
return iter->second;
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
* @param type 证券类型
|
||||
* @return 对应的证券类型信息,如果不存在,则返回Null<StockTypeInf>()
|
||||
*/
|
||||
StockTypeInfo getStockTypeInfo(uint32 type) const;
|
||||
StockTypeInfo getStockTypeInfo(uint32_t type) const;
|
||||
|
||||
/** 获取市场简称列表 */
|
||||
MarketList getAllMarket() const;
|
||||
@ -187,7 +187,7 @@ private:
|
||||
typedef unordered_map<string, MarketInfo> MarketInfoMap;
|
||||
MarketInfoMap m_marketInfoDict;
|
||||
|
||||
typedef unordered_map<uint32, StockTypeInfo> StockTypeInfoMap;
|
||||
typedef unordered_map<uint32_t, StockTypeInfo> StockTypeInfoMap;
|
||||
StockTypeInfoMap m_stockTypeInfo;
|
||||
|
||||
Parameter m_baseInfoDriverParam;
|
||||
|
@ -39,7 +39,7 @@ string StockTypeInfo::toString() const {
|
||||
}
|
||||
|
||||
StockTypeInfo::StockTypeInfo()
|
||||
: m_type(Null<uint32>()),
|
||||
: m_type(Null<uint32_t>()),
|
||||
m_tick(0.0),
|
||||
m_tickValue(0.0),
|
||||
m_unit(1.0),
|
||||
@ -47,7 +47,7 @@ StockTypeInfo::StockTypeInfo()
|
||||
m_minTradeNumber(0),
|
||||
m_maxTradeNumber(0) {}
|
||||
|
||||
StockTypeInfo::StockTypeInfo(uint32 type, const string& description, price_t tick,
|
||||
StockTypeInfo::StockTypeInfo(uint32_t type, const string& description, price_t tick,
|
||||
price_t tickValue, int precision, double minTradeNumber,
|
||||
double maxTradeNumber)
|
||||
: m_type(type),
|
||||
|
@ -34,10 +34,10 @@ class HKU_API StockTypeInfo {
|
||||
public:
|
||||
/** 默认构造函数,返回Null<StockTypeInfo>() */
|
||||
StockTypeInfo();
|
||||
StockTypeInfo(uint32, const string&, price_t, price_t, int, double, double);
|
||||
StockTypeInfo(uint32_t, const string&, price_t, price_t, int, double, double);
|
||||
|
||||
/** 获取证券类型 */
|
||||
uint32 type() const {
|
||||
uint32_t type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public:
|
||||
string toString() const;
|
||||
|
||||
private:
|
||||
uint32 m_type; //证券类型
|
||||
uint32_t m_type; //证券类型
|
||||
string m_description; //描述信息
|
||||
price_t m_tick; //最小跳动量
|
||||
price_t m_tickValue; //每一个tick价格
|
||||
|
@ -25,7 +25,7 @@ class HKU_API BaseInfoDriver {
|
||||
|
||||
public:
|
||||
typedef unordered_map<string, MarketInfo> MarketInfoMap;
|
||||
typedef unordered_map<uint32, StockTypeInfo> StockTypeInfoMap;
|
||||
typedef unordered_map<uint32_t, StockTypeInfo> StockTypeInfoMap;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
|
@ -44,7 +44,7 @@ PriceList HistoryFinanceReader ::getHistoryFinanceInfo(Datetime date, const stri
|
||||
memcpy(&report_size, header_buf + 12, 4);
|
||||
|
||||
char stock_code[7];
|
||||
uint32 address = 0;
|
||||
uint32_t address = 0;
|
||||
for (int i = 0; i < max_count; i++) {
|
||||
if (!fread(stock_code, 1, 7, fp)) {
|
||||
HKU_ERROR("read stock_code failed! {}", filename);
|
||||
|
@ -108,7 +108,7 @@ bool MySQLBaseInfoDriver::_loadStockTypeInfo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
StockWeightList MySQLBaseInfoDriver::_getStockWeightList(uint64 stockid) {
|
||||
StockWeightList MySQLBaseInfoDriver::_getStockWeightList(uint64_t stockid) {
|
||||
StockWeightList result;
|
||||
if (!m_pool) {
|
||||
HKU_ERROR("Connect pool ptr is null!");
|
||||
@ -166,7 +166,7 @@ bool MySQLBaseInfoDriver::_loadStock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
unordered_map<uint64, string> marketDict;
|
||||
unordered_map<uint64_t, string> marketDict;
|
||||
for (auto &m : marketTable) {
|
||||
marketDict[m.id()] = m.market();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
virtual bool _loadStock() override;
|
||||
|
||||
private:
|
||||
StockWeightList _getStockWeightList(uint64);
|
||||
StockWeightList _getStockWeightList(uint64_t);
|
||||
|
||||
private:
|
||||
ConnectPool<MySQLConnect> *m_pool;
|
||||
|
@ -122,7 +122,7 @@ bool SQLiteBaseInfoDriver::_loadStock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
unordered_map<uint64, string> marketDict;
|
||||
unordered_map<uint64_t, string> marketDict;
|
||||
for (auto& m : marketTable) {
|
||||
marketDict[m.id()] = m.market();
|
||||
}
|
||||
@ -175,7 +175,7 @@ bool SQLiteBaseInfoDriver::_loadStock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
StockWeightList SQLiteBaseInfoDriver::_getStockWeightList(uint64 stockid) {
|
||||
StockWeightList SQLiteBaseInfoDriver::_getStockWeightList(uint64_t stockid) {
|
||||
StockWeightList result;
|
||||
if (!m_pool) {
|
||||
HKU_ERROR("Connect pool ptr is null!");
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual Parameter getFinanceInfo(const string& market, const string& code) override;
|
||||
|
||||
private:
|
||||
StockWeightList _getStockWeightList(uint64 stockid);
|
||||
StockWeightList _getStockWeightList(uint64_t stockid);
|
||||
|
||||
private:
|
||||
//股票基本信息数据库实例
|
||||
|
@ -19,7 +19,7 @@ class MarketInfoTable {
|
||||
public:
|
||||
MarketInfoTable() : m_marketid(0), m_lastDate(0) {}
|
||||
|
||||
uint64 id() const {
|
||||
uint64_t id() const {
|
||||
return m_marketid;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
return m_code;
|
||||
}
|
||||
|
||||
int64 lastDate() const {
|
||||
int64_t lastDate() const {
|
||||
return m_lastDate;
|
||||
}
|
||||
|
||||
@ -72,12 +72,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uint64 m_marketid;
|
||||
uint64_t m_marketid;
|
||||
string m_market;
|
||||
string m_name;
|
||||
string m_description;
|
||||
string m_code;
|
||||
int64 m_lastDate;
|
||||
int64_t m_lastDate;
|
||||
};
|
||||
|
||||
} // namespace hku
|
||||
|
@ -49,14 +49,14 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
uint64 stockid;
|
||||
uint64 marketid;
|
||||
uint64_t stockid;
|
||||
uint64_t marketid;
|
||||
string code;
|
||||
string name;
|
||||
uint32 type;
|
||||
uint32 valid;
|
||||
uint64 startDate;
|
||||
uint64 endDate;
|
||||
uint32_t type;
|
||||
uint32_t valid;
|
||||
uint64_t startDate;
|
||||
uint64_t endDate;
|
||||
};
|
||||
|
||||
} // namespace hku
|
||||
|
@ -26,15 +26,15 @@ public:
|
||||
m_minTradeNumber(0),
|
||||
m_maxTradeNumber(0) {}
|
||||
|
||||
int64 id() const {
|
||||
int64_t id() const {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
uint32 type() const {
|
||||
uint32_t type() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
uint32 precision() const {
|
||||
uint32_t precision() const {
|
||||
return m_precision;
|
||||
}
|
||||
|
||||
@ -93,9 +93,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
int64 m_id;
|
||||
uint32 m_type; //证券类型
|
||||
uint32 m_precision; //价格精度
|
||||
int64_t m_id;
|
||||
uint32_t m_type; //证券类型
|
||||
uint32_t m_precision; //价格精度
|
||||
double m_tick; //最小跳动量
|
||||
double m_tickValue; //每一个tick价格
|
||||
double m_minTradeNumber; //每笔最小交易量
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
freeCount(0) {}
|
||||
|
||||
public:
|
||||
uint64 stockid;
|
||||
uint64 date;
|
||||
uint64_t stockid;
|
||||
uint64_t date;
|
||||
double countAsGift;
|
||||
double countForSell;
|
||||
double priceForSell;
|
||||
|
@ -219,4 +219,95 @@ bool KDataTempCsvDriver::getIndexRangeByDate(const string& market, const string&
|
||||
return true;
|
||||
}
|
||||
|
||||
KRecordList KDataTempCsvDriver::getKRecordList(const string& market, const string& code,
|
||||
KQuery query) {
|
||||
KRecordList result;
|
||||
return result;
|
||||
}
|
||||
|
||||
KRecordList KDataTempCsvDriver::_getKRecordListByIndex(const string& market, const string& code,
|
||||
size_t start_ix, size_t end_ix,
|
||||
KQuery::KType kType) {
|
||||
KRecordList result;
|
||||
|
||||
string filename;
|
||||
if (kType == KQuery::DAY) {
|
||||
filename = m_day_filename;
|
||||
} else if (kType == KQuery::MIN) {
|
||||
filename = m_min_filename;
|
||||
} else {
|
||||
HKU_INFO("Only support DAY and MIN!");
|
||||
return result;
|
||||
}
|
||||
|
||||
std::ifstream infile(filename.c_str());
|
||||
if (!infile) {
|
||||
HKU_ERROR("Can't open this file: {}", filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
string line;
|
||||
if (!std::getline(infile, line)) {
|
||||
infile.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
_get_title_column(line);
|
||||
|
||||
size_t line_no = 0;
|
||||
while (std::getline(infile, line)) {
|
||||
if (line_no++ < start_ix)
|
||||
continue;
|
||||
|
||||
if (line_no >= end_ix)
|
||||
break;
|
||||
|
||||
_get_token(line);
|
||||
size_t token_count = m_token_buf.size();
|
||||
|
||||
KRecord record;
|
||||
string action;
|
||||
try {
|
||||
action = "DATE";
|
||||
if (token_count >= m_column[DATE])
|
||||
record.datetime = Datetime(m_token_buf[m_column[DATE]]);
|
||||
|
||||
action = "OPEN";
|
||||
if (token_count >= m_column[OPEN])
|
||||
record.openPrice = boost::lexical_cast<price_t>(m_token_buf[m_column[OPEN]]);
|
||||
|
||||
action = "HIGH";
|
||||
if (token_count >= m_column[HIGH])
|
||||
record.highPrice = boost::lexical_cast<price_t>(m_token_buf[m_column[HIGH]]);
|
||||
|
||||
action = "LOW";
|
||||
if (token_count >= m_column[LOW])
|
||||
record.lowPrice = boost::lexical_cast<price_t>(m_token_buf[m_column[LOW]]);
|
||||
|
||||
action = "CLOSE";
|
||||
if (token_count >= m_column[CLOSE])
|
||||
record.closePrice = boost::lexical_cast<price_t>(m_token_buf[m_column[CLOSE]]);
|
||||
|
||||
action = "VOLUME";
|
||||
if (token_count >= m_column[VOLUME])
|
||||
record.transCount = boost::lexical_cast<price_t>(m_token_buf[m_column[VOLUME]]);
|
||||
|
||||
action = "AMOUNT";
|
||||
if (token_count >= m_column[AMOUNT])
|
||||
record.transAmount = boost::lexical_cast<price_t>(m_token_buf[m_column[AMOUNT]]);
|
||||
|
||||
result.push_back(record);
|
||||
|
||||
} catch (...) {
|
||||
HKU_WARN("Invalid data in line {}! at trans {}", line_no, action);
|
||||
}
|
||||
|
||||
line_no++;
|
||||
}
|
||||
|
||||
infile.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} /* namespace hku */
|
||||
|
@ -70,11 +70,23 @@ public:
|
||||
virtual KRecord getKRecord(const string& market, const string& code, size_t pos,
|
||||
KQuery::KType kType) override;
|
||||
|
||||
/**
|
||||
* 获取 K 线数据
|
||||
* @param market 市场简称
|
||||
* @param code 证券代码
|
||||
* @param query 查询条件
|
||||
*/
|
||||
virtual KRecordList getKRecordList(const string& market, const string& code,
|
||||
KQuery query) override;
|
||||
|
||||
private:
|
||||
void _get_title_column(const string&);
|
||||
void _get_token(const string&);
|
||||
string _get_filename();
|
||||
|
||||
KRecordList _getKRecordListByIndex(const string& market, const string& code, size_t start_ix,
|
||||
size_t end_ix, KQuery::KType kType);
|
||||
|
||||
private:
|
||||
string m_day_filename;
|
||||
string m_min_filename;
|
||||
|
@ -214,11 +214,12 @@ void H5KDataDriver::loadKData(const string& market, const string& code, KQuery::
|
||||
return;
|
||||
}
|
||||
|
||||
/*KRecordList result = getKRecordList(market, code, KQuery(start_ix, end_ix, kType));
|
||||
/*int64_t end = end_ix == Null<size_t>() ? Null<int64_t>() : (int64_t)end_ix;
|
||||
KRecordList result = getKRecordList(market, code, KQuery(start_ix, end, kType));
|
||||
for (auto& record : result) {
|
||||
out_buffer->push_back(record);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
return;*/
|
||||
|
||||
if (KQuery::DAY == kType || KQuery::MIN5 == kType || KQuery::MIN == kType) {
|
||||
_loadBaseData(market, code, kType, start_ix, end_ix, out_buffer);
|
||||
@ -615,8 +616,8 @@ bool H5KDataDriver::_getBaseIndexRangeByDate(const string& market, const string&
|
||||
|
||||
H5::DataSet dataset;
|
||||
H5::DataSpace dataspace;
|
||||
uint64 start_number = query.startDatetime().number();
|
||||
uint64 end_number = query.endDatetime().number();
|
||||
uint64_t start_number = query.startDatetime().number();
|
||||
uint64_t end_number = query.endDatetime().number();
|
||||
hsize_t startpos = 0, endpos = 0;
|
||||
try {
|
||||
string tablename(market + code);
|
||||
@ -744,7 +745,7 @@ bool H5KDataDriver::_getOtherIndexRangeByDate(const string& market, const string
|
||||
}
|
||||
|
||||
size_t mid, low = 0, high = total - 1;
|
||||
uint64 startDatetime = query.startDatetime().number();
|
||||
uint64_t startDatetime = query.startDatetime().number();
|
||||
H5IndexRecord h5record;
|
||||
while (low <= high) {
|
||||
H5ReadIndexRecords(dataset, high, 1, &h5record);
|
||||
@ -775,7 +776,7 @@ bool H5KDataDriver::_getOtherIndexRangeByDate(const string& market, const string
|
||||
|
||||
out_start = mid;
|
||||
|
||||
uint64 endDatetime = query.endDatetime().number();
|
||||
uint64_t endDatetime = query.endDatetime().number();
|
||||
low = mid, high = total - 1;
|
||||
while (low <= high) {
|
||||
H5ReadIndexRecords(dataset, high, 1, &h5record);
|
||||
@ -971,8 +972,8 @@ TimeLineList H5KDataDriver::getTimeLineList(const string& market, const string&
|
||||
: _getTimeLine(market, code, query.startDatetime(), query.endDatetime());
|
||||
}
|
||||
|
||||
TimeLineList H5KDataDriver::_getTimeLine(const string& market, const string& code, int64 start_ix,
|
||||
int64 end_ix) {
|
||||
TimeLineList H5KDataDriver::_getTimeLine(const string& market, const string& code, int64_t start_ix,
|
||||
int64_t end_ix) {
|
||||
TimeLineList result;
|
||||
H5FilePtr h5file;
|
||||
H5::Group group;
|
||||
@ -1059,8 +1060,8 @@ TimeLineList H5KDataDriver::_getTimeLine(const string& market, const string& cod
|
||||
|
||||
H5::DataSet dataset;
|
||||
H5::DataSpace dataspace;
|
||||
uint64 start_number = start.number();
|
||||
uint64 end_number = end.number();
|
||||
uint64_t start_number = start.number();
|
||||
uint64_t end_number = end.number();
|
||||
hsize_t startpos = 0, endpos = 0;
|
||||
try {
|
||||
string tablename(market + code);
|
||||
@ -1192,8 +1193,8 @@ TransList H5KDataDriver::getTransList(const string& market, const string& code,
|
||||
: _getTransList(market, code, query.startDatetime(), query.endDatetime());
|
||||
}
|
||||
|
||||
TransList H5KDataDriver::_getTransList(const string& market, const string& code, int64 start_ix,
|
||||
int64 end_ix) {
|
||||
TransList H5KDataDriver::_getTransList(const string& market, const string& code, int64_t start_ix,
|
||||
int64_t end_ix) {
|
||||
TransList result;
|
||||
H5FilePtr h5file;
|
||||
H5::Group group;
|
||||
@ -1244,7 +1245,7 @@ TransList H5KDataDriver::_getTransList(const string& market, const string& code,
|
||||
|
||||
TransRecord record;
|
||||
result.reserve(total + 2);
|
||||
uint64 number = 0, second = 0;
|
||||
uint64_t number = 0, second = 0;
|
||||
for (hsize_t i = 0; i < total; i++) {
|
||||
number = pBuf[i].datetime / 100;
|
||||
second = pBuf[i].datetime - number * 100;
|
||||
@ -1289,8 +1290,8 @@ TransList H5KDataDriver::_getTransList(const string& market, const string& code,
|
||||
|
||||
H5::DataSet dataset;
|
||||
H5::DataSpace dataspace;
|
||||
uint64 start_number = start.number() * 100 + start.second();
|
||||
uint64 end_number = end.number() * 100 + (end.isNull() ? 0 : end.second());
|
||||
uint64_t start_number = start.number() * 100 + start.second();
|
||||
uint64_t end_number = end.number() * 100 + (end.isNull() ? 0 : end.second());
|
||||
hsize_t startpos = 0, endpos = 0;
|
||||
try {
|
||||
string tablename(market + code);
|
||||
@ -1397,7 +1398,7 @@ TransList H5KDataDriver::_getTransList(const string& market, const string& code,
|
||||
|
||||
TransRecord record;
|
||||
result.reserve(total + 2);
|
||||
uint64 number = 0, second = 0;
|
||||
uint64_t number = 0, second = 0;
|
||||
for (hsize_t i = 0; i < total; i++) {
|
||||
number = pBuf[i].datetime / 100;
|
||||
second = pBuf[i].datetime - number * 100;
|
||||
|
@ -70,11 +70,11 @@ private:
|
||||
// start,
|
||||
// Datetime end);
|
||||
|
||||
TimeLineList _getTimeLine(const string& market, const string& code, int64 start, int64 end);
|
||||
TimeLineList _getTimeLine(const string& market, const string& code, int64_t start, int64_t end);
|
||||
TimeLineList _getTimeLine(const string& market, const string& code, const Datetime& start,
|
||||
const Datetime& end);
|
||||
|
||||
TransList _getTransList(const string& market, const string& code, int64 start, int64 end);
|
||||
TransList _getTransList(const string& market, const string& code, int64_t start, int64_t end);
|
||||
TransList _getTransList(const string& market, const string& code, const Datetime& start,
|
||||
const Datetime& end);
|
||||
|
||||
|
@ -18,31 +18,31 @@ namespace hku {
|
||||
typedef shared_ptr<H5::H5File> H5FilePtr;
|
||||
|
||||
struct H5Record {
|
||||
uint64 datetime;
|
||||
uint32 openPrice;
|
||||
uint32 highPrice;
|
||||
uint32 lowPrice;
|
||||
uint32 closePrice;
|
||||
uint64 transAmount;
|
||||
uint64 transCount;
|
||||
uint64_t datetime;
|
||||
uint32_t openPrice;
|
||||
uint32_t highPrice;
|
||||
uint32_t lowPrice;
|
||||
uint32_t closePrice;
|
||||
uint64_t transAmount;
|
||||
uint64_t transCount;
|
||||
};
|
||||
|
||||
struct H5IndexRecord {
|
||||
uint64 datetime;
|
||||
uint64 start;
|
||||
uint64_t datetime;
|
||||
uint64_t start;
|
||||
};
|
||||
|
||||
struct H5TimeLineRecord {
|
||||
uint64 datetime;
|
||||
uint64 price;
|
||||
uint64 vol;
|
||||
uint64_t datetime;
|
||||
uint64_t price;
|
||||
uint64_t vol;
|
||||
};
|
||||
|
||||
struct H5TransRecord {
|
||||
uint64 datetime;
|
||||
uint64 price;
|
||||
uint64 vol;
|
||||
uint8 buyorsell;
|
||||
uint64_t datetime;
|
||||
uint64_t price;
|
||||
uint64_t vol;
|
||||
uint8_t buyorsell;
|
||||
};
|
||||
|
||||
} // namespace hku
|
||||
|
@ -13,21 +13,21 @@
|
||||
namespace hku {
|
||||
|
||||
struct TdxDayData {
|
||||
uint32 date;
|
||||
uint32 open;
|
||||
uint32 high;
|
||||
uint32 low;
|
||||
uint32 close;
|
||||
uint32_t date;
|
||||
uint32_t open;
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
uint32_t close;
|
||||
float amount;
|
||||
uint32 vol;
|
||||
uint32 other;
|
||||
uint32_t vol;
|
||||
uint32_t other;
|
||||
|
||||
Datetime getDatetime() {
|
||||
return Datetime(uint64(date) * 10000);
|
||||
return Datetime(uint64_t(date) * 10000);
|
||||
}
|
||||
|
||||
void toKRecord(KRecord& record) {
|
||||
record.datetime = Datetime(uint64(date) * 10000);
|
||||
record.datetime = Datetime(uint64_t(date) * 10000);
|
||||
record.openPrice = price_t(open) * 0.01;
|
||||
record.highPrice = price_t(high) * 0.01;
|
||||
record.lowPrice = price_t(low) * 0.01;
|
||||
@ -46,8 +46,8 @@ struct TdxMinData {
|
||||
float low;
|
||||
float close;
|
||||
float amount;
|
||||
uint32 vol;
|
||||
uint32 other;
|
||||
uint32_t vol;
|
||||
uint32_t other;
|
||||
|
||||
Datetime getDatetime() {
|
||||
int tmp_date = date >> 11;
|
||||
|
@ -14,18 +14,21 @@
|
||||
|
||||
namespace hku {
|
||||
|
||||
TimeDelta::TimeDelta(int64_t days, int64_t hours, int64_t minutes, int64_t seconds, int64_t milliseconds,
|
||||
int64_t microseconds) {
|
||||
TimeDelta::TimeDelta(int64_t days, int64_t hours, int64_t minutes, int64_t seconds,
|
||||
int64_t milliseconds, int64_t microseconds) {
|
||||
// 各参数添加限制,防止出现总和溢出的情况
|
||||
HKU_CHECK(days <= 99999999 && days >= -99999999, "Out of range! Input days: {}", days);
|
||||
HKU_CHECK(hours >= -100000 && hours <= 100000, "Out of range! Input hours: {}", hours);
|
||||
HKU_CHECK(minutes >= -100000 && minutes <= 100000, "Out of range! Input minutes: {}", minutes);
|
||||
HKU_CHECK(seconds >= -8639900 && seconds <= 8639900, "Out of range! Input seconds: {}", seconds);
|
||||
HKU_CHECK(milliseconds >= -86399000000 && milliseconds <= 86399000000, "Out of range! Input milliseconds: {}",
|
||||
milliseconds);
|
||||
HKU_CHECK(microseconds >= -86399000000 && microseconds <= 86399000000, "Out of range! Input microseconds: {}",
|
||||
microseconds);
|
||||
int64_t total = ((((days * 24 + hours) * 60 + minutes) * 60 + seconds) * 1000 + milliseconds) * 1000 + microseconds;
|
||||
HKU_CHECK(seconds >= -8639900 && seconds <= 8639900, "Out of range! Input seconds: {}",
|
||||
seconds);
|
||||
HKU_CHECK(milliseconds >= -86399000000 && milliseconds <= 86399000000,
|
||||
"Out of range! Input milliseconds: {}", milliseconds);
|
||||
HKU_CHECK(microseconds >= -86399000000 && microseconds <= 86399000000,
|
||||
"Out of range! Input microseconds: {}", microseconds);
|
||||
int64_t total =
|
||||
((((days * 24 + hours) * 60 + minutes) * 60 + seconds) * 1000 + milliseconds) * 1000 +
|
||||
microseconds;
|
||||
HKU_CHECK(total >= m_min_micro_seconds && total <= m_max_micro_seconds, "Out of total range!");
|
||||
m_duration = bt::time_duration(0, 0, 0, total);
|
||||
}
|
||||
@ -57,7 +60,8 @@ int64_t TimeDelta::hours() const {
|
||||
if (ticks() % m_one_day_ticks == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
int64_t pos_ticks = std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
int64_t pos_ticks =
|
||||
std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
return bt::time_duration(0, 0, 0, pos_ticks).hours();
|
||||
}
|
||||
}
|
||||
@ -69,7 +73,8 @@ int64_t TimeDelta::minutes() const {
|
||||
if (ticks() % m_one_day_ticks == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
int64_t pos_ticks = std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
int64_t pos_ticks =
|
||||
std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
return bt::time_duration(0, 0, 0, pos_ticks).minutes();
|
||||
}
|
||||
}
|
||||
@ -81,7 +86,8 @@ int64_t TimeDelta::seconds() const {
|
||||
if (ticks() % m_one_day_ticks == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
int64_t pos_ticks = std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
int64_t pos_ticks =
|
||||
std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
return bt::time_duration(0, 0, 0, pos_ticks).seconds();
|
||||
}
|
||||
}
|
||||
@ -93,7 +99,8 @@ int64_t TimeDelta::milliseconds() const {
|
||||
if (ticks() % m_one_day_ticks == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
int64_t pos_ticks = std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
int64_t pos_ticks =
|
||||
std::abs((ticks() / m_one_day_ticks - 1) * m_one_day_ticks) + ticks();
|
||||
int64_t milli = pos_ticks % 1000000;
|
||||
return milli == 0 ? 0 : (milli - microseconds()) / 1000;
|
||||
}
|
||||
@ -114,25 +121,29 @@ int64_t TimeDelta::microseconds() const {
|
||||
}
|
||||
|
||||
TimeDelta HKU_API Hours(int64_t hours) {
|
||||
HKU_CHECK(hours >= TimeDelta::minTicks() / 3600000000LL && hours <= TimeDelta::maxTicks() / 3600000000LL,
|
||||
HKU_CHECK(hours >= TimeDelta::minTicks() / 3600000000LL &&
|
||||
hours <= TimeDelta::maxTicks() / 3600000000LL,
|
||||
"Out of total range!");
|
||||
return TimeDelta::fromTicks(hours * 3600000000LL);
|
||||
}
|
||||
|
||||
TimeDelta HKU_API Minutes(int64_t mins) {
|
||||
HKU_CHECK(mins >= TimeDelta::minTicks() / 60000000LL && mins <= TimeDelta::maxTicks() / 60000000LL,
|
||||
"Out of total range!");
|
||||
HKU_CHECK(
|
||||
mins >= TimeDelta::minTicks() / 60000000LL && mins <= TimeDelta::maxTicks() / 60000000LL,
|
||||
"Out of total range!");
|
||||
return TimeDelta::fromTicks(mins * 60000000LL);
|
||||
}
|
||||
|
||||
TimeDelta HKU_API Seconds(int64_t secs) {
|
||||
HKU_CHECK(secs >= TimeDelta::minTicks() / 1000000LL && secs <= TimeDelta::maxTicks() / 1000000LL,
|
||||
"Out of total range!");
|
||||
HKU_CHECK(
|
||||
secs >= TimeDelta::minTicks() / 1000000LL && secs <= TimeDelta::maxTicks() / 1000000LL,
|
||||
"Out of total range!");
|
||||
return TimeDelta::fromTicks(secs * 1000000LL);
|
||||
}
|
||||
|
||||
TimeDelta HKU_API Milliseconds(int64_t milliseconds) {
|
||||
HKU_CHECK(milliseconds >= TimeDelta::minTicks() / 1000LL && milliseconds <= TimeDelta::maxTicks() / 1000LL,
|
||||
HKU_CHECK(milliseconds >= TimeDelta::minTicks() / 1000LL &&
|
||||
milliseconds <= TimeDelta::maxTicks() / 1000LL,
|
||||
"Out of total range!");
|
||||
return TimeDelta::fromTicks(milliseconds * 1000LL);
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ void IndicatorImp::execute_mod() {
|
||||
if (m_right->get(i - diff, r) == 0.0) {
|
||||
_set(Null<price_t>(), i, r);
|
||||
} else {
|
||||
_set(int64(m_left->get(i, r)) % int64(m_right->get(i - diff, r)), i, r);
|
||||
_set(int64_t(m_left->get(i, r)) % int64_t(m_right->get(i - diff, r)), i, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -812,7 +812,7 @@ void IndicatorImp::execute_mod() {
|
||||
if (m_right->get(i, r) == 0.0) {
|
||||
_set(Null<price_t>(), i, r);
|
||||
} else {
|
||||
_set(int64(m_left->get(i - diff, r)) % int64(m_right->get(i, r)), i, r);
|
||||
_set(int64_t(m_left->get(i - diff, r)) % int64_t(m_right->get(i, r)), i, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ void save(Archive& ar, const hku::KQuery& query, unsigned int version) {
|
||||
ar& BOOST_SERIALIZATION_NVP(recoverType);
|
||||
|
||||
if (query.queryType() == hku::KQuery::INDEX) {
|
||||
hku::int64 start = query.start();
|
||||
hku::int64 end = query.end();
|
||||
hku::int64_t start = query.start();
|
||||
hku::int64_t end = query.end();
|
||||
ar& BOOST_SERIALIZATION_NVP(start);
|
||||
ar& BOOST_SERIALIZATION_NVP(end);
|
||||
} else if (query.queryType() == hku::KQuery::DATE) {
|
||||
hku::uint64 start = query.startDatetime().number();
|
||||
hku::uint64 end = query.endDatetime().number();
|
||||
hku::uint64_t start = query.startDatetime().number();
|
||||
hku::uint64_t end = query.endDatetime().number();
|
||||
ar& BOOST_SERIALIZATION_NVP(start);
|
||||
ar& BOOST_SERIALIZATION_NVP(end);
|
||||
} else {
|
||||
@ -57,12 +57,12 @@ void load(Archive& ar, hku::KQuery& query, unsigned int version) {
|
||||
hku::KQuery::RecoverType enum_recover = hku::KQuery::getRecoverTypeEnum(recoverType);
|
||||
|
||||
if (enum_query == hku::KQuery::INDEX) {
|
||||
hku::int64 start, end;
|
||||
hku::int64_t start, end;
|
||||
ar& BOOST_SERIALIZATION_NVP(start);
|
||||
ar& BOOST_SERIALIZATION_NVP(end);
|
||||
query = hku::KQuery(start, end, enmu_ktype, enum_recover);
|
||||
} else if (enum_query == hku::KQuery::DATE) {
|
||||
hku::uint64 start, end;
|
||||
hku::uint64_t start, end;
|
||||
ar& BOOST_SERIALIZATION_NVP(start);
|
||||
ar& BOOST_SERIALIZATION_NVP(end);
|
||||
query =
|
||||
|
@ -21,7 +21,7 @@ namespace boost {
|
||||
namespace serialization {
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::KRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime = record.datetime.number();
|
||||
hku::uint64_t datetime = record.datetime.number();
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar& make_nvp("openPrice", record.openPrice);
|
||||
ar& make_nvp("highPrice", record.highPrice);
|
||||
@ -33,7 +33,7 @@ void save(Archive& ar, const hku::KRecord& record, unsigned int version) {
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::KRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime;
|
||||
hku::uint64_t datetime;
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
record.datetime = hku::Datetime(datetime);
|
||||
ar& make_nvp("openPrice", record.openPrice);
|
||||
|
@ -27,7 +27,7 @@ void save(Archive& ar, const hku::MarketInfo& record, unsigned int version) {
|
||||
hku::string name = record.name();
|
||||
hku::string description = record.description();
|
||||
hku::string code = record.code();
|
||||
hku::uint64 lastDate = record.lastDate().number();
|
||||
hku::uint64_t lastDate = record.lastDate().number();
|
||||
ar& BOOST_SERIALIZATION_NVP(market);
|
||||
ar& BOOST_SERIALIZATION_NVP(name);
|
||||
ar& BOOST_SERIALIZATION_NVP(description);
|
||||
@ -38,7 +38,7 @@ void save(Archive& ar, const hku::MarketInfo& record, unsigned int version) {
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::MarketInfo& record, unsigned int version) {
|
||||
hku::string market, name, description, code;
|
||||
hku::uint64 lastDate;
|
||||
hku::uint64_t lastDate;
|
||||
ar& BOOST_SERIALIZATION_NVP(market);
|
||||
ar& BOOST_SERIALIZATION_NVP(name);
|
||||
ar& BOOST_SERIALIZATION_NVP(description);
|
||||
|
@ -22,7 +22,7 @@ namespace serialization {
|
||||
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::StockTypeInfo& record, unsigned int version) {
|
||||
hku::uint32 type = record.type();
|
||||
hku::uint32_t type = record.type();
|
||||
hku::string description = record.description();
|
||||
hku::price_t tick = record.tick();
|
||||
hku::price_t tickValue = record.tickValue();
|
||||
@ -40,7 +40,7 @@ void save(Archive& ar, const hku::StockTypeInfo& record, unsigned int version) {
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::StockTypeInfo& record, unsigned int version) {
|
||||
hku::uint32 type;
|
||||
hku::uint32_t type;
|
||||
hku::string description;
|
||||
hku::price_t tick, tickValue;
|
||||
int precision;
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const hku::StockWeight& record, unsigned int version) {
|
||||
hku::uint64 datetime = record.datetime().number();
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::StockWeight& record, unsigned int version) {
|
||||
hku::uint64_t datetime = record.datetime().number();
|
||||
hku::price_t countAsGift = record.countAsGift();
|
||||
hku::price_t countForSell = record.countForSell();
|
||||
hku::price_t priceForSell = record.priceForSell();
|
||||
@ -29,34 +29,34 @@ void save(Archive & ar, const hku::StockWeight& record, unsigned int version) {
|
||||
hku::price_t increasement = record.increasement();
|
||||
hku::price_t totalCount = record.totalCount();
|
||||
hku::price_t freeCount = record.freeCount();
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar & BOOST_SERIALIZATION_NVP(countAsGift);
|
||||
ar & BOOST_SERIALIZATION_NVP(countForSell);
|
||||
ar & BOOST_SERIALIZATION_NVP(priceForSell);
|
||||
ar & BOOST_SERIALIZATION_NVP(bonus);
|
||||
ar & BOOST_SERIALIZATION_NVP(increasement);
|
||||
ar & BOOST_SERIALIZATION_NVP(totalCount);
|
||||
ar & BOOST_SERIALIZATION_NVP(freeCount);
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar& BOOST_SERIALIZATION_NVP(countAsGift);
|
||||
ar& BOOST_SERIALIZATION_NVP(countForSell);
|
||||
ar& BOOST_SERIALIZATION_NVP(priceForSell);
|
||||
ar& BOOST_SERIALIZATION_NVP(bonus);
|
||||
ar& BOOST_SERIALIZATION_NVP(increasement);
|
||||
ar& BOOST_SERIALIZATION_NVP(totalCount);
|
||||
ar& BOOST_SERIALIZATION_NVP(freeCount);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar, hku::StockWeight& record, unsigned int version) {
|
||||
hku::uint64 datetime;
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::StockWeight& record, unsigned int version) {
|
||||
hku::uint64_t datetime;
|
||||
hku::price_t countAsGift, countForSell, priceForSell, bonus;
|
||||
hku::price_t increasement, totalCount, freeCount;
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar & BOOST_SERIALIZATION_NVP(countAsGift);
|
||||
ar & BOOST_SERIALIZATION_NVP(countForSell);
|
||||
ar & BOOST_SERIALIZATION_NVP(priceForSell);
|
||||
ar & BOOST_SERIALIZATION_NVP(bonus);
|
||||
ar & BOOST_SERIALIZATION_NVP(increasement);
|
||||
ar & BOOST_SERIALIZATION_NVP(totalCount);
|
||||
ar & BOOST_SERIALIZATION_NVP(freeCount);
|
||||
record = hku::StockWeight(hku::Datetime(datetime), countAsGift,
|
||||
countForSell, priceForSell, bonus, increasement,
|
||||
totalCount, freeCount);
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar& BOOST_SERIALIZATION_NVP(countAsGift);
|
||||
ar& BOOST_SERIALIZATION_NVP(countForSell);
|
||||
ar& BOOST_SERIALIZATION_NVP(priceForSell);
|
||||
ar& BOOST_SERIALIZATION_NVP(bonus);
|
||||
ar& BOOST_SERIALIZATION_NVP(increasement);
|
||||
ar& BOOST_SERIALIZATION_NVP(totalCount);
|
||||
ar& BOOST_SERIALIZATION_NVP(freeCount);
|
||||
record = hku::StockWeight(hku::Datetime(datetime), countAsGift, countForSell, priceForSell,
|
||||
bonus, increasement, totalCount, freeCount);
|
||||
}
|
||||
}} /* namespace boost::serailization */
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_FREE(hku::StockWeight)
|
||||
|
||||
|
@ -19,23 +19,24 @@
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const hku::TimeLineRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime = record.datetime.number();
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar & make_nvp("price", record.price);
|
||||
ar & make_nvp("vol", record.vol);
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::TimeLineRecord& record, unsigned int version) {
|
||||
hku::uint64_t datetime = record.datetime.number();
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar& make_nvp("price", record.price);
|
||||
ar& make_nvp("vol", record.vol);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar, hku::TimeLineRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime;
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::TimeLineRecord& record, unsigned int version) {
|
||||
hku::uint64_t datetime;
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
record.datetime = hku::Datetime(datetime);
|
||||
ar & make_nvp("price", record.price);
|
||||
ar & make_nvp("vol", record.vol);
|
||||
ar& make_nvp("price", record.price);
|
||||
ar& make_nvp("vol", record.vol);
|
||||
}
|
||||
}} /* namespace boost::serailization */
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_FREE(hku::TimeLineRecord)
|
||||
|
||||
|
@ -19,25 +19,26 @@
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const hku::TransRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime = record.datetime.number();
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar & make_nvp("price", record.price);
|
||||
ar & make_nvp("vol", record.vol);
|
||||
ar & make_nvp("direct", record.direct);
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const hku::TransRecord& record, unsigned int version) {
|
||||
hku::uint64_t datetime = record.datetime.number();
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
ar& make_nvp("price", record.price);
|
||||
ar& make_nvp("vol", record.vol);
|
||||
ar& make_nvp("direct", record.direct);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive & ar, hku::TransRecord& record, unsigned int version) {
|
||||
hku::uint64 datetime;
|
||||
ar & BOOST_SERIALIZATION_NVP(datetime);
|
||||
template <class Archive>
|
||||
void load(Archive& ar, hku::TransRecord& record, unsigned int version) {
|
||||
hku::uint64_t datetime;
|
||||
ar& BOOST_SERIALIZATION_NVP(datetime);
|
||||
record.datetime = hku::Datetime(datetime);
|
||||
ar & make_nvp("price", record.price);
|
||||
ar & make_nvp("vol", record.vol);
|
||||
ar & make_nvp("direct", record.direct);
|
||||
ar& make_nvp("price", record.price);
|
||||
ar& make_nvp("vol", record.vol);
|
||||
ar& make_nvp("direct", record.direct);
|
||||
}
|
||||
}} /* namespace boost::serailization */
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
BOOST_SERIALIZATION_SPLIT_FREE(hku::TransRecord)
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
friend class boost::serialization::access;
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
uint64 datetime_num = datetime.number();
|
||||
uint64_t datetime_num = datetime.number();
|
||||
ar& boost::serialization::make_nvp("datetime", datetime_num);
|
||||
ar& BOOST_SERIALIZATION_NVP(number);
|
||||
ar& BOOST_SERIALIZATION_NVP(price);
|
||||
@ -54,7 +54,7 @@ public:
|
||||
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
uint64 datetime_num;
|
||||
uint64_t datetime_num;
|
||||
ar& boost::serialization::make_nvp("datetime", datetime_num);
|
||||
datetime = Datetime(datetime_num);
|
||||
ar& BOOST_SERIALIZATION_NVP(number);
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
template <class Archive>
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
namespace bs = boost::serialization;
|
||||
hku::uint64 date_number = datetime.number();
|
||||
hku::uint64_t date_number = datetime.number();
|
||||
ar& bs::make_nvp("datetime", date_number);
|
||||
ar& BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
@ -46,7 +46,7 @@ private:
|
||||
template <class Archive>
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
namespace bs = boost::serialization;
|
||||
hku::uint64 date_number;
|
||||
hku::uint64_t date_number;
|
||||
ar& bs::make_nvp("datetime", date_number);
|
||||
datetime = Datetime(date_number);
|
||||
ar& BOOST_SERIALIZATION_NVP(value);
|
||||
|
@ -54,8 +54,8 @@ private:
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
namespace bs = boost::serialization;
|
||||
ar& BOOST_SERIALIZATION_NVP(stock);
|
||||
uint64 take = takeDatetime.number();
|
||||
uint64 clean = cleanDatetime.number();
|
||||
uint64_t take = takeDatetime.number();
|
||||
uint64_t clean = cleanDatetime.number();
|
||||
ar& bs::make_nvp("takeDatetime", take);
|
||||
ar& bs::make_nvp("cleanDatetime", clean);
|
||||
ar& BOOST_SERIALIZATION_NVP(number);
|
||||
@ -72,7 +72,7 @@ private:
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
namespace bs = boost::serialization;
|
||||
ar& BOOST_SERIALIZATION_NVP(stock);
|
||||
uint64 take, clean;
|
||||
uint64_t take, clean;
|
||||
ar& bs::make_nvp("takeDatetime", take);
|
||||
ar& bs::make_nvp("cleanDatetime", clean);
|
||||
takeDatetime = Datetime(take);
|
||||
|
@ -1438,12 +1438,12 @@ FundsRecord TradeManager ::getFunds(const Datetime& indatetime, KQuery::KType kt
|
||||
price_t checkout_cash = 0.0;
|
||||
price_t checkin_stock = 0.0;
|
||||
price_t checkout_stock = 0.0;
|
||||
map<uint64, Stock_Number> stock_map;
|
||||
map<uint64, Stock_Number> short_stock_map;
|
||||
map<uint64, Stock_Number>::iterator stock_iter;
|
||||
map<uint64, Stock_Number>::iterator short_stock_iter;
|
||||
map<uint64, BorrowRecord> bor_stock_map;
|
||||
map<uint64, BorrowRecord>::iterator bor_stock_iter;
|
||||
map<uint64_t, Stock_Number> stock_map;
|
||||
map<uint64_t, Stock_Number> short_stock_map;
|
||||
map<uint64_t, Stock_Number>::iterator stock_iter;
|
||||
map<uint64_t, Stock_Number>::iterator short_stock_iter;
|
||||
map<uint64_t, BorrowRecord> bor_stock_map;
|
||||
map<uint64_t, BorrowRecord>::iterator bor_stock_iter;
|
||||
|
||||
TradeRecordList::const_iterator iter = m_trade_list.begin();
|
||||
for (; iter != m_trade_list.end(); ++iter) {
|
||||
|
@ -535,12 +535,12 @@ private:
|
||||
|
||||
list<LoanRecord> m_loan_list; //当前融资情况
|
||||
|
||||
typedef map<uint64, BorrowRecord> borrow_stock_map_type;
|
||||
typedef map<uint64_t, BorrowRecord> borrow_stock_map_type;
|
||||
borrow_stock_map_type m_borrow_stock; //当前借入的股票及其数量
|
||||
|
||||
TradeRecordList m_trade_list; //交易记录
|
||||
|
||||
typedef map<uint64, PositionRecord> position_map_type;
|
||||
typedef map<uint64_t, PositionRecord> position_map_type;
|
||||
position_map_type m_position; //当前持仓交易对象的持仓记录 ["sh000001"-> ]
|
||||
PositionRecordList m_position_history; //持仓历史记录
|
||||
position_map_type m_short_position; //空头仓位记录
|
||||
|
@ -87,7 +87,7 @@ private:
|
||||
void save(Archive& ar, const unsigned int version) const {
|
||||
namespace bs = boost::serialization;
|
||||
ar& BOOST_SERIALIZATION_NVP(stock);
|
||||
hku::uint64 date_number = datetime.number();
|
||||
hku::uint64_t date_number = datetime.number();
|
||||
ar& bs::make_nvp("datetime", date_number);
|
||||
string business_name = getBusinessName(business);
|
||||
ar& bs::make_nvp<string>("business", business_name);
|
||||
@ -106,7 +106,7 @@ private:
|
||||
void load(Archive& ar, const unsigned int version) {
|
||||
namespace bs = boost::serialization;
|
||||
ar& BOOST_SERIALIZATION_NVP(stock);
|
||||
hku::uint64 date_number;
|
||||
hku::uint64_t date_number;
|
||||
ar& bs::make_nvp("datetime", date_number);
|
||||
datetime = Datetime(date_number);
|
||||
string business_name;
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
ar& BOOST_SERIALIZATION_NVP(valid);
|
||||
string business_name(getBusinessName(business));
|
||||
ar& bs::make_nvp<string>("business", business_name);
|
||||
uint64 datetime_num = datetime.number();
|
||||
uint64_t datetime_num = datetime.number();
|
||||
ar& bs::make_nvp("datetime", datetime_num);
|
||||
ar& BOOST_SERIALIZATION_NVP(stoploss);
|
||||
ar& BOOST_SERIALIZATION_NVP(goal);
|
||||
@ -65,7 +65,7 @@ private:
|
||||
string business_name;
|
||||
ar& bs::make_nvp<string>("business", business_name);
|
||||
business = getBusinessEnum(business_name);
|
||||
uint64 datetime_num;
|
||||
uint64_t datetime_num;
|
||||
ar& bs::make_nvp("datetime", datetime_num);
|
||||
datetime = Datetime(datetime_num);
|
||||
ar& BOOST_SERIALIZATION_NVP(stoploss);
|
||||
|
@ -118,13 +118,13 @@ public:
|
||||
virtual bool sub_moveNext() = 0; ///< 子类接口 @see moveNext
|
||||
|
||||
virtual void sub_bindNull(int idx) = 0; ///< 子类接口 @see bind
|
||||
virtual void sub_bindInt(int idx, int64 value) = 0; ///< 子类接口 @see bind
|
||||
virtual void sub_bindInt(int idx, int64_t value) = 0; ///< 子类接口 @see bind
|
||||
virtual void sub_bindDouble(int idx, double item) = 0; ///< 子类接口 @see bind
|
||||
virtual void sub_bindText(int idx, const string& item) = 0; ///< 子类接口 @see bind
|
||||
virtual void sub_bindBlob(int idx, const string& item) = 0; ///< 子类接口 @see bind
|
||||
|
||||
virtual int sub_getNumColumns() const = 0; ///< 子类接口 @see getNumColumns
|
||||
virtual void sub_getColumnAsInt64(int idx, int64&) = 0; ///< 子类接口 @see getColumn
|
||||
virtual void sub_getColumnAsInt64(int idx, int64_t&) = 0; ///< 子类接口 @see getColumn
|
||||
virtual void sub_getColumnAsDouble(int idx, double&) = 0; ///< 子类接口 @see getColumn
|
||||
virtual void sub_getColumnAsText(int idx, string&) = 0; ///< 子类接口 @see getColumn
|
||||
virtual void sub_getColumnAsBlob(int idx, string&) = 0; ///< 子类接口 @see getColumn
|
||||
@ -233,7 +233,7 @@ template <typename T>
|
||||
typename std::enable_if<std::numeric_limits<T>::is_integer>::type SQLStatementBase::getColumn(
|
||||
int idx, T& item) {
|
||||
HKU_CHECK(isValid(), "Invalid statement!");
|
||||
int64 temp;
|
||||
int64_t temp;
|
||||
sub_getColumnAsInt64(idx, temp);
|
||||
item = (T)temp;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -101,15 +101,15 @@ void MySQLStatement::_bindResult() {
|
||||
m_result_bind[idx].length = &m_result_length[idx];
|
||||
|
||||
if (field->type == MYSQL_TYPE_LONGLONG) {
|
||||
int64 item = 0;
|
||||
int64_t item = 0;
|
||||
m_result_buffer.push_back(item);
|
||||
auto& buf = m_result_buffer.back();
|
||||
m_result_bind[idx].buffer = boost::any_cast<int64>(&buf);
|
||||
m_result_bind[idx].buffer = boost::any_cast<int64_t>(&buf);
|
||||
} else if (field->type == MYSQL_TYPE_LONG) {
|
||||
int32 item = 0;
|
||||
int32_t item = 0;
|
||||
m_result_buffer.push_back(item);
|
||||
auto& buf = m_result_buffer.back();
|
||||
m_result_bind[idx].buffer = boost::any_cast<int32>(&buf);
|
||||
m_result_bind[idx].buffer = boost::any_cast<int32_t>(&buf);
|
||||
} else if (field->type == MYSQL_TYPE_DOUBLE) {
|
||||
double item = 0;
|
||||
m_result_buffer.push_back(item);
|
||||
@ -129,10 +129,10 @@ void MySQLStatement::_bindResult() {
|
||||
vector<char>* p = boost::any_cast<vector<char>>(&buf);
|
||||
m_result_bind[idx].buffer = p->data();
|
||||
} else if (field->type == MYSQL_TYPE_TINY) {
|
||||
int8 item = 0;
|
||||
int8_t item = 0;
|
||||
m_result_buffer.push_back(item);
|
||||
auto& buf = m_result_buffer.back();
|
||||
m_result_bind[idx].buffer = boost::any_cast<int8>(&buf);
|
||||
m_result_bind[idx].buffer = boost::any_cast<int8_t>(&buf);
|
||||
} else if (field->type == MYSQL_TYPE_SHORT) {
|
||||
short item = 0;
|
||||
m_result_buffer.push_back(item);
|
||||
@ -173,13 +173,13 @@ void MySQLStatement::sub_bindNull(int idx) {
|
||||
m_param_bind[idx].buffer_type = MYSQL_TYPE_NULL;
|
||||
}
|
||||
|
||||
void MySQLStatement::sub_bindInt(int idx, int64 value) {
|
||||
void MySQLStatement::sub_bindInt(int idx, int64_t value) {
|
||||
HKU_CHECK(idx < m_param_bind.size(), "idx out of range! idx: {}, total: {}", idx,
|
||||
m_param_bind.size());
|
||||
m_param_buffer.push_back(value);
|
||||
auto& buf = m_param_buffer.back();
|
||||
m_param_bind[idx].buffer_type = MYSQL_TYPE_LONGLONG;
|
||||
m_param_bind[idx].buffer = boost::any_cast<int64>(&buf);
|
||||
m_param_bind[idx].buffer = boost::any_cast<int64_t>(&buf);
|
||||
}
|
||||
|
||||
void MySQLStatement::sub_bindDouble(int idx, double item) {
|
||||
@ -219,11 +219,11 @@ int MySQLStatement::sub_getNumColumns() const {
|
||||
return mysql_stmt_field_count(m_stmt);
|
||||
}
|
||||
|
||||
void MySQLStatement::sub_getColumnAsInt64(int idx, int64& item) {
|
||||
void MySQLStatement::sub_getColumnAsInt64(int idx, int64_t& item) {
|
||||
HKU_CHECK(idx < m_result_buffer.size(), "idx out of range! idx: {}, total: {}",
|
||||
m_result_buffer.size());
|
||||
|
||||
HKU_CHECK(m_result_error[idx] == 0, "Error occurred in sub_getColumnAsInt64! idx: {}", idx);
|
||||
HKU_CHECK(m_result_error[idx] == 0, "Error occurred in sub_getColumnAsint64_t! idx: {}", idx);
|
||||
|
||||
if (m_result_is_null[idx]) {
|
||||
item = 0;
|
||||
@ -231,10 +231,10 @@ void MySQLStatement::sub_getColumnAsInt64(int idx, int64& item) {
|
||||
}
|
||||
|
||||
try {
|
||||
item = boost::any_cast<int64>(m_result_buffer[idx]);
|
||||
item = boost::any_cast<int64_t>(m_result_buffer[idx]);
|
||||
} catch (...) {
|
||||
try {
|
||||
item = boost::any_cast<int32>(m_result_buffer[idx]);
|
||||
item = boost::any_cast<int32_t>(m_result_buffer[idx]);
|
||||
} catch (...) {
|
||||
HKU_THROW("Field type mismatch! idx: {}", idx);
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ public:
|
||||
virtual bool sub_moveNext() override;
|
||||
|
||||
virtual void sub_bindNull(int idx) override;
|
||||
virtual void sub_bindInt(int idx, int64 value) override;
|
||||
virtual void sub_bindInt(int idx, int64_t value) override;
|
||||
virtual void sub_bindDouble(int idx, double item) override;
|
||||
virtual void sub_bindText(int idx, const string& item) override;
|
||||
virtual void sub_bindBlob(int idx, const string& item) override;
|
||||
|
||||
virtual int sub_getNumColumns() const override;
|
||||
virtual void sub_getColumnAsInt64(int idx, int64& item) override;
|
||||
virtual void sub_getColumnAsInt64(int idx, int64_t& item) override;
|
||||
virtual void sub_getColumnAsDouble(int idx, double& item) override;
|
||||
virtual void sub_getColumnAsText(int idx, string& item) override;
|
||||
virtual void sub_getColumnAsBlob(int idx, string& item) override;
|
||||
|
@ -87,7 +87,7 @@ void SQLiteStatement::sub_bindNull(int idx) {
|
||||
HKU_CHECK(status == SQLITE_OK, sqlite3_errmsg(m_db));
|
||||
}
|
||||
|
||||
void SQLiteStatement::sub_bindInt(int idx, int64 value) {
|
||||
void SQLiteStatement::sub_bindInt(int idx, int64_t value) {
|
||||
_reset();
|
||||
int status = sqlite3_bind_int64(m_stmt, idx + 1, value);
|
||||
HKU_CHECK(status == SQLITE_OK, sqlite3_errmsg(m_db));
|
||||
@ -111,7 +111,7 @@ void SQLiteStatement::sub_bindBlob(int idx, const string& item) {
|
||||
HKU_CHECK(status == SQLITE_OK, sqlite3_errmsg(m_db));
|
||||
}
|
||||
|
||||
void SQLiteStatement::sub_getColumnAsInt64(int idx, int64& item) {
|
||||
void SQLiteStatement::sub_getColumnAsInt64(int idx, int64_t& item) {
|
||||
item = sqlite3_column_int64(m_stmt, idx);
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@ public:
|
||||
virtual bool sub_moveNext() override;
|
||||
|
||||
virtual void sub_bindNull(int idx) override;
|
||||
virtual void sub_bindInt(int idx, int64 value) override;
|
||||
virtual void sub_bindInt(int idx, int64_t value) override;
|
||||
virtual void sub_bindDouble(int idx, double item) override;
|
||||
virtual void sub_bindText(int idx, const string& item) override;
|
||||
virtual void sub_bindBlob(int idx, const string& item) override;
|
||||
|
||||
virtual int sub_getNumColumns() const override;
|
||||
virtual void sub_getColumnAsInt64(int idx, int64& item) override;
|
||||
virtual void sub_getColumnAsInt64(int idx, int64_t& item) override;
|
||||
virtual void sub_getColumnAsDouble(int idx, double& item) override;
|
||||
virtual void sub_getColumnAsText(int idx, string& item) override;
|
||||
virtual void sub_getColumnAsBlob(int idx, string& item) override;
|
||||
|
@ -165,7 +165,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(total-1) */
|
||||
@ -178,7 +179,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.endPos(), 5121);
|
||||
CHECK_EQ(kdata.lastPos(), 5120);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(total) */
|
||||
@ -242,7 +244,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据, KQuery(0,0) */
|
||||
@ -283,12 +286,13 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-total) */
|
||||
total = stock.getCount();
|
||||
query = KQuery(-(int64)total);
|
||||
query = KQuery(-(int64_t)total);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 5121);
|
||||
CHECK_EQ(kdata.empty(), false);
|
||||
@ -300,12 +304,13 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-total-1) */
|
||||
total = stock.getCount();
|
||||
query = KQuery(-1 - (int64)total);
|
||||
query = KQuery(-1 - (int64_t)total);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 5121);
|
||||
CHECK_EQ(kdata.empty(), false);
|
||||
@ -317,12 +322,13 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-total + 1) */
|
||||
total = stock.getCount();
|
||||
query = KQuery(1 - (int64)total);
|
||||
query = KQuery(1 - (int64_t)total);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 5120);
|
||||
CHECK_EQ(kdata.empty(), false);
|
||||
@ -334,7 +340,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-2, -1) */
|
||||
@ -347,7 +354,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.endPos(), total - 1);
|
||||
CHECK_EQ(kdata.lastPos(), total - 2);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(201112050000), 2363.111, 2363.127, 2327.61, 2333.229, 4864121.6, 52214970);
|
||||
expect =
|
||||
KRecord(Datetime(201112050000), 2363.111, 2363.127, 2327.61, 2333.229, 4864121.6, 52214970);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-10, -2) */
|
||||
@ -359,11 +367,13 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.endPos(), total - 2);
|
||||
CHECK_EQ(kdata.lastPos(), total - 2 - 1);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(201111230000), 2415.197, 2418.56, 2390.654, 2395.065, 5004336, 50547851);
|
||||
expect =
|
||||
KRecord(Datetime(201111230000), 2415.197, 2418.56, 2390.654, 2395.065, 5004336, 50547851);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112020000), 2374.899, 2378.299, 2344.846, 2360.664, 5732015.7, 59868846);
|
||||
expect =
|
||||
KRecord(Datetime(201112020000), 2374.899, 2378.299, 2344.846, 2360.664, 5732015.7, 59868846);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-1, 1) */
|
||||
@ -376,7 +386,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.lastPos(), 0);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-total, 1) */
|
||||
query = KQuery(-(int64)total, 1);
|
||||
query = KQuery(-(int64_t)total, 1);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 1);
|
||||
CHECK_EQ(kdata.empty(), false);
|
||||
@ -388,7 +398,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(-total, 2) */
|
||||
query = KQuery(-(int64)total, 2);
|
||||
query = KQuery(-(int64_t)total, 2);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 2);
|
||||
CHECK_EQ(kdata.empty(), false);
|
||||
@ -403,7 +413,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record.datetime, Datetime(199012200000));
|
||||
|
||||
/** @arg SH000001日线数据,KQuery(0, -total) */
|
||||
query = KQuery(0, -(int64)total);
|
||||
query = KQuery(0, -(int64_t)total);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 0);
|
||||
CHECK_EQ(kdata.empty(), true);
|
||||
@ -424,18 +434,20 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112050000), 2363.111, 2363.127, 2327.61, 2333.229, 4864121.6, 52214970);
|
||||
expect =
|
||||
KRecord(Datetime(201112050000), 2363.111, 2363.127, 2327.61, 2333.229, 4864121.6, 52214970);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
///==============================
|
||||
/// 测试分钟线
|
||||
///==============================
|
||||
/** @arg SH000001全部1分钟K线数据,KQuery(0) */
|
||||
query = KQuery(0, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(0, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682823L);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
expect =
|
||||
KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
@ -444,7 +456,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(total-1) */
|
||||
total = stock.getCount(KQuery::MIN);
|
||||
query = KQuery(total - 1, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(total - 1, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 1);
|
||||
record = kdata[0];
|
||||
@ -453,7 +465,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(total) */
|
||||
total = stock.getCount(KQuery::MIN);
|
||||
query = KQuery(total, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(total, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 0);
|
||||
|
||||
@ -462,7 +474,8 @@ TEST_CASE("test_getKData_by_index") {
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 1);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
expect =
|
||||
KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(1,2) */
|
||||
@ -507,7 +520,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.size(), 0);
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-1) */
|
||||
query = KQuery(-1, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(-1, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 1);
|
||||
record = kdata[0];
|
||||
@ -515,7 +528,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-total) */
|
||||
total = stock.getCount(KQuery::MIN);
|
||||
query = KQuery(-(int64)total, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(-(int64_t)total, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682823);
|
||||
record = kdata[0];
|
||||
@ -526,7 +539,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-total-1) */
|
||||
total = stock.getCount(KQuery::MIN);
|
||||
query = KQuery(-1 - (int64)total, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(-1 - (int64_t)total, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682823);
|
||||
record = kdata[0];
|
||||
@ -537,7 +550,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-total + 1) */
|
||||
total = stock.getCount(KQuery::MIN);
|
||||
query = KQuery(1 - (int64)total, Null<int64>(), KQuery::MIN);
|
||||
query = KQuery(1 - (int64_t)total, Null<int64_t>(), KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682822);
|
||||
record = kdata[0];
|
||||
@ -569,14 +582,14 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.size(), 0);
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-total, 1) */
|
||||
query = KQuery(-(int64)total, 1, KQuery::MIN);
|
||||
query = KQuery(-(int64_t)total, 1, KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 1);
|
||||
record = kdata[0];
|
||||
CHECK_EQ(record.datetime, Datetime(200001040931));
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(-total, 2) */
|
||||
query = KQuery(-(int64)total, 2, KQuery::MIN);
|
||||
query = KQuery(-(int64_t)total, 2, KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 2);
|
||||
record = kdata[0];
|
||||
@ -586,7 +599,7 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(record.datetime, Datetime(200001040932));
|
||||
|
||||
/** @arg SH000001分钟线数据,KQuery(0, -total) */
|
||||
query = KQuery(0, -(int64)total, KQuery::MIN);
|
||||
query = KQuery(0, -(int64_t)total, KQuery::MIN);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 0);
|
||||
|
||||
@ -619,9 +632,12 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.startPos(), 1);
|
||||
CHECK_EQ(kdata.endPos(), 4);
|
||||
CHECK_EQ(kdata.lastPos(), 3);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199101310000), 127.61, 135.19, 127.61, 129.97, 3637.1, 67197));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199102280000), 129.5, 134.87, 128.06, 133.01, 3027.3, 50982));
|
||||
CHECK_EQ(kdata[2], KRecord(Datetime(199103310000), 132.53, 132.53, 120.11, 120.19, 1725.3, 24528));
|
||||
CHECK_EQ(kdata[0],
|
||||
KRecord(Datetime(199101310000), 127.61, 135.19, 127.61, 129.97, 3637.1, 67197));
|
||||
CHECK_EQ(kdata[1],
|
||||
KRecord(Datetime(199102280000), 129.5, 134.87, 128.06, 133.01, 3027.3, 50982));
|
||||
CHECK_EQ(kdata[2],
|
||||
KRecord(Datetime(199103310000), 132.53, 132.53, 120.11, 120.19, 1725.3, 24528));
|
||||
|
||||
/** @arg 测试季线 */
|
||||
query = KQuery(1, 4, KQuery::QUARTER);
|
||||
@ -631,9 +647,12 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.startPos(), 1);
|
||||
CHECK_EQ(kdata.endPos(), 4);
|
||||
CHECK_EQ(kdata.lastPos(), 3);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199103310000), 127.61, 135.19, 120.11, 120.19, 8389.7, 142707));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199106300000), 120.69, 137.56, 104.96, 137.56, 12095.6, 222753));
|
||||
CHECK_EQ(kdata[2], KRecord(Datetime(199109300000), 136.64, 191.18, 131.87, 180.92, 32436.9, 527079));
|
||||
CHECK_EQ(kdata[0],
|
||||
KRecord(Datetime(199103310000), 127.61, 135.19, 120.11, 120.19, 8389.7, 142707));
|
||||
CHECK_EQ(kdata[1],
|
||||
KRecord(Datetime(199106300000), 120.69, 137.56, 104.96, 137.56, 12095.6, 222753));
|
||||
CHECK_EQ(kdata[2],
|
||||
KRecord(Datetime(199109300000), 136.64, 191.18, 131.87, 180.92, 32436.9, 527079));
|
||||
|
||||
/** @arg 测试5分钟线 */
|
||||
query = KQuery(1, 4, KQuery::MIN5);
|
||||
@ -643,9 +662,12 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.startPos(), 1);
|
||||
CHECK_EQ(kdata.endPos(), 4);
|
||||
CHECK_EQ(kdata.lastPos(), 3);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(200001040940), 1369.187, 1369.371, 1367.389, 1367.389, 70687.3, 251473));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(200001040945), 1367.389, 1367.389, 1364.645, 1364.763, 73577.1, 223346));
|
||||
CHECK_EQ(kdata[2], KRecord(Datetime(200001040950), 1364.763, 1364.763, 1363.128, 1363.192, 65066.3, 167971));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(200001040940), 1369.187, 1369.371, 1367.389, 1367.389,
|
||||
70687.3, 251473));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(200001040945), 1367.389, 1367.389, 1364.645, 1364.763,
|
||||
73577.1, 223346));
|
||||
CHECK_EQ(kdata[2], KRecord(Datetime(200001040950), 1364.763, 1364.763, 1363.128, 1363.192,
|
||||
65066.3, 167971));
|
||||
|
||||
/** @arg 测试15分钟线 */
|
||||
query = KQuery(1, 4, KQuery::MIN15);
|
||||
@ -655,12 +677,12 @@ TEST_CASE("test_getKData_by_index") {
|
||||
CHECK_EQ(kdata.startPos(), 1);
|
||||
CHECK_EQ(kdata.endPos(), 4);
|
||||
CHECK_EQ(kdata.lastPos(), 3);
|
||||
CHECK_EQ(kdata[0],
|
||||
KRecord(Datetime(200001041000), 1364.7630, 1364.7630, 1361.4590, 1361.4590, 204277.1000, 457452.0000));
|
||||
CHECK_EQ(kdata[1],
|
||||
KRecord(Datetime(200001041015), 1361.5580, 1366.0930, 1361.2950, 1365.9270, 307531.8000, 548313.0000));
|
||||
CHECK_EQ(kdata[2],
|
||||
KRecord(Datetime(200001041030), 1366.0430, 1367.6830, 1365.9460, 1367.6830, 279102.7000, 451981.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(200001041000), 1364.7630, 1364.7630, 1361.4590, 1361.4590,
|
||||
204277.1000, 457452.0000));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(200001041015), 1361.5580, 1366.0930, 1361.2950, 1365.9270,
|
||||
307531.8000, 548313.0000));
|
||||
CHECK_EQ(kdata[2], KRecord(Datetime(200001041030), 1366.0430, 1367.6830, 1365.9460, 1367.6830,
|
||||
279102.7000, 451981.0000));
|
||||
}
|
||||
|
||||
/** @par 检测点 */
|
||||
@ -696,7 +718,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据, 起始时间为第一条记录日期的前一天 */
|
||||
@ -713,7 +736,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据, 起始时间等于第一条记录日期 */
|
||||
@ -730,7 +754,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
expect = KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
expect =
|
||||
KRecord(Datetime(201112060000), 2326.66, 2331.892, 2310.155, 2325.905, 4262559.5, 45917078);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
/** @arg SH000001日线数据, 起始时间等于第一条记录日期的后一天 */
|
||||
@ -762,8 +787,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(201112020000), 2374.8990, 2378.2990, 2344.8460, 2360.6640, 5732015.7000, 59868846.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(201112020000), 2374.8990, 2378.2990, 2344.8460, 2360.6640,
|
||||
5732015.7000, 59868846.0000));
|
||||
|
||||
/** @arg SH000001日线数据, 指定起始时间为第一条记录,截至日期为最后一条记录 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -779,8 +804,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(201112050000), 2363.1110, 2363.1270, 2327.6100, 2333.2290, 4864121.6000, 52214970.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(201112050000), 2363.1110, 2363.1270, 2327.6100, 2333.2290,
|
||||
4864121.6000, 52214970.0000));
|
||||
|
||||
/** @arg SH000001日线数据, 指定起始时间为第一条记录,截至日期为最后一条记录的后一天 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -796,8 +821,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(201112060000), 2326.6600, 2331.8920, 2310.1550, 2325.9050, 4262559.5000, 45917078.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(201112060000), 2326.6600, 2331.8920, 2310.1550, 2325.9050,
|
||||
4262559.5000, 45917078.0000));
|
||||
|
||||
/** @arg SH000001日线数据, 中间任意一段日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -809,12 +834,12 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.endPos(), 1214);
|
||||
CHECK_EQ(kdata.lastPos(), 1213);
|
||||
record = kdata[0];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(199510180000), 705.7200, 716.8300, 705.7200, 716.8300, 232685.5000, 4273054.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(199510180000), 705.7200, 716.8300, 705.7200, 716.8300,
|
||||
232685.5000, 4273054.0000));
|
||||
|
||||
record = kdata[kdata.size() - 1];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(199510230000), 729.7600, 729.9700, 718.4400, 723.0900, 235482.7000, 3877994.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(199510230000), 729.7600, 729.9700, 718.4400, 723.0900,
|
||||
235482.7000, 3877994.0000));
|
||||
|
||||
/** @arg SH000001日线数据, 起始日期等于结束日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -860,7 +885,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.endPos(), 1);
|
||||
CHECK_EQ(kdata.lastPos(), 0);
|
||||
record = kdata[0];
|
||||
CHECK_EQ(record, KRecord(Datetime(199012190000), 96.0500, 99.9800, 95.7900, 99.9800, 49.4000, 1260.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(199012190000), 96.0500, 99.9800, 95.7900, 99.9800, 49.4000,
|
||||
1260.0000));
|
||||
|
||||
query = KQueryByDate(Datetime(201111140000), Datetime(201111150000));
|
||||
kdata = stock.getKData(query);
|
||||
@ -870,8 +896,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.endPos(), 5105);
|
||||
CHECK_EQ(kdata.lastPos(), 5104);
|
||||
record = kdata[0];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(201111140000), 2498.6720, 2529.6320, 2496.3350, 2528.7140, 8252378.1000, 81229813.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(201111140000), 2498.6720, 2529.6320, 2496.3350, 2528.7140,
|
||||
8252378.1000, 81229813.0000));
|
||||
|
||||
query = KQueryByDate(Datetime(201112060000), Datetime(201112070000));
|
||||
kdata = stock.getKData(query);
|
||||
@ -881,8 +907,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.endPos(), 5121);
|
||||
CHECK_EQ(kdata.lastPos(), 5120);
|
||||
record = kdata[0];
|
||||
CHECK_EQ(record,
|
||||
KRecord(Datetime(201112060000), 2326.6600, 2331.8920, 2310.1550, 2325.9050, 4262559.5000, 45917078.0000));
|
||||
CHECK_EQ(record, KRecord(Datetime(201112060000), 2326.6600, 2331.8920, 2310.1550, 2325.9050,
|
||||
4262559.5000, 45917078.0000));
|
||||
|
||||
///===================================
|
||||
/// 测试周线
|
||||
@ -896,10 +922,12 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199012280000), 113.5700, 126.4500, 109.1300, 126.4500, 28.2000, 321.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1],
|
||||
KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199012280000), 113.5700, 126.4500, 109.1300, 126.4500,
|
||||
28.2000, 321.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112090000), 2363.1110, 2363.1270,
|
||||
2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
|
||||
/** @arg 起始时间等于第一条记录日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -910,10 +938,12 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[10], KRecord(Datetime(199103010000), 134.3700, 134.8700, 132.4700, 132.5300, 827.1000, 11500.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1],
|
||||
KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[10], KRecord(Datetime(199103010000), 134.3700, 134.8700, 132.4700, 132.5300,
|
||||
827.1000, 11500.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112090000), 2363.1110, 2363.1270,
|
||||
2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
|
||||
/** @arg 起始时间等于第一条记录日期的后一天 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -924,10 +954,12 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 1);
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012280000), 113.5700, 126.4500, 109.1300, 126.4500, 28.2000, 321.0000));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199101040000), 126.5600, 131.4400, 126.4800, 131.4400, 47.3000, 730.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1],
|
||||
KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012280000), 113.5700, 126.4500, 109.1300, 126.4500,
|
||||
28.2000, 321.0000));
|
||||
CHECK_EQ(kdata[1], KRecord(Datetime(199101040000), 126.5600, 131.4400, 126.4800, 131.4400,
|
||||
47.3000, 730.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112090000), 2363.1110, 2363.1270,
|
||||
2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
|
||||
/** @arg 指定起始时间为第一条记录,截至日期为最后一条记录的前一天且不等于前一条记录的日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -938,9 +970,10 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), total - 1);
|
||||
CHECK_EQ(kdata.lastPos(), total - 2);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112020000), 2383.8930, 2423.5590, 2319.4400, 2360.6640,
|
||||
32821965.5000, 336317856.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112020000), 2383.8930, 2423.5590,
|
||||
2319.4400, 2360.6640, 32821965.5000, 336317856.0000));
|
||||
|
||||
/** @arg 指定起始时间为第一条记录,截至日期为最后一条记录 */
|
||||
query = KQueryByDate(Datetime(199012210000), Datetime(201112090000), KQuery::WEEK);
|
||||
@ -950,9 +983,10 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), total - 1);
|
||||
CHECK_EQ(kdata.lastPos(), total - 2);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112020000), 2383.8930, 2423.5590, 2319.4400, 2360.6640,
|
||||
32821965.5000, 336317856.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112020000), 2383.8930, 2423.5590,
|
||||
2319.4400, 2360.6640, 32821965.5000, 336317856.0000));
|
||||
|
||||
/** @arg 指定起始时间为第一条记录,截至日期为最后一条记录的后一天 */
|
||||
query = KQueryByDate(Datetime(199012210000), Datetime(201112100000), KQuery::WEEK);
|
||||
@ -962,9 +996,10 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), total);
|
||||
CHECK_EQ(kdata.lastPos(), total - 1);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1],
|
||||
KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201112090000), 2363.1110, 2363.1270,
|
||||
2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
|
||||
/** @arg 中间任意一段日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -975,10 +1010,10 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 1043);
|
||||
CHECK_EQ(kdata.endPos(), 1054);
|
||||
CHECK_EQ(kdata.lastPos(), 1053);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(201108190000), 2598.1380, 2636.3600, 2513.7540, 2534.3580, 40330572.2000,
|
||||
385608932.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201111040000), 2470.2540, 2536.7790, 2433.7150, 2528.2940,
|
||||
50520578.9000, 516983184.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(201108190000), 2598.1380, 2636.3600, 2513.7540, 2534.3580,
|
||||
40330572.2000, 385608932.0000));
|
||||
CHECK_EQ(kdata[kdata.size() - 1], KRecord(Datetime(201111040000), 2470.2540, 2536.7790,
|
||||
2433.7150, 2528.2940, 50520578.9000, 516983184.0000));
|
||||
|
||||
/** @arg 起始日期等于结束日期 */
|
||||
stock = sm.getStock("sh000001");
|
||||
@ -1023,7 +1058,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 0);
|
||||
CHECK_EQ(kdata.endPos(), 1);
|
||||
CHECK_EQ(kdata.lastPos(), 0);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300, 59.4000, 1485.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199012210000), 96.0500, 109.1300, 95.7900, 109.1300,
|
||||
59.4000, 1485.0000));
|
||||
|
||||
query = KQueryByDate(Datetime(199707250000), Datetime(199708010000), KQuery::WEEK);
|
||||
kdata = stock.getKData(query);
|
||||
@ -1032,8 +1068,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 338);
|
||||
CHECK_EQ(kdata.endPos(), 339);
|
||||
CHECK_EQ(kdata.lastPos(), 338);
|
||||
CHECK_EQ(kdata[0],
|
||||
KRecord(Datetime(199707250000), 1215.8390, 1223.8230, 1158.1360, 1170.8620, 2433586.7000, 20739544.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199707250000), 1215.8390, 1223.8230, 1158.1360, 1170.8620,
|
||||
2433586.7000, 20739544.0000));
|
||||
|
||||
query = KQueryByDate(Datetime(201112090000), Datetime(201112100000), KQuery::WEEK);
|
||||
kdata = stock.getKData(query);
|
||||
@ -1042,8 +1078,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
CHECK_EQ(kdata.startPos(), 1058);
|
||||
CHECK_EQ(kdata.endPos(), 1059);
|
||||
CHECK_EQ(kdata.lastPos(), 1058);
|
||||
CHECK_EQ(kdata[0],
|
||||
KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050, 9126681.1000, 98132048.0000));
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(201112090000), 2363.1110, 2363.1270, 2310.1550, 2325.9050,
|
||||
9126681.1000, 98132048.0000));
|
||||
|
||||
///===================================
|
||||
/// 测试分钟线
|
||||
@ -1054,7 +1090,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682823L);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
expect =
|
||||
KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[1];
|
||||
@ -1071,7 +1108,8 @@ TEST_CASE("test_getKData_by_date") {
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata.size(), 682823L);
|
||||
record = kdata[0];
|
||||
expect = KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
expect =
|
||||
KRecord(Datetime(200001040931), 1366.58, 1368.692, 1366.579, 1368.692, 4124880, 191158);
|
||||
CHECK_EQ(record, expect);
|
||||
|
||||
record = kdata[1];
|
||||
@ -1192,40 +1230,54 @@ TEST_CASE("test_getKData_recover") {
|
||||
KData kdata;
|
||||
|
||||
/** @arg 前向复权*/
|
||||
query = KQuery(0, Null<int64>(), KQuery::DAY, KQuery::FORWARD);
|
||||
query = KQuery(0, Null<int64_t>(), KQuery::DAY, KQuery::FORWARD);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata[2710], KRecord(Datetime(201106030000), 10.02, 10.14, 10.0, 10.09, 38726.1, 384820));
|
||||
CHECK_EQ(kdata[2709], KRecord(Datetime(201106020000), 10.34, 10.38, 9.93, 10.04, 103909.3, 780543.0));
|
||||
CHECK_EQ(kdata[2554], KRecord(Datetime(201010140000), 11.04, 11.42, 10.91, 10.95, 322428.8, 2195006));
|
||||
CHECK_EQ(kdata[2710],
|
||||
KRecord(Datetime(201106030000), 10.02, 10.14, 10.0, 10.09, 38726.1, 384820));
|
||||
CHECK_EQ(kdata[2709],
|
||||
KRecord(Datetime(201106020000), 10.34, 10.38, 9.93, 10.04, 103909.3, 780543.0));
|
||||
CHECK_EQ(kdata[2554],
|
||||
KRecord(Datetime(201010140000), 11.04, 11.42, 10.91, 10.95, 322428.8, 2195006));
|
||||
CHECK_EQ(kdata[2548], KRecord(Datetime(201009290000), 9.26, 9.64, 9.20, 9.48, 99719.8, 799165));
|
||||
CHECK_EQ(kdata[2547], KRecord(Datetime(201009280000), 9.82, 9.82, 9.55, 9.55, 81241.5, 639882));
|
||||
|
||||
/** @arg 后向复权*/
|
||||
query = KQuery(0, Null<int64>(), KQuery::DAY, KQuery::BACKWARD);
|
||||
query = KQuery(0, Null<int64_t>(), KQuery::DAY, KQuery::BACKWARD);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199911100000), 29.5, 29.8, 27.0, 27.75, 485910.2, 1740850));
|
||||
CHECK_EQ(kdata[151], KRecord(Datetime(200007050000), 23.25, 23.47, 23.15, 23.22, 3298.8, 14218));
|
||||
CHECK_EQ(kdata[152], KRecord(Datetime(200007060000), 23.30, 23.42, 23.16, 23.23, 3049.5, 13200));
|
||||
CHECK_EQ(kdata[657], KRecord(Datetime(200208210000), 18.35, 18.75, 18.18, 18.55, 36409.8, 197640));
|
||||
CHECK_EQ(kdata[658], KRecord(Datetime(200208220000), 18.77, 18.89, 18.62, 18.81, 13101.3, 106872));
|
||||
CHECK_EQ(kdata[151],
|
||||
KRecord(Datetime(200007050000), 23.25, 23.47, 23.15, 23.22, 3298.8, 14218));
|
||||
CHECK_EQ(kdata[152],
|
||||
KRecord(Datetime(200007060000), 23.30, 23.42, 23.16, 23.23, 3049.5, 13200));
|
||||
CHECK_EQ(kdata[657],
|
||||
KRecord(Datetime(200208210000), 18.35, 18.75, 18.18, 18.55, 36409.8, 197640));
|
||||
CHECK_EQ(kdata[658],
|
||||
KRecord(Datetime(200208220000), 18.77, 18.89, 18.62, 18.81, 13101.3, 106872));
|
||||
|
||||
/** @arg 前向等比复权*/
|
||||
query = KQuery(0, Null<int64>(), KQuery::DAY, KQuery::EQUAL_FORWARD);
|
||||
query = KQuery(0, Null<int64_t>(), KQuery::DAY, KQuery::EQUAL_FORWARD);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata[2710], KRecord(Datetime(201106030000), 10.02, 10.14, 10.0, 10.09, 38726.1, 384820));
|
||||
CHECK_EQ(kdata[2709], KRecord(Datetime(201106020000), 10.33, 10.37, 9.93, 10.04, 103909.3, 780543.0));
|
||||
CHECK_EQ(kdata[2554], KRecord(Datetime(201010140000), 11.03, 11.40, 10.90, 10.94, 322428.8, 2195006));
|
||||
CHECK_EQ(kdata[2710],
|
||||
KRecord(Datetime(201106030000), 10.02, 10.14, 10.0, 10.09, 38726.1, 384820));
|
||||
CHECK_EQ(kdata[2709],
|
||||
KRecord(Datetime(201106020000), 10.33, 10.37, 9.93, 10.04, 103909.3, 780543.0));
|
||||
CHECK_EQ(kdata[2554],
|
||||
KRecord(Datetime(201010140000), 11.03, 11.40, 10.90, 10.94, 322428.8, 2195006));
|
||||
CHECK_EQ(kdata[2548], KRecord(Datetime(201009290000), 9.27, 9.64, 9.21, 9.49, 99719.8, 799165));
|
||||
CHECK_EQ(kdata[2547], KRecord(Datetime(201009280000), 9.82, 9.82, 9.55, 9.56, 81241.5, 639882));
|
||||
|
||||
/** @arg 等比后向复权*/
|
||||
query = KQuery(0, Null<int64>(), KQuery::DAY, KQuery::EQUAL_BACKWARD);
|
||||
query = KQuery(0, Null<int64_t>(), KQuery::DAY, KQuery::EQUAL_BACKWARD);
|
||||
kdata = stock.getKData(query);
|
||||
CHECK_EQ(kdata[0], KRecord(Datetime(199911100000), 29.5, 29.8, 27.0, 27.75, 485910.2, 1740850));
|
||||
CHECK_EQ(kdata[151], KRecord(Datetime(200007050000), 23.25, 23.47, 23.15, 23.22, 3298.8, 14218));
|
||||
CHECK_EQ(kdata[152], KRecord(Datetime(200007060000), 23.30, 23.42, 23.16, 23.23, 3049.5, 13200));
|
||||
CHECK_EQ(kdata[657], KRecord(Datetime(200208210000), 18.32, 18.72, 18.15, 18.52, 36409.8, 197640));
|
||||
CHECK_EQ(kdata[658], KRecord(Datetime(200208220000), 18.74, 18.86, 18.59, 18.79, 13101.3, 106872));
|
||||
CHECK_EQ(kdata[151],
|
||||
KRecord(Datetime(200007050000), 23.25, 23.47, 23.15, 23.22, 3298.8, 14218));
|
||||
CHECK_EQ(kdata[152],
|
||||
KRecord(Datetime(200007060000), 23.30, 23.42, 23.16, 23.23, 3049.5, 13200));
|
||||
CHECK_EQ(kdata[657],
|
||||
KRecord(Datetime(200208210000), 18.32, 18.72, 18.15, 18.52, 36409.8, 197640));
|
||||
CHECK_EQ(kdata[658],
|
||||
KRecord(Datetime(200208220000), 18.74, 18.86, 18.59, 18.79, 13101.3, 106872));
|
||||
}
|
||||
|
||||
/** @par 检测点 */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,40 +39,40 @@ TEST_CASE("test_mysql") {
|
||||
con->exec(
|
||||
"create table t2019 (id INTEGER PRIMARY KEY AUTO_INCREMENT, "
|
||||
"name VARCHAR(50), "
|
||||
"data_int32 INT, data_int64 BIGINT, data_double DOUBLE, data_float FLOAT)");
|
||||
"data_int32_t INT, data_int64_t BIGINT, data_double DOUBLE, data_float FLOAT)");
|
||||
}
|
||||
|
||||
class T2019 {
|
||||
TABLE_BIND5(t2019, name, data_int32, data_int64, data_double, data_float);
|
||||
TABLE_BIND5(t2019, name, data_int32_t, data_int64_t, data_double, data_float);
|
||||
|
||||
public:
|
||||
T2019()
|
||||
: name(Null<string>()),
|
||||
data_int32(Null<int32>()),
|
||||
data_int64(Null<int64>()),
|
||||
data_int32_t(Null<int32_t>()),
|
||||
data_int64_t(Null<int64_t>()),
|
||||
data_double(Null<double>()),
|
||||
data_float(Null<float>()) {}
|
||||
|
||||
void reset() {
|
||||
name = "";
|
||||
data_int32 = Null<int32>();
|
||||
data_int64 = Null<int64>();
|
||||
data_int32_t = Null<int32_t>();
|
||||
data_int64_t = Null<int64_t>();
|
||||
data_double = Null<double>();
|
||||
data_float = Null<float>();
|
||||
}
|
||||
|
||||
public:
|
||||
string name;
|
||||
int32 data_int32;
|
||||
int64 data_int64;
|
||||
int32_t data_int32_t;
|
||||
int64_t data_int64_t;
|
||||
double data_double;
|
||||
float data_float;
|
||||
};
|
||||
|
||||
T2019 x;
|
||||
x.name = "Davis";
|
||||
x.data_int32 = 32;
|
||||
x.data_int64 = 3147483647;
|
||||
x.data_int32_t = 32;
|
||||
x.data_int64_t = 3147483647;
|
||||
x.data_double = 3.1415926;
|
||||
x.data_float = 3.14f;
|
||||
con->save(x);
|
||||
@ -81,8 +81,8 @@ TEST_CASE("test_mysql") {
|
||||
con->load(rx);
|
||||
|
||||
CHECK(rx.name == x.name);
|
||||
CHECK(rx.data_int32 == x.data_int32);
|
||||
CHECK(rx.data_int64 == x.data_int64);
|
||||
CHECK(rx.data_int32_t == x.data_int32_t);
|
||||
CHECK(rx.data_int64_t == x.data_int64_t);
|
||||
CHECK(std::abs(rx.data_double - x.data_double) < 0.00001);
|
||||
CHECK(std::abs(rx.data_float - x.data_float) < 0.00001);
|
||||
con->exec("drop table t2019");
|
||||
|
@ -22,7 +22,7 @@ struct Constant {
|
||||
null_price(Null<price_t>()),
|
||||
null_int(Null<int>()),
|
||||
null_size(Null<size_t>()),
|
||||
null_int64(Null<int64>()),
|
||||
null_int64(Null<int64_t>()),
|
||||
STOCKTYPE_BLOCK(0),
|
||||
STOCKTYPE_A(1),
|
||||
STOCKTYPE_INDEX(2),
|
||||
@ -49,7 +49,7 @@ struct Constant {
|
||||
double null_price;
|
||||
int null_int;
|
||||
size_t null_size;
|
||||
int64 null_int64;
|
||||
int64_t null_int64;
|
||||
bool pickle_support; //是否支持pickle
|
||||
|
||||
int STOCKTYPE_BLOCK; /// 板块
|
||||
@ -75,7 +75,7 @@ void export_Constant() {
|
||||
.def_readonly("null_price", &Constant::null_price, "同 nan")
|
||||
.def_readonly("null_int", &Constant::null_int, "无效int")
|
||||
.def_readonly("null_size", &Constant::null_size, "无效size")
|
||||
.def_readonly("null_int64", &Constant::null_int64, "无效int64")
|
||||
.def_readonly("null_int64", &Constant::null_int64, "无效int64_t")
|
||||
.def_readonly("pickle_support", &Constant::pickle_support, "是否支持 pickle")
|
||||
|
||||
.def_readonly("STOCKTYPE_BLOCK", &Constant::STOCKTYPE_BLOCK, "板块")
|
||||
|
@ -15,16 +15,16 @@ using namespace hku;
|
||||
void export_KQuery() {
|
||||
scope in_Query =
|
||||
class_<KQuery>("Query", "K线数据查询条件", init<>())
|
||||
.def(init<int64, optional<int64, KQuery::KType, KQuery::RecoverType> >())
|
||||
.def(init<int64_t, optional<int64_t, KQuery::KType, KQuery::RecoverType> >())
|
||||
.def(init<Datetime, optional<Datetime, KQuery::KType, KQuery::RecoverType> >())
|
||||
|
||||
.def(self_ns::str(self))
|
||||
.def(self_ns::repr(self))
|
||||
|
||||
.add_property("start", &KQuery::start,
|
||||
"起始索引,当按日期查询方式创建时无效,为 constant.null_int64")
|
||||
"起始索引,当按日期查询方式创建时无效,为 constant.null_int64_t")
|
||||
.add_property("end", &KQuery::end,
|
||||
"结束索引,当按日期查询方式创建时无效,为 constant.null_int64")
|
||||
"结束索引,当按日期查询方式创建时无效,为 constant.null_int64_t")
|
||||
.add_property("start_datetime", &KQuery::startDatetime,
|
||||
"起始日期,当按索引查询方式创建时无效,为 constant.null_datetime")
|
||||
.add_property("end_datetime", &KQuery::endDatetime,
|
||||
|
@ -14,7 +14,7 @@ using namespace hku;
|
||||
|
||||
void export_StockTypeInfo() {
|
||||
class_<StockTypeInfo>("StockTypeInfo", "股票类型详情记录", init<>())
|
||||
.def(init<uint32, const string&, price_t, price_t, int, double, double>())
|
||||
.def(init<uint32_t, const string&, price_t, price_t, int, double, double>())
|
||||
|
||||
.def("__str__", &StockTypeInfo::toString)
|
||||
.def("__repr__", &StockTypeInfo::toString)
|
||||
|
@ -40,20 +40,20 @@ void export_trade_manage_main();
|
||||
void export_trade_sys_main();
|
||||
|
||||
KData Py_GetKData(const string& market_code, py::object start = py::long_(0),
|
||||
py::object end = py::long_(Null<int64>()), KQuery::KType ktype = KQuery::DAY,
|
||||
py::object end = py::long_(Null<int64_t>()), KQuery::KType ktype = KQuery::DAY,
|
||||
KQuery::RecoverType recovertType = KQuery::NO_RECOVER) {
|
||||
py::extract<KQuery> query_x(start);
|
||||
if (query_x.check()) {
|
||||
return getKData(market_code, query_x());
|
||||
}
|
||||
|
||||
py::extract<int64> int_x(start);
|
||||
py::extract<int64_t> int_x(start);
|
||||
if (int_x.check()) {
|
||||
int64 start_ix = 0, end_ix = 0;
|
||||
int64_t start_ix = 0, end_ix = 0;
|
||||
if (end.is_none()) {
|
||||
end_ix = Null<int64>();
|
||||
end_ix = Null<int64_t>();
|
||||
} else {
|
||||
py::extract<int64> int_y(end);
|
||||
py::extract<int64_t> int_y(end);
|
||||
if (!int_y.check()) {
|
||||
HKU_THROW_EXCEPTION(
|
||||
std::invalid_argument,
|
||||
@ -136,7 +136,7 @@ BOOST_PYTHON_MODULE(core) {
|
||||
:return: 对应的证券实例,如果实例不存在,则返回空实例,即Stock(),不抛出异常
|
||||
:rtype: Stock)");
|
||||
|
||||
int64 null_int = Null<int64>();
|
||||
int64_t null_int = Null<int64_t>();
|
||||
py::def(
|
||||
"get_kdata", Py_GetKData,
|
||||
(py::arg("market_code"), py::arg("start") = py::long_(0), py::arg("end") = py::object(),
|
||||
|
Loading…
Reference in New Issue
Block a user