/*
* test_Stock.cpp
*
* Created on: 2011-12-10
* Author: fasiondog
*/
#include "doctest/doctest.h"
#include <cmath>
#include <hikyuu/StockManager.h>
#include <hikyuu/KQuery.h>
#include <hikyuu/KData.h>
#include <hikyuu/Stock.h>
using namespace hku;
#define MEMORY_CHECK \
{ \
Stock mem_stock = sm["sh000001"]; \
CHECK_EQ(mem_stock.isBuffer(KQuery::DAY), true); \
CHECK_EQ(mem_stock.isBuffer(KQuery::WEEK), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MONTH), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::QUARTER), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::HALFYEAR), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::YEAR), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MIN), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MIN5), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MIN15), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MIN30), false); \
CHECK_EQ(mem_stock.isBuffer(KQuery::MIN60), false); \
}
/**
* @defgroup test_hikyuu_Stock test_hikyuu_Stock
* @ingroup test_hikyuu_base_suite
* @{
*/
/** @par 检测点 */
TEST_CASE("test_Stock_Relational_comparison") {
StockManager& sm = StockManager::instance();
Stock s1;
/** @arg 和Null<Stock>()进行相等比较 */
CHECK_EQ(s1, Null<Stock>());
/** @arg 和Null<Stock>()进行不等比较 */
s1 = sm.getStock("sh000001");
CHECK_NE(s1, Null<Stock>());
/** @arg 相等比较 */
Stock s2 = sm.getStock("sh000001");
CHECK_EQ(s1, s2);
/** @arg 不等比较 */
s2 = sm.getStock("sz000001");
CHECK_NE(s1, s2);
MEMORY_CHECK;
}
/** @par 检测点 */
TEST_CASE("test_Stock_getWeight") {
StockManager& sm = StockManager::instance();
Stock stock = sm.getStock("sz000001");
StockWeight weight;
/** @arg 查询全部权息信息 */
StockWeightList weightList = stock.getWeight();
CHECK_EQ(weightList.size(), 23);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(199104030000L));
CHECK_EQ(weight.countAsGift(), 0.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 150);
CHECK_EQ(weight.freeCount(), 68);
weight = weightList.back();
CHECK_EQ(weight.datetime(), Datetime(201108050000L));
CHECK_EQ(weight.countAsGift(), 0.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 512335);
CHECK_EQ(weight.freeCount(), 310536);
/** @arg 查询指定日期范围内的权息信息,指定的起始日期和结束日期没有刚好对应的权息记录 */
weightList = stock.getWeight(Datetime(199501010000), Datetime(199701010000));
CHECK_EQ(weightList.size(), 2);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(199509250000));
CHECK_EQ(weight.countAsGift(), 2.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 3.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 51728);
CHECK_EQ(weight.freeCount(), 35721);
weight = weightList.back();
CHECK_EQ(weight.datetime(), Datetime(199605270000));
CHECK_EQ(weight.countAsGift(), 5.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 5.0);
CHECK_EQ(weight.totalCount(), 103456);
CHECK_EQ(weight.freeCount(), 71393);
/** @arg 查询指定日期范围内的权息信息,指定的起始日期刚好存在对应权息记录,而结束日期没有 */
weightList = stock.getWeight(Datetime(199509250000), Datetime(199701010000));
CHECK_EQ(weightList.size(), 2);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(199509250000));
CHECK_EQ(weight.countAsGift(), 2.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 3.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 51728);
CHECK_EQ(weight.freeCount(), 35721);
weight = weightList.back();
CHECK_EQ(weight.datetime(), Datetime(199605270000));
CHECK_EQ(weight.countAsGift(), 5.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 5.0);
CHECK_EQ(weight.totalCount(), 103456);
CHECK_EQ(weight.freeCount(), 71393);
/** @arg 查询指定日期范围内的权息信息,指定的结束日期刚好存在对应权息记录,而起始日期没有 */
weightList = stock.getWeight(Datetime(199501010000), Datetime(199605270000));
CHECK_EQ(weightList.size(), 1);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(199509250000));
CHECK_EQ(weight.countAsGift(), 2.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 3.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 51728);
CHECK_EQ(weight.freeCount(), 35721);
/** @arg 查询指定日期范围内的权息信息,结束日期为Null<Datetime>() */
weightList = stock.getWeight(Datetime(201101010000), Null<Datetime>());
CHECK_EQ(weightList.size(), 1);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(201108050000));
CHECK_EQ(weight.countAsGift(), 0.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 512335);
CHECK_EQ(weight.freeCount(), 310536);
/** @arg 查询指定日期范围内的权息信息,只指定起始日期,结束日期为默认值 */
weightList = stock.getWeight(Datetime(201101010000));
CHECK_EQ(weightList.size(), 1);
weight = weightList.front();
CHECK_EQ(weight.datetime(), Datetime(201108050000));
CHECK_EQ(weight.countAsGift(), 0.0);
CHECK_EQ(weight.countForSell(), 0.0);
CHECK_EQ(weight.priceForSell(), 0.0);
CHECK_EQ(weight.bonus(), 0.0);
CHECK_EQ(weight.increasement(), 0.0);
CHECK_EQ(weight.totalCount(), 512335);
CHECK_EQ(weight.freeCount(), 310536);
MEMORY_CHECK;
}
/** @par 检测点 */
TEST_CASE("test_Stock_getCount") {
StockManager& sm = StockManager::instance();
/** @arg 查询sh000001的日线数量*/
Stock stock = sm.getStock("sh000001");
CHECK_EQ(stock.getCount(KQuery::DAY), 5121);
/** @arg 查询sz000001的日线数量 */
stock = sm.getStock("Sz000001");
CHECK_EQ(stock.getCount(KQuery::DAY), 4937);
/** @arg 查询sh000001的周线数量*/
stock = sm.getStock("sh000001");
CHECK_EQ(stock.getCount(KQuery::WEEK), 1059);
/** @arg 查询sz000001的周线数量 */
stock = sm.getStock("Sz000001");
CHECK_EQ(stock.getCount(KQuery::WEEK), 1037);
/** @arg 查询sh000001的月线数量*/
stock = sm.getStock("sh000001");
CHECK_EQ(stock.getCount(KQuery::MONTH), 253);
/** @arg 查询sz000001的月线数量 */
stock = sm.getStock("Sz000001");
CHECK_EQ(stock.getCount(KQuery::MONTH), 250);
/** @arg 查询sh000001的季线数量*/
stock = sm.getStock("sh000001");
CHECK_EQ(stock.getCount(KQuery::QUARTER), 85);
/** @arg 查询sz000001的季线数量 */
stock = sm.getStock("Sz000001");
CHECK_EQ(stock.getCount(KQuery::QUARTER), 84);
/** @arg 查询sh000001的半年线数量*/
stock = sm.getStock("sh000001");
CHECK_EQ(stock.getCount(KQuery:
没有合适的资源?快使用搜索试试~ 我知道了~
基于C++Python的开源框架.rar
共1213个文件
cpp:414个
h:397个
py:166个
需积分: 5 0 下载量 79 浏览量
2023-06-21
16:52:57
上传
评论 1
收藏 51.31MB RAR 举报
温馨提示
介绍:一个用python实现的科学计算包。包括:1、一个强大的N维数组对象Array;2、比较成熟的(广播)函数库;3、用于整合C/C++和Fortran代码的工具包;4、实用的线性代数、傅里叶变换和随机数生成函数。numpy和稀疏矩阵运算包scipy配合使用更加方便。 scipy 介绍:SciPy是一款方便、易于使用、专为科学和工程设计的Python工具包。它包括统计、优化、线性代数、傅里叶变换、信号和图像处理、常微分方程求解等等。 pandas 介绍:Python Data Analysis Library 或 pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。Pandas 纳入了大量库和一些标准的数据模型,提供了高效地操作大型数据集所需的工具。pandas提供了大量能使我们快速便捷地处理数据的函数和方法。你很快就会发现,它是使Python成为强大而高效的数据分析环境的重要因素之一。 quantdsl 介绍: quantdsl包是Quant DSL语法在Python中的一个实现。Quant DSL 是财务定量分析领域专用语言
资源推荐
资源详情
资源评论
收起资源包目录
基于C++Python的开源框架.rar (1213个子文件)
LICENSE.996 3KB
make.bat 778B
extract_pot.bat 270B
resource.bat 111B
to_ts.bat 41B
.clang-format 3KB
test_Stock.cpp 87KB
TradeManager.cpp 78KB
test_KData.cpp 60KB
_build_in.cpp 52KB
H5KDataDriver.cpp 38KB
IndicatorImp.cpp 38KB
test_TradeManager.cpp 35KB
System.cpp 35KB
sha2.cpp 27KB
Stock.cpp 24KB
blf.cpp 22KB
test_Datetime.cpp 22KB
StockManager.cpp 20KB
test_iniparser.cpp 20KB
AllocateFundsBase.cpp 19KB
test_Indicator.cpp 19KB
Performance.cpp 17KB
test_Simple_SYS_for_ev.cpp 16KB
KDataImp.cpp 16KB
Datetime.cpp 14KB
IniParser.cpp 13KB
_TradeManager.cpp 13KB
test_TimeDelta.cpp 13KB
TdxKDataDriver.cpp 12KB
test_Simple_SYS_for_cn.cpp 12KB
_MoneyManager.cpp 12KB
SQLiteBaseInfoDriver.cpp 11KB
MySQLStatement.cpp 11KB
_System.cpp 11KB
Portfolio.cpp 10KB
StrategyBase.cpp 9KB
Indicator.cpp 9KB
test_StockManager.cpp 9KB
GlobalSpotAgent.cpp 9KB
HttpHandle.cpp 9KB
base64.cpp 9KB
_save_load.cpp 8KB
test_Simple_SYS_for_pg.cpp 8KB
test_TransList.cpp 8KB
cbcrypt.cpp 8KB
_Signal.cpp 8KB
test_Simple_SYS_for_tp.cpp 8KB
MySQLBaseInfoDriver.cpp 8KB
SpotAgent.cpp 7KB
test_Simple_SYS_for_base.cpp 7KB
test_TimeLine.cpp 7KB
IAma.cpp 7KB
test_export.cpp 7KB
test_SUMBARS.cpp 7KB
_Indicator.cpp 7KB
_Stock.cpp 7KB
test_MA.cpp 7KB
_StockManager.cpp 7KB
MoneyManagerBase.cpp 6KB
test_ALIGN.cpp 6KB
test_MACD.cpp 6KB
test_Simple_SYS_for_st.cpp 6KB
Parameter.cpp 6KB
test_SAFTYLOSS.cpp 6KB
_TradeCost.cpp 6KB
KDataTempCsvDriver.cpp 6KB
_Selector.cpp 6KB
_KDataDriver.cpp 6KB
test_IKData.cpp 6KB
_ProfitGoal.cpp 6KB
TradeRecord.cpp 6KB
TimeDelta.cpp 6KB
_Stoploss.cpp 6KB
test_LLVBARS.cpp 6KB
MySQLKDataDriver.cpp 6KB
test_HHVBARS.cpp 6KB
test_crtFixedATC.cpp 6KB
bcrypt_pbkdf.cpp 6KB
test_FILTER.cpp 6KB
_TimeDelta.cpp 5KB
_Datetime.cpp 5KB
QLBlockInfoDriver.cpp 5KB
test_sqlite.cpp 5KB
test_Parameter.cpp 5KB
test_mysql.cpp 5KB
_IndicatorImp.cpp 5KB
test_LAST.cpp 5KB
DataDriverFactory.cpp 5KB
IKData.cpp 5KB
ISaftyLoss.cpp 5KB
util.cpp 5KB
test_EVERY.cpp 5KB
main.cpp 5KB
test_EXIST.cpp 5KB
test_BACKSET.cpp 5KB
test_HHV.cpp 5KB
test_LLV.cpp 5KB
test_AMA.cpp 5KB
_AllocateFunds.cpp 5KB
共 1213 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
野生的狒狒
- 粉丝: 3393
- 资源: 2436
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Django和OpenCV的智能车视频处理系统.zip
- (源码)基于ESP8266的WebDAV服务器与3D打印机管理系统.zip
- (源码)基于Nio实现的Mycat 2.0数据库代理系统.zip
- (源码)基于Java的高校学生就业管理系统.zip
- (源码)基于Spring Boot框架的博客系统.zip
- (源码)基于Spring Boot框架的博客管理系统.zip
- (源码)基于ESP8266和Blynk的IR设备控制系统.zip
- (源码)基于Java和JSP的校园论坛系统.zip
- (源码)基于ROS Kinetic框架的AGV激光雷达导航与SLAM系统.zip
- (源码)基于PythonDjango框架的资产管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功