goctp

package module
v6.6.8-20220912 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 10 Imported by: 0

README

goctp

介绍

CTP 封装之 golang 版,支持 Windows Linux x64. 封装代码由 ctp_generate 生成

运行

环境变量
{
  "userID": "008105",
  "investorID": "",
  "password": "1",
  "brokerID": "9999",
  "appID": "simnow_client_test",
  "authCode": "看穿码",
  "tradeFront": "tcp://180.168.146.187:10202",
  "quoteFront": "tcp://180.168.146.187:10212"
}
示例

main.go

版本切换

复制官方库文件(_se.so _se.dll)覆盖到 lnx win 下同名文件即可。

QA

operator delete(void*, unsigned long)@CXXABI_1.3.9’未定义的引用

不同系统,不同版本的底层依赖不同 重新编译即可

视频资料

golang 环境-linux goctp 环境 -win 行情 demo 交易 demo 交易 板价追单 交易 追单-01 交易 追单-02 交易 板价止损 交易 追单止盈

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2String

func Bytes2String(t []byte) string

Types

type AccountField

type AccountField struct {
	// 交易帐号
	InvestorID string
	// 上次质押金额
	PreMortgage 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
	// 信用额度
	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
}

资金账户

type CombinationTypeType

type CombinationTypeType byte

组合类型

const (
	// 期货组合
	CombinationTypeFuture CombinationTypeType = '0'
	// 垂直价差BUL
	CombinationTypeBUL CombinationTypeType = '1'
	// 垂直价差BER
	CombinationTypeBER CombinationTypeType = '2'
	// 跨式组合
	CombinationTypeSTD CombinationTypeType = '3'
	// 宽跨式组合
	CombinationTypeSTG CombinationTypeType = '4'
	// 备兑组合
	CombinationTypePRT CombinationTypeType = '5'
	// 时间价差组合
	CombinationTypeCLD CombinationTypeType = '6'
)

type DirectionType

type DirectionType byte

买卖方向类型

const (
	// 买
	DirectionBuy DirectionType = '0'
	// 卖
	DirectionSell DirectionType = '1'
)

type GetVersionType

type GetVersionType func() string

type HFQuote

type HFQuote struct {
	IsLogin    bool
	InvestorID string
	BrokerID   string

	ReqConnect       ReqConnectType
	ReleaseAPI       ReleaseAPIType
	ReqUserLogin     ReqUserLoginType
	ReqSubMarketData ReqSubscriptType

	Ticks sync.Map // 合约:TickField
	// contains filtered or unexported fields
}

HFQuote 行情接口

func (*HFQuote) FrontConnected

func (q *HFQuote) FrontConnected()

func (*HFQuote) FrontDisConnected

func (q *HFQuote) FrontDisConnected(reason int)

func (*HFQuote) Init

func (q *HFQuote) Init()

func (*HFQuote) RegOnFrontConnected

func (q *HFQuote) RegOnFrontConnected(on OnFrontConnectedType)

RegOnFrontConnected 注册前置响应

func (*HFQuote) RegOnFrontDisConnected

func (q *HFQuote) RegOnFrontDisConnected(on OnFrontDisConnectedType)

RegOnFrontDisConnected 注册连接响应

func (*HFQuote) RegOnRspUserLogin

func (q *HFQuote) RegOnRspUserLogin(on OnRspUserLoginType)

RegOnRspUserLogin 注册登录响应

func (*HFQuote) RegOnTick

func (q *HFQuote) RegOnTick(on OnTickType)

RegOnTick 注册行情响应

func (*HFQuote) Release

func (q *HFQuote) Release()

func (*HFQuote) ReqLogin

func (q *HFQuote) ReqLogin(investor, pwd, broker string)

ReqLogin 登录

func (*HFQuote) ReqSubscript

func (q *HFQuote) ReqSubscript(instruments ...string)

func (*HFQuote) RspUserLogin

func (q *HFQuote) RspUserLogin(loginField *ctpdefine.CThostFtdcRspUserLoginField, infoField *ctpdefine.CThostFtdcRspInfoField)

func (*HFQuote) RtnDepthMarketData

func (q *HFQuote) RtnDepthMarketData(dataField *ctpdefine.CThostFtdcDepthMarketDataField)

type HFTrade

type HFTrade struct {
	UserID     string // 交易员
	InvestorID string // 帐号
	BrokerID   string // 经纪商
	TradingDay string // 交易日

	SessionID int // 判断是否自己的委托用

	Instruments       sync.Map // 合约列表 (key: InstrumentID, value: *InstrumentField)
	InstrumentStatuss sync.Map // 合约状态 (key: InstrumentID, value: *InstrumentStatus)

	Positions sync.Map // 合成后的持仓 (key: instrument_long/short value: *ctp.CThostFtdcInvestorPositionField)
	Orders    sync.Map // 委托 (key: sessionID_OrderRef, value: *OrderField)
	Trades    sync.Map // 成交 (key: TradeID_buy/sell, value: &TradeField)

	Account       *AccountField            // 帐户权益
	UserAccounts  map[string]*AccountField // 交易员:多帐户权益 string->*AccountField
	UserPositions map[string]*sync.Map     // 交易员:多帐户持仓
	Investors     map[string]struct{}      // 多个帐号(交易员)

	IsLogin     bool                     // 登录成功
	Version     string                   // 版本号,如 v6.5.1_20200908 10:25:08
	PrivateMode ctp.THOST_TE_RESUME_TYPE // 私有流模式

	// 继承类要实现的函数
	ReqConnect                  ReqConnectType
	ReleaseAPI                  ReleaseAPIType
	ReqUserLogin                ReqUserLoginType
	ReqAuthenticate             ReqAuthenticateType
	ReqSettlementInfoConfirm    ReqSettlementInfoConfirmType
	ReqQryInstrument            ReqQryInstrumentType
	ReqQryClassifiedInstrument  ReqQryClassifiedInstrumentType
	ReqQryTradingAccount        ReqQryTradingAccountType
	ReqQryInvestorPosition      ReqQryInvestorPositionType
	ReqOrder                    ReqOrderInsertType
	ReqAction                   ReqOrderActionType
	ReqFromBankToFutureByFuture ReqTransferType
	ReqFromFutureToBankByFuture ReqTransferType
	GetVersion                  GetVersionType
	ReqQryInvestor              ReqQryInvestorType
	ReqQryOrder                 ReqQryOrderType
	ReqQryTrade                 ReqQryTradeType
	// contains filtered or unexported fields
}

HFTrade 交易接口

func (*HFTrade) ErrRtnOrderAction

func (t *HFTrade) ErrRtnOrderAction(field *ctp.CThostFtdcOrderActionField, info *ctp.CThostFtdcRspInfoField)

ErrRtnOrderAction 撤单错误

func (*HFTrade) ErrRtnOrderInsert

func (t *HFTrade) ErrRtnOrderInsert(field *ctp.CThostFtdcInputOrderField, info *ctp.CThostFtdcRspInfoField)

ErrRtnOrderInsert 委托错误O

func (*HFTrade) FrontConnected

func (t *HFTrade) FrontConnected()

FrontConnected 连接

func (*HFTrade) FrontDisConnected

func (t *HFTrade) FrontDisConnected(reason int)

FrontDisConnected 断开响应

func (*HFTrade) Init

func (t *HFTrade) Init()

func (*HFTrade) RegOnErrAction

func (t *HFTrade) RegOnErrAction(on OnRtnErrActionType)

RegOnErrAction 注册撤单响应

func (*HFTrade) RegOnErrRtnOrder

func (t *HFTrade) RegOnErrRtnOrder(on OnRtnErrOrderType)

RegOnErrRtnOrder 注册委托响应

func (*HFTrade) RegOnFrontConnected

func (t *HFTrade) RegOnFrontConnected(on OnFrontConnectedType)

RegOnFrontConnected 注册连接响应

func (*HFTrade) RegOnFrontDisConnected

func (t *HFTrade) RegOnFrontDisConnected(on OnFrontDisConnectedType)

RegOnFrontDisConnected 注册连接响应

func (*HFTrade) RegOnRspUserLogin

func (t *HFTrade) RegOnRspUserLogin(on OnRspUserLoginType)

RegOnRspUserLogin 注册登陆响应

<error id="INVALID_DATA_SYNC_STATUS" value="1" prompt="CTP:不在已同步状态"/>
<error id="INCONSISTENT_INFORMATION" value="2" prompt="CTP:会话信息不一致"/>
<error id="INVALID_LOGIN" value="3" prompt="CTP:不合法的登录"/>
<error id="USER_NOT_ACTIVE" value="4" prompt="CTP:用户不活跃"/>
<error id="DUPLICATE_LOGIN" value="5" prompt="CTP:重复的登录"/>
<error id="NOT_LOGIN_YET" value="6" prompt="CTP:还没有登录"/>
<error id="NOT_INITED" value="7" prompt="CTP:还没有初始化"/>
<error id="FRONT_NOT_ACTIVE" value="8" prompt="CTP:前置不活跃"/>
<error id="LOGIN_FORBIDDEN" value="75" prompt="CTP:连续登录失败次数超限,登录被禁止"/>

func (*HFTrade) RegOnRtnCancel

func (t *HFTrade) RegOnRtnCancel(on OnRtnOrderType)

RegOnRtnCancel 注册撤单响应

func (*HFTrade) RegOnRtnFromBankToFuture

func (t *HFTrade) RegOnRtnFromBankToFuture(on OnRtnFromBankToFutureByFuture)

RegOnRtnFromBankToFuture 注册银行转期货

func (*HFTrade) RegOnRtnFromFutureToBank

func (t *HFTrade) RegOnRtnFromFutureToBank(on OnRtnFromFutureToBankByFuture)

RegOnRtnFromFutureToBank 注册期货转银行

func (*HFTrade) RegOnRtnInstrumentStatus

func (t *HFTrade) RegOnRtnInstrumentStatus(on OnRtnInstrumentStatusType)

RegOnRtnInstrumentStatus 注册合约状态变化

func (*HFTrade) RegOnRtnOrder

func (t *HFTrade) RegOnRtnOrder(on OnRtnOrderType)

RegOnRtnOrder 注册委托响应

func (*HFTrade) RegOnRtnTrade

func (t *HFTrade) RegOnRtnTrade(on OnRtnTradeType)

RegOnRtnTrade 注册成交响应

func (*HFTrade) Release

func (t *HFTrade) Release()

func (*HFTrade) ReqBankToFuture

func (t *HFTrade) ReqBankToFuture(bankID, bankAccount, bankPwd string, amount float64)

ReqBankToFuture 银行转期货

func (*HFTrade) ReqFutureToBank

func (t *HFTrade) ReqFutureToBank(bankID, bankAccount string, amount float64)

ReqFutureToBank 期货转银行

func (*HFTrade) ReqLogin

func (t *HFTrade) ReqLogin(user, pwd, broker, appID, authCode string)

ReqLogin 登录

func (*HFTrade) ReqOrderAction

func (t *HFTrade) ReqOrderAction(orderID string) int

ReqOrderAction 撤单

func (*HFTrade) ReqOrderInsert

func (t *HFTrade) ReqOrderInsert(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string

ReqOrderInsert 限价委托

func (*HFTrade) ReqOrderInsertByUser

func (t *HFTrade) ReqOrderInsertByUser(investor, instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string

------------------- 函数封装 ---------------------- ReqOrderInsert 限价委托

func (*HFTrade) ReqOrderInsertFAK

func (t *HFTrade) ReqOrderInsertFAK(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string

ReqOrderInsertFAK FAK委托[全成or撤单]

func (*HFTrade) ReqOrderInsertFOK

func (t *HFTrade) ReqOrderInsertFOK(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string

ReqOrderInsertFOK FOK委托[部成撤单]

func (*HFTrade) ReqOrderInsertMarket

func (t *HFTrade) ReqOrderInsertMarket(instrument string, buySell DirectionType, openClose OffsetFlagType, volume int) string

ReqOrderInsertMarket 市价委托

func (*HFTrade) RspAuthenticate

func (t *HFTrade) RspAuthenticate(info *ctp.CThostFtdcRspInfoField)

RspAuthenticate 认证

func (*HFTrade) RspQryInstrument

func (t *HFTrade) RspQryInstrument(field *ctp.CThostFtdcInstrumentField, b bool)

RspQryInstrument 合约

func (*HFTrade) RspQryInvestor

func (t *HFTrade) RspQryInvestor(field *ctp.CThostFtdcInvestorField, b bool)

RspQryInvestor 查用户(交易员下有多个帐号)

func (*HFTrade) RspQryInvestorPosition

func (t *HFTrade) RspQryInvestorPosition(field *ctp.CThostFtdcInvestorPositionField, b bool)

RspQryInvestorPosition 持仓

func (*HFTrade) RspQryOrder

func (t *HFTrade) RspQryOrder(field *ctp.CThostFtdcOrderField, b bool)

RspQryOrder 查委托响应

func (*HFTrade) RspQryTrade

func (t *HFTrade) RspQryTrade(field *ctp.CThostFtdcTradeField, b bool)

RspQryTrade 查成交响应

func (*HFTrade) RspQryTradingAccount

func (t *HFTrade) RspQryTradingAccount(field *ctp.CThostFtdcTradingAccountField, b bool)

RspQryTradingAccount 权益

func (*HFTrade) RspSettlementInfoConfirm

func (t *HFTrade) RspSettlementInfoConfirm()

RspSettlementInfoConfirm 确认结算

func (*HFTrade) RspUserLogin

func (t *HFTrade) RspUserLogin(loginField *ctp.CThostFtdcRspUserLoginField, infoField *ctp.CThostFtdcRspInfoField)

RspUserLogin 登录

func (*HFTrade) RtnFromBankToFutureByFuture

func (t *HFTrade) RtnFromBankToFutureByFuture(field *ctp.CThostFtdcRspTransferField)

RtnFromBankToFutureByFuture 银行转期货-期货端

func (*HFTrade) RtnFromFutureToBankByFuture

func (t *HFTrade) RtnFromFutureToBankByFuture(field *ctp.CThostFtdcRspTransferField)

RtnFromFutureToBankByFuture // 期货转银行-期货端

func (*HFTrade) RtnInstrumentStatus

func (t *HFTrade) RtnInstrumentStatus(field *ctp.CThostFtdcInstrumentStatusField)

RtnInstrumentStatus 合约/品种/交易所 状态响应

func (*HFTrade) RtnOrder

func (t *HFTrade) RtnOrder(field *ctp.CThostFtdcOrderField)

RtnOrder 委托响应

func (*HFTrade) RtnTrade

func (t *HFTrade) RtnTrade(field *ctp.CThostFtdcTradeField)

RtnTrade 成交响应

func (*HFTrade) SetQuick

func (t *HFTrade) SetQuick(investorAraay ...string)

SetQuick 以quick模式启动(须在NewTrade前调用)

type HedgeFlagType

type HedgeFlagType byte

投机套保标志类型

const (
	// 投机
	HedgeFlagSpeculation HedgeFlagType = '1'
	// 套利
	HedgeFlagArbitrage HedgeFlagType = '2'
	// 套保
	HedgeFlagHedge HedgeFlagType = '3'
	// 做市商
	HedgeFlagMarketMaker HedgeFlagType = '5'
	// 第一腿投机第二腿套保 大商所专用
	HedgeFlagSpecHedge HedgeFlagType = '6'
	// 第一腿套保第二腿投机  大商所专用
	HedgeFlagHedgeSpec HedgeFlagType = '7'
)

type InstrumentField

type InstrumentField struct {
	// 合约代码
	InstrumentID string
	// 交易所代码
	ExchangeID string
	// 产品代码
	ProductID string
	// 产品类型
	ProductClass ProductClassType
	// 市价单最大下单量
	MaxMarketOrderVolume int
	// 市价单最小下单量
	MinMarketOrderVolume int
	// 限价单最大下单量
	MaxLimitOrderVolume int
	// 限价单最小下单量
	MinLimitOrderVolume int
	// 合约数量乘数
	VolumeMultiple int
	// 最小变动价位
	PriceTick float64
	// 持仓类型
	PositionType PositionTypeType
	// 是否使用大额单边保证金算法
	UseMaxMarginSideAlgorithm bool
	// 基础商品代码
	UnderlyingInstrID string
	// 执行价
	StrikePrice float64
	// 期权类型
	OptionsType OptionsTypeType
	// 合约基础商品乘数
	UnderlyingMultiple float64
	// 组合类型
	CombinationType CombinationTypeType
	// 到期日
	ExpireDate string
	// 开始交割日
	StartDelivDate string
	// 结束交割日
	EndDelivDate string
}

合约

type InstrumentStatus

type InstrumentStatus struct {
	// 交易所代码
	ExchangeID string
	// 合约代码
	InstrumentID string
	// 合约交易状态
	InstrumentStatus InstrumentStatusType
	// 进入本状态时间
	EnterTime string
}

InstrumentStatus 合约状态

type InstrumentStatusType

type InstrumentStatusType byte

合约交易状态类型

const (
	// 开盘前
	InstrumentStatusBeforeTrading InstrumentStatusType = '0'
	// 非交易
	InstrumentStatusNoTrading InstrumentStatusType = '1'
	// 连续交易
	InstrumentStatusContinous InstrumentStatusType = '2'
	// 集合竞价报单
	InstrumentStatusAuctionOrdering InstrumentStatusType = '3'
	// 集合竞价价格平衡
	InstrumentStatusAuctionBalance InstrumentStatusType = '4'
	// 集合竞价撮合
	InstrumentStatusAuctionMatch InstrumentStatusType = '5'
	// 收盘
	InstrumentStatusClosed InstrumentStatusType = '6'
)

type OffsetFlagType

type OffsetFlagType byte

开平标志类型

const (
	// 开仓
	OffsetFlagOpen OffsetFlagType = '0'
	// 平仓
	OffsetFlagClose OffsetFlagType = '1'
	// 强平
	OffsetFlagForceClose OffsetFlagType = '2'
	// 平今
	OffsetFlagCloseToday OffsetFlagType = '3'
	// 平昨
	OffsetFlagCloseYesterday OffsetFlagType = '4'
	// 强减
	OffsetFlagForceOff OffsetFlagType = '5'
	// 本地强平
	OffsetFlagLocalForceClose OffsetFlagType = '6'
)

type OnFrontConnectedType

type OnFrontConnectedType func()

公共-连接

type OnFrontDisConnectedType

type OnFrontDisConnectedType func(reason int)

公共-断开

type OnRspUserLoginType

type OnRspUserLoginType func(loginField *RspUserLoginField, info *RspInfoField)

公共-登录

type OnRtnErrActionType

type OnRtnErrActionType func(orderID string, info *RspInfoField)

交易-错误撤单

type OnRtnErrOrderType

type OnRtnErrOrderType func(field *OrderField, info *RspInfoField)

交易-错误委托

type OnRtnFromBankToFutureByFuture

type OnRtnFromBankToFutureByFuture func(field *TransferField)

银转-银行->期货

type OnRtnFromFutureToBankByFuture

type OnRtnFromFutureToBankByFuture func(field *TransferField)

银转-期货->银行

type OnRtnInstrumentStatusType

type OnRtnInstrumentStatusType func(field *InstrumentStatus)

交易-合约状态响应

type OnRtnOrderType

type OnRtnOrderType func(field *OrderField)

交易-委托响应

type OnRtnTradeType

type OnRtnTradeType func(field *TradeField)

交易-成交响应

type OnTickType

type OnTickType func(tick *TickField)

行情

type OptionsTypeType

type OptionsTypeType byte

期权类型

const (
	// 看涨
	OptionsTypeCallOptions OptionsTypeType = '1'
	// 看跌
	OptionsTypePutOptions OptionsTypeType = '2'
)

type OrderField

type OrderField struct {
	// 交易帐号
	InvestorID string
	// 合约代码
	InstrumentID string
	// 报单引用
	OrderRef string
	// 买卖方向
	Direction DirectionType
	// 组合开平标志
	OffsetFlag OffsetFlagType
	// 组合投机套保标志
	HedgeFlag HedgeFlagType
	// 价格
	LimitPrice float64
	// 数量
	VolumeTotalOriginal int
	// 交易所代码
	ExchangeID string
	// 报单编号
	OrderSysID string
	// 报单状态
	OrderStatus OrderStatusType
	// 今成交数量
	VolumeTraded int
	// 剩余数量
	VolumeLeft int
	// 报单日期
	InsertDate string
	// 委托时间
	InsertTime string
	// 撤销时间
	CancelTime string
	// 前置编号
	FrontID int
	// 会话编号
	SessionID int
	// 状态信息
	StatusMsg string
	// 是否本次登录后的委托
	IsLocal bool
	// 成交时间(有OnTrade更新)
	LastTradeTime string
	// 成交均价
	TradePrice float64
}

报单

type OrderStatusType

type OrderStatusType byte

报单状态类型

const (
	// 全部成交
	OrderStatusAllTraded OrderStatusType = '0'
	// 部分成交还在队列中
	OrderStatusPartTradedQueueing OrderStatusType = '1'
	// 部分成交不在队列中
	OrderStatusPartTradedNotQueueing OrderStatusType = '2'
	// 未成交还在队列中
	OrderStatusNoTradeQueueing OrderStatusType = '3'
	// 未成交不在队列中
	OrderStatusNoTradeNotQueueing OrderStatusType = '4'
	// 撤单
	OrderStatusCanceled OrderStatusType = '5'
	// 未知
	OrderStatusUnknown OrderStatusType = 'a'
	// 尚未触发
	OrderStatusNotTouched OrderStatusType = 'b'
	// 已触发
	OrderStatusTouched OrderStatusType = 'c'
)

type PosiDirectionType

type PosiDirectionType byte

持仓多空方向类型

const (
	// 净
	PosiDirectionNet PosiDirectionType = '1'
	// 多头
	PosiDirectionLong PosiDirectionType = '2'
	// 空头
	PosiDirectionShort PosiDirectionType = '3'
)

type PositionField

type PositionField struct {
	// 交易帐号
	InvestorID string
	// 合约代码
	InstrumentID string
	// 持仓多空方向
	PositionDirection PosiDirectionType
	// 投机套保标志
	HedgeFlag HedgeFlagType
	// 上日持仓
	YdPosition int
	// 今日持仓
	Position int
	// 多头冻结
	LongFrozen int
	// 空头冻结
	ShortFrozen int
	// 开仓冻结金额
	LongFrozenAmount float64
	// 开仓冻结金额
	ShortFrozenAmount float64
	// 开仓量
	OpenVolume int
	// 平仓量
	CloseVolume int
	// 开仓金额
	OpenAmount float64
	// 平仓金额
	CloseAmount float64
	// 持仓成本
	PositionCost float64
	// 上次占用的保证金
	PreMargin float64
	// 占用的保证金
	UseMargin float64
	// 冻结的保证金
	FrozenMargin float64
	// 冻结的资金
	FrozenCash float64
	// 冻结的手续费
	FrozenCommission float64
	// 资金差额
	CashIn float64
	// 手续费
	Commission float64
	// 平仓盈亏
	CloseProfit float64
	// 持仓盈亏
	PositionProfit float64
	// 上次结算价
	PreSettlementPrice float64
	// 本次结算价
	SettlementPrice float64
	// 开仓成本
	OpenCost float64
	// 交易所保证金
	ExchangeMargin float64
	// 组合成交形成的持仓
	CombPosition int
	// 组合多头冻结
	CombLongFrozen int
	// 组合空头冻结
	CombShortFrozen int
	// 逐日盯市平仓盈亏
	CloseProfitByDate float64
	// 逐笔对冲平仓盈亏
	CloseProfitByTrade float64
	// 今日持仓
	TodayPosition int
	// 执行冻结
	StrikeFrozen int
	// 执行冻结金额
	StrikeFrozenAmount float64
	// 放弃执行冻结
	AbandonFrozen int
	// 交易所代码
	ExchangeID string
	// 执行冻结的昨仓
	YdStrikeFrozen int
	// 大商所持仓成本差值,只有大商所使用
	PositionCostOffset float64
}

投资者持仓

type PositionTypeType

type PositionTypeType byte

持仓类型类型

const (
	// 净持仓
	PositionTypeNet PositionTypeType = '1'
	// 综合持仓
	PositionTypeGross PositionTypeType = '2'
)

type ProductClassType

type ProductClassType byte

产品类型类型

const (
	// 期货
	ProductClassFutures ProductClassType = '1'
	// 期货期权
	ProductClassOptions ProductClassType = '2'
	// 组合
	ProductClassCombinationProductClassType = '3'
	// 即期
	ProductClassSpot ProductClassType = '4'
	// 期转现
	ProductClassEFP ProductClassType = '5'
	// 现货期权
	ProductClassSpotOption ProductClassType = '6'
)

type ReleaseAPIType

type ReleaseAPIType func()

type ReqAuthenticateType

type ReqAuthenticateType func(*ctp.CThostFtdcReqAuthenticateField, int)

type ReqConnectType

type ReqConnectType = func(string)

type ReqOrderActionType

type ReqOrderActionType = func(*ctp.CThostFtdcInputOrderActionField, int)

type ReqOrderInsertType

type ReqOrderInsertType func(*ctp.CThostFtdcInputOrderField, int)

type ReqQryClassifiedInstrumentType

type ReqQryClassifiedInstrumentType func(*ctp.CThostFtdcQryClassifiedInstrumentField, int)

type ReqQryInstrumentType

type ReqQryInstrumentType func(*ctp.CThostFtdcQryInstrumentField, int)

type ReqQryInvestorPositionType

type ReqQryInvestorPositionType func(*ctp.CThostFtdcQryInvestorPositionField, int)

type ReqQryInvestorType

type ReqQryInvestorType = func(*ctp.CThostFtdcQryInvestorField, int)

type ReqQryOrderType

type ReqQryOrderType = func(f *ctp.CThostFtdcQryOrderField, i int)

type ReqQryTradeType

type ReqQryTradeType = func(f *ctp.CThostFtdcQryTradeField, i int)

type ReqQryTradingAccountType

type ReqQryTradingAccountType func(*ctp.CThostFtdcQryTradingAccountField, int)

type ReqSettlementInfoConfirmType

type ReqSettlementInfoConfirmType func(*ctp.CThostFtdcSettlementInfoConfirmField, int)

type ReqSubscriptType

type ReqSubscriptType func(...string)

type ReqTransferType

type ReqTransferType = func(*ctp.CThostFtdcReqTransferField, int)

type ReqUserLoginType

type ReqUserLoginType func(*ctp.CThostFtdcReqUserLoginField, int)

type RspInfoField

type RspInfoField struct {
	// 错误代码
	ErrorID int
	// 错误信息
	ErrorMsg string
}

响应信息

type RspUserLoginField

type RspUserLoginField struct {
	// 交易日
	TradingDay string
	// 登录成功时间
	LoginTime string
	// 经纪公司代码
	BrokerID string
	// 用户代码
	UserID string
	// 前置编号
	FrontID int
	// 会话编号
	SessionID int
	// 最大报单引用
	MaxOrderRef string
	// 上期所时间
	//SHFETime string
	//// 大商所时间
	//DCETime string
	//// 郑商所时间
	//CZCETime string
	//// 中金所时间
	//FFEXTime string
	//// 能源中心时间
	//INETime string
	// 交易系统名称
	SystemName string
	// 后台版本信息
	SysVersion string
}

用户登录应答

type TickField

type TickField struct {
	// 交易日
	TradingDay string
	// 合约代码
	InstrumentID string
	// 交易所代码
	ExchangeID string
	// 合约在交易所的代码
	//ExchangeInstID string
	// 最新价
	LastPrice float64
	// 上次结算价
	//PreSettlementPrice float64
	// 昨收盘
	//PreClosePrice float64
	// 昨持仓量
	//PreOpenInterest float64
	// 今开盘
	OpenPrice float64
	// 最高价
	HighestPrice float64
	// 最低价
	LowestPrice float64
	// 数量
	Volume int
	// 成交金额
	Turnover float64
	// 持仓量
	OpenInterest float64
	// 今收盘
	ClosePrice float64
	// 本次结算价
	SettlementPrice float64
	// 涨停板价
	UpperLimitPrice float64
	// 跌停板价
	LowerLimitPrice float64
	// 昨虚实度
	//PreDelta float64
	// 今虚实度
	CurrDelta 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
	// 业务日期
	ActionDay string
}

行情响应

type TradeField

type TradeField struct {
	// 交易帐号
	InvestorID string
	// 合约代码
	InstrumentID string
	// 交易所代码
	ExchangeID string
	// 成交编号
	TradeID string
	// 买卖方向
	Direction DirectionType
	// 报单编号
	OrderSysID string
	// 开平标志
	OffsetFlag OffsetFlagType
	// 投机套保标志
	HedgeFlag HedgeFlagType
	// 价格
	Price float64
	// 数量
	Volume int
	// 成交时期
	TradeDate string
	// 成交时间
	TradeTime string
	// 交易日
	TradingDay string
}

成交

type TransferField

type TransferField struct {
	Time       string  // 时间
	CurrencyID string  // 币种
	Amout      float64 // 金额
	ErrorID    int     // 错误码
	ErrorMsg   string  // 错误描述
}

TransferField 银转响应

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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