hub

package
v0.0.0-...-a648b3d Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter ctp socket adapter

func NewAdapter

func NewAdapter(host string, timeout time.Duration, h func(*Packet)) (*Adapter, error)

NewAdapter create new adapter

func (*Adapter) Close

func (adapter *Adapter) Close()

Close close the connection

func (*Adapter) Post

func (adapter *Adapter) Post(msgType int32, req proto.Message, requestID int32)

Post post request

type DemoEnv

type DemoEnv struct {
	// contains filtered or unexported fields
}

DemoEnv DemoEnv

func NewDemoEnv

func NewDemoEnv(options *DemoEnvOptions) *DemoEnv

NewDemoEnv create demo env

func (*DemoEnv) CancelDemoOrder

func (e *DemoEnv) CancelDemoOrder(req *hubpb.ReqCancelOrder) error

CancelDemoOrder cancel demo order

func (*DemoEnv) CheckDemoTrade

func (e *DemoEnv) CheckDemoTrade(mds *pb.MarketDataSnapshot)

CheckDemoTrade 检查成交

func (*DemoEnv) CurrentDemoOrderList

func (e *DemoEnv) CurrentDemoOrderList() []hubpb.DemoOrder

CurrentDemoOrderList do list

func (*DemoEnv) InsertDemoOrder

func (e *DemoEnv) InsertDemoOrder(req *hubpb.ReqInsertOrder) error

InsertDemoOrder 发送模拟

func (*DemoEnv) PushTick

func (e *DemoEnv) PushTick(rtn *pb.MarketDataSnapshot)

PushTick 收行情算成交

type DemoEnvOptions

type DemoEnvOptions struct {
	GetUID        func() string
	OnDemoOrder   func(*hubpb.DemoOrder)
	OnDemoTrade   func(*pb.Trade)
	GetInstrument func(string) *pb.Instrument
}

DemoEnvOptions oiptions

type Packet

type Packet struct {
	MsgType    int32
	RequestID  int32
	IsLast     int32
	BodyLength int32
	BodyList   [][]byte
}

Packet pkt

func (*Packet) Get1

func (pkt *Packet) Get1(p1 proto.Message) error

Get1 get 1 param

func (*Packet) Get2

func (pkt *Packet) Get2(p1 proto.Message, p2 proto.Message) error

Get2 get 2 param

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Subscriber subscribe tick 订阅,退订,和断线重连(重订)

func NewSubscriber

func NewSubscriber(host, account, password string, fronts []string, timeout time.Duration, onTick func(*ctp.CThostFtdcDepthMarketDataField)) (*Subscriber, error)

NewSubscriber create subscriber

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(exchange, symbol string) error

Subscribe quote

func (*Subscriber) UnSubscribe

func (s *Subscriber) UnSubscribe(exchange, symbol string) error

UnSubscribe un sub

type SyncAdapter

type SyncAdapter struct {
	Data interface{}
	// contains filtered or unexported fields
}

SyncAdapter sync

func NewSyncAdapter

func NewSyncAdapter(host string, timeout time.Duration, fronts []string, h func(*Packet)) (*SyncAdapter, error)

NewSyncAdapter create new sync adapter

func (*SyncAdapter) Send

func (sa *SyncAdapter) Send(msgType int32, req proto.Message, requestID int32, timeout time.Duration) ([]*Packet, error)

Send send msg

type SyncPool

type SyncPool struct {
	// contains filtered or unexported fields
}

SyncPool as pool

func NewSyncPool

func NewSyncPool(options *SyncPoolOptions) *SyncPool

NewSyncPool create new pool

func (*SyncPool) GetAdapter

func (p *SyncPool) GetAdapter(brokerID, account string) (*SyncAdapter, error)

GetAdapter get adapter from pool

type SyncPoolOptions

type SyncPoolOptions struct {
	NewSyncAdapter func(brokerID, account string) (*SyncAdapter, error)
}

SyncPoolOptions options

Jump to

Keyboard shortcuts

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