futu

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 55 Imported by: 0

README

Futu open api golang client

GoDoc CI codecov Release

富途牛牛 OpenAPI Golang 客户端,要求Golang版本 >= 1.21

Futu Open API 官方文档: https://openapi.futunn.com/futu-api-doc/

代码目录说明

  • 根目录: 提供用户友好的客户端SDK,对底层的client包做了一层用法包装
  • client: 基础客户端,拥有所有功能,需要用pb定义的结构体传参,可以直接使用,但是使用起来略繁琐
  • .proto: protobuf 定义文件
  • adapt: protobuf 结构体和普通类型的适配层
  • infra: 底层支持库,使用者无需关心
  • pb: 基于 protobuf 文件生成的 golang 代码
  • protoid: 接口ID常量列表

使用说明

本SDK跟FutuOpenD的通信协议格式是protobuf,使用FutuOpenD的默认配置即可,不要改成json格式。

具体用法可以参考单元测试,里面每个接口都有用例。

方法设计的原则是,必填参数显式要求传递,可选参数放在可变参数adapt.Option传递。但有部分必填参数实际上可以有默认值,这种情况不会显式要求传递。

每个接口都有一对方法,其中结尾有WithContext的方法是方便让使用者可以自己通过context设置超时时间,不带WithContext的方法使用了默认超时时间5s。

以下是一个简单示例:

import "github.com/hyperjiang/futu"

sdk, err := futu.NewSDK()
if err != nil {
    log.Fatal(err)
}

res, err := sdk.GetGlobalState()
fmt.Println(res)

对于系统推送过来的数据,需要调用RegisterHandler(protoID uint32, h Handler)来注册自己的处理逻辑。 如果没有设置,SDK会使用默认的Handler,只打印收到的消息到日志。 可以设置推送Handler的协议ID如下:

  • protoid.Notify // 1003
  • protoid.TrdUpdateOrder // 2208
  • protoid.TrdUpdateOrderFill // 2218
  • protoid.QotUpdateBasicQot // 3005
  • protoid.QotUpdateKL // 3007
  • protoid.QotUpdateRT // 3009
  • protoid.QotUpdateTicker // 3011
  • protoid.QotUpdateOrderBook // 3013
  • protoid.QotUpdateBroker // 3015
  • protoid.QotUpdatePriceReminder // 3019

设置其他ID没有任何作用,因为永远不可能触发到。

支持的功能

基础功能(用户无需调用)
  • 支持使用RSA和AES加解密
  • 初始化连接
  • 获取全局状态
  • 事件通知推送
  • 保活心跳
行情接口
  • QotSub = 3001 // 订阅或者反订阅
  • QotGetSubInfo = 3003 // 获取订阅信息
  • QotGetBasicQot = 3004 // 获取股票基本报价
  • QotUpdateBasicQot = 3005 // 推送股票基本报价
  • QotGetKL = 3006 // 获取K线
  • QotUpdateKL = 3007 // 推送K线
  • QotGetRT = 3008 // 获取分时
  • QotUpdateRT = 3009 // 推送分时
  • QotGetTicker = 3010 // 获取逐笔
  • QotUpdateTicker = 3011 // 推送逐笔
  • QotGetOrderBook = 3012 // 获取买卖盘
  • QotUpdateOrderBook = 3013 // 推送买卖盘
  • QotGetBroker = 3014 // 获取经纪队列
  • QotUpdateBroker = 3015 // 推送经纪队列
  • QotUpdatePriceReminder = 3019 // 到价提醒通知
  • QotRequestHistoryKL = 3103 // 在线获取单只股票一段历史K线
  • QotRequestHistoryKLQuota = 3104 // 获取历史K线额度
  • QotRequestRehab = 3105 // 在线获取单只股票复权信息
  • QotGetStaticInfo = 3202 // 获取股票静态信息
  • QotGetSecuritySnapshot = 3203 // 获取股票快照
  • QotGetPlateSet = 3204 // 获取板块集合下的板块
  • QotGetPlateSecurity = 3205 // 获取板块下的股票
  • QotGetReference = 3206 // 获取正股相关股票
  • QotGetOwnerPlate = 3207 // 获取股票所属板块
  • QotGetOptionChain = 3209 // 获取期权链
  • QotGetWarrant = 3210 // 获取窝轮
  • QotGetCapitalFlow = 3211 // 获取资金流向
  • QotGetCapitalDistribution = 3212 // 获取资金分布
  • QotGetUserSecurity = 3213 // 获取自选股分组下的股票
  • QotModifyUserSecurity = 3214 // 修改自选股分组下的股票
  • QotStockFilter = 3215 // 获取条件选股
  • QotGetIpoList = 3217 // 获取新股
  • QotGetFutureInfo = 3218 // 获取期货合约资料
  • QotRequestTradeDate = 3219 // 获取市场交易日,在线拉取不在本地计算
  • QotSetPriceReminder = 3220 // 设置到价提醒
  • QotGetPriceReminder = 3221 // 获取到价提醒
  • QotGetUserSecurityGroup = 3222 // 获取自选股分组列表
  • QotGetMarketState = 3223 // 获取指定品种的市场状态
  • QotGetOptionExpirationDate = 3224 // 获取期权到期日
交易接口
  • TrdGetAccList = 2001 // 获取交易业务账户列表
  • TrdUnlockTrade = 2005 // 解锁或锁定交易
  • TrdSubAccPush = 2008 // 订阅业务账户的交易推送数据
  • TrdGetFunds = 2101 // 获取账户资金
  • TrdGetPositionList = 2102 // 获取账户持仓
  • TrdGetMaxTrdQtys = 2111 // 获取最大交易数量
  • TrdGetOrderList = 2201 // 获取订单列表
  • TrdPlaceOrder = 2202 // 下单
  • TrdModifyOrder = 2205 // 修改订单
  • TrdUpdateOrder = 2208 // 推送订单状态变动通知
  • TrdGetOrderFillList = 2211 // 获取成交列表
  • TrdUpdateOrderFill = 2218 // 推送成交通知
  • TrdGetHistoryOrderList = 2221 // 获取历史订单列表
  • TrdGetHistoryOrderFillList = 2222 // 获取历史成交列表
  • TrdGetMarginRatio = 2223 // 获取融资融券数据
  • TrdGetOrderFee = 2225 // 获取订单费用
  • TrdFlowSummary = 2226 // 查询账户现金流水

Documentation

Index

Constants

View Source
const (
	DateFormat = "2006-01-02"
	TimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SDK

type SDK struct {
	client.Options
	// contains filtered or unexported fields
}

SDK is Futu SDK.

func NewSDK

func NewSDK(opts ...client.Option) (*SDK, error)

NewSDK creates a new Futu SDK.

func (*SDK) Close

func (sdk *SDK) Close() error

Close closes the client.

func (*SDK) GetAccList

func (sdk *SDK) GetAccList(opts ...adapt.Option) ([]*trdcommon.TrdAcc, error)

GetAccList 2001 - gets the trading account list.

func (*SDK) GetAccListWithContext

func (sdk *SDK) GetAccListWithContext(ctx context.Context, opts ...adapt.Option) ([]*trdcommon.TrdAcc, error)

GetAccListWithContext 2001 - gets the account list with context.

func (*SDK) GetBasicQot

func (sdk *SDK) GetBasicQot(codes []string) ([]*qotcommon.BasicQot, error)

GetBasicQot 3004 - gets the basic quotes of given securities.

func (*SDK) GetBasicQotWithContext

func (sdk *SDK) GetBasicQotWithContext(ctx context.Context, codes []string) ([]*qotcommon.BasicQot, error)

GetBasicQotWithContext 3004 - gets the basic quotes of given securities with context.

func (*SDK) GetBroker

func (sdk *SDK) GetBroker(code string) (*qotgetbroker.S2C, error)

GetBroker 3014 - gets broker data.

code: security code

func (*SDK) GetBrokerWithContext

func (sdk *SDK) GetBrokerWithContext(ctx context.Context, code string) (*qotgetbroker.S2C, error)

GetBrokerWithContext 3014 - gets the broker with context.

code: security code

func (*SDK) GetCapitalDistribution

func (sdk *SDK) GetCapitalDistribution(code string) (*qotgetcapitaldistribution.S2C, error)

GetCapitalDistribution 3212 - gets the capital distribution.

code: security code

func (*SDK) GetCapitalDistributionWithContext

func (sdk *SDK) GetCapitalDistributionWithContext(ctx context.Context, code string) (*qotgetcapitaldistribution.S2C, error)

GetCapitalDistributionWithContext 3212 - gets the capital distribution with context.

code: security code

func (*SDK) GetCapitalFlow

func (sdk *SDK) GetCapitalFlow(code string, opts ...adapt.Option) (*qotgetcapitalflow.S2C, error)

GetCapitalFlow 3211 - gets the capital flow.

code: security code

func (*SDK) GetCapitalFlowWithContext

func (sdk *SDK) GetCapitalFlowWithContext(ctx context.Context, code string, opts ...adapt.Option) (*qotgetcapitalflow.S2C, error)

GetCapitalFlowWithContext 3211 - gets the capital flow with context.

code: security code

func (*SDK) GetClient

func (sdk *SDK) GetClient() *client.Client

GetClient returns the client.

func (*SDK) GetFunds

func (sdk *SDK) GetFunds(header *trdcommon.TrdHeader, opts ...adapt.Option) (*trdcommon.Funds, error)

GetFunds 2101 - gets the funds.

func (*SDK) GetFundsWithContext

func (sdk *SDK) GetFundsWithContext(ctx context.Context, header *trdcommon.TrdHeader, opts ...adapt.Option) (*trdcommon.Funds, error)

GetFundsWithContext 2101 - gets the funds with context.

func (*SDK) GetFutureInfo

func (sdk *SDK) GetFutureInfo(codes []string) ([]*qotgetfutureinfo.FutureInfo, error)

GetFutureInfo 3218 - gets the future information.

codes: security codes

func (*SDK) GetFutureInfoWithContext

func (sdk *SDK) GetFutureInfoWithContext(ctx context.Context, codes []string) ([]*qotgetfutureinfo.FutureInfo, error)

GetFutureInfoWithContext 3218 - gets the future information with context.

codes: security codes

func (*SDK) GetGlobalState

func (sdk *SDK) GetGlobalState() (*getglobalstate.S2C, error)

GetGlobalState 1002 - gets the global state.

func (*SDK) GetGlobalStateWithContext

func (sdk *SDK) GetGlobalStateWithContext(ctx context.Context) (*getglobalstate.S2C, error)

GetGlobalStateWithContext 1002 - gets the global state with context.

func (*SDK) GetHistoryOrderFillList

func (sdk *SDK) GetHistoryOrderFillList(header *trdcommon.TrdHeader, fc *trdcommon.TrdFilterConditions, opts ...adapt.Option) ([]*trdcommon.OrderFill, error)

GetHistoryOrderFillList 2222 - gets the history filled order list.

func (*SDK) GetHistoryOrderFillListWithContext

func (sdk *SDK) GetHistoryOrderFillListWithContext(ctx context.Context, header *trdcommon.TrdHeader, fc *trdcommon.TrdFilterConditions, opts ...adapt.Option) ([]*trdcommon.OrderFill, error)

GetHistoryOrderFillListWithContext 2222 - gets the history filled order list with context.

func (*SDK) GetHistoryOrderList

func (sdk *SDK) GetHistoryOrderList(header *trdcommon.TrdHeader, fc *trdcommon.TrdFilterConditions, opts ...adapt.Option) ([]*trdcommon.Order, error)

GetHistoryOrderList 2221 - gets the history order list.

func (*SDK) GetHistoryOrderListWithContext

func (sdk *SDK) GetHistoryOrderListWithContext(ctx context.Context, header *trdcommon.TrdHeader, fc *trdcommon.TrdFilterConditions, opts ...adapt.Option) ([]*trdcommon.Order, error)

GetHistoryOrderListWithContext 2221 - gets the history order list with context.

func (*SDK) GetIpoList

func (sdk *SDK) GetIpoList(market int32) ([]*qotgetipolist.IpoData, error)

GetIpoList 3217 - gets the IPO list.

market: market

func (*SDK) GetIpoListWithContext

func (sdk *SDK) GetIpoListWithContext(ctx context.Context, market int32) ([]*qotgetipolist.IpoData, error)

GetIpoListWithContext 3217 - gets the IPO list with context.

market: market

func (*SDK) GetKL

func (sdk *SDK) GetKL(code string, klType int32, opts ...adapt.Option) (*qotgetkl.S2C, error)

GetKL 3006 - gets K-line data.

code: security code

klType: K-line type

func (*SDK) GetKLWithContext

func (sdk *SDK) GetKLWithContext(ctx context.Context, code string, klType int32, opts ...adapt.Option) (*qotgetkl.S2C, error)

GetKLWithContext 3006 - gets K-line data with context.

func (*SDK) GetMarginRatio

func (sdk *SDK) GetMarginRatio(header *trdcommon.TrdHeader, codes []string) ([]*trdgetmarginratio.MarginRatioInfo, error)

GetMarginRatio 2223 - gets the margin ratio.

func (*SDK) GetMarginRatioWithContext

func (sdk *SDK) GetMarginRatioWithContext(ctx context.Context, header *trdcommon.TrdHeader, codes []string) ([]*trdgetmarginratio.MarginRatioInfo, error)

GetMarginRatioWithContext 2223 - gets the margin ratio with context.

func (*SDK) GetMarketState

func (sdk *SDK) GetMarketState(codes []string) ([]*qotgetmarketstate.MarketInfo, error)

GetMarketState 3223 - gets the market state.

codes: security codes

func (*SDK) GetMarketStateWithContext

func (sdk *SDK) GetMarketStateWithContext(ctx context.Context, codes []string) ([]*qotgetmarketstate.MarketInfo, error)

GetMarketStateWithContext 3223 - gets the market state with context.

codes: security codes

func (*SDK) GetMaxTrdQtys

func (sdk *SDK) GetMaxTrdQtys(header *trdcommon.TrdHeader, orderType int32, code string, price float64, opts ...adapt.Option) (*trdcommon.MaxTrdQtys, error)

GetOrderList 2111 - gets the maximum available trading quantities.

header: trading header

orderType: order type

code: security code, e.g. US.AAPL

price: price

func (*SDK) GetMaxTrdQtysWithContext

func (sdk *SDK) GetMaxTrdQtysWithContext(ctx context.Context, header *trdcommon.TrdHeader, orderType int32, code string, price float64, opts ...adapt.Option) (*trdcommon.MaxTrdQtys, error)

GetMaxTrdQtysWithContext 2111 - gets the maximum available trading quantities with context.

header: trading header

orderType: order type

code: security code, e.g. AAPL

price: price

func (*SDK) GetOpenOrderList

func (sdk *SDK) GetOpenOrderList(header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.Order, error)

GetOpenOrderList 2201 - gets the open order list.

func (*SDK) GetOpenOrderListWithContext

func (sdk *SDK) GetOpenOrderListWithContext(ctx context.Context, header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.Order, error)

GetOpenOrderListWithContext 2201 - gets the open order list with context.

func (*SDK) GetOptionChain

func (sdk *SDK) GetOptionChain(code string, beginTime string, endTime string, opts ...adapt.Option) ([]*qotgetoptionchain.OptionChain, error)

GetOptionChain 3209 - gets the option chain with context.

code: security code

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) GetOptionChainWithContext

func (sdk *SDK) GetOptionChainWithContext(ctx context.Context, code string, beginTime string, endTime string, opts ...adapt.Option) ([]*qotgetoptionchain.OptionChain, error)

GetOptionChainWithContext 3209 - gets the option chain with context.

code: security code

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) GetOptionExpirationDate

func (sdk *SDK) GetOptionExpirationDate(code string, opts ...adapt.Option) ([]*qotgetoptionexpirationdate.OptionExpirationDate, error)

GetOptionExpirationDate 3224 - gets the option expiration date.

code: security code

func (*SDK) GetOptionExpirationDateWithContext

func (sdk *SDK) GetOptionExpirationDateWithContext(ctx context.Context, code string, opts ...adapt.Option) ([]*qotgetoptionexpirationdate.OptionExpirationDate, error)

GetOptionExpirationDateWithContext 3224 - gets the option expiration date with context.

code: security code

func (*SDK) GetOrderBook

func (sdk *SDK) GetOrderBook(code string, opts ...adapt.Option) (*qotgetorderbook.S2C, error)

GetOrderBook 3012 - gets order book data.

code: security code

func (*SDK) GetOrderBookWithContext

func (sdk *SDK) GetOrderBookWithContext(ctx context.Context, code string, opts ...adapt.Option) (*qotgetorderbook.S2C, error)

GetOrderBookWithContext 3012 - gets the order book with context.

code: security code

func (*SDK) GetOrderFee

func (sdk *SDK) GetOrderFee(header *trdcommon.TrdHeader, orderIdExList []string) ([]*trdcommon.OrderFee, error)

GetOrderFee 2225 - gets the order fee.

func (*SDK) GetOrderFeeWithContext

func (sdk *SDK) GetOrderFeeWithContext(ctx context.Context, header *trdcommon.TrdHeader, orderIdExList []string) ([]*trdcommon.OrderFee, error)

GetOrderFeeWithContext 2225 - gets the order fee with context.

func (*SDK) GetOrderFillList

func (sdk *SDK) GetOrderFillList(header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.OrderFill, error)

GetHistoryOrderList 2211 - gets the filled order list.

func (*SDK) GetOrderFillListWithContext

func (sdk *SDK) GetOrderFillListWithContext(ctx context.Context, header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.OrderFill, error)

GetOrderFillListWithContext 2211 - gets the filled order list with context.

func (*SDK) GetOwnerPlate

func (sdk *SDK) GetOwnerPlate(codes []string) ([]*qotgetownerplate.SecurityOwnerPlate, error)

GetOwnerPlate 3207 - gets the owner plate.

codes: security codes

func (*SDK) GetOwnerPlateWithContext

func (sdk *SDK) GetOwnerPlateWithContext(ctx context.Context, codes []string) ([]*qotgetownerplate.SecurityOwnerPlate, error)

GetOwnerPlateWithContext 3207 - gets the owner plate with context.

codes: security codes

func (*SDK) GetPlateSecurity

func (sdk *SDK) GetPlateSecurity(plateCode string, opts ...adapt.Option) ([]*qotcommon.SecurityStaticInfo, error)

GetPlateSecurity 3205 - gets the plate securities.

plateCode: plate code

func (*SDK) GetPlateSecurityWithContext

func (sdk *SDK) GetPlateSecurityWithContext(ctx context.Context, plateCode string, opts ...adapt.Option) ([]*qotcommon.SecurityStaticInfo, error)

GetPlateSecurityWithContext 3205 - gets the plate securities with context.

plateCode: plate code

func (*SDK) GetPlateSet

func (sdk *SDK) GetPlateSet(market int32, plateSetType int32) ([]*qotcommon.PlateInfo, error)

GetPlateSet 3204 - gets the plate set.

market: market

plateSetType: plate set type

func (*SDK) GetPlateSetWithContext

func (sdk *SDK) GetPlateSetWithContext(ctx context.Context, market int32, plateSetType int32) ([]*qotcommon.PlateInfo, error)

GetPlateSetWithContext 3204 - gets the plate set with context.

market: market

plateSetType: plate set type

func (*SDK) GetPositionList

func (sdk *SDK) GetPositionList(header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.Position, error)

GetPositionList 2102 - gets the position list.

func (*SDK) GetPositionListWithContext

func (sdk *SDK) GetPositionListWithContext(ctx context.Context, header *trdcommon.TrdHeader, opts ...adapt.Option) ([]*trdcommon.Position, error)

GetPositionListWithContext 2102 - gets the position list with context.

func (*SDK) GetPriceReminder

func (sdk *SDK) GetPriceReminder(code string, market int32) ([]*qotgetpricereminder.PriceReminder, error)

GetPriceReminder 3221 - gets the price reminder.

code: security code

market: market, if security is set, this param is ignored

func (*SDK) GetPriceReminderWithContext

func (sdk *SDK) GetPriceReminderWithContext(ctx context.Context, code string, market int32) ([]*qotgetpricereminder.PriceReminder, error)

GetPriceReminderWithContext 3221 - gets the price reminder with context.

code: security code

market: market, if security is set, this param is ignored

func (*SDK) GetRT

func (sdk *SDK) GetRT(code string) (*qotgetrt.S2C, error)

GetRT 3008 - gets real-time data.

code: security code

func (*SDK) GetRTWithContext

func (sdk *SDK) GetRTWithContext(ctx context.Context, code string) (*qotgetrt.S2C, error)

GetRTWithContext 3008 - gets real-time data with context.

code: security code

func (*SDK) GetReference

func (sdk *SDK) GetReference(code string, refType int32) ([]*qotcommon.SecurityStaticInfo, error)

GetReference 3206 - gets the reference data.

code: security code

refType: reference type

func (*SDK) GetReferenceWithContext

func (sdk *SDK) GetReferenceWithContext(ctx context.Context, code string, refType int32) ([]*qotcommon.SecurityStaticInfo, error)

GetReferenceWithContext 3206 - gets the reference with context.

code: security code

refType: reference type

func (*SDK) GetSecuritySnapshot

func (sdk *SDK) GetSecuritySnapshot(codes []string) ([]*qotgetsecuritysnapshot.Snapshot, error)

GetSecuritySnapshot 3203 - gets the security snapshot.

codes: security codes

func (*SDK) GetSecuritySnapshotWithContext

func (sdk *SDK) GetSecuritySnapshotWithContext(ctx context.Context, codes []string) ([]*qotgetsecuritysnapshot.Snapshot, error)

GetSecuritySnapshotWithContext 3203 - gets the security snapshot with context.

codes: security codes

func (*SDK) GetStaticInfo

func (sdk *SDK) GetStaticInfo(opts ...adapt.Option) ([]*qotcommon.SecurityStaticInfo, error)

GetStaticInfo 3202 - gets the static information.

func (*SDK) GetStaticInfoWithContext

func (sdk *SDK) GetStaticInfoWithContext(ctx context.Context, opts ...adapt.Option) ([]*qotcommon.SecurityStaticInfo, error)

GetStaticInfoWithContext 3202 - gets the static information with context.

func (*SDK) GetSubInfo

func (sdk *SDK) GetSubInfo(opts ...adapt.Option) (*qotgetsubinfo.S2C, error)

GetSubInfo 3003 - gets the subscription information.

func (*SDK) GetSubInfoWithContext

func (sdk *SDK) GetSubInfoWithContext(ctx context.Context, opts ...adapt.Option) (*qotgetsubinfo.S2C, error)

GetSubInfoWithContext 3003 - gets the subscription information with context.

func (*SDK) GetTicker

func (sdk *SDK) GetTicker(code string, opts ...adapt.Option) (*qotgetticker.S2C, error)

GetTicker 3010 - gets ticker data.

code: security code

func (*SDK) GetTickerWithContext

func (sdk *SDK) GetTickerWithContext(ctx context.Context, code string, opts ...adapt.Option) (*qotgetticker.S2C, error)

GetTickerWithContext 3010 - gets the ticker data with context.

code: security code

func (*SDK) GetUserSecurity

func (sdk *SDK) GetUserSecurity(groupName string) ([]*qotcommon.SecurityStaticInfo, error)

GetUserSecurity 3213 - gets the user security.

groupName: group name

func (*SDK) GetUserSecurityGroup

func (sdk *SDK) GetUserSecurityGroup(groupType int32) ([]*qotgetusersecuritygroup.GroupData, error)

GetUserSecurityGroup 3222 - gets the user security group.

groupType: group type

func (*SDK) GetUserSecurityGroupWithContext

func (sdk *SDK) GetUserSecurityGroupWithContext(ctx context.Context, groupType int32) ([]*qotgetusersecuritygroup.GroupData, error)

GetUserSecurityGroupWithContext 3222 - gets the user security group with context.

groupType: group type

func (*SDK) GetUserSecurityWithContext

func (sdk *SDK) GetUserSecurityWithContext(ctx context.Context, groupName string) ([]*qotcommon.SecurityStaticInfo, error)

GetUserSecurityWithContext 3213 - gets the user security with context.

groupName: group name

func (*SDK) GetWarrant

func (sdk *SDK) GetWarrant(begin int32, num int32, opts ...adapt.Option) (*qotgetwarrant.S2C, error)

GetWarrant 3210 - gets the warrant, only available in Hong Kong market. Sort by score in descending order by default.

begin: begin index

num: number of warrants

func (*SDK) GetWarrantWithContext

func (sdk *SDK) GetWarrantWithContext(ctx context.Context, begin int32, num int32, opts ...adapt.Option) (*qotgetwarrant.S2C, error)

GetWarrantWithContext 3210 - gets the warrant with context, only available in Hong Kong market. Sort by score in descending order by default.

begin: begin index

num: number of warrants

func (*SDK) ModifyOrder

func (sdk *SDK) ModifyOrder(header *trdcommon.TrdHeader, orderID uint64, modifyOrderOp int32, opts ...adapt.Option) (*trdmodifyorder.S2C, error)

ModifyOrder 2205 - modifies an order with context.

header: trading header

orderID: order ID, use 0 if forAll=true

modifyOrderOp: modify order operation

func (*SDK) ModifyOrderWithContext

func (sdk *SDK) ModifyOrderWithContext(ctx context.Context, header *trdcommon.TrdHeader, orderID uint64, modifyOrderOp int32, opts ...adapt.Option) (*trdmodifyorder.S2C, error)

ModifyOrderWithContext 2205 - modifies an order with context.

header: trading header

orderID: order ID, use 0 if forAll=true

modifyOrderOp: modify order operation

func (*SDK) ModifyUserSecurity

func (sdk *SDK) ModifyUserSecurity(groupName string, codes []string, op int32) error

ModifyUserSecurity 3214 - modifies the user security.

groupName: group name

codes: security codes

op: operation, 1 for add, 2 for delete

func (*SDK) ModifyUserSecurityWithContext

func (sdk *SDK) ModifyUserSecurityWithContext(ctx context.Context, groupName string, codes []string, op int32) error

ModifyUserSecurityWithContext 3214 - modifies the user security with context.

groupName: group name

codes: security codes

op: operation

func (*SDK) PlaceOrder

func (sdk *SDK) PlaceOrder(header *trdcommon.TrdHeader, trdSide int32, orderType int32, code string, qty float64, price float64, opts ...adapt.Option) (*trdplaceorder.S2C, error)

PlaceOrder 2202 - places an order.

header: trading header

trdSide: trading side

orderType: order type

code: security code, e.g. US.AAPL

qty: quantity

price: price

func (*SDK) PlaceOrderWithContext

func (sdk *SDK) PlaceOrderWithContext(ctx context.Context, header *trdcommon.TrdHeader, trdSide int32, orderType int32, code string, qty float64, price float64, opts ...adapt.Option) (*trdplaceorder.S2C, error)

PlaceOrderWithContext 2202 - places an order with context.

header: trading header

trdSide: trading side

orderType: order type

code: security code, e.g. US.AAPL

qty: quantity

price: price

func (*SDK) RegisterHandler

func (sdk *SDK) RegisterHandler(protoID uint32, h client.Handler) *SDK

RegisterHandler registers a handler for notifications of a specified protoID.

func (*SDK) RequestHistoryKL

func (sdk *SDK) RequestHistoryKL(code string, klType int32, beginTime string, endTime string, opts ...adapt.Option) (*qotrequesthistorykl.S2C, error)

RequestHistoryKL 3103 - requests the history K-line data.

code: security code

klType: K-line type

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) RequestHistoryKLQuota

func (sdk *SDK) RequestHistoryKLQuota(opts ...adapt.Option) (*qotrequesthistoryklquota.S2C, error)

RequestHistoryKLQuota 3104 - requests the history K-line quota.

func (*SDK) RequestHistoryKLQuotaWithContext

func (sdk *SDK) RequestHistoryKLQuotaWithContext(ctx context.Context, opts ...adapt.Option) (*qotrequesthistoryklquota.S2C, error)

RequestHistoryKLQuotaWithContext 3104 - requests the history K-line quota with context.

func (*SDK) RequestHistoryKLWithContext

func (sdk *SDK) RequestHistoryKLWithContext(ctx context.Context, code string, klType int32, beginTime string, endTime string, opts ...adapt.Option) (*qotrequesthistorykl.S2C, error)

RequestHistoryKLWithContext 3103 - requests the history K-line data with context.

code: security code

klType: K-line type

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) RequestRehab

func (sdk *SDK) RequestRehab(code string) (*qotrequestrehab.S2C, error)

RequestRehab 3105 - requests the rehab data.

func (*SDK) RequestRehabWithContext

func (sdk *SDK) RequestRehabWithContext(ctx context.Context, code string) (*qotrequestrehab.S2C, error)

RequestRehabWithContext 3105 - requests the rehab data with context.

code: security code

func (*SDK) RequestTradeDate

func (sdk *SDK) RequestTradeDate(market int32, code string, beginTime string, endTime string) ([]*qotrequesttradedate.TradeDate, error)

RequestTradeDate 3219 - requests the trade date.

market: market

code: security code

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) RequestTradeDateWithContext

func (sdk *SDK) RequestTradeDateWithContext(ctx context.Context, market int32, code string, beginTime string, endTime string) ([]*qotrequesttradedate.TradeDate, error)

RequestTradeDateWithContext 3219 - requests the trade date with context.

market: market

code: security code

beginTime: begin time, format: "yyyy-MM-dd"

endTime: end time, format: "yyyy-MM-dd"

func (*SDK) SetPriceReminder

func (sdk *SDK) SetPriceReminder(code string, op int32, opts ...adapt.Option) (int64, error)

SetPriceReminder 3220 - sets the price reminder.

code: security code

op: operation, 1 for add, 2 for delete

func (*SDK) SetPriceReminderWithContext

func (sdk *SDK) SetPriceReminderWithContext(ctx context.Context, code string, op int32, opts ...adapt.Option) (int64, error)

SetPriceReminderWithContext 3220 - sets the price reminder with context.

code: security code

op: operation

func (*SDK) StockFilter

func (sdk *SDK) StockFilter(market int32, opts ...adapt.Option) (*qotstockfilter.S2C, error)

StockFilter 3215 - filters the stocks.

market: market

func (*SDK) StockFilterWithContext

func (sdk *SDK) StockFilterWithContext(ctx context.Context, market int32, opts ...adapt.Option) (*qotstockfilter.S2C, error)

StockFilterWithContext 3215 - filters the stock with context.

market: market

func (*SDK) Subscribe

func (sdk *SDK) Subscribe(codes []string, subTypes []int32, isSub bool, opts ...adapt.Option) error

Subscribe 3001 - subscribes or unsubscribes.

codes: security codes

subTypes: subscription types

isSub: true for subscribe, false for unsubscribe

func (*SDK) SubscribeAccPush

func (sdk *SDK) SubscribeAccPush(accIDList []uint64) error

SubscribeAccPush 2008 - subscribes the trading account push data.

accIDList: account ID list

func (*SDK) SubscribeAccPushWithContext

func (sdk *SDK) SubscribeAccPushWithContext(ctx context.Context, accIDList []uint64) error

SubscribeAccPushWithContext 2008 - subscribes the trading account push data.

accIDList: account ID list

func (*SDK) SubscribeWithContext

func (sdk *SDK) SubscribeWithContext(ctx context.Context, codes []string, subTypes []int32, isSub bool, opts ...adapt.Option) error

SubscribeWithContext 3001 - subscribes or unsubscribes with context.

codes: security codes

subTypes: subscription types

isSub: true for subscribe, false for unsubscribe

func (*SDK) TrdFlowSummary added in v1.3.0

func (sdk *SDK) TrdFlowSummary(header *trdcommon.TrdHeader, clearingDate string) ([]*trdflowsummary.FlowSummaryInfo, error)

TrdFlowSummary 2226 - gets the trading flow summary.

func (*SDK) TrdFlowSummaryWithContext added in v1.3.0

func (sdk *SDK) TrdFlowSummaryWithContext(ctx context.Context, header *trdcommon.TrdHeader, clearingDate string) ([]*trdflowsummary.FlowSummaryInfo, error)

TrdFlowSummaryWithContext 2226 - gets the trading flow summary with context.

func (*SDK) UnlockTrade

func (sdk *SDK) UnlockTrade(unlock bool, pwdMD5 string, securityFirm int32) error

UnlockTrade 2005 - unlocks or locks the trade.

unlock: true for unlock, false for lock

pwdMD5: MD5 of the password

securityFirm: security firm

func (*SDK) UnlockTradeWithContext

func (sdk *SDK) UnlockTradeWithContext(ctx context.Context, unlock bool, pwdMD5 string, securityFirm int32) error

UnlockTrade 2005 - unlocks or locks the trade.

unlock: true for unlock, false for lock

pwdMD5: MD5 of the password

securityFirm: security firm

Jump to

Keyboard shortcuts

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