client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 75 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClientVersion is the version of the client.
	ClientVersion int32 = 100
)

Variables

View Source
var (
	ErrChannelClosed = errors.New("channel is closed")
	ErrInterrupted   = errors.New("process is interrupted")
	ErrTimeout       = errors.New("timeout")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Options
	// contains filtered or unexported fields
}

Client is the client to connect to Futu OpenD.

func New

func New(opts ...Option) (*Client, error)

New creates a new client.

func (*Client) Close

func (client *Client) Close() error

Close closes the client.

func (*Client) GetConnID

func (client *Client) GetConnID() uint64

GetConnID returns the connection ID.

func (*Client) GetGlobalState

func (client *Client) GetGlobalState(ctx context.Context) (*getglobalstate.S2C, error)

GetGlobalState 1002 - gets the global state.

func (*Client) GetUserID

func (client *Client) GetUserID() uint64

GetUserID returns the user ID.

func (*Client) QotGetBasicQot

func (client *Client) QotGetBasicQot(ctx context.Context, c2s *qotgetbasicqot.C2S) (*qotgetbasicqot.S2C, error)

QotGetBasicQot 3004 - 获取已订阅股票的实时报价

func (*Client) QotGetBroker

func (client *Client) QotGetBroker(ctx context.Context, c2s *qotgetbroker.C2S) (*qotgetbroker.S2C, error)

QotGetBroker 3014 - 获取已订阅股票的实时经纪队列

func (*Client) QotGetCapitalDistribution

func (client *Client) QotGetCapitalDistribution(ctx context.Context, c2s *qotgetcapitaldistribution.C2S) (*qotgetcapitaldistribution.S2C, error)

QotGetCapitalDistribution 3212 - 获取资金分布

func (*Client) QotGetCapitalFlow

func (client *Client) QotGetCapitalFlow(ctx context.Context, c2s *qotgetcapitalflow.C2S) (*qotgetcapitalflow.S2C, error)

QotGetCapitalFlow 3211 - 获取资金流向

func (*Client) QotGetFutureInfo

func (client *Client) QotGetFutureInfo(ctx context.Context, c2s *qotgetfutureinfo.C2S) (*qotgetfutureinfo.S2C, error)

QotGetFutureInfo 3218 - 获取期货合约资料

func (*Client) QotGetIpoList

func (client *Client) QotGetIpoList(ctx context.Context, c2s *qotgetipolist.C2S) (*qotgetipolist.S2C, error)

QotGetIpoList 3217 - 获取指定市场的IPO信息

func (*Client) QotGetKL

func (client *Client) QotGetKL(ctx context.Context, c2s *qotgetkl.C2S) (*qotgetkl.S2C, error)

QotGetKL 3006 - 获取已订阅股票的实时K线数据

func (*Client) QotGetMarketState

func (client *Client) QotGetMarketState(ctx context.Context, c2s *qotgetmarketstate.C2S) (*qotgetmarketstate.S2C, error)

QotGetMarketState 3223 - 获取指定标的的市场状态

func (*Client) QotGetOptionChain

func (client *Client) QotGetOptionChain(ctx context.Context, c2s *qotgetoptionchain.C2S) (*qotgetoptionchain.S2C, error)

QotGetOptionChain 3209 - 获取期权链

func (*Client) QotGetOptionExpirationDate

func (client *Client) QotGetOptionExpirationDate(ctx context.Context, c2s *qotgetoptionexpirationdate.C2S) (*qotgetoptionexpirationdate.S2C, error)

QotGetOptionExpirationDate 3224 - 获取期权到期日

func (*Client) QotGetOrderBook

func (client *Client) QotGetOrderBook(ctx context.Context, c2s *qotgetorderbook.C2S) (*qotgetorderbook.S2C, error)

QotGetOrderBook 3012 - 获取已订阅股票的实时摆盘

func (*Client) QotGetOwnerPlate

func (client *Client) QotGetOwnerPlate(ctx context.Context, c2s *qotgetownerplate.C2S) (*qotgetownerplate.S2C, error)

QotGetOwnerPlate 3207 - 获取股票所属板块

func (*Client) QotGetPlateSecurity

func (client *Client) QotGetPlateSecurity(ctx context.Context, c2s *qotgetplatesecurity.C2S) (*qotgetplatesecurity.S2C, error)

QotGetPlateSecurity 3205 - 获取指定板块内的股票列表,获取股指的成分股

func (*Client) QotGetPlateSet

func (client *Client) QotGetPlateSet(ctx context.Context, c2s *qotgetplateset.C2S) (*qotgetplateset.S2C, error)

QotGetPlateSet 3204 - 获取板块列表

func (*Client) QotGetPriceReminder

func (client *Client) QotGetPriceReminder(ctx context.Context, c2s *qotgetpricereminder.C2S) (*qotgetpricereminder.S2C, error)

QotGetPriceReminder 3221 - 获取对指定股票/指定市场设置的到价提醒列表

func (*Client) QotGetRT

func (client *Client) QotGetRT(ctx context.Context, c2s *qotgetrt.C2S) (*qotgetrt.S2C, error)

QotGetRT 3008 - 获取已订阅股票的实时分时数据

func (*Client) QotGetReference

func (client *Client) QotGetReference(ctx context.Context, c2s *qotgetreference.C2S) (*qotgetreference.S2C, error)

QotGetReference 3206 - 获取证券的关联数据,如:获取正股相关窝轮、获取期货相关合约

func (*Client) QotGetSecuritySnapshot

func (client *Client) QotGetSecuritySnapshot(ctx context.Context, c2s *qotgetsecuritysnapshot.C2S) (*qotgetsecuritysnapshot.S2C, error)

QotGetSecuritySnapshot 3203 - 获取股票快照

func (*Client) QotGetStaticInfo

func (client *Client) QotGetStaticInfo(ctx context.Context, c2s *qotgetstaticinfo.C2S) (*qotgetstaticinfo.S2C, error)

QotGetStaticInfo 3202 - 获取股票静态信息

func (*Client) QotGetSubInfo

func (client *Client) QotGetSubInfo(ctx context.Context, c2s *qotgetsubinfo.C2S) (*qotgetsubinfo.S2C, error)

QotGetSubInfo 3003 - 获取订阅状态

func (*Client) QotGetTicker

func (client *Client) QotGetTicker(ctx context.Context, c2s *qotgetticker.C2S) (*qotgetticker.S2C, error)

QotGetTicker 3010 - 获取已订阅股票的实时逐笔

func (*Client) QotGetUserSecurity

func (client *Client) QotGetUserSecurity(ctx context.Context, c2s *qotgetusersecurity.C2S) (*qotgetusersecurity.S2C, error)

QotGetUserSecurity 3213 - 获取指定分组的自选股列表

func (*Client) QotGetUserSecurityGroup

func (client *Client) QotGetUserSecurityGroup(ctx context.Context, c2s *qotgetusersecuritygroup.C2S) (*qotgetusersecuritygroup.S2C, error)

QotGetUserSecurityGroup 3222 - 获取自选股分组列表

func (*Client) QotGetWarrant

func (client *Client) QotGetWarrant(ctx context.Context, c2s *qotgetwarrant.C2S) (*qotgetwarrant.S2C, error)

QotGetWarrant 3210 - 筛选窝轮(仅用于香港市场)

func (*Client) QotModifyUserSecurity

func (client *Client) QotModifyUserSecurity(ctx context.Context, c2s *qotmodifyusersecurity.C2S) error

QotModifyUserSecurity 3214 - 修改自选股分组下的股票,该接口的S2C返回的是空

func (*Client) QotRequestHistoryKL

func (client *Client) QotRequestHistoryKL(ctx context.Context, c2s *qotrequesthistorykl.C2S) (*qotrequesthistorykl.S2C, error)

QotRequestHistoryKL 3103 - 在线获取单只股票一段历史K线

func (*Client) QotRequestHistoryKLQuota

func (client *Client) QotRequestHistoryKLQuota(ctx context.Context, c2s *qotrequesthistoryklquota.C2S) (*qotrequesthistoryklquota.S2C, error)

QotRequestHistoryKLQuota 3104 - 获取历史K线额度使用明细

func (*Client) QotRequestRehab

func (client *Client) QotRequestRehab(ctx context.Context, c2s *qotrequestrehab.C2S) (*qotrequestrehab.S2C, error)

QotRequestRehab 3105 - 获取股票的复权因子

func (*Client) QotRequestTradeDate

func (client *Client) QotRequestTradeDate(ctx context.Context, c2s *qotrequesttradedate.C2S) (*qotrequesttradedate.S2C, error)

QotRequestTradeDate 3219 - 请求指定市场/指定标的的交易日历

func (*Client) QotSetPriceReminder

func (client *Client) QotSetPriceReminder(ctx context.Context, c2s *qotsetpricereminder.C2S) (*qotsetpricereminder.S2C, error)

QotSetPriceReminder 3220 - 新增、删除、修改、启用、禁用指定股票的到价提醒

func (*Client) QotStockFilter

func (client *Client) QotStockFilter(ctx context.Context, c2s *qotstockfilter.C2S) (*qotstockfilter.S2C, error)

QotStockFilter 3215 - 获取条件选股

func (*Client) QotSub

func (client *Client) QotSub(ctx context.Context, c2s *qotsub.C2S) error

QotSub 3001 - 订阅或者反订阅,该接口的S2C返回的是空

func (*Client) RegisterHandler

func (client *Client) RegisterHandler(protoID uint32, h Handler) *Client

RegisterHandler registers a handler for notifications of a specified protoID.

func (*Client) Request

func (client *Client) Request(protoID uint32, req proto.Message, resCh *infra.ProtobufChan) error

Request sends a request to the server.

func (*Client) TrdGetAccList

func (client *Client) TrdGetAccList(ctx context.Context, c2s *trdgetacclist.C2S) (*trdgetacclist.S2C, error)

TrdGetAccList 2001 - 获取交易业务账户列表

func (*Client) TrdGetFunds

func (client *Client) TrdGetFunds(ctx context.Context, c2s *trdgetfunds.C2S) (*trdgetfunds.S2C, error)

TrdGetFunds 2101 - 查询账户资金

func (*Client) TrdGetHistoryOrderFillList

func (client *Client) TrdGetHistoryOrderFillList(ctx context.Context, c2s *trdgethistoryorderfilllist.C2S) (*trdgethistoryorderfilllist.S2C, error)

TrdGetHistoryOrderFillList 2222 - 获取历史成交列表

func (*Client) TrdGetHistoryOrderList

func (client *Client) TrdGetHistoryOrderList(ctx context.Context, c2s *trdgethistoryorderlist.C2S) (*trdgethistoryorderlist.S2C, error)

TrdGetHistoryOrderList 2221 - 获取历史订单列表

func (*Client) TrdGetMarginRatio

func (client *Client) TrdGetMarginRatio(ctx context.Context, c2s *trdgetmarginratio.C2S) (*trdgetmarginratio.S2C, error)

TrdGetMarginRatio 2223 - 获取融资融券数据

func (*Client) TrdGetMaxTrdQtys

func (client *Client) TrdGetMaxTrdQtys(ctx context.Context, c2s *trdgetmaxtrdqtys.C2S) (*trdgetmaxtrdqtys.S2C, error)

TrdGetMaxTrdQtys 2111 - 查询指定证券的最大可买可卖数量

func (*Client) TrdGetOrderFee

func (client *Client) TrdGetOrderFee(ctx context.Context, c2s *trdgetorderfee.C2S) (*trdgetorderfee.S2C, error)

TrdGetOrderFee 2225 - 获取交易费用

func (*Client) TrdGetOrderFillList

func (client *Client) TrdGetOrderFillList(ctx context.Context, c2s *trdgetorderfilllist.C2S) (*trdgetorderfilllist.S2C, error)

TrdGetOrderFillList 2211 - 获取成交列表

func (*Client) TrdGetOrderList

func (client *Client) TrdGetOrderList(ctx context.Context, c2s *trdgetorderlist.C2S) (*trdgetorderlist.S2C, error)

TrdGetOrderList 2201 - 查询未完成订单

func (*Client) TrdGetPositionList

func (client *Client) TrdGetPositionList(ctx context.Context, c2s *trdgetpositionlist.C2S) (*trdgetpositionlist.S2C, error)

TrdGetPositionList 2102 - 查询持仓

func (*Client) TrdModifyOrder

func (client *Client) TrdModifyOrder(ctx context.Context, c2s *trdmodifyorder.C2S) (*trdmodifyorder.S2C, error)

TrdModifyOrder 2205 - 修改订单

func (*Client) TrdPlaceOrder

func (client *Client) TrdPlaceOrder(ctx context.Context, c2s *trdplaceorder.C2S) (*trdplaceorder.S2C, error)

TrdPlaceOrder 2202 - 下单

func (*Client) TrdSubAccPush

func (client *Client) TrdSubAccPush(ctx context.Context, c2s *trdsubaccpush.C2S) error

TrdSubAccPush 2008 - 订阅业务账户的交易推送数据,该接口的S2C返回的是空

func (*Client) TrdUnlockTrade

func (client *Client) TrdUnlockTrade(ctx context.Context, c2s *trdunlocktrade.C2S) error

TrdUnlockTrade 2005 - 解锁或锁定交易,该接口的S2C返回的是空。 真实账户调用下单或改单撤单接口,需要先解锁交易;模拟账户无需解锁。

type Handler

type Handler func(s2c proto.Message) error

Handler is the definition of a handler function.

type Option

type Option func(*Options)

Option is for setting options.

func WithAddr

func WithAddr(addr string) Option

WithAddr sets futu OpenD address.

func WithID

func WithID(id string) Option

WithID sets client id.

func WithPrivateKey

func WithPrivateKey(privateKey []byte) Option

WithPrivateKey sets private key.

func WithPublicKey

func WithPublicKey(publicKey []byte) Option

WithPublicKey sets public key.

func WithRecvNotify

func WithRecvNotify(recvNotify bool) Option

WithRecvNotify sets whether to receive notifications.

func WithResChanSize

func WithResChanSize(size int) Option

WithResChanSize sets response channel size.

type Options

type Options struct {
	Addr        string
	ID          string
	PrivateKey  []byte
	PublicKey   []byte
	RecvNotify  bool
	ResChanSize int
}

Options are futu client options.

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions creates options with defaults.

Jump to

Keyboard shortcuts

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