Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2String(t []byte) string
- func CheckErr(err error)
- func Contain(obj interface{}, target interface{}) (bool, error)
- func TemplateMap(templateString string, mapContent map[string]string) string
- type AccountField
- type BizType
- type CombinationTypeType
- type CommissionRateField
- type DirectionType
- type GetVersionType
- type GoroutineTickPoolConfig
- type HedgeFlagType
- type InstLifePhaseType
- type InstrumentField
- type InstrumentStatus
- type InstrumentStatusType
- type InvestorRangeType
- type MarginRateField
- type MiCiQuantTrade
- func (t *MiCiQuantTrade) ErrRtnOrderAction(field *ctp.CThostFtdcOrderActionField, info *ctp.CThostFtdcRspInfoField)
- func (t *MiCiQuantTrade) ErrRtnOrderInsert(field *ctp.CThostFtdcInputOrderField, info *ctp.CThostFtdcRspInfoField)
- func (t *MiCiQuantTrade) FrontConnected()
- func (t *MiCiQuantTrade) FrontDisConnected(reason int)
- func (t *MiCiQuantTrade) Init(c *TradeConfig)
- func (t *MiCiQuantTrade) RegOnErrAction(on OnRtnErrActionType)
- func (t *MiCiQuantTrade) RegOnErrRtnOrder(on OnRtnErrOrderType)
- func (t *MiCiQuantTrade) RegOnFrontConnected(on OnFrontConnectedType)
- func (t *MiCiQuantTrade) RegOnFrontDisConnected(on OnFrontDisConnectedType)
- func (t *MiCiQuantTrade) RegOnRspQryInstrumentCommissionRate(on OnRspQryInstrumentCommissionRateSync)
- func (t *MiCiQuantTrade) RegOnRspQryInstrumentMarginRate(on OnRspQryInstrumentMarginRateSync)
- func (t *MiCiQuantTrade) RegOnRspUserLogin(on OnRspUserLoginType)
- func (t *MiCiQuantTrade) RegOnRtnCancel(on OnRtnOrderType)
- func (t *MiCiQuantTrade) RegOnRtnFromBankToFuture(on OnRtnFromBankToFutureByFuture)
- func (t *MiCiQuantTrade) RegOnRtnFromFutureToBank(on OnRtnFromFutureToBankByFuture)
- func (t *MiCiQuantTrade) RegOnRtnInstrumentStatus(on OnRtnInstrumentStatusType)
- func (t *MiCiQuantTrade) RegOnRtnOrder(on OnRtnOrderType)
- func (t *MiCiQuantTrade) RegOnRtnTrade(on OnRtnTradeType)
- func (t *MiCiQuantTrade) Release()
- func (t *MiCiQuantTrade) ReqBankToFuture(bankID, bankAccount, bankPwd string, amount float64)
- func (t *MiCiQuantTrade) ReqFutureToBank(bankID, bankAccount string, amount float64)
- func (t *MiCiQuantTrade) ReqLogin()
- func (t *MiCiQuantTrade) ReqOrderAction(orderID string) int
- func (t *MiCiQuantTrade) ReqOrderInsert(instrument string, buySell DirectionType, openClose OffsetFlagType, ...) string
- func (t *MiCiQuantTrade) ReqOrderInsertFAK(instrument string, buySell DirectionType, openClose OffsetFlagType, ...) string
- func (t *MiCiQuantTrade) ReqOrderInsertFOK(instrument string, buySell DirectionType, openClose OffsetFlagType, ...) string
- func (t *MiCiQuantTrade) ReqOrderInsertMarket(instrument string, buySell DirectionType, openClose OffsetFlagType, volume int) string
- func (t *MiCiQuantTrade) ReqQryInstrumentCommissionRateSync(instrumentID string) error
- func (t *MiCiQuantTrade) ReqQryInstrumentMarginRateSync(hedgeFlag HedgeFlagType, instrumentID string) error
- func (t *MiCiQuantTrade) RspAuthenticate(info *ctp.CThostFtdcRspInfoField)
- func (t *MiCiQuantTrade) RspQryInstrument(field *ctp.CThostFtdcInstrumentField, b bool)
- func (t *MiCiQuantTrade) RspQryInstrumentCommissionRate(data *ctp.CThostFtdcInstrumentCommissionRateField, endFlow bool)
- func (t *MiCiQuantTrade) RspQryInstrumentMarginRate(data *ctp.CThostFtdcInstrumentMarginRateField, endFlow bool)
- func (t *MiCiQuantTrade) RspQryInvestorPosition(field *ctp.CThostFtdcInvestorPositionField, b bool)
- func (t *MiCiQuantTrade) RspQryTradingAccount(field *ctp.CThostFtdcTradingAccountField)
- func (t *MiCiQuantTrade) RspSettlementInfoConfirm()
- func (t *MiCiQuantTrade) RspUserLogin(loginField *ctp.CThostFtdcRspUserLoginField, ...)
- func (t *MiCiQuantTrade) RtnFromBankToFutureByFuture(field *ctp.CThostFtdcRspTransferField)
- func (t *MiCiQuantTrade) RtnFromFutureToBankByFuture(field *ctp.CThostFtdcRspTransferField)
- func (t *MiCiQuantTrade) RtnInstrumentStatus(field *ctp.CThostFtdcInstrumentStatusField)
- func (t *MiCiQuantTrade) RtnOrder(field *ctp.CThostFtdcOrderField)
- func (t *MiCiQuantTrade) RtnTrade(field *ctp.CThostFtdcTradeField)
- type MiciQuantQuote
- func (q *MiciQuantQuote) FrontConnected()
- func (q *MiciQuantQuote) FrontDisConnected(reason int)
- func (q *MiciQuantQuote) Init()
- func (q *MiciQuantQuote) RegOnFrontConnected(on OnFrontConnectedType)
- func (q *MiciQuantQuote) RegOnFrontDisConnected(on OnFrontDisConnectedType)
- func (q *MiciQuantQuote) RegOnGoroutineTickPoolError(on OnGoroutineTickPoolErrorType)
- func (q *MiciQuantQuote) RegOnRspUserLogin(on OnRspUserLoginType)
- func (q *MiciQuantQuote) RegOnTick(on OnTickType)
- func (q *MiciQuantQuote) RegOnTickError(on OnTickErrorType)
- func (q *MiciQuantQuote) ReqLogin()
- func (q *MiciQuantQuote) RspUserLogin(loginField *ctpdefine.CThostFtdcRspUserLoginField, ...)
- func (q *MiciQuantQuote) RtnDepthMarketData(tick *TickField)
- func (q *MiciQuantQuote) RtnDepthMarketDataErr(tick *TickField, err error)
- func (q *MiciQuantQuote) RtnOnGoroutineTickPoolError(err error)
- type OffsetFlagType
- type OnFrontConnectedType
- type OnFrontDisConnectedType
- type OnGoroutineTickPoolErrorType
- type OnRspQryInstrumentCommissionRateSync
- type OnRspQryInstrumentMarginRateSync
- type OnRspUserLoginType
- type OnRtnErrActionType
- type OnRtnErrOrderType
- type OnRtnFromBankToFutureByFuture
- type OnRtnFromFutureToBankByFuture
- type OnRtnInstrumentStatusType
- type OnRtnOrderType
- type OnRtnTradeType
- type OnTickErrorType
- type OnTickInvokeModeType
- type OnTickType
- type OptionsTypeType
- type OrderField
- type OrderStatusType
- type PosiDirectionType
- type PositionField
- type PositionTypeType
- type ProductClassType
- type QuoteAccountConfig
- type QuoteConfig
- type ReleaseAPIType
- type ReqAuthenticateType
- type ReqConnectType
- type ReqOrderActionType
- type ReqOrderInsertType
- type ReqQryClassifiedInstrumentType
- type ReqQryInstrumentCommissionRateType
- type ReqQryInstrumentMarginRateType
- type ReqQryInstrumentType
- type ReqQryInvestorPositionType
- type ReqQryTradingAccountType
- type ReqSettlementInfoConfirmType
- type ReqSubscriptType
- type ReqTransferType
- type ReqUserLoginType
- type RspInfoField
- type RspUserLoginField
- type TickField
- type TradeAccountConfig
- type TradeConfig
- type TradeField
- type TransferField
Constants ¶
const ( // BizTypeFuture 期货 BizTypeFuture = '1' // BizTypeStock 证券 BizTypeStock = '2' )
const ( Initialized int32 = iota UnInitialized )
Variables ¶
var ( QuoteAddrExist = errors.New("quote address already exists") GoroutineTickPoolExists = errors.New("goroutine tick pool instance already exists") GoroutineTickPoolClosed = errors.New("goroutine tick pool closed") GoroutineTickPoolUninitialized = errors.New("goroutine tick pool uninitialized") )
Functions ¶
func Bytes2String ¶
Types ¶
type AccountField ¶
type AccountField struct {
// 上次质押金额
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
}
AccountField 资金账户
type CombinationTypeType ¶
type CombinationTypeType byte
CombinationTypeType 组合类型
const ( // CombinationTypeFuture 期货组合 CombinationTypeFuture CombinationTypeType = '0' // CombinationTypeBUL 垂直价差BUL CombinationTypeBUL CombinationTypeType = '1' // CombinationTypeBER 垂直价差BER CombinationTypeBER CombinationTypeType = '2' // CombinationTypeSTD 跨式组合 CombinationTypeSTD CombinationTypeType = '3' // CombinationTypeSTG 宽跨式组合 CombinationTypeSTG CombinationTypeType = '4' // CombinationTypePRT 备兑组合 CombinationTypePRT CombinationTypeType = '5' // CombinationTypeCLD 时间价差组合 CombinationTypeCLD CombinationTypeType = '6' )
type CommissionRateField ¶ added in v1.1.3
type CommissionRateField struct {
// 合约代码
InstrumentID string
// 交易所代码
ExchangeID string
// 投资者范围
InvestorRange InvestorRangeType
// 业务类型
BizType BizType
// 开仓手续费率
OpenRatioByMoney float64
// 开仓手续费
OpenRatioByVolume float64
// 平仓手续费率
CloseRatioByMoney float64
// 平仓手续费
CloseRatioByVolume float64
// 平今手续费率
CloseTodayRatioByMoney float64
// 平今手续费
CloseTodayRatioByVolume float64
}
CommissionRateField 手续费(率)响应
type DirectionType ¶
type DirectionType byte
DirectionType 买卖方向类型
const ( // DirectionBuy 买 DirectionBuy DirectionType = '0' // DirectionSell 卖 DirectionSell DirectionType = '1' )
type GetVersionType ¶ added in v1.0.8
type GetVersionType func() string
type GoroutineTickPoolConfig ¶ added in v1.1.81
type GoroutineTickPoolConfig struct {
TotalClientSubscriptionContracts int // 合计订阅合约数量(多行情)
}
GoroutineTickPoolConfig Tick协程池配置
type HedgeFlagType ¶
type HedgeFlagType byte
HedgeFlagType 投机套保标志类型
const ( // HedgeFlagSpeculation 投机 HedgeFlagSpeculation HedgeFlagType = '1' // HedgeFlagArbitrage 套利 HedgeFlagArbitrage HedgeFlagType = '2' // HedgeFlagHedge 套保 HedgeFlagHedge HedgeFlagType = '3' // HedgeFlagMarketMaker 做市商 HedgeFlagMarketMaker HedgeFlagType = '5' // HedgeFlagSpecHedge 第一腿投机第二腿套保 大商所专用 HedgeFlagSpecHedge HedgeFlagType = '6' // HedgeFlagHedgeSpec 第一腿套保第二腿投机 大商所专用 HedgeFlagHedgeSpec HedgeFlagType = '7' )
type InstLifePhaseType ¶ added in v1.1.3
type InstLifePhaseType byte
InstLifePhaseType 合约生命周期状态
const ( // InstLifePhaseTypeNotStart 未上市 InstLifePhaseTypeNotStart InstLifePhaseType = '0' // InstLifePhaseTypeStarted 上市 InstLifePhaseTypeStarted InstLifePhaseType = '1' // InstLifePhaseTypePause 停牌 InstLifePhaseTypePause InstLifePhaseType = '2' // InstLifePhaseTypeExpired 到期 InstLifePhaseTypeExpired InstLifePhaseType = '3' )
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
// 交割年份
DeliveryYear int
// 交割月
DeliveryMonth int
// 创建日
CreateDate string
// 上市日
OpenDate string
// 到期日
ExpireDate string
// 开始交割日
StartDelivDate string
// 结束交割日
EndDelivDate string
// 合约生命周期状态
InstLifePhase InstLifePhaseType
}
InstrumentField 合约
type InstrumentStatus ¶
type InstrumentStatus struct {
// 交易所代码
ExchangeID string
// 合约代码
InstrumentID string
// 合约交易状态
InstrumentStatus InstrumentStatusType
// 进入本状态时间
EnterTime string
}
InstrumentStatus 合约状态
type InstrumentStatusType ¶
type InstrumentStatusType byte
InstrumentStatusType 合约交易状态类型
const ( // InstrumentStatusBeforeTrading 开盘前 InstrumentStatusBeforeTrading InstrumentStatusType = '0' // InstrumentStatusNoTrading 非交易 InstrumentStatusNoTrading InstrumentStatusType = '1' // InstrumentStatusContinous 连续交易 InstrumentStatusContinous InstrumentStatusType = '2' // InstrumentStatusAuctionOrdering 集合竞价报单 InstrumentStatusAuctionOrdering InstrumentStatusType = '3' // InstrumentStatusAuctionBalance 集合竞价价格平衡 InstrumentStatusAuctionBalance InstrumentStatusType = '4' // InstrumentStatusAuctionMatch 集合竞价撮合 InstrumentStatusAuctionMatch InstrumentStatusType = '5' // InstrumentStatusClosed 收盘 InstrumentStatusClosed InstrumentStatusType = '6' )
type InvestorRangeType ¶ added in v1.1.3
type InvestorRangeType byte
InvestorRangeType 投资者范围类型
const ( // InvestorRangeTypeAll 所有 InvestorRangeTypeAll InvestorRangeType = '1' // InvestorRangeTypeGroup 投资者组 InvestorRangeTypeGroup InvestorRangeType = '2' // InvestorRangeTypeSingle 单一投资者 InvestorRangeTypeSingle InvestorRangeType = '3' )
type MarginRateField ¶ added in v1.1.3
type MarginRateField struct {
// 合约代码
InstrumentID string
// 交易所代码
ExchangeID string
// 是否相对交易所收取
IsRelative bool
// 投机套保标志
HedgeFlag HedgeFlagType
// 投资者范围
InvestorRange InvestorRangeType
// 多头保证金率
LongMarginRatioByMoney float64
// 多头保证金费
LongMarginRatioByVolume float64
// 空头保证金率
ShortMarginRatioByMoney float64
// 空头保证金费
ShortMarginRatioByVolume float64
}
MarginRateField 保证金(率)响应
type MiCiQuantTrade ¶ added in v1.1.3
type MiCiQuantTrade struct {
IsInitialized bool
Config *TradeConfig
TradingDay string // 交易日
SessionID int // 判断是否自己的委托用
Instruments sync.Map // 合约列表 (key: InstrumentID, value: *InstrumentField)
InstrumentStatus 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 // 帐户权益
IsLogin bool // 登录成功
Version string // 版本号,如 v6.5.1_20200908 10:25:08
ThresholdReqQryInstrumentMarginRateMsTime int64 // 保证金查询毫秒阈值
LastReqQryInstrumentMarginRateMsTime int64 // 最近一次查询保证金的毫秒时间戳
ThresholdReqQryInstrumentCommissionRateMsTime int64 // 手续费查询毫秒阈值
LastReqQryInstrumentCommissionRateMsTime int64 // 最近一次查询手续费的毫秒时间戳
OnRspQryInstrumentMarginRate OnRspQryInstrumentMarginRateSync
OnRspQryInstrumentCommissionRate OnRspQryInstrumentCommissionRateSync
// 继承类要实现的函数
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
ReqQryInstrumentMarginRate ReqQryInstrumentMarginRateType
ReqQryInstrumentCommissionRate ReqQryInstrumentCommissionRateType
// contains filtered or unexported fields
}
MiCiQuantTrade 交易接口
func (*MiCiQuantTrade) ErrRtnOrderAction ¶ added in v1.1.3
func (t *MiCiQuantTrade) ErrRtnOrderAction(field *ctp.CThostFtdcOrderActionField, info *ctp.CThostFtdcRspInfoField)
ErrRtnOrderAction 撤单错误
func (*MiCiQuantTrade) ErrRtnOrderInsert ¶ added in v1.1.3
func (t *MiCiQuantTrade) ErrRtnOrderInsert(field *ctp.CThostFtdcInputOrderField, info *ctp.CThostFtdcRspInfoField)
ErrRtnOrderInsert 委托错误
func (*MiCiQuantTrade) FrontConnected ¶ added in v1.1.3
func (t *MiCiQuantTrade) FrontConnected()
FrontConnected 连接
func (*MiCiQuantTrade) FrontDisConnected ¶ added in v1.1.3
func (t *MiCiQuantTrade) FrontDisConnected(reason int)
FrontDisConnected 断开响应
func (*MiCiQuantTrade) Init ¶ added in v1.1.3
func (t *MiCiQuantTrade) Init(c *TradeConfig)
func (*MiCiQuantTrade) RegOnErrAction ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnErrAction(on OnRtnErrActionType)
RegOnErrAction 注册撤单响应
func (*MiCiQuantTrade) RegOnErrRtnOrder ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnErrRtnOrder(on OnRtnErrOrderType)
RegOnErrRtnOrder 注册委托响应
func (*MiCiQuantTrade) RegOnFrontConnected ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnFrontConnected(on OnFrontConnectedType)
RegOnFrontConnected 注册连接响应
func (*MiCiQuantTrade) RegOnFrontDisConnected ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnFrontDisConnected(on OnFrontDisConnectedType)
RegOnFrontDisConnected 注册连接响应
func (*MiCiQuantTrade) RegOnRspQryInstrumentCommissionRate ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRspQryInstrumentCommissionRate(on OnRspQryInstrumentCommissionRateSync)
RegOnRspQryInstrumentCommissionRate 注册查询手续费
func (*MiCiQuantTrade) RegOnRspQryInstrumentMarginRate ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRspQryInstrumentMarginRate(on OnRspQryInstrumentMarginRateSync)
RegOnRspQryInstrumentMarginRate 注册查询保证金
func (*MiCiQuantTrade) RegOnRspUserLogin ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRspUserLogin(on OnRspUserLoginType)
RegOnRspUserLogin 注册登陆响应
func (*MiCiQuantTrade) RegOnRtnCancel ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnCancel(on OnRtnOrderType)
RegOnRtnCancel 注册撤单响应
func (*MiCiQuantTrade) RegOnRtnFromBankToFuture ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnFromBankToFuture(on OnRtnFromBankToFutureByFuture)
RegOnRtnFromBankToFuture 注册银行转期货
func (*MiCiQuantTrade) RegOnRtnFromFutureToBank ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnFromFutureToBank(on OnRtnFromFutureToBankByFuture)
RegOnRtnFromFutureToBank 注册期货转银行
func (*MiCiQuantTrade) RegOnRtnInstrumentStatus ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnInstrumentStatus(on OnRtnInstrumentStatusType)
RegOnRtnInstrumentStatus 注册合约状态变化
func (*MiCiQuantTrade) RegOnRtnOrder ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnOrder(on OnRtnOrderType)
RegOnRtnOrder 注册委托响应
func (*MiCiQuantTrade) RegOnRtnTrade ¶ added in v1.1.3
func (t *MiCiQuantTrade) RegOnRtnTrade(on OnRtnTradeType)
RegOnRtnTrade 注册成交响应
func (*MiCiQuantTrade) Release ¶ added in v1.1.3
func (t *MiCiQuantTrade) Release()
func (*MiCiQuantTrade) ReqBankToFuture ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqBankToFuture(bankID, bankAccount, bankPwd string, amount float64)
ReqBankToFuture 银行转期货
func (*MiCiQuantTrade) ReqFutureToBank ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqFutureToBank(bankID, bankAccount string, amount float64)
ReqFutureToBank 期货转银行
func (*MiCiQuantTrade) ReqOrderAction ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqOrderAction(orderID string) int
ReqOrderAction 撤单
func (*MiCiQuantTrade) ReqOrderInsert ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqOrderInsert(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string
ReqOrderInsert 限价委托
func (*MiCiQuantTrade) ReqOrderInsertFAK ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqOrderInsertFAK(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string
ReqOrderInsertFAK FAK委托[全成or撤单]
func (*MiCiQuantTrade) ReqOrderInsertFOK ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqOrderInsertFOK(instrument string, buySell DirectionType, openClose OffsetFlagType, price float64, volume int) string
ReqOrderInsertFOK FOK委托[部成撤单]
func (*MiCiQuantTrade) ReqOrderInsertMarket ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqOrderInsertMarket(instrument string, buySell DirectionType, openClose OffsetFlagType, volume int) string
ReqOrderInsertMarket 市价委托
func (*MiCiQuantTrade) ReqQryInstrumentCommissionRateSync ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqQryInstrumentCommissionRateSync(instrumentID string) error
ReqQryInstrumentCommissionRateSync 请求查询合约手续费率
func (*MiCiQuantTrade) ReqQryInstrumentMarginRateSync ¶ added in v1.1.3
func (t *MiCiQuantTrade) ReqQryInstrumentMarginRateSync(hedgeFlag HedgeFlagType, instrumentID string) error
ReqQryInstrumentMarginRateSync 请求查询合约保证金率
func (*MiCiQuantTrade) RspAuthenticate ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspAuthenticate(info *ctp.CThostFtdcRspInfoField)
RspAuthenticate 认证
func (*MiCiQuantTrade) RspQryInstrument ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspQryInstrument(field *ctp.CThostFtdcInstrumentField, b bool)
RspQryInstrument 合约
func (*MiCiQuantTrade) RspQryInstrumentCommissionRate ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspQryInstrumentCommissionRate(data *ctp.CThostFtdcInstrumentCommissionRateField, endFlow bool)
RspQryInstrumentCommissionRate 查询手续费
func (*MiCiQuantTrade) RspQryInstrumentMarginRate ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspQryInstrumentMarginRate(data *ctp.CThostFtdcInstrumentMarginRateField, endFlow bool)
RspQryInstrumentMarginRate 查询保证金
func (*MiCiQuantTrade) RspQryInvestorPosition ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspQryInvestorPosition(field *ctp.CThostFtdcInvestorPositionField, b bool)
RspQryInvestorPosition 持仓
func (*MiCiQuantTrade) RspQryTradingAccount ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspQryTradingAccount(field *ctp.CThostFtdcTradingAccountField)
RspQryTradingAccount 权益
func (*MiCiQuantTrade) RspSettlementInfoConfirm ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspSettlementInfoConfirm()
RspSettlementInfoConfirm 确认结算
func (*MiCiQuantTrade) RspUserLogin ¶ added in v1.1.3
func (t *MiCiQuantTrade) RspUserLogin(loginField *ctp.CThostFtdcRspUserLoginField, infoField *ctp.CThostFtdcRspInfoField)
RspUserLogin 登录
func (*MiCiQuantTrade) RtnFromBankToFutureByFuture ¶ added in v1.1.3
func (t *MiCiQuantTrade) RtnFromBankToFutureByFuture(field *ctp.CThostFtdcRspTransferField)
RtnFromBankToFutureByFuture 银行转期货-期货端
func (*MiCiQuantTrade) RtnFromFutureToBankByFuture ¶ added in v1.1.3
func (t *MiCiQuantTrade) RtnFromFutureToBankByFuture(field *ctp.CThostFtdcRspTransferField)
RtnFromFutureToBankByFuture // 期货转银行-期货端
func (*MiCiQuantTrade) RtnInstrumentStatus ¶ added in v1.1.3
func (t *MiCiQuantTrade) RtnInstrumentStatus(field *ctp.CThostFtdcInstrumentStatusField)
RtnInstrumentStatus 合约/品种/交易所 状态响应
func (*MiCiQuantTrade) RtnOrder ¶ added in v1.1.3
func (t *MiCiQuantTrade) RtnOrder(field *ctp.CThostFtdcOrderField)
RtnOrder 委托响应
func (*MiCiQuantTrade) RtnTrade ¶ added in v1.1.3
func (t *MiCiQuantTrade) RtnTrade(field *ctp.CThostFtdcTradeField)
RtnTrade 成交响应
type MiciQuantQuote ¶ added in v1.1.6
type MiciQuantQuote struct {
IsInitialized int32
Config *QuoteConfig
ReqConnect ReqConnectType
Release ReleaseAPIType
ReqUserLogin ReqUserLoginType
ReqSubscript ReqSubscriptType
// contains filtered or unexported fields
}
MiciQuantQuote 行情接口
func (*MiciQuantQuote) FrontConnected ¶ added in v1.1.6
func (q *MiciQuantQuote) FrontConnected()
func (*MiciQuantQuote) FrontDisConnected ¶ added in v1.1.6
func (q *MiciQuantQuote) FrontDisConnected(reason int)
func (*MiciQuantQuote) Init ¶ added in v1.1.6
func (q *MiciQuantQuote) Init()
func (*MiciQuantQuote) RegOnFrontConnected ¶ added in v1.1.6
func (q *MiciQuantQuote) RegOnFrontConnected(on OnFrontConnectedType)
RegOnFrontConnected 注册前置响应
func (*MiciQuantQuote) RegOnFrontDisConnected ¶ added in v1.1.6
func (q *MiciQuantQuote) RegOnFrontDisConnected(on OnFrontDisConnectedType)
RegOnFrontDisConnected 注册连接响应
func (*MiciQuantQuote) RegOnGoroutineTickPoolError ¶ added in v1.1.81
func (q *MiciQuantQuote) RegOnGoroutineTickPoolError(on OnGoroutineTickPoolErrorType)
RegOnGoroutineTickPoolError 注册onTick协程池化错误
func (*MiciQuantQuote) RegOnRspUserLogin ¶ added in v1.1.6
func (q *MiciQuantQuote) RegOnRspUserLogin(on OnRspUserLoginType)
RegOnRspUserLogin 注册登录响应
func (*MiciQuantQuote) RegOnTick ¶ added in v1.1.6
func (q *MiciQuantQuote) RegOnTick(on OnTickType)
RegOnTick 注册行情响应
func (*MiciQuantQuote) RegOnTickError ¶ added in v1.1.81
func (q *MiciQuantQuote) RegOnTickError(on OnTickErrorType)
RegOnTickError RegOnTick 注册行情响应错误
func (*MiciQuantQuote) RspUserLogin ¶ added in v1.1.6
func (q *MiciQuantQuote) RspUserLogin(loginField *ctpdefine.CThostFtdcRspUserLoginField, infoField *ctpdefine.CThostFtdcRspInfoField)
func (*MiciQuantQuote) RtnDepthMarketData ¶ added in v1.1.6
func (q *MiciQuantQuote) RtnDepthMarketData(tick *TickField)
func (*MiciQuantQuote) RtnDepthMarketDataErr ¶ added in v1.1.81
func (q *MiciQuantQuote) RtnDepthMarketDataErr(tick *TickField, err error)
func (*MiciQuantQuote) RtnOnGoroutineTickPoolError ¶ added in v1.1.81
func (q *MiciQuantQuote) RtnOnGoroutineTickPoolError(err error)
type OffsetFlagType ¶
type OffsetFlagType byte
OffsetFlagType 开平标志类型
const ( // OffsetFlagOpen 开仓 OffsetFlagOpen OffsetFlagType = '0' // OffsetFlagClose 平仓 OffsetFlagClose OffsetFlagType = '1' // OffsetFlagForceClose 强平 OffsetFlagForceClose OffsetFlagType = '2' // OffsetFlagCloseToday 平今 OffsetFlagCloseToday OffsetFlagType = '3' // OffsetFlagCloseYesterday 平昨 OffsetFlagCloseYesterday OffsetFlagType = '4' // OffsetFlagForceOff 强减 OffsetFlagForceOff OffsetFlagType = '5' // OffsetFlagLocalForceClose 本地强平 OffsetFlagLocalForceClose OffsetFlagType = '6' )
type OnFrontDisConnectedType ¶
type OnFrontDisConnectedType func(reason int)
OnFrontDisConnectedType 公共-断开
type OnGoroutineTickPoolErrorType ¶ added in v1.1.81
type OnGoroutineTickPoolErrorType func(err error)
OnGoroutineTickPoolErrorType onTick协程池化错误
type OnRspQryInstrumentCommissionRateSync ¶ added in v1.1.3
type OnRspQryInstrumentCommissionRateSync func(field *CommissionRateField)
OnRspQryInstrumentCommissionRateSync 查询 - 手续费(率)
type OnRspQryInstrumentMarginRateSync ¶ added in v1.1.3
type OnRspQryInstrumentMarginRateSync func(field *MarginRateField)
OnRspQryInstrumentMarginRateSync 查询 - 保证金(率)
type OnRspUserLoginType ¶
type OnRspUserLoginType func(loginField *RspUserLoginField, info *RspInfoField)
OnRspUserLoginType 公共-登录
type OnRtnErrActionType ¶
type OnRtnErrActionType func(orderID string, info *RspInfoField)
OnRtnErrActionType 交易-错误撤单
type OnRtnErrOrderType ¶
type OnRtnErrOrderType func(field *OrderField, info *RspInfoField)
OnRtnErrOrderType 交易-错误委托
type OnRtnFromBankToFutureByFuture ¶
type OnRtnFromBankToFutureByFuture func(field *TransferField)
OnRtnFromBankToFutureByFuture 银转-银行->期货
type OnRtnFromFutureToBankByFuture ¶
type OnRtnFromFutureToBankByFuture func(field *TransferField)
OnRtnFromFutureToBankByFuture 银转-期货->银行
type OnRtnInstrumentStatusType ¶
type OnRtnInstrumentStatusType func(field *InstrumentStatus)
OnRtnInstrumentStatusType 交易-合约状态响应
type OnTickErrorType ¶ added in v1.1.81
OnTickErrorType 行情错误
type OnTickInvokeModeType ¶ added in v1.1.81
type OnTickInvokeModeType uint
OnTickInvokeModeType onTick调用方式类型
const ( CommonOnTick OnTickInvokeModeType = iota // 同步调用OnTick GoroutineOnTick // 启用Goroutine调用OnTick GoroutinePoolOnTick // 启用池化Goroutine调用OnTick )
type OptionsTypeType ¶
type OptionsTypeType byte
OptionsTypeType 期权类型
const ( // OptionsTypeCallOptions 看涨 OptionsTypeCallOptions OptionsTypeType = '1' // OptionsTypePutOptions 看跌 OptionsTypePutOptions OptionsTypeType = '2' )
type OrderField ¶
type OrderField struct {
// 合约代码
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
}
OrderField 报单
type OrderStatusType ¶
type OrderStatusType byte
OrderStatusType 报单状态类型
const ( // OrderStatusAllTraded 全部成交 OrderStatusAllTraded OrderStatusType = '0' // OrderStatusPartTradedQueueing 部分成交还在队列中 OrderStatusPartTradedQueueing OrderStatusType = '1' // OrderStatusPartTradedNotQueueing 部分成交不在队列中 OrderStatusPartTradedNotQueueing OrderStatusType = '2' // OrderStatusNoTradeQueueing 未成交还在队列中 OrderStatusNoTradeQueueing OrderStatusType = '3' // OrderStatusNoTradeNotQueueing 未成交不在队列中 OrderStatusNoTradeNotQueueing OrderStatusType = '4' // OrderStatusCanceled 撤单 OrderStatusCanceled OrderStatusType = '5' // OrderStatusUnknown 未知 OrderStatusUnknown OrderStatusType = 'a' // OrderStatusNotTouched 尚未触发 OrderStatusNotTouched OrderStatusType = 'b' // OrderStatusTouched 已触发 OrderStatusTouched OrderStatusType = 'c' )
type PosiDirectionType ¶
type PosiDirectionType byte
PosiDirectionType 持仓多空方向类型
const ( // PosiDirectionNet 净 PosiDirectionNet PosiDirectionType = '1' // PosiDirectionLong 多头 PosiDirectionLong PosiDirectionType = '2' // PosiDirectionShort 空头 PosiDirectionShort PosiDirectionType = '3' )
type PositionField ¶
type PositionField struct {
// 合约代码
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
}
PositionField 投资者持仓
type PositionTypeType ¶
type PositionTypeType byte
PositionTypeType 持仓类型类型
const ( // PositionTypeNet 净持仓 PositionTypeNet PositionTypeType = '1' // PositionTypeGross 综合持仓 PositionTypeGross PositionTypeType = '2' )
type ProductClassType ¶
type ProductClassType byte
ProductClassType 产品类型类型
const ( // ProductClassFutures 期货 ProductClassFutures ProductClassType = '1' // ProductClassOptions 期货期权 ProductClassOptions ProductClassType = '2' // ProductClassCombinationProductClassType 组合 ProductClassCombinationProductClassType = '3' // ProductClassSpot 即期 ProductClassSpot ProductClassType = '4' // ProductClassEFP 期转现 ProductClassEFP ProductClassType = '5' // ProductClassSpotOption 现货期权 ProductClassSpotOption ProductClassType = '6' )
type QuoteAccountConfig ¶ added in v1.1.7
type QuoteAccountConfig struct {
ProductInfo string // 产品信息
InvestorID string // 账号
Password string // 密码
BrokerID string // brokerID
Addr string // 行情地址
}
QuoteAccountConfig 行情账户配置
type QuoteConfig ¶ added in v1.1.7
type QuoteConfig struct {
AccountConfig *QuoteAccountConfig
CloseUniqueAddressLimit bool // 关闭唯一地址限制(关闭后允许不同账号连接相同地址,默认限制)
OnTickInvokeMode OnTickInvokeModeType // OnTick调用方式
}
QuoteConfig 行情配置
type ReleaseAPIType ¶ added in v1.0.8
type ReleaseAPIType func()
type ReqAuthenticateType ¶ added in v1.0.8
type ReqAuthenticateType func(*ctp.CThostFtdcReqAuthenticateField, int)
type ReqConnectType ¶ added in v1.0.8
type ReqConnectType func()
type ReqOrderActionType ¶ added in v1.0.8
type ReqOrderActionType func(*ctp.CThostFtdcInputOrderActionField, int)
type ReqOrderInsertType ¶ added in v1.0.8
type ReqOrderInsertType func(*ctp.CThostFtdcInputOrderField, int)
type ReqQryClassifiedInstrumentType ¶ added in v1.0.8
type ReqQryClassifiedInstrumentType func(*ctp.CThostFtdcQryClassifiedInstrumentField, int)
type ReqQryInstrumentCommissionRateType ¶ added in v1.1.3
type ReqQryInstrumentCommissionRateType func(*ctp.CThostFtdcQryInstrumentCommissionRateField, int)
type ReqQryInstrumentMarginRateType ¶ added in v1.1.3
type ReqQryInstrumentMarginRateType func(*ctp.CThostFtdcQryInstrumentMarginRateField, int)
type ReqQryInstrumentType ¶ added in v1.0.8
type ReqQryInstrumentType func(*ctp.CThostFtdcQryInstrumentField, int)
type ReqQryInvestorPositionType ¶ added in v1.0.8
type ReqQryInvestorPositionType func(*ctp.CThostFtdcQryInvestorPositionField, int)
type ReqQryTradingAccountType ¶ added in v1.0.8
type ReqQryTradingAccountType func(*ctp.CThostFtdcQryTradingAccountField, int)
type ReqSettlementInfoConfirmType ¶ added in v1.0.8
type ReqSettlementInfoConfirmType func(*ctp.CThostFtdcSettlementInfoConfirmField, int)
type ReqSubscriptType ¶ added in v1.0.8
type ReqSubscriptType func(string)
type ReqTransferType ¶ added in v1.0.8
type ReqTransferType func(*ctp.CThostFtdcReqTransferField, int)
type ReqUserLoginType ¶ added in v1.0.8
type ReqUserLoginType func(*ctp.CThostFtdcReqUserLoginField, int)
type RspInfoField ¶
RspInfoField 响应信息
type RspUserLoginField ¶
type RspUserLoginField struct {
// 交易日
TradingDay string
// 登录成功时间
LoginTime string
// 经纪公司代码
BrokerID string
// 用户代码
UserID string
// 交易系统名称
//SystemName string
// 前置编号
FrontID int
// 会话编号
SessionID int
// 最大报单引用
MaxOrderRef string
}
RspUserLoginField 用户登录应答
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
}
TickField 行情响应
type TradeAccountConfig ¶ added in v1.1.7
type TradeAccountConfig struct {
InvestorID string // 账号
Password string // 密码
BrokerID string // brokerID
AuthCode string // 授权码
AppID string // 产品名称
Addr string // 交易地址
ProductInfo string // 产品信息
}
TradeAccountConfig 交易账户配置
type TradeConfig ¶ added in v1.1.3
type TradeConfig struct {
AccountConfig *TradeAccountConfig
QueryInstrumentMarginRateMsTimeThreshold int64 // 保证金查询毫秒阈值
QueryInstrumentCommissionRateMsTimeThreshold int64 // 手续费查询毫秒阈值
}
TradeConfig 交易配置
type TradeField ¶
type TradeField struct {
// 合约代码
InstrumentID string
// 交易所代码
ExchangeID string
// 成交编号
TradeID string
// 买卖方向
Direction DirectionType
// 报单编号
OrderSysID string
// 开平标志
OffsetFlag OffsetFlagType
// 投机套保标志
HedgeFlag HedgeFlagType
// 价格
Price float64
// 数量
Volume int
// 成交时期
TradeDate string
// 成交时间
TradeTime string
// 交易日
TradingDay string
}
TradeField 成交