基础数据结构

交易业务类型

hikyuu.trade_manage.get_business_name(business)
参数:

business (BUSINESS) – 交易业务类型

返回:

交易业务类型名称(“INIT”|”BUY”|”SELL”|”GIFT”|”BONUS”|”CHECKIN”|”CHECKOUT”|”UNKNOWN”

返回类型:

string

class hikyuu.trade_manage.BUSINESS
  • BUSINESS.INIT - 建立初始账户

  • BUSINESS.BUY - 买入

  • BUSINESS.SELL - 卖出

  • BUSINESS.GIFT - 送股

  • BUSINESS.BONUS - 分红

  • BUSINESS.CHECKIN - 存入现金

  • BUSINESS.CHECKOUT - 取出现金

  • BUSINESS.INVALID - 无效类型

交易成本记录

交易成本计算的返回结果

class hikyuu.trade_manage.CostRecord

交易成本记录

commission  佣金(float)
stamptax    印花税(float)
transferfee 过户费(float)
others      其它费用(float)
total       总成本(float),= 佣金 + 印花税 + 过户费 + 其它费用

交易记录

class hikyuu.trade_manage.TradeRecordList

交易记录列表,C++ std::vector<TradeRecord>包装

to_np()

仅在安装了numpy模块时生效,转换为numpy.array

to_df()

仅在安装了pandas模块时生效,转换为pandas.DataFrame

class hikyuu.trade_manage.TradeRecord([stock, datetime, business, planPrice, realPrice, goalPrice, number, cost, stoploss, cash, part])

交易记录

stock     股票(Stock)
datetime  交易时间(Datetime)
business  交易类型
plan_price 计划交易价格(float)
real_price 实际交易价格(float)
goal_price 目标价格(float),如果为0表示未限定目标
number    成交数量(float)
cost      交易成本

类型:CostRecord

stoploss 止损价(float)
cash     现金余额(float)
part

交易指示来源,区别是交易系统哪个部件发出的指示,参见: System.Part

持仓记录

class hikyuu.trade_manage.PositionRecordList

持仓记录列表,C++ std::vector<PositionRecord>包装

to_np()

仅在安装了numpy模块时生效,转换为numpy.array

to_df()

仅在安装了pandas模块时生效,转换为pandas.DataFrame

class hikyuu.trade_manage.PositionRecord([stock, take_datetime, clean_datetime, number, stoploss, goal_price, total_number, buy_money, total_cost, total_risk, sell_money])

持仓记录

stock          交易对象(Stock)
take_datetime  初次建仓时刻(Datetime)
clean_datetime 平仓日期,当前持仓记录中为 constant.null_datetime
number       当前持仓数量(float)
stoploss     当前止损价(float)
goal_price   当前的目标价格(float)
total_number 累计持仓数量(float)
buy_money    累计买入资金(float)
total_cost   累计交易总成本(float)
total_risk   累计交易风险(float) = 各次 (买入价格-止损)*买入数量, 不包含交易成本
sell_money   累计卖出资金(float)

资产情况记录

由TradeManager::getFunds返回

class hikyuu.trade_manage.FundsRecord([cash, market_value, short_market_value, base_cash, base_asset, borrow_cash, borrow_asset])

当前资产情况记录,由 TradeManager.getFunds() 返回

cash               当前现金(float)
market_value       当前多头市值(float)
short_market_value 当前空头仓位市值(float)
base_cash          当前投入本金(float)
base_asset         当前投入的资产价值(float)
borrow_cash        当前借入的资金(float),即负债
borrow_asset       当前借入证券资产价值(float)