testctp

package
v1.2.3-3.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 原始指针 Ctp.TradeApi = new(testctp.TradeApi)
	OldThis *TradeApi

	// 交易所合约详情列表 InstrumentStruct
	MapInstruments safe.Map

	// 资金账户信息 AccountStruct
	MapAccounts safe.Map

	// 报单列表(已成交、未成交、撤单等状态)的列表数据 OrderStruct
	MapOrders safe.Map

	// 报单成交列表
	MapTrades safe.Map

	// 持仓列表 PositionStruct
	MapPositions safe.Map

	// 持仓明细列表 PositionDetailStruct
	MapPositionDetails safe.Map

	// OrderRef 对应的 tick 数据
	MapOrderRefTick safe.Map
)

Functions

func CheckErr

func CheckErr(err error)

检查错误,有就抛出 panic

func CheckPanic

func CheckPanic()

处理 panic

func DateFormat

func DateFormat(date string, inputFormat string, outputFormat string) string

*

  • 日期格式化 *
  • 例:DateFormat("2020-01-23", "2006-01-02", "20060102")
  • DateFormat("2020-01-23 14:05:06", "2006-01-02 15:04:05", "20060102150405")

func DateTimeToUnix

func DateTimeToUnix(strTime string) int

*

  • 时间转时间戳(注意格式) *
  • 例:DateTimeToUnix("2006-01-02 15:04:05")

func DateToTime

func DateToTime(date string) string

日期转时间(例: 2020-06-29 08:00:00 转为 08:00:00)

func DateToUnix

func DateToUnix(strTime string) int

*

  • 日期转时间戳(注意格式) *
  • 例:DateToUnix("2006-01-02")

func Decimal

func Decimal(f float64, n int) float64

float64 保留几位小数点

func Exit

func Exit()

退出程序

func Float64ToString

func Float64ToString(f float64) string

float64 转 string

func GetCurrentDate

func GetCurrentDate() string

获得当前日期

func GetCurrentTime

func GetCurrentTime() string

获得当前时间

func GetCurrentUnix

func GetCurrentUnix() int

获得当前时间戳

func GetDateMonth

func GetDateMonth(date string) string

获取日期中的月份(例: 20200629 转为 6)

func GetMapIntrsKeys

func GetMapIntrsKeys(m map[int]interface{}) []int

获得 Map key 键的 倒序(sort.Sort(sort.Reverse(sort.IntSlice(s))))

func GetMapIntsKeys

func GetMapIntsKeys(m map[int]interface{}) []int

获得 Map key 键的 正序(sort.Ints)

func GetPositionProfit

func GetPositionProfit(InstrumentID string, OpenPrice float64, LastPrice float64, Number int, Direction string) float64

*

  • 计算盈亏 *
  • @param InstrumentID string 合约
  • @param OpenPrice float64 开仓价格
  • @param LastPrice float64 最新价|平仓价格
  • @param Number int 数量
  • @param Direction string 持仓方向[0|2:买,1|3:卖]

func GetString

func GetString(str interface{}) string

获取字符串信息

func GetVersion

func GetVersion() string

获取版本信息

func Int32ToString

func Int32ToString(n int32) string

int32 转 string

func IntToString

func IntToString(i int) string

int 转 string

func IsNullPointer

func IsNullPointer(p interface{}) bool

是否空指针

func JsonDecode

func JsonDecode(str string, data interface{}) error

JsonDecode

func JsonEncode

func JsonEncode(str interface{}) string

JsonEncode

func LogPrintf

func LogPrintf(format string, a ...interface{})

log.Printf

func LogPrintln

func LogPrintln(a ...interface{})

log.Println

func PrintErr

func PrintErr(err error)

打印错误(存在错误的时候)

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

fmt.Printf

func Println

func Println(a ...interface{}) (n int, err error)

fmt.Println

func ReqFailMsg

func ReqFailMsg(Msg string, iResult int) string

请求 api 出现错误

func ReqMsg

func ReqMsg(Msg string)

请求日志

func Sleep

func Sleep(number int)

休眠(毫秒,1000 毫秒等于 1 秒)

func Sprintf

func Sprintf(format string, a ...interface{}) string

fmt.Sprintf

func StrReplace

func StrReplace(content string, old string, newStr string) string

*

  • 字符串替换 *
  • 例: result = StrReplace("文本内容", "被替换字符串", "替换为新的字符串")

func StringToFloat64

func StringToFloat64(str string) float64

string 转 float64

func StringToInt

func StringToInt(str string) int

string 转 int

func StringToInt32

func StringToInt32(str string) int32

string 转 int32

func TimeToUnix

func TimeToUnix(strTime string) int

*

  • 时间转时间戳 *
  • 例:TimeToUnix("09:30:00")

func ToLower

func ToLower(str string) string

将字符串转换成小写

func ToUpper

func ToUpper(str string) string

将字符串转换成大写

func TrimSpace

func TrimSpace(str string) string

去掉左右两边空格

func UnixToDateTime

func UnixToDateTime(TimeStamp int, Format string) string

*

  • 时间戳转日期 *
  • 例:UnixToTime(1686580152, "2006-01-02 15:04:05")

func UnixToTime

func UnixToTime(TimeStamp int) string

*

  • 时间戳转时间 *
  • 例:UnixToTime(1686580152)

Types

type AccountStruct

type AccountStruct struct {
	// Map 数据 Key 键
	MapKey string
	// 经纪公司代码
	BrokerID string
	// 投资者帐号
	AccountID string
	// 上次质押金额
	PreMortgage float64
	// 上次信用额度
	PreCredit float64
	// 上次存款额
	PreDeposit float64
	// 上次结算准备金
	PreBalance float64
	// 上次占用的保证金
	PreMargin float64
	// 利息基数
	InterestBase float64
	// 利息收入
	Interest float64
	// 入金金额
	Deposit float64
	// 出金金额
	Withdraw float64
	// 冻结的保证金
	FrozenMargin float64
	// 冻结的资金
	FrozenCash float64
	// 冻结的手续费
	FrozenCommission float64
	// 当前保证金总额
	CurrMargin float64
	// 资金差额
	CashIn float64
	// 手续费
	Commission float64
	// 平仓盈亏
	CloseProfit float64
	// 持仓盈亏
	PositionProfit float64
	// 期货结算准备金
	Balance float64
	// 可用资金
	Available float64
	// 可取资金
	WithdrawQuota float64
	// 基本准备金
	Reserve float64
	// 交易日
	TradingDay string
	// 结算编号
	SettlementID int
	// 信用额度
	Credit float64
	// 质押金额
	Mortgage float64
	// 交易所保证金
	ExchangeMargin float64
	// 投资者交割保证金
	DeliveryMargin float64
	// 交易所交割保证金
	ExchangeDeliveryMargin float64
	// 保底期货结算准备金
	ReserveBalance float64
	// 币种代码
	CurrencyID string
	// 上次货币质入金额
	PreFundMortgageIn float64
	// 上次货币质出金额
	PreFundMortgageOut float64
	// 货币质入金额
	FundMortgageIn float64
	// 货币质出金额
	FundMortgageOut float64
	// 货币质押余额
	FundMortgageAvailable float64
	// 可质押货币金额
	MortgageableFund float64
	// 特殊产品占用保证金
	SpecProductMargin float64
	// 特殊产品冻结保证金
	SpecProductFrozenMargin float64
	// 特殊产品手续费
	SpecProductCommission float64
	// 特殊产品冻结手续费
	SpecProductFrozenCommission float64
	// 特殊产品持仓盈亏
	SpecProductPositionProfit float64
	// 特殊产品平仓盈亏
	SpecProductCloseProfit float64
	// 根据持仓盈亏算法计算的特殊产品持仓盈亏
	SpecProductPositionProfitByAlg float64
	// 特殊产品交易所保证金
	SpecProductExchangeMargin float64
	// 业务类型
	BizType string
	// 延时换汇冻结金额
	FrozenSwap float64
	// 剩余换汇额度
	RemainSwap float64
}

资金账户信息

type CtpClient

type CtpClient struct {

	// 行情模块 api
	MdApi goctp.CThostFtdcMdApi

	// 交易模块 api
	TradeApi goctp.CThostFtdcTraderApi

	// ctp 服务器,及交易账号
	MdFront    []string
	TradeFront []string

	// 经纪公司账号
	BrokerID   string
	InvestorID string
	Password   string

	// 经纪公司的保证金(与合约保证金相加)
	MarginRatio float64

	// 客户端认证
	AppID    string
	AuthCode string

	// 当前交易日期(格式:2023-01-01)
	TradeDate string

	// 当前交易日期(格式:20230101)
	TradingDay string

	// 当前交易月份(格式:202301)
	TradeMonth string

	// 行情请求编号
	MdRequestId int

	// 交易请求编号
	TradeRequestId int

	// 交易系统是否已经初始化了
	IsTradeInit bool

	// 交易程序是否初始化完成(自动完成如下动作:交易账号登录、结算单确认、查询合约、查询资金账户、查询用户报单、查询用户持仓 后算完成)
	IsTradeInitFinish bool

	// 交易程序是否已登录过
	IsTradeLogin bool

	// 行情系统是否已经初始化了
	IsMdInit bool

	// 行情程序是否已登录过
	IsMdLogin bool
}

Ctp 客户端 行情、交易模块 全局变量

type FtdcMdSpi

type FtdcMdSpi struct {
	CtpClient
}

Ctp 行情 spi 回调函数

type FtdcTradeSpi

type FtdcTradeSpi struct {
	CtpClient
}

Ctp 交易 spi 回调函数

type InputOrderStruct

type InputOrderStruct struct {
	// 合约代码
	InstrumentID string
	// 买卖方向【0:买,1:卖】
	Direction byte
	// 价格
	Price float64
	// 数量
	Volume int
	// 报单引用
	OrderRef int
	// 组合开平标志【平仓可以设置】
	CombOffsetFlag byte
	// 开仓策略代码
	StrategyCode string
	// 平仓策略代码
	CloseStrategyCode string
	// 策略消息
	StrategyMsg string
	// 止损价(抄底摸顶时使用小止损)
	StopPrice float64
	// 有效秒数【0表示不限制,秒倒计时,到0撤单】
	Second int
	// 时间【回测模式用到了】
	UpdateTime string
	// 持仓均价(平仓时用来计算盈亏)
	OpenPrice float64
	// 股票价(标的价,期权会用到)
	StockPrice float64
	// 持仓key(平仓时会用到)
	PositionKey string

	// 传递tick 数据给 回测ctp
	TestingTick TickStruct
}

输入报单

type InstrumentStruct

type InstrumentStruct struct {
	// Map 数据 Key 键
	MapKey string
	// 合约代码
	InstrumentID string
	// 交易所代码
	ExchangeID string
	// 合约名称(码表里的名称)
	InstrumentName string
	// 合约名称(交易所合约的名称)
	InstrumentOldName string
	// 合约代码
	InstrumentCode string
	// 合约在交易所的代码
	ExchangeInstID string
	// 产品代码
	ProductID string
	// 产品类型
	ProductClass string
	// 交割年份
	DeliveryYear int
	// 交割月
	DeliveryMonth int
	// 市价单最大下单量
	MaxMarketOrderVolume int
	// 市价单最小下单量
	MinMarketOrderVolume int
	// 限价单最大下单量
	MaxLimitOrderVolume int
	// 限价单最小下单量
	MinLimitOrderVolume int
	// 合约数量乘数
	VolumeMultiple int
	// 最小变动价位
	PriceTick float64
	// 创建日
	CreateDate string
	// 上市日
	OpenDate string
	// 到期日
	ExpireDate string
	// 开始交割日
	StartDelivDate string
	// 结束交割日
	EndDelivDate string
	// 合约生命周期状态
	InstLifePhase string
	// 当前是否交易
	IsTrading int
	// 持仓类型
	PositionType string
	// 持仓日期类型
	PositionDateType string
	// 多头保证金率
	LongMarginRatio float64
	// 空头保证金率
	ShortMarginRatio float64
	// 是否使用大额单边保证金算法
	MaxMarginSideAlgorithm string
	// 基础商品代码
	UnderlyingInstrID string
	// 执行价
	StrikePrice float64
	// 期权类型
	OptionsType string
	// 合约基础商品乘数
	UnderlyingMultiple float64
	// 组合类型
	CombinationType string
}

交易所合约详情

func GetInstrumentInfo

func GetInstrumentInfo(InstrumentID string) (InstrumentStruct, bool)

获得合约详情信息

type MdApi

type MdApi struct {
	goctp.CThostFtdcMdApi
	MdSpi goctp.CThostFtdcMdSpi
}

func (*MdApi) GetApiVersion

func (p *MdApi) GetApiVersion() string

获取API的版本信息

func (*MdApi) GetRspInfo

func (p *MdApi) GetRspInfo() goctp.CThostFtdcRspInfoField

响应信息

func (*MdApi) GetTradingDay

func (p *MdApi) GetTradingDay() string

获取当前交易日

func (*MdApi) Init

func (p *MdApi) Init()

初始化

func (*MdApi) Join

func (p *MdApi) Join() int

等待接口线程结束运行

func (*MdApi) RegisterFensUserInfo

func (p *MdApi) RegisterFensUserInfo(pFensUserInfo goctp.CThostFtdcFensUserInfoField)

注册名字服务器用户信息

func (*MdApi) RegisterFront

func (p *MdApi) RegisterFront(pszFrontAddress string)

注册前置机网络地址

func (*MdApi) RegisterNameServer

func (p *MdApi) RegisterNameServer(pszNsAddress string)

注册名字服务器网络地址

func (*MdApi) RegisterSpi

func (p *MdApi) RegisterSpi(pSpi goctp.CThostFtdcMdSpi)

注册回调接口

func (*MdApi) Release

func (p *MdApi) Release()

删除接口对象本身

func (*MdApi) ReqUserLogin

func (p *MdApi) ReqUserLogin(pReqUserLoginField goctp.CThostFtdcReqUserLoginField, nRequestID int) int

用户登录请求

func (*MdApi) ReqUserLogout

func (p *MdApi) ReqUserLogout(pUserLogout goctp.CThostFtdcUserLogoutField, nRequestID int) int

登出请求

func (*MdApi) SubscribeForQuoteRsp

func (p *MdApi) SubscribeForQuoteRsp(ppInstrumentID *string, nCount int) int

订阅询价。

func (*MdApi) SubscribeMarketData

func (p *MdApi) SubscribeMarketData(ppInstrumentID *string, nCount int) int

订阅行情

func (*MdApi) UnSubscribeForQuoteRsp

func (p *MdApi) UnSubscribeForQuoteRsp(ppInstrumentID *string, nCount int) int

退订询价

func (*MdApi) UnSubscribeMarketData

func (p *MdApi) UnSubscribeMarketData(ppInstrumentID *string, nCount int) int

退订行情

type OrderStruct

type OrderStruct struct {
	// Map 数据 Key 键
	MapKey string
	// 经纪公司代码
	BrokerID string
	// 投资者代码
	InvestorID string
	// 合约代码
	InstrumentID string
	// 合约名称
	InstrumentName string
	// 交易所代码
	ExchangeID string
	// 前置编号
	FrontID int
	// 会话编号
	SessionID int
	// 报单编号
	OrderSysID string
	// 委托时间
	InsertTime string
	// 报单日期
	InsertDate string
	// 报单引用
	OrderRef string
	// 买卖方向
	Direction string
	// 组合开平标志
	CombOffsetFlag string
	// 组合投机套保标志
	CombHedgeFlag string
	// 价格
	LimitPrice float64
	// 数量
	Volume int
	// 成交数量
	VolumeTraded int
	// 剩余数量
	VolumeTotal int
	// 状态信息
	StatusMsg string
	// 报单状态
	OrderStatus string
	// 买卖方向,中文
	DirectionTitle string
	// 报单状态,中文
	OrderStatusTitle string
	// 投机套保标志
	CombHedgeFlagTitle string
	// 开平标志,中文
	CombOffsetFlagTitle string
}

报单列表(已成交、未成交、撤单等状态)的列表数据

type PositionDetailStruct

type PositionDetailStruct struct {
	// key
	MapKey string
	// 经纪公司代码
	BrokerID string
	// 投资者代码
	InvestorID string
	// 合约代码
	InstrumentID string
	// 合约名称
	InstrumentName string
	// 投机套保标志
	HedgeFlag string
	// 投机套保标志标题
	HedgeFlagTitle string
	// 买卖
	Direction string
	// 买卖标题
	DirectionTitle string
	// 开仓日期
	OpenDate string
	// 成交编号
	TradeID string
	// 数量
	Volume int
	// Position int
	// 开仓价
	OpenPrice float64
	// 交易日
	TradingDay string
	// 结算价
	SettlementPrice float64
	// 交易所代码
	ExchangeID string
	// 逐日盯市平仓盈亏
	CloseProfitByDate float64
	// 逐笔对冲平仓盈亏
	CloseProfitByTrade float64
	// 逐日盯市持仓盈亏
	PositionProfitByDate float64
	// 逐笔对冲持仓盈亏
	PositionProfitByTrade float64
	// 平仓量
	CloseVolume int
	// 平仓金额
	CloseAmount float64
	// 先开先平剩余数量(DCE)
	TimeFirstVolume int
}

持仓明细

type PositionStruct

type PositionStruct struct {
	// key
	MapKey string
	// 经纪公司代码
	BrokerID string
	// 投资者帐号
	InvestorID string
	// 合约代码
	InstrumentID string
	// 合约名称
	InstrumentName string
	// 交易所代码
	ExchangeID string
	// 投机套保标志
	HedgeFlag string
	// 投机套保标志标题
	HedgeFlagTitle string
	// 持仓日期类型(1:今日持仓,历史持仓)
	PositionDate string
	// 持仓日期类型标题
	PositionDateTitle string
	// 持仓多空方向(接口字段 PosiDirection)
	Direction string
	// 持仓多空方向标题
	DirectionTitle string
	// 开仓成本(接口字段 OpenCost)
	OpenPrice float64
	// 持仓成本
	PositionCost float64
	// 手续费
	Commission float64
	// 总持仓(接口字段 Position)
	Volume int
	// 上日持仓
	YdPosition int
	// 今日持仓
	TodayPosition int
	// 冻结的持仓量
	ShortVolume int
	// 多头冻结
	LongFrozen int
	// 空头冻结
	ShortFrozen int
	// 开仓量
	OpenVolume int
	// 平仓量
	CloseVolume int
	// 平仓盈亏
	CloseProfit float64
	// 持仓盈亏
	PositionProfit float64
	// 上次结算价
	PreSettlementPrice float64
	// 本次结算价
	SettlementPrice float64
	// 结算编号
	SettlementID int
	// 交易日
	TradingDay string
}

持仓列表

type RspInfoStruct

type RspInfoStruct struct {
	// 错误代码
	ErrorID int
	// 错误信息
	ErrorMsg string
	// 报单引用
	OrderRef int
}

响应信息(Ctp 接口错误)

type TickStruct

type TickStruct struct {
	// 交易日
	TradingDay string
	// 合约代码
	InstrumentID string
	// 合约名称
	InstrumentName string
	// 合约code【合约代码字母部分,非官方字段】
	InstrumentCode string
	// 交易所代码
	ExchangeID string
	// 最新价
	LastPrice float64
	// 上次结算价
	PreSettlementPrice float64
	// 昨收盘
	PreClosePrice float64
	// 昨持仓量
	PreOpenInterest int
	// 今开盘
	OpenPrice float64
	// 最高价
	HighestPrice float64
	// 最低价
	LowestPrice float64
	// 数量
	Volume int
	// 成交金额
	Turnover float64
	// 持仓量
	OpenInterest int
	// 今收盘
	ClosePrice float64
	// 本次结算价
	SettlementPrice float64
	// 涨停板价
	UpperLimitPrice float64
	// 跌停板价
	LowerLimitPrice float64
	// 最后修改时间
	UpdateTime string
	// 最后修改毫秒
	UpdateMillisec int
	// 申买价一
	BidPrice1 float64
	// 申买量一
	BidVolume1 int
	// 申卖价一
	AskPrice1 float64
	// 申卖量一
	AskVolume1 int
	// 申买价二
	BidPrice2 float64
	// 申买量二
	BidVolume2 int
	// 申卖价二
	AskPrice2 float64
	// 申卖量二
	AskVolume2 int
	// 申买价三
	BidPrice3 float64
	// 申买量三
	BidVolume3 int
	// 申卖价三
	AskPrice3 float64
	// 申卖量三
	AskVolume3 int
	// 申买价四
	BidPrice4 float64
	// 申买量四
	BidVolume4 int
	// 申卖价四
	AskPrice4 float64
	// 申卖量四
	AskVolume4 int
	// 申买价五
	BidPrice5 float64
	// 申买量五
	BidVolume5 int
	// 申卖价五
	AskPrice5 float64
	// 申卖量五
	AskVolume5 int
	// 当日均价
	AveragePrice float64
	// 当日均价(可直接使用的价格)
	NewAveragePrice float64

	// 最低价
	MinPrice float64
	// 最高价
	MaxPrice float64
	// 夜盘最后一笔报价(通常是 23:00:00 - 02:30:00 时间段的报价,如果没有则表示没有夜盘)
	NightLastPrice float64
	// 回测模式 - 是否最后一条数据(Y:是)
	BackTestingFinish string
}

深度行情

type TradeApi

type TradeApi struct {
	goctp.CThostFtdcTraderApi
	TradeSpi goctp.CThostFtdcTraderSpi

	SessionID int

	BrokerID string

	InvestorID string

	// 报单编号
	OrderSysID int

	// 成交编号
	TradeID int

	TradingDay int

	// 1手保证金
	Margin float64

	// 1手手续费
	Commission float64
}

func (*TradeApi) GetApiVersion

func (p *TradeApi) GetApiVersion() string

获取API的版本信息

func (*TradeApi) GetOrderSysID

func (p *TradeApi) GetOrderSysID() string

获取报单编号

func (*TradeApi) GetRspInfo

func (p *TradeApi) GetRspInfo() goctp.CThostFtdcRspInfoField

响应信息

func (*TradeApi) GetTradeID

func (p *TradeApi) GetTradeID() string

获取成交编号

func (*TradeApi) GetTradingDay

func (p *TradeApi) GetTradingDay() string

获取当前交易日

func (*TradeApi) Init

func (p *TradeApi) Init()

初始化

func (*TradeApi) Join

func (p *TradeApi) Join() int

等待接口线程结束运行

func (*TradeApi) OldThis

func (p *TradeApi) OldThis() *TradeApi

原始指针 Ctp.TradeApi = new(testctp.TradeApi)

func (*TradeApi) RegisterFensUserInfo

func (p *TradeApi) RegisterFensUserInfo(pFensUserInfo goctp.CThostFtdcFensUserInfoField)

注册名字服务器用户信息

func (*TradeApi) RegisterFront

func (p *TradeApi) RegisterFront(pszFrontAddress string)

注册前置机网络地址

func (*TradeApi) RegisterNameServer

func (p *TradeApi) RegisterNameServer(pszNsAddress string)

注册名字服务器网络地址

func (*TradeApi) RegisterSpi

func (p *TradeApi) RegisterSpi(pSpi goctp.CThostFtdcTraderSpi)

注册回调接口

func (*TradeApi) RegisterUserSystemInfo

func (p *TradeApi) RegisterUserSystemInfo(pUserSystemInfo goctp.CThostFtdcUserSystemInfoField) int

注册用户终端信息,用于中继服务器多连接模式

func (*TradeApi) Release

func (p *TradeApi) Release()

删除接口对象本身

func (*TradeApi) ReqAuthenticate

func (p *TradeApi) ReqAuthenticate(pReqAuthenticateField goctp.CThostFtdcReqAuthenticateField, nRequestID int) int

客户端认证请求

func (*TradeApi) ReqBatchOrderAction

func (p *TradeApi) ReqBatchOrderAction(pInputBatchOrderAction goctp.CThostFtdcInputBatchOrderActionField, nRequestID int) int

批量报单操作请求

func (*TradeApi) ReqCombActionInsert

func (p *TradeApi) ReqCombActionInsert(pInputCombAction goctp.CThostFtdcInputCombActionField, nRequestID int) int

申请组合录入请求

func (*TradeApi) ReqDayEndFileReadyByFuture

func (p *TradeApi) ReqDayEndFileReadyByFuture(pReqDayEndFileReady goctp.CThostFtdcReqDayEndFileReadyField, nRequestID int) int

期货发起日终文件就绪请求

func (*TradeApi) ReqExecCombineOrderAction

func (p *TradeApi) ReqExecCombineOrderAction(pInputExecCombineOrderAction goctp.CThostFtdcInputExecCombineOrderActionField, nRequestID int) int

行权指令合并操作请求

func (*TradeApi) ReqExecCombineOrderInsert

func (p *TradeApi) ReqExecCombineOrderInsert(pInputExecCombineOrder goctp.CThostFtdcInputExecCombineOrderField, nRequestID int) int

行权指令合并录入请求

func (*TradeApi) ReqExecOrderAction

func (p *TradeApi) ReqExecOrderAction(pInputExecOrderAction goctp.CThostFtdcInputExecOrderActionField, nRequestID int) int

执行宣告操作请求

func (*TradeApi) ReqExecOrderInsert

func (p *TradeApi) ReqExecOrderInsert(pInputExecOrder goctp.CThostFtdcInputExecOrderField, nRequestID int) int

执行宣告录入请求

func (*TradeApi) ReqForQuoteInsert

func (p *TradeApi) ReqForQuoteInsert(pInputForQuote goctp.CThostFtdcInputForQuoteField, nRequestID int) int

询价录入请求

func (*TradeApi) ReqFromBankToFutureByFuture

func (p *TradeApi) ReqFromBankToFutureByFuture(pReqTransfer goctp.CThostFtdcReqTransferField, nRequestID int) int

期货发起银行资金转期货请求

func (*TradeApi) ReqFromFutureToBankByFuture

func (p *TradeApi) ReqFromFutureToBankByFuture(pReqTransfer goctp.CThostFtdcReqTransferField, nRequestID int) int

期货发起期货资金转银行请求

func (*TradeApi) ReqInternalTransfer

func (p *TradeApi) ReqInternalTransfer(pInputInternalTransfer goctp.CThostFtdcInputInternalTransferField, nRequestID int) int

请求资金内转

func (*TradeApi) ReqLockInsert

func (p *TradeApi) ReqLockInsert(pInputLock goctp.CThostFtdcInputLockField, nRequestID int) int

锁定请求

func (*TradeApi) ReqOrderAction

func (p *TradeApi) ReqOrderAction(pInputOrderAction goctp.CThostFtdcInputOrderActionField, nRequestID int) int

报单操作请求

func (*TradeApi) ReqOrderInsert

func (p *TradeApi) ReqOrderInsert(pInputOrder goctp.CThostFtdcInputOrderField, nRequestID int) int

报单录入请求

func (*TradeApi) ReqParkedOrderAction

func (p *TradeApi) ReqParkedOrderAction(pParkedOrderAction goctp.CThostFtdcParkedOrderActionField, nRequestID int) int

预埋撤单录入请求

func (*TradeApi) ReqParkedOrderInsert

func (p *TradeApi) ReqParkedOrderInsert(pParkedOrder goctp.CThostFtdcParkedOrderField, nRequestID int) int

预埋单录入请求

func (*TradeApi) ReqQryAccountregister

func (p *TradeApi) ReqQryAccountregister(pQryAccountregister goctp.CThostFtdcQryAccountregisterField, nRequestID int) int

请求查询银期签约关系

func (*TradeApi) ReqQryBrokerTradingAlgos

func (p *TradeApi) ReqQryBrokerTradingAlgos(pQryBrokerTradingAlgos goctp.CThostFtdcQryBrokerTradingAlgosField, nRequestID int) int

请求查询经纪公司交易算法

func (*TradeApi) ReqQryBrokerTradingParams

func (p *TradeApi) ReqQryBrokerTradingParams(pQryBrokerTradingParams goctp.CThostFtdcQryBrokerTradingParamsField, nRequestID int) int

请求查询经纪公司交易参数

func (*TradeApi) ReqQryCFMMCTradingAccountKey

func (p *TradeApi) ReqQryCFMMCTradingAccountKey(pQryCFMMCTradingAccountKey goctp.CThostFtdcQryCFMMCTradingAccountKeyField, nRequestID int) int

请求查询保证金监管系统经纪公司资金账户密钥

func (*TradeApi) ReqQryCombAction

func (p *TradeApi) ReqQryCombAction(pQryCombAction goctp.CThostFtdcQryCombActionField, nRequestID int) int

请求查询申请组合

func (*TradeApi) ReqQryCombInstrumentGuard

func (p *TradeApi) ReqQryCombInstrumentGuard(pQryCombInstrumentGuard goctp.CThostFtdcQryCombInstrumentGuardField, nRequestID int) int

请求查询组合合约安全系数

func (*TradeApi) ReqQryContractBank

func (p *TradeApi) ReqQryContractBank(pQryContractBank goctp.CThostFtdcQryContractBankField, nRequestID int) int

请求查询签约银行

func (*TradeApi) ReqQryDepthMarketData

func (p *TradeApi) ReqQryDepthMarketData(pQryDepthMarketData goctp.CThostFtdcQryDepthMarketDataField, nRequestID int) int

请求查询行情

func (*TradeApi) ReqQryETFOptionInstrCommRate

func (p *TradeApi) ReqQryETFOptionInstrCommRate(pQryETFOptionInstrCommRate goctp.CThostFtdcQryETFOptionInstrCommRateField, nRequestID int) int

请求查询ETF期权合约手续费

func (*TradeApi) ReqQryEWarrantOffset

func (p *TradeApi) ReqQryEWarrantOffset(pQryEWarrantOffset goctp.CThostFtdcQryEWarrantOffsetField, nRequestID int) int

请求查询仓单折抵信息

func (*TradeApi) ReqQryExchange

func (p *TradeApi) ReqQryExchange(pQryExchange goctp.CThostFtdcQryExchangeField, nRequestID int) int

请求查询交易所

func (*TradeApi) ReqQryExchangeMarginRate

func (p *TradeApi) ReqQryExchangeMarginRate(pQryExchangeMarginRate goctp.CThostFtdcQryExchangeMarginRateField, nRequestID int) int

请求查询交易所保证金率

func (*TradeApi) ReqQryExchangeMarginRateAdjust

func (p *TradeApi) ReqQryExchangeMarginRateAdjust(pQryExchangeMarginRateAdjust goctp.CThostFtdcQryExchangeMarginRateAdjustField, nRequestID int) int

请求查询交易所调整保证金率

func (*TradeApi) ReqQryExchangeRate

func (p *TradeApi) ReqQryExchangeRate(pQryExchangeRate goctp.CThostFtdcQryExchangeRateField, nRequestID int) int

请求查询汇率

func (*TradeApi) ReqQryExecCombineOrder

func (p *TradeApi) ReqQryExecCombineOrder(pQryExecCombineOrder goctp.CThostFtdcQryExecCombineOrderField, nRequestID int) int

请求查询行权指令合并

func (*TradeApi) ReqQryExecFreeze

func (p *TradeApi) ReqQryExecFreeze(pQryExecFreeze goctp.CThostFtdcQryExecFreezeField, nRequestID int) int

请求查询E+1日行权冻结

func (*TradeApi) ReqQryExecOrder

func (p *TradeApi) ReqQryExecOrder(pQryExecOrder goctp.CThostFtdcQryExecOrderField, nRequestID int) int

请求查询执行宣告

func (*TradeApi) ReqQryForQuote

func (p *TradeApi) ReqQryForQuote(pQryForQuote goctp.CThostFtdcQryForQuoteField, nRequestID int) int

请求查询询价

func (*TradeApi) ReqQryFutureTradingAccount

func (p *TradeApi) ReqQryFutureTradingAccount(pQryFutureTradingAccount goctp.CThostFtdcQryFutureTradingAccountField, nRequestID int) int

请求查询对应的期货资金账户

func (*TradeApi) ReqQryInstrument

func (p *TradeApi) ReqQryInstrument(pQryInstrument goctp.CThostFtdcQryInstrumentField, nRequestID int) int

请求查询合约

func (*TradeApi) ReqQryInstrumentCommissionRate

func (p *TradeApi) ReqQryInstrumentCommissionRate(pQryInstrumentCommissionRate goctp.CThostFtdcQryInstrumentCommissionRateField, nRequestID int) int

请求查询合约手续费率

func (*TradeApi) ReqQryInstrumentMarginRate

func (p *TradeApi) ReqQryInstrumentMarginRate(pQryInstrumentMarginRate goctp.CThostFtdcQryInstrumentMarginRateField, nRequestID int) int

请求查询合约保证金率

func (*TradeApi) ReqQryInstrumentOrderCommRate

func (p *TradeApi) ReqQryInstrumentOrderCommRate(pQryInstrumentOrderCommRate goctp.CThostFtdcQryInstrumentOrderCommRateField, nRequestID int) int

请求查询报单手续费

func (*TradeApi) ReqQryInternalTransfer

func (p *TradeApi) ReqQryInternalTransfer(pQryInternalTransfer goctp.CThostFtdcQryInternalTransferField, nRequestID int) int

请求查询资金记录

func (*TradeApi) ReqQryInvestor

func (p *TradeApi) ReqQryInvestor(pQryInvestor goctp.CThostFtdcQryInvestorField, nRequestID int) int

请求查询投资者

func (*TradeApi) ReqQryInvestorLevel

func (p *TradeApi) ReqQryInvestorLevel(pQryInvestorLevel goctp.CThostFtdcQryInvestorLevelField, nRequestID int) int

请求查询投资者分级

func (*TradeApi) ReqQryInvestorPosition

func (p *TradeApi) ReqQryInvestorPosition(pQryInvestorPosition goctp.CThostFtdcQryInvestorPositionField, nRequestID int) int

请求查询投资者持仓

func (*TradeApi) ReqQryInvestorPositionCombineDetail

func (p *TradeApi) ReqQryInvestorPositionCombineDetail(pQryInvestorPositionCombineDetail goctp.CThostFtdcQryInvestorPositionCombineDetailField, nRequestID int) int

请求查询投资者持仓明细

func (*TradeApi) ReqQryInvestorPositionDetail

func (p *TradeApi) ReqQryInvestorPositionDetail(pQryInvestorPositionDetail goctp.CThostFtdcQryInvestorPositionDetailField, nRequestID int) int

请求查询投资者持仓明细

func (*TradeApi) ReqQryInvestorProductGroupMargin

func (p *TradeApi) ReqQryInvestorProductGroupMargin(pQryInvestorProductGroupMargin goctp.CThostFtdcQryInvestorProductGroupMarginField, nRequestID int) int

请求查询投资者品种/跨品种保证金

func (*TradeApi) ReqQryLimitAmount

func (p *TradeApi) ReqQryLimitAmount(pQryLimitAmount goctp.CThostFtdcQryLimitAmountField, nRequestID int) int

请求查询金额限制

func (*TradeApi) ReqQryLimitPosi

func (p *TradeApi) ReqQryLimitPosi(pQryLimitPosi goctp.CThostFtdcQryLimitPosiField, nRequestID int) int

请求查询持仓限制

func (*TradeApi) ReqQryLock

func (p *TradeApi) ReqQryLock(pQryLock goctp.CThostFtdcQryLockField, nRequestID int) int

请求查询锁定

func (*TradeApi) ReqQryLockPosition

func (p *TradeApi) ReqQryLockPosition(pQryLockPosition goctp.CThostFtdcQryLockPositionField, nRequestID int) int

请求查询锁定证券仓位

func (*TradeApi) ReqQryMMInstrumentCommissionRate

func (p *TradeApi) ReqQryMMInstrumentCommissionRate(pQryMMInstrumentCommissionRate goctp.CThostFtdcQryMMInstrumentCommissionRateField, nRequestID int) int

请求查询做市商合约手续费率

func (*TradeApi) ReqQryMMOptionInstrCommRate

func (p *TradeApi) ReqQryMMOptionInstrCommRate(pQryMMOptionInstrCommRate goctp.CThostFtdcQryMMOptionInstrCommRateField, nRequestID int) int

请求查询做市商期权合约手续费

func (*TradeApi) ReqQryNotice

func (p *TradeApi) ReqQryNotice(pQryNotice goctp.CThostFtdcQryNoticeField, nRequestID int) int

请求查询客户通知

func (*TradeApi) ReqQryOptionInstrCommRate

func (p *TradeApi) ReqQryOptionInstrCommRate(pQryOptionInstrCommRate goctp.CThostFtdcQryOptionInstrCommRateField, nRequestID int) int

请求查询期权合约手续费

func (*TradeApi) ReqQryOptionInstrTradeCost

func (p *TradeApi) ReqQryOptionInstrTradeCost(pQryOptionInstrTradeCost goctp.CThostFtdcQryOptionInstrTradeCostField, nRequestID int) int

请求查询期权交易成本

func (*TradeApi) ReqQryOrder

func (p *TradeApi) ReqQryOrder(pQryOrder goctp.CThostFtdcQryOrderField, nRequestID int) int

请求查询报单

func (*TradeApi) ReqQryParkedOrder

func (p *TradeApi) ReqQryParkedOrder(pQryParkedOrder goctp.CThostFtdcQryParkedOrderField, nRequestID int) int

请求查询预埋单

func (*TradeApi) ReqQryParkedOrderAction

func (p *TradeApi) ReqQryParkedOrderAction(pQryParkedOrderAction goctp.CThostFtdcQryParkedOrderActionField, nRequestID int) int

请求查询预埋撤单

func (*TradeApi) ReqQryProduct

func (p *TradeApi) ReqQryProduct(pQryProduct goctp.CThostFtdcQryProductField, nRequestID int) int

请求查询产品

func (*TradeApi) ReqQryProductExchRate

func (p *TradeApi) ReqQryProductExchRate(pQryProductExchRate goctp.CThostFtdcQryProductExchRateField, nRequestID int) int

请求查询产品报价汇率

func (*TradeApi) ReqQryProductGroup

func (p *TradeApi) ReqQryProductGroup(pQryProductGroup goctp.CThostFtdcQryProductGroupField, nRequestID int) int

请求查询产品组

func (*TradeApi) ReqQryQuote

func (p *TradeApi) ReqQryQuote(pQryQuote goctp.CThostFtdcQryQuoteField, nRequestID int) int

请求查询报价

func (*TradeApi) ReqQrySecAgentACIDMap

func (p *TradeApi) ReqQrySecAgentACIDMap(pQrySecAgentACIDMap goctp.CThostFtdcQrySecAgentACIDMapField, nRequestID int) int

请求查询二级代理操作员银期权限

func (*TradeApi) ReqQrySettlementInfo

func (p *TradeApi) ReqQrySettlementInfo(pQrySettlementInfo goctp.CThostFtdcQrySettlementInfoField, nRequestID int) int

请求查询投资者结算结果

func (*TradeApi) ReqQrySettlementInfoConfirm

func (p *TradeApi) ReqQrySettlementInfoConfirm(pQrySettlementInfoConfirm goctp.CThostFtdcQrySettlementInfoConfirmField, nRequestID int) int

请求查询结算信息确认

func (*TradeApi) ReqQryTrade

func (p *TradeApi) ReqQryTrade(pQryTrade goctp.CThostFtdcQryTradeField, nRequestID int) int

请求查询成交

func (*TradeApi) ReqQryTradingAccount

func (p *TradeApi) ReqQryTradingAccount(pQryTradingAccount goctp.CThostFtdcQryTradingAccountField, nRequestID int) int

请求查询资金账户

func (*TradeApi) ReqQryTradingCode

func (p *TradeApi) ReqQryTradingCode(pQryTradingCode goctp.CThostFtdcQryTradingCodeField, nRequestID int) int

请求查询交易编码

func (*TradeApi) ReqQryTradingNotice

func (p *TradeApi) ReqQryTradingNotice(pQryTradingNotice goctp.CThostFtdcQryTradingNoticeField, nRequestID int) int

请求查询交易通知

func (*TradeApi) ReqQryTransferBank

func (p *TradeApi) ReqQryTransferBank(pQryTransferBank goctp.CThostFtdcQryTransferBankField, nRequestID int) int

请求查询转帐银行

func (*TradeApi) ReqQryTransferSerial

func (p *TradeApi) ReqQryTransferSerial(pQryTransferSerial goctp.CThostFtdcQryTransferSerialField, nRequestID int) int

请求查询转帐流水

func (*TradeApi) ReqQueryBankAccountMoneyByFuture

func (p *TradeApi) ReqQueryBankAccountMoneyByFuture(pReqQueryAccount goctp.CThostFtdcReqQueryAccountField, nRequestID int) int

期货发起查询银行余额请求

func (*TradeApi) ReqQueryCFMMCTradingAccountToken

func (p *TradeApi) ReqQueryCFMMCTradingAccountToken(pQueryCFMMCTradingAccountToken goctp.CThostFtdcQueryCFMMCTradingAccountTokenField, nRequestID int) int

请求查询监控中心用户令牌

func (*TradeApi) ReqQueryMaxOrderVolume

func (p *TradeApi) ReqQueryMaxOrderVolume(pQueryMaxOrderVolume goctp.CThostFtdcQueryMaxOrderVolumeField, nRequestID int) int

查询最大报单数量请求

func (*TradeApi) ReqQuoteAction

func (p *TradeApi) ReqQuoteAction(pInputQuoteAction goctp.CThostFtdcInputQuoteActionField, nRequestID int) int

报价操作请求

func (*TradeApi) ReqQuoteInsert

func (p *TradeApi) ReqQuoteInsert(pInputQuote goctp.CThostFtdcInputQuoteField, nRequestID int) int

报价录入请求

func (*TradeApi) ReqRemoveParkedOrder

func (p *TradeApi) ReqRemoveParkedOrder(pRemoveParkedOrder goctp.CThostFtdcRemoveParkedOrderField, nRequestID int) int

请求删除预埋单

func (*TradeApi) ReqRemoveParkedOrderAction

func (p *TradeApi) ReqRemoveParkedOrderAction(pRemoveParkedOrderAction goctp.CThostFtdcRemoveParkedOrderActionField, nRequestID int) int

请求删除预埋撤单

func (*TradeApi) ReqReserveOpenAccountTpdByFuture

func (p *TradeApi) ReqReserveOpenAccountTpdByFuture(pReqReserveOpenAccountTpd goctp.CThostFtdcReqReserveOpenAccountTpdField, nRequestID int) int

期货发起第三方存管业务开户预指定请求

func (*TradeApi) ReqSecuritiesDepositInterestByFuture

func (p *TradeApi) ReqSecuritiesDepositInterestByFuture(pReqSecuritiesDepositInterest goctp.CThostFtdcReqSecuritiesDepositInterestField, nRequestID int) int

期货发起第三方存管证券资金结息请求

func (*TradeApi) ReqSettlementInfoConfirm

func (p *TradeApi) ReqSettlementInfoConfirm(pSettlementInfoConfirm goctp.CThostFtdcSettlementInfoConfirmField, nRequestID int) int

投资者结算结果确认

func (*TradeApi) ReqTradingAccountPasswordUpdate

func (p *TradeApi) ReqTradingAccountPasswordUpdate(pTradingAccountPasswordUpdate goctp.CThostFtdcTradingAccountPasswordUpdateField, nRequestID int) int

资金账户口令更新请求

func (*TradeApi) ReqUserLogin

func (p *TradeApi) ReqUserLogin(pReqUserLoginField goctp.CThostFtdcReqUserLoginField, nRequestID int) int

用户登录请求

func (*TradeApi) ReqUserLogout

func (p *TradeApi) ReqUserLogout(pUserLogout goctp.CThostFtdcUserLogoutField, nRequestID int) int

登出请求

func (*TradeApi) ReqUserPasswordUpdate

func (p *TradeApi) ReqUserPasswordUpdate(pUserPasswordUpdate goctp.CThostFtdcUserPasswordUpdateField, nRequestID int) int

用户口令更新请求

func (*TradeApi) Reset

func (p *TradeApi) Reset()

重置数据

func (*TradeApi) SetAccount

func (p *TradeApi) SetAccount(BrokerID string, InvestorID string)

设置资金账户信息

func (*TradeApi) SetInstrument

func (p *TradeApi) SetInstrument(sInstrument InstrumentStruct)

设置合约信息

func (*TradeApi) SetOrderRefTick

func (p *TradeApi) SetOrderRefTick(iRequestID int, pTick TickStruct)

设置报单引用的 tick 数据

func (*TradeApi) SetTradingDay

func (p *TradeApi) SetTradingDay(TradingDay int)

设置当前交易日期(格式:20230101)

func (*TradeApi) SubmitUserSystemInfo

func (p *TradeApi) SubmitUserSystemInfo(pUserSystemInfo goctp.CThostFtdcUserSystemInfoField) int

上报用户终端信息,用于中继服务器操作员登录模式

func (*TradeApi) SubscribePrivateTopic

func (p *TradeApi) SubscribePrivateTopic(nResumeType goctp.Ctp_soptTHOST_TE_RESUME_TYPE)

订阅私有流。

func (*TradeApi) SubscribePublicTopic

func (p *TradeApi) SubscribePublicTopic(nResumeType goctp.Ctp_soptTHOST_TE_RESUME_TYPE)

订阅公共流。

type TradeStruct

type TradeStruct struct {
	// key
	MapKey string
	// 经纪公司代码
	BrokerID string
	// 投资者代码
	InvestorID string
	// 报单引用
	OrderRef string
	// 用户代码
	UserID string
	// 交易所代码
	ExchangeID string
	// 成交编号
	TradeID string
	// 买卖方向
	Direction string
	// 买卖方标题
	DirectionTitle string
	// 报单编号
	OrderSysID string
	// 会员代码
	ParticipantID string
	// 客户代码
	ClientID string
	// 开平标志
	OffsetFlag string
	// 开平标志标题
	OffsetFlagTitle string
	// 投机套保标志
	HedgeFlag string
	// 投机套保标志标题
	HedgeFlagTitle string
	// 价格
	Price float64
	// 数量
	Volume int
	// 成交时期
	TradeDate string
	// 成交时间
	TradeTime string
	// 成交类型
	TradeType string
	// 成交价来源
	PriceSource string
	// 交易所交易员代码
	TraderID string
	// 本地报单编号
	OrderLocalID string
	// 结算会员编号
	ClearingPartID string
	// 业务单元
	BusinessUnit string
	// 序号
	SequenceNo int
	// 交易日
	TradingDay string
	// 结算编号
	SettlementID int
	// 经纪公司报单编号
	BrokerOrderSeq int
	// 成交来源
	TradeSource string
	// 投资单元代码
	InvestUnitID string
	// 合约代码
	InstrumentID string
	// 合约在交易所的代码
	ExchangeInstID string
}

成交

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL