hikyuu2/hikyuu_pywrap/_StockManager.cpp

165 lines
6.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* _StockManager.cpp
*
* Created on: 2011-12-4
* Author: fasiondog
*/
#include <hikyuu/StockManager.h>
#include "pybind_utils.h"
using namespace hku;
namespace py = pybind11;
void export_StockManager(py::module& m) {
py::class_<StockManager>(m, "StockManager", "证券信息管理类")
.def_static("instance", &StockManager::instance, py::return_value_policy::reference,
"获取StockManager单例实例")
.def(
"init", &StockManager::init, py::arg("base_info_param"), py::arg("block_param"),
py::arg("kdata_param"), py::arg("preload_param"), py::arg("hikyuu_param"),
py::arg("context") = StrategyContext({"all"}),
R"(init(self, base_info_param, block_param, kdata_param, preload_param, hikyuu_param, context)
:param base_info_param
param block_param
param kdata_param K线数据驱动参数
param preload_param
param hikyuu_param
param StrategyContext context , )")
.def("reload", &StockManager::reload, "重新加载所有证券数据")
.def("tmpdir", &StockManager::tmpdir, R"(tmpdir(self) -> str
m_config中的tmpdir)")
.def("datadir", &StockManager::datadir, R"(datadir(self) -> str
)")
.def("get_base_info_parameter", &StockManager::getBaseInfoDriverParameter,
py::return_value_policy::copy, "获取当前基础信息驱动参数")
.def("get_block_parameter", &StockManager::getBlockDriverParameter,
py::return_value_policy::copy, "获取当前板块信息驱动参数")
.def("get_kdata_parameter", &StockManager::getKDataDriverParameter,
py::return_value_policy::copy, "获取当前K线数据驱动参数")
.def("get_preload_parameter", &StockManager::getPreloadParameter,
py::return_value_policy::copy, "获取当前预加载参数")
.def("get_hikyuu_parameter", &StockManager::getHikyuuParameter, py::return_value_policy::copy,
"获取当前其他参数")
.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)")
.def("get_block", &StockManager::getBlock, R"(get_block(self, category, name)
:param str category:
:param str name:
:return: Block
:rtype: Block)")
.def("get_block_list", py::overload_cast<>(&StockManager::getBlockList))
.def("get_block_list", py::overload_cast<const string&>(&StockManager::getBlockList),
R"(get_block_list(self[, category])
:param str category:
:return:
:rtype: BlockList)")
.def("get_trading_calendar", &StockManager::getTradingCalendar, py::arg("query"),
py::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, py::arg("code"),
py::arg("day_filename"), py::arg("min_filename"), py::arg("tick") = 0.01,
py::arg("tick_value") = 0.01, py::arg("precision") = 2, py::arg("min_trade_num") = 1,
py::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线数据时
stock market "TMP", sm tmpsm['tmp0001']
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)",
py::keep_alive<1, 2>())
.def("remove_temp_csv_stock", &StockManager::removeTempCsvStock,
R"(remove_temp_csv_stock(self, code)
Stock
:param str code: )")
.def("is_holiday", &StockManager::isHoliday, R"(is_holiday(self, d)
:param Datetime d: )")
.def("__len__", &StockManager::size, "返回证券数量")
.def("__getitem__", &StockManager::getStock, "同 get_stock")
.def(
"__iter__",
[](const StockManager& sm) {
return py::make_iterator<py::return_value_policy::reference_internal, StockMapIterator,
StockMapIterator, const Stock&>(sm.begin(), sm.end());
},
py::keep_alive<0, 1>());
}