hikyuu2/hikyuu_pywrap/_StockManager.cpp

156 lines
6.4 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* _StockManager.cpp
*
* Created on: 2011-12-4
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/StockManager.h>
using namespace boost::python;
using namespace hku;
2020-07-10 00:23:33 +08:00
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getTradingCalendar_overloads, getTradingCalendar, 1, 2)
2016-04-03 00:08:31 +08:00
BlockList (StockManager::*getBlockList_1)(const string&) = &StockManager::getBlockList;
BlockList (StockManager::*getBlockList_2)() = &StockManager::getBlockList;
2020-07-10 00:23:33 +08:00
void export_StockManager() {
class_<StockManager>("StockManager", "证券信息管理类", no_init)
.def("instance", &StockManager::instance, return_value_policy<reference_existing_object>(),
"获取StockManager单例实例")
.staticmethod("instance")
2021-02-17 19:43:59 +08:00
.def(
"init", &StockManager::init,
(arg("base_info_param"), arg("block_param"), arg("kdata_param"), arg("preload_param"),
arg("hikyuu_param"), arg("context") = StrategyContext({"all"})),
R"(init(self, base_info_param, block_param, kdata_param, preload_param, hikyuu_param, context)
2020-07-10 00:23:33 +08:00
:param base_info_param
param block_param
param kdata_param K线数据驱动参数
param preload_param
2021-02-17 19:43:59 +08:00
param hikyuu_param
param StrategyContext context , )")
2020-07-10 00:23:33 +08:00
2021-01-29 00:18:01 +08:00
.def("reload", &StockManager::reload, "重新加载所有证券数据")
2020-07-10 00:23:33 +08:00
.def("tmpdir", &StockManager::tmpdir, R"(tmpdir(self) -> str
m_config中的tmpdir)")
.def("get_base_info_parameter", &StockManager::getBaseInfoDriverParameter,
2020-12-19 23:57:24 +08:00
return_value_policy<copy_const_reference>(), "获取当前基础信息驱动参数")
2020-07-10 00:23:33 +08:00
.def("get_block_parameter", &StockManager::getBlockDriverParameter,
2020-12-19 23:57:24 +08:00
return_value_policy<copy_const_reference>(), "获取当前板块信息驱动参数")
.def("get_kdata_parameter", &StockManager::getKDataDriverParameter,
return_value_policy<copy_const_reference>(), "获取当前K线数据驱动参数")
.def("get_preload_parameter", &StockManager::getPreloadParameter,
return_value_policy<copy_const_reference>(), "获取当前预加载参数")
.def("get_hikyuu_parameter", &StockManager::getHikyuuParameter,
return_value_policy<copy_const_reference>(), "获取当前其他参数")
2020-07-10 00:23:33 +08:00
.def("get_market_list", &StockManager::getAllMarket, R"(get_market_list(self)
:rtype: StringList)")
.def("get_market_info", &StockManager::getMarketInfo, R"(get_market_info(self, market)
:param string market:
:return: Null<MarketInfo>()
:rtype: MarketInfo)")
.def("get_stock_type_info", &StockManager::getStockTypeInfo,
R"(get_stock_type_info(self, stk_type)
:param int stk_type: :py:data:`constant`
:return: Null<StockTypeInfo>()
:rtype: StockTypeInfo)")
.def("get_stock", &StockManager::getStock, R"(get_stock(self, querystr)
"市场简称证券代码"
:param str querystr: "sh000001"
:return: Null<Stock>()
:rtype: Stock)")
2020-07-31 00:20:22 +08:00
.def("get_block", &StockManager::getBlock, R"(get_block(self, category, name)
2020-07-10 00:23:33 +08:00
:param str category:
:param str name:
:return: Block
:rtype: Block)")
.def("get_block_list", getBlockList_1)
.def("get_block_list", getBlockList_2, R"(get_block_list(self[, category])
:param str category:
:return:
:rtype: BlockList)")
.def("get_trading_calendar", &StockManager::getTradingCalendar,
(arg("query"), arg("market") = "SH"),
R"(get_trading_calendar(self, query[, market='SH'])
:param KQuery query: Query查询条件
:param str market:
:return:
:rtype: DatetimeList)")
.def(
"add_temp_csv_stock", &StockManager::addTempCsvStock,
(arg("code"), arg("day_filename"), arg("min_filename"), arg("tick") = 0.01,
arg("tick_value") = 0.01, arg("precision") = 2, arg("min_trade_num") = 1,
arg("max_trade_num") = 1000000),
R"(add_temp_csv_stock(code, day_filename, min_filename[, tick=0.01, tick_value=0.01, precision=2, min_trade_num = 1, max_trade_num=1000000])
CSV文件K线数据StockCSV格式的K线数据时
CSV文件第一行为标题 DatetimeDateOPENHIGHLOWCLOSEAMOUNTVOLUMEVOLCOUNT
:param str code: Stock相同Null<Stock>
:param str day_filename: 线CSV文件名
:param str min_filename: 线CSV文件名
:param float tick: 0.01
:param float tick_value: 0.01
:param int precision: 2
:param int min_trade_num: 1
:param int max_trade_num: 1000000
:return: Stock
:rtype: Stock)")
.def("remove_temp_csv_stock", &StockManager::removeTempCsvStock,
R"(remove_temp_csv_stock(self, code)
2020-07-10 00:23:33 +08:00
Stock
:param str code: )")
.def("is_holiday", &StockManager::isHoliday, R"(is_holiday(self, d)
:param Datetime d: )")
2020-07-10 00:23:33 +08:00
.def("__len__", &StockManager::size, "返回证券数量")
.def("__getitem__", &StockManager::getStock, "同 get_stock")
.def("__iter__", iterator<const StockManager>());
2015-01-07 01:26:14 +08:00
}