hikyuu2/hikyuu/core_doc.py
2019-04-10 23:06:21 +08:00

1051 lines
26 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.

#!/usr/bin/python
# -*- coding: utf8 -*-
# cp936
#
# The MIT License (MIT)
#
# Copyright (c) 2010-2017 fasiondog
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from hikyuu._hikyuu import *
#------------------------------------------------------------------
# from _DataType.cpp
#------------------------------------------------------------------
DatetimeList.__doc__ = """日期序列对应C++中的std::vector<Datetime>"""
PriceList.__doc__ ="""价格序列其中价格使用double表示对应C++中的std::vector<double>。"""
toPriceList.__doc__ = """
Python的可迭代对象如 listtuple PriceList
:param arg: Python序列
:rtype: PriceList
"""
StringList.__doc__ = """字符串列表对应C++中的std::vector<String>"""
#------------------------------------------------------------------
# from _Datetime.cpp
#------------------------------------------------------------------
Datetime.__doc__ = """日期时间类,精确到秒"""
Datetime.dayOfWeek.__doc__ = """
dayOfWeek(self)
01
:rtype: int
"""
Datetime.dateOfWeek.__doc__ = """
dateOfWeek(self, day)
06
:param int day: 066
:rtype: Datetime
"""
Datetime.dayOfYear.__doc__ = """
dayOfYear(self)
111
:rtype: int
"""
Datetime.startOfWeek.__doc__ = """
startOfWeek(self)
"""
Datetime.endOfWeek.__doc__ = """
endOfWeek(self)
"""
Datetime.startOfMonth.__doc__ = """
startOfMonth(self)
"""
Datetime.endOfMonth.__doc__ = """
endOfMonth(self)
"""
Datetime.startOfQuarter.__doc__ = """
startOfQuarter(self)
"""
Datetime.endOfQuarter.__doc__ = """
endOfQuarter(self)
"""
Datetime.startOfHalfyear.__doc__ = """
startOfHalfyear(self)
"""
Datetime.endOfHalfyear.__doc__ = """
endOfHalfyear(self)
"""
Datetime.startOfYear.__doc__ = """
startOfYear(self)
"""
Datetime.endOfYear.__doc__ = """
endOfYear(self)
"""
Datetime.nextDay.__doc__ = """
nextDay(self)
"""
Datetime.nextWeek.__doc__ = """
nextWeek(self)
"""
Datetime.nextMonth.__doc__ = """
nextMonth(self)
"""
Datetime.nextQuarter.__doc__ = """
nextQuarter(self)
"""
Datetime.nextHalfyear.__doc__ = """
nextHalfyear(self)
"""
Datetime.nextYear.__doc__ = """
nextYear(self)
"""
Datetime.preDay.__doc__ = """
preDay(self)
"""
Datetime.preWeek.__doc__ = """
preWeek(self)
"""
Datetime.preMonth.__doc__ = """
preMonth(self)
"""
Datetime.preQuarter.__doc__ = """
preQuarter(self)
"""
Datetime.preHalfyear.__doc__ = """
preHalfyear(self)
"""
Datetime.preYear.__doc__ = """
preYear(self)
"""
Datetime.max.__doc__ = """
max()
"""
Datetime.min.__doc__ = """
min()
"""
Datetime.now.__doc__ = """
now()
"""
Datetime.today.__doc__ = """
today()
"""
getDateRange.__doc__ = """\n
[start, end)
:param Datetime start:
:param Datetime end:
:rtype: DatetimeList
"""
#------------------------------------------------------------------
# from _util.cpp
#------------------------------------------------------------------
roundUp.__doc__ = """
roundUp(arg1[, arg2=0])
10.111
:param float arg1:
:param int arg2:
:return:
"""
roundDown.__doc__ = """
roundDown(arg1[, arg2=0])
10.110
:param float arg1:
:param int arg2:
:return:
"""
#------------------------------------------------------------------
# from _Log.cpp
#------------------------------------------------------------------
get_log_level.__doc__ = """获取当前日志打印级别"""
set_log_level.__doc__ = """设置当前日志打印级别"""
LOG_LEVEL.__doc__ = """
- DEBUG
- TRACE
- INFO
- WARN
- ERROR
- FATAL
- NO_PRINT
"""
#------------------------------------------------------------------
# from _MarketInfo.cpp
#------------------------------------------------------------------
MarketInfo.__doc__ = """
.. py:attribute:: market : SH, SZ
.. py:attribute:: name :
.. py:attribute:: description :
.. py:attribute:: code :
.. py:attribute:: lastDate : K线数据最后交易日期
"""
#------------------------------------------------------------------
# from _StockTypeInfo.cpp
#------------------------------------------------------------------
StockTypeInfo.__doc__ = """
.. py:attribute:: type :
.. py:attribute:: description :
.. py:attribute:: tick :
.. py:attribute:: tickValue : tick价格
.. py:attribute:: unit : = tickValue/tick
.. py:attribute:: precision :
.. py:attribute:: minTradeNumber :
.. py:attribute:: maxTradeNumber :
"""
#------------------------------------------------------------------
# from _StockWeight.cpp
#------------------------------------------------------------------
StockWeight.__doc__ = """
.. py:attribute:: datetime :
.. py:attribute:: countAsGift : 10X股
.. py:attribute:: countForSell : 10X股
.. py:attribute:: priceForSell :
.. py:attribute:: bonus : 10
.. py:attribute:: increasement : 10X股
.. py:attribute:: totalCount :
.. py:attribute:: freeCount :
"""
StockWeightList.__doc__ = """std::vector<StockWeight> 包装"""
#------------------------------------------------------------------
# from _StockManager.cpp
#------------------------------------------------------------------
StockManager.__doc__ = """证券信息管理类"""
StockManager.instance.__doc__ = """
instance()
StockManager单例实例
"""
StockManager.tmpdir.__doc__ = """
tmpdir()
m_config中的tmpdir
"""
StockManager.getAllMarket.__doc__ = """
getAllMarket()
:rtype: StringList
"""
StockManager.getMarketInfo.__doc__ = """
getMarketInfo(market)
:param string market:
:return: Null<MarketInfo>()
:rtype: MarketInfo
"""
StockManager.getStockTypeInfo.__doc__ = """
getStockTypeInfo(stk_type)
:param int stk_type: :py:data:`constant`
:return: Null<StockTypeInfo>()
:rtype: StockTypeInfo
"""
StockManager.size.__doc__ = """\n
size()
"""
StockManager.__len__.__doc__ = """\n
"""
StockManager.getStock.__doc__ = """
getStock(querystr)
"市场简称证券代码"
:param str querystr: "sh000001"
:return: Null<Stock>()
:rtype: Stock
"""
StockManager.__getitem__.__doc__ = """
getStock
"""
StockManager.getBlock.__doc__ = """
getBlock(category, name)
:param str category:
:param str name:
:return: Block
:rtype: Block
"""
StockManager.getBlockList.__doc__ = """
getBlockList([category])
:param str category:
:return:
:rtype: BlockList
"""
StockManager.getTradingCalendar.__doc__ = """
getTradingCalendar(query[, market='SH'])
:param KQuery query: Query查询条件
:param str market:
:return:
:rtype: DatetimeList
"""
StockManager.addTempCsvStock.__doc__ = """
addTempCsvStock(code, day_filename, min_filename[, tick=0.01, tickValue=0.01, precision=2, minTradeNumber = 1, maxTradeNumber=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 tickValue: 0.01
:param int precision: 2
:param int minTradeNumber: 1
:param int maxTradeNumber: 1000000
:return: Stock
:rtype: Stock
"""
StockManager.removeTempCsvStock.__doc__ = """
removeTempCsvStock(code)
Stock
:param str code:
"""
#------------------------------------------------------------------
# from _KQuery.cpp
#------------------------------------------------------------------
KQueryByDate.__doc__ = """
KQueryByDate(start, end, kType, recoverType)
[start, end) K线数据条件
:param Datetime start:
:param Datetime end:
:param KQuery.KType kType: K线数据类型线线
:param KQuery.RecoverType recoverType:
:return:
:rtype: KQuery
"""
KQueryByIndex.__doc__ = """
KQueryByIndex(start, end, kType, recoverType)
[start, end) K线数据条件使 Query
:param ind start:
:param ind end:
:param KQuery.KType kType: K线数据类型线线
:param KQuery.RecoverType recoverType:
:return:
:rtype: KQuery
"""
KQuery.__doc__ = """K线数据查询条件一般在Python中使用 Query 即可,不用指明 KQuery"""
KQuery.getQueryTypeName.__doc__ = """
getQueryTypeName(queryType)
queryType名称
:param KQuery.QueryType queryType:
:rtype: str
"""
KQuery.getKTypeName.__doc__ = """
getKTypeName(kType)
KType名称
:param KQuery.KType kType: K线类型
:rtype: str
"""
KQuery.getRecoverTypeName.__doc__ = """
getRecoverTypeName(recoverType)
recoverType名称
:param KQuery.RecoverType recoverType:
:rtype: str
"""
KQuery.getQueryTypeEnum.__doc__ = """
getQueryTypeEnum(queryType)
queryType枚举值
:param str queryType: DATE
:rtype: KQuery.QueryType
"""
KQuery.getKTypeEnum.__doc__ = """
getKTypeEnum(ktype)
:param str ktype: DAY
:rtype: KQuery.KType
"""
KQuery.getRecoverTypeEnum.__doc__ = """
getRecoverTypeEnum(recoverType)
:param str recoverType: NO_RECOVER
:rtype: KQuery.RecoverType
"""
KQuery.QueryType.__doc__ = """
- DATE -
- INDEX -
"""
KQuery.RecoverType.__doc__ = """
K线复权类别枚举定义
- NO_RECOVER -
- FORWARD -
- BACKWARD -
- EQUAL_FORWARD -
- EQUAL_BACKWARD -
"""
KQuery.start.__doc__ = """
constant.null_int64
"""
KQuery.end.__doc__ = """
constant.null_int64
"""
KQuery.startDatetime.__doc__ = """
constant.null_datetime
"""
KQuery.endDatetime.__doc__ = """
constant.null_datetime
"""
KQuery.queryType.__doc__ = """
"""
KQuery.kType.__doc__ = """
K线类型
"""
KQuery.recoverType.__doc__ = """
"""
#------------------------------------------------------------------
# from _KRecord.cpp
#------------------------------------------------------------------
KRecord.__doc__ = """K线记录组成K线数据属性可读写"""
KRecord.datetime.__doc__ = """日期时间"""
KRecord.openPrice.__doc__ = """开盘价"""
KRecord.highPrice.__doc__ = """最高价"""
KRecord.lowPrice.__doc__ = """最低价"""
KRecord.closePrice.__doc__ = """收盘价"""
KRecord.transAmount.__doc__ = """成交金额"""
KRecord.transCount.__doc__ = """成交量"""
KRecordList.__doc__ = """C++ std::vector<KRecord>包装"""
#------------------------------------------------------------------
# from _KData.cpp
#------------------------------------------------------------------
KData.__doc__ = """
Stock.getKData K线数据 KRecord list
"""
KData.startPos.__doc__ = """
K线记录中对应的起始位置KData为空返回0
"""
KData.endPos.__doc__ = """
K线记录中对应范围的下一条记录的位置0,lastPos + 1
"""
KData.lastPos.__doc__ = """
K线记录中对应的最后一条记录的位置0,endPos - 1
"""
KData.getDatetimeList.__doc__ = """
getDatetimeList()
:rtype: DatetimeList
"""
KData.getKRecord.__doc__ = """
getKRecord(pos)
K线记录
:param int pos:
:rtype: KRecord
"""
KData.get.__doc__ = """
get(pos)
getKRecordK线记录
:param int pos:
:rtype: KRecord
"""
KData.getKRecordByDate.__doc__ = """
getKRecordByDate(datetime)
K线记录
:param Datetime datetime:
:rtype: KRecord
"""
KData.getByDate.__doc__ = """
getByDate(datetime)
K线记录 getKRecordByDate
:param Datetime datetime:
:rtype: KRecord
"""
KData.size.__doc__ = """
size()
K线记录数量 __len__
"""
KData.empty.__doc__ = """
empty()
:rtype: bool
"""
KData.getQuery.__doc__ = """
getQuery()
:rtype: KQuery
"""
KData.getStock.__doc__ = """
getStock()
Stock
:rtype: Stock
"""
KData.tocsv.__doc__ = """
tocsv(filename)
CSV文件
:param str filename:
"""
#------------------------------------------------------------------
# from _TimeLineRecord.cpp
#------------------------------------------------------------------
TimeLineRecord.__doc__ = """分时线记录,属性可读写。"""
TimeLineRecord.datetime.__doc__ = """时间"""
TimeLineRecord.price.__doc__ = """价格"""
TimeLineRecord.vol.__doc__ = """成交量"""
TimeLineList.__doc__ = """
Stock.getTimeLineList 线 TimeLineRecord list
"""
#------------------------------------------------------------------
# from _TransRecord.cpp
#------------------------------------------------------------------
TransRecord.__doc__ = """历史分笔成交记录,属性可读写。"""
TransRecord.datetime.__doc__ = """时间"""
TransRecord.price.__doc__ = """价格"""
TransRecord.vol.__doc__ = """成交量"""
TransRecord.direct.__doc__ = """买卖盘方向"""
TransList.__doc__ = """
"""
#------------------------------------------------------------------
# from _Stock.cpp
#------------------------------------------------------------------
Stock.market.__doc__ = """获取所属市场简称,市场简称是市场的唯一标识"""
Stock.code.__doc__ = """获取证券代码"""
Stock.market_code.__doc__ = """市场简称+证券代码,如: sh000001"""
Stock.name.__doc__ = """获取证券名称"""
Stock.type.__doc__ = """获取证券类型,参见::py:data:`constant`"""
Stock.valid.__doc__ = """该证券当前是否有效"""
Stock.startDatetime.__doc__ = """证券起始日期"""
Stock.lastDatetime.__doc__ = """证券最后日期"""
Stock.tick.__doc__ = """最小跳动量"""
Stock.tickValue.__doc__ = """最小跳动量价值"""
Stock.unit.__doc__ = """每单位价值 = tickValue / tick"""
Stock.precision.__doc__ = """价格精度"""
Stock.atom.__doc__ = """最小交易数量同minTradeNumber"""
Stock.minTradeNumber.__doc__ = """最小交易数量"""
Stock.maxTradeNumber.__doc__ = """最大交易数量"""
Stock.isNull.__doc__ = """
isNull()
Null
:rtype: bool
"""
Stock.getKData.__doc__ = """
getKData(query)
K线数据
:param Query query:
:return: K线数据
:rtype: KData
"""
Stock.getCount.__doc__ = """
getCount([ktype=Query.DAY])
K线数据量
:param KQuery.KType ktype: K线数据类别
:return: K线记录数
:rtype: int
"""
Stock.getMarketValue.__doc__ = """
getMarketValue(datetime, ktype)
:param Datetime datetime:
:param KQuery.KType ktype: K线数据类别
:return:
:rtype: float
"""
Stock.getKRecord.__doc__ = """
getKRecord(pos[, ktype=Query.DAY])
K线数据记录
:param int pos:
:param KQuery.KType ktype: K线数据类别
:return: K线记录
:rtype: KRecord
"""
Stock.getKRecordByDate.__doc__ = """
getKRecordByDate(datetime[, ktype=Query.DAY])
线/线KRecord
:param Datetime datetime:
:param KQuery.KType ktype: K线数据类别
:return: K线记录
:rtype: KRecord
"""
Stock.getKRecordList.__doc__ = """
getKRecordList(start, end, ktype)
K线记录 [start, end)使getKData替代
:param int start:
:param int end:
:param KQuery.KType ktype: K线类别
:return: K线记录列表
:rtype: KRecordList
"""
Stock.getDatetimeList.__doc__ = """
getDatetimeList(query)
:param Query query:
:rtype: DatetimeList
getDatetimeList(start, end, ktype)
:param int start:
:param ind end:
:param KQuery.KType ktype: K线类型
:rtype: DatetimeList
"""
Stock.getTimeLineList.__doc__ = """
getTimeLineList(self, query)
线
:param Query query: K线类型
:rtype: TimeLineList
"""
Stock.getTransList.__doc__ = """
getTransList(self, query)
:param Query query: K线类型
:rtype: TransList
"""
Stock.getWeight.__doc__ = """
getWeight([start, end])
[start,end)
:param Datetime start:
:param Datetime end:
:rtype: StockWeightList
"""
Stock.getFinanceInfo.__doc__ = """
getFinanceInfo(self)
:rtype: Parameter
"""
Stock.getHistoryFinanceInfo.__doc__ = """
getHistoryFinanceInfo(self, date)
, https://hikyuu.org/finance_fields.html
:param Datetime date: 0331063009301231 Datetime(201109300000)
:rtype: PriceList
"""
Stock.realtimeUpdate.__doc__ = """
realtimeUpdate(krecord)
线
:param KRecord krecord: K线记录
"""
Stock.loadKDataToBuffer.__doc__ = """
loadKDataToBuffer(ktype)
K线数据加载至内存缓存
:param KQuery.KType ktype: K线类型
"""
Stock.releaseKDataBuffer.__doc__ = """
releaseKDataBuffer(ktype)
K线数据
:param KQuery.KType ktype: K线类型
"""
#------------------------------------------------------------------
# from _Block.cpp
#------------------------------------------------------------------
BlockList.__doc__ = """C++ std::vector<Block>包装"""
Block.__doc__ = """板块类,可视为证券的容器"""
Block.category.__doc__ = """板块分类,可读写"""
Block.name.__doc__ = """板块名称,可读写"""
Block.size.__doc__ = """
size()
"""
Block.empty.__doc__ = """
empty()
"""
Block.add.__doc__ = """
add(stock)
:param Stock stock:
:return:
:rtype: bool
add(market_code)
"市场简称证券代码"
:param str market_code:
:return:
:rtype: bool
"""
Block.remove.__doc__ = """
remove(stock)
:param Stock stock:
:return:
:rtype: bool
remove(market_code)
:param str market_code:
:return:
:rtype: bool
"""
Block.clear.__doc__ = """移除包含的所有证券"""
Block.__len__.__doc__ = """包含的证券数量"""
#------------------------------------------------------------------
# from _save_load.cpp
#------------------------------------------------------------------
hku_save.__doc__ = """
hku_save(var, filename)
hikyuu内建类型的变量StockTradeManager等XML
:param var: hikyuu内建类型的变量
:param str filename:
"""
hku_load.__doc__ = """
hku_load(var, filename)
hku_save var中
:param var:
:param str filename:
"""
#------------------------------------------------------------------
# from iostream.cpp
#------------------------------------------------------------------
OstreamRedirect.__doc__ ="""
OstreamRedirect([stdout=True, stderr=True])
C++ std::coutstd::cerr至pythonApp无法显示C++ iostream的输出信息Jupyter notebookstd::cout或std::cerr使open方法或with语法才会启用重定向
使with示例
with OstreamRedirect():
your_function() #C++使std::iostream输出
:param bool stdout: C++ std::cout
:param bool stderr: C++ std::cerr
"""
OstreamRedirect.open.__doc__ = """
open()
"""
OstreamRedirect.close.__doc__ = """
close()
"""