get_margin_contract - 合约查询

get_margin_contract 是 PTrade 中用于合约查询的接口。

提示

  • live-or-trading-module-only

原型

get_margin_contract(compact_source=None)

释义

get_margin_contract 是 PTrade 中用于合约查询的接口。

研究:不支持;回测:不支持;模拟:官方目录未明确;实盘:支持。

参数

参数 是否必填 官方原始定义
compact_source compact_source=None

返回值

正常返回一个DataFrame类型字段,columns为每个合约所包含的信息(相应字段无数据时返回None),异常返回None(NoneType)

合约包含以下信息:

open_date:开户日期(str:int);

compact_id:合约编号(str:str);

stock_code:证券代码(str:str);

entrust_no:委托编号(str:str);

entrust_price:委托价格(str:float);

entrust_amount:委托数量(str:float);

business_amount:成交数量(str:float);

business_balance:成交金额(str:float);

compact_type:合约类别(str:str);

compact_source:合约来源(str:str);

compact_status:合约状态(str:str);

repaid_interest:已还利息(str:float);

repaid_amount:已还数量(str:float);

示例

def initialize(context):

g.security = '600570.SS'

set_universe(g.security)

def handle_data(context, data):

# 获取最新合约

df = get_margin_contract()

log.info(df)

详细说明

get_margin_contract(compact_source=None)

使用场景

该函数仅支持PTrade客户端可用,仅在两融交易模块可用。

接口说明

该接口用于合约查询。

注意事项

参数详细说明

compact_source:合约来源(int),0为普通头寸,1为专项头寸,该字段不入参默认表示普通头寸;

返回值

正常返回一个DataFrame类型字段,columns为每个合约所包含的信息(相应字段无数据时返回None),异常返回None(NoneType)

合约包含以下信息:

open_date:开户日期(str:int);

compact_id:合约编号(str:str);

stock_code:证券代码(str:str);

entrust_no:委托编号(str:str);

entrust_price:委托价格(str:float);

entrust_amount:委托数量(str:float);

business_amount:成交数量(str:float);

business_balance:成交金额(str:float);

compact_type:合约类别(str:str);

compact_source:合约来源(str:str);

compact_status:合约状态(str:str);

repaid_interest:已还利息(str:float);

repaid_amount:已还数量(str:float);

repaid_balance:已还金额(str:float);

used_bail_balance:已用保证金(str:float);

ret_end_date:归还截止日(str:int);

date_clear:清算日期(str:int);

fin_income:融资合约盈亏(str:float);

slo_income:融券合约盈亏(str:float);

total_debit:负债总额(str:float);

compact_interest:合约利息金额(str:float);

real_compact_interest:日间实时利息金额(str:float);

real_compact_balance:日间实时合约金额(str:float);

real_compact_amount:日间实时合约数量(str:float);

open_date compact_id stock_code ... real_compact_balance real_compact_amount

0 20250218 20250131234567 600570.SS ... 103235.31 2800

1 20250219 20250131232321 000002.SZ ... 532581.10 72130

2 20250220 20250131232131 600519.SS ... 444000.00 300