websocket

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package "websocket" provides primitives to interact with the AsyncAPI specification.

Code generated by github.com/lerenn/asyncapi-codegen version v0.45.3 DO NOT EDIT.

Index

Constants

View Source
const (
	// AuthChannelPath is the constant representing the 'AuthChannel' channel path.
	AuthChannelPath = "auth"
	// ChildOrderEventsChannelPath is the constant representing the 'ChildOrderEventsChannel' channel path.
	ChildOrderEventsChannelPath = "child_order_events"
	// LightningBoardChannelPath is the constant representing the 'LightningBoardChannel' channel path.
	LightningBoardChannelPath = "lightning_board_{product_code}"
	// LightningBoardSnapshotChannelPath is the constant representing the 'LightningBoardSnapshotChannel' channel path.
	LightningBoardSnapshotChannelPath = "lightning_board_snapshot_{product_code}"
	// LightningExecutionsChannelPath is the constant representing the 'LightningExecutionsChannel' channel path.
	LightningExecutionsChannelPath = "lightning_executions_{product_code}"
	// LightningTickerChannelPath is the constant representing the 'LightningTickerChannel' channel path.
	LightningTickerChannelPath = "lightning_ticker_{product_code}"
	// ParentOrderEventsChannelPath is the constant representing the 'ParentOrderEventsChannel' channel path.
	ParentOrderEventsChannelPath = "parent_order_events"
	// SubscribeChannelPath is the constant representing the 'SubscribeChannel' channel path.
	SubscribeChannelPath = "subscribe"
	// UnsubscribeChannelPath is the constant representing the 'UnsubscribeChannel' channel path.
	UnsubscribeChannelPath = "unsubscribe"
)
View Source
const AsyncAPIVersion = "1.0.0"

AsyncAPIVersion is the version of the used AsyncAPI document

Variables

ChannelsPaths is an array of all channels paths

Functions

This section is empty.

Types

type AppController

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

AppController is the structure that provides sending capabilities to the developer and and connect the broker with the App

func NewAppController

func NewAppController(bc extensions.BrokerController, options ...ControllerOption) (*AppController, error)

NewAppController links the App to the broker

func (*AppController) Close

func (c *AppController) Close(ctx context.Context)

Close will clean up any existing resources on the controller

func (*AppController) SendAsSendAuthOperation

func (c *AppController) SendAsSendAuthOperation(
	ctx context.Context,
	msg AuthMessageFromAuthChannel,
) error

SendAsSendAuthOperation will send a AuthMessageFromAuthChannel message on Auth channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SendAsSendSubscribeOperation

func (c *AppController) SendAsSendSubscribeOperation(
	ctx context.Context,
	msg SubscribeMessageFromSubscribeChannel,
) error

SendAsSendSubscribeOperation will send a SubscribeMessageFromSubscribeChannel message on Subscribe channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SendAsSendUnsubscribeOperation

func (c *AppController) SendAsSendUnsubscribeOperation(
	ctx context.Context,
	msg UnsubscribeMessageFromUnsubscribeChannel,
) error

SendAsSendUnsubscribeOperation will send a UnsubscribeMessageFromUnsubscribeChannel message on Unsubscribe channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToAllChannels

func (c *AppController) SubscribeToAllChannels(ctx context.Context, as AppSubscriber) error

SubscribeToAllChannels will receive messages from channels where channel has no parameter on which the app is expecting messages. For channels with parameters, they should be subscribed independently.

func (*AppController) SubscribeToReceiveChildOrderEventsOperation

func (c *AppController) SubscribeToReceiveChildOrderEventsOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg EventsMessageFromChildOrderEventsChannel) error,
) error

SubscribeToReceiveChildOrderEventsOperation will receive EventsMessageFromChildOrderEventsChannel messages from ChildOrderEvents channel.

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToReceiveExecutionsOperation

func (c *AppController) SubscribeToReceiveExecutionsOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg ExecutionsMessageFromLightningExecutionsChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToReceiveOrderBookDiffOperation

func (c *AppController) SubscribeToReceiveOrderBookDiffOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg DiffMessageFromLightningBoardChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToReceiveOrderBookOperation

func (c *AppController) SubscribeToReceiveOrderBookOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg SnapshotMessageFromLightningBoardSnapshotChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToReceiveParentOrderEventsOperation

func (c *AppController) SubscribeToReceiveParentOrderEventsOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg EventsMessageFromParentOrderEventsChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) SubscribeToReceiveTickerOperation

func (c *AppController) SubscribeToReceiveTickerOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg TickerMessageFromLightningTickerChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*AppController) UnsubscribeFromAllChannels

func (c *AppController) UnsubscribeFromAllChannels(ctx context.Context)

UnsubscribeFromAllChannels will stop the subscription of all remaining subscribed channels

func (*AppController) UnsubscribeFromReceiveChildOrderEventsOperation

func (c *AppController) UnsubscribeFromReceiveChildOrderEventsOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveChildOrderEventsOperation will stop the reception of EventsMessageFromChildOrderEventsChannel messages from ChildOrderEvents channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFromReceiveExecutionsOperation

func (c *AppController) UnsubscribeFromReceiveExecutionsOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveExecutionsOperation will stop the reception of ExecutionsMessageFromLightningExecutionsChannel messages from LightningExecutions channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFromReceiveOrderBookDiffOperation

func (c *AppController) UnsubscribeFromReceiveOrderBookDiffOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveOrderBookDiffOperation will stop the reception of DiffMessageFromLightningBoardChannel messages from LightningBoard channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFromReceiveOrderBookOperation

func (c *AppController) UnsubscribeFromReceiveOrderBookOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveOrderBookOperation will stop the reception of SnapshotMessageFromLightningBoardSnapshotChannel messages from LightningBoardSnapshot channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFromReceiveParentOrderEventsOperation

func (c *AppController) UnsubscribeFromReceiveParentOrderEventsOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveParentOrderEventsOperation will stop the reception of EventsMessageFromParentOrderEventsChannel messages from ParentOrderEvents channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*AppController) UnsubscribeFromReceiveTickerOperation

func (c *AppController) UnsubscribeFromReceiveTickerOperation(
	ctx context.Context,
)

UnsubscribeFromReceiveTickerOperation will stop the reception of TickerMessageFromLightningTickerChannel messages from LightningTicker channel. A timeout can be set in context to avoid blocking operation, if needed.

type AppSubscriber

type AppSubscriber interface {
	// ReceiveChildOrderEventsOperationReceived receive all EventsMessageFromChildOrderEventsChannel messages from ChildOrderEvents channel.
	ReceiveChildOrderEventsOperationReceived(ctx context.Context, msg EventsMessageFromChildOrderEventsChannel) error

	// ReceiveExecutionsOperationReceived receive all ExecutionsMessageFromLightningExecutionsChannel messages from LightningExecutions channel.
	ReceiveExecutionsOperationReceived(ctx context.Context, msg ExecutionsMessageFromLightningExecutionsChannel) error

	// ReceiveOrderBookOperationReceived receive all SnapshotMessageFromLightningBoardSnapshotChannel messages from LightningBoardSnapshot channel.
	ReceiveOrderBookOperationReceived(ctx context.Context, msg SnapshotMessageFromLightningBoardSnapshotChannel) error

	// ReceiveOrderBookDiffOperationReceived receive all DiffMessageFromLightningBoardChannel messages from LightningBoard channel.
	ReceiveOrderBookDiffOperationReceived(ctx context.Context, msg DiffMessageFromLightningBoardChannel) error

	// ReceiveParentOrderEventsOperationReceived receive all EventsMessageFromParentOrderEventsChannel messages from ParentOrderEvents channel.
	ReceiveParentOrderEventsOperationReceived(ctx context.Context, msg EventsMessageFromParentOrderEventsChannel) error

	// ReceiveTickerOperationReceived receive all TickerMessageFromLightningTickerChannel messages from LightningTicker channel.
	ReceiveTickerOperationReceived(ctx context.Context, msg TickerMessageFromLightningTickerChannel) error
}

AppSubscriber contains all handlers that are listening messages for App

type AuthMessageFromAuthChannel

type AuthMessageFromAuthChannel struct {
	// Payload will be inserted in the message payload
	Payload AuthMessageFromAuthChannelPayload
}

AuthMessageFromAuthChannel is the message expected for 'AuthMessageFromAuthChannel' channel.

func NewAuthMessageFromAuthChannel

func NewAuthMessageFromAuthChannel() AuthMessageFromAuthChannel

type AuthMessageFromAuthChannelPayload

type AuthMessageFromAuthChannelPayload struct {
	// Description: API Key
	ApiKey string `json:"api_key"`

	// Description: Random string (16-255 characters)
	Nonce string `json:"nonce"`

	// Description: Hex string signed with HMAC SHA256 using API Secret
	Signature string `json:"signature"`

	// Description: Current Unix Timestamp (10 or 13 digits)
	Timestamp int64 `json:"timestamp"`
}

AuthMessageFromAuthChannelPayload is a schema from the AsyncAPI specification required in messages

type BoardData

type BoardData struct {
	MidPrice float64      `json:"mid_price"`
	Bids     []PriceLevel `json:"bids"`
	Asks     []PriceLevel `json:"asks"`
}

type BoardMessage

type BoardMessage struct {
	ProductCode string    `json:"product_code"`
	Data        BoardData `json:"data"`
}

type BoardSnapshotMessage

type BoardSnapshotMessage struct {
	ProductCode string    `json:"product_code"`
	Data        BoardData `json:"data"`
}

type ChildOrderEventSchema

type ChildOrderEventSchema struct {
	// Description: Child Order Acceptance ID
	ChildOrderAcceptanceId string `json:"child_order_acceptance_id"`

	// Description: Child Order ID
	ChildOrderId string `json:"child_order_id"`

	// Description: Child Order Type (Example: LIMIT, MARKET)
	ChildOrderType *string `json:"child_order_type,omitempty"`

	// Description: Commission
	Commission *float64 `json:"commission,omitempty"`

	// Description: Event Occurrence Time
	EventDate time.Time `json:"event_date"`

	// Description: Event Type (`ORDER`, `ORDER_FAILED`, `CANCEL`, `CANCEL_FAILED`, `EXECUTION`, `EXPIRE`)
	EventType string `json:"event_type"`

	// Description: Execution ID (EXECUTION Event)
	ExecId *int64 `json:"exec_id,omitempty"`

	// Description: Order Validity Period
	ExpireDate *time.Time `json:"expire_date,omitempty"`

	// Description: Unexecuted Quantity
	OutstandingSize *float64 `json:"outstanding_size,omitempty"`

	// Description: Price
	Price *float64 `json:"price,omitempty"`

	// Description: Product Code
	ProductCode string `json:"product_code"`

	// Description: Reason for Order Failure
	Reason *string `json:"reason,omitempty"`

	// Description: SFD Deduction Amount
	Sfd *float64 `json:"sfd,omitempty"`

	// Description: Buy/Sell Type (BUY/SELL)
	Side *string `json:"side,omitempty"`

	// Description: Quantity
	Size *float64 `json:"size,omitempty"`
}

ChildOrderEventSchema is a schema from the AsyncAPI specification required in messages Description: Child Order Event Information

type Client

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

Client represents a bitFlyer WebSocket API client

func NewClient

func NewClient(ctx context.Context, wsURL string) (*Client, error)

NewClient creates a new WebSocket client

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, apiKey, apiSecret string) error

Auth authenticates for using private API

func (*Client) Close

func (c *Client) Close(ctx context.Context)

Close closes the WebSocket connection

func (*Client) OnBoard

func (c *Client) OnBoard(handler func(BoardMessage))

OnBoard sets a callback to receive order book information

func (*Client) OnBoardSnapshot

func (c *Client) OnBoardSnapshot(handler func(BoardSnapshotMessage))

OnBoardSnapshot sets a callback to receive order book snapshots

func (*Client) OnExecutions

func (c *Client) OnExecutions(handler func(ExecutionsMessage))

OnExecutions sets a callback to receive execution information

func (*Client) OnOrderEvents

func (c *Client) OnOrderEvents(handler func(OrderEventMessage))

OnOrderEvents sets a callback to receive order events

func (*Client) OnTicker

func (c *Client) OnTicker(handler func(TickerMessage))

OnTicker sets a callback to receive ticker information

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, channel string) error

Subscribe subscribes to the specified channel

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ctx context.Context, channel string) error

Unsubscribe cancels subscription to the specified channel

type ControllerOption

type ControllerOption func(controller *controller)

ControllerOption is the type of the options that can be passed when creating a new Controller

func WithErrorHandler

func WithErrorHandler(handler extensions.ErrorHandler) ControllerOption

WithErrorHandler attaches a errorhandler to handle errors from subscriber functions

func WithLogger

func WithLogger(logger extensions.Logger) ControllerOption

WithLogger attaches a logger to the controller

func WithMiddlewares

func WithMiddlewares(middlewares ...extensions.Middleware) ControllerOption

WithMiddlewares attaches middlewares that will be executed when sending or receiving messages

type DiffMessageFromLightningBoardChannel

type DiffMessageFromLightningBoardChannel struct {
	// Payload will be inserted in the message payload
	Payload DiffMessageFromLightningBoardChannelPayload
}

DiffMessageFromLightningBoardChannel is the message expected for 'DiffMessageFromLightningBoardChannel' channel.

func NewDiffMessageFromLightningBoardChannel

func NewDiffMessageFromLightningBoardChannel() DiffMessageFromLightningBoardChannel

type DiffMessageFromLightningBoardChannelPayload

type DiffMessageFromLightningBoardChannelPayload struct {
	// Description: Order information (Snapshot/Diff of Order Book)
	Data OrderBookSchema `json:"data"`

	// Description: Market product code (example: `BTC_JPY`, `FX_BTC_JPY`, `ETH_BTC`)
	ProductCode string `json:"product_code"`
}

DiffMessageFromLightningBoardChannelPayload is a schema from the AsyncAPI specification required in messages

type Error

type Error struct {
	Channel string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

type EventsMessageFromChildOrderEventsChannel

type EventsMessageFromChildOrderEventsChannel struct {
	// Payload will be inserted in the message payload
	Payload []ChildOrderEventSchema
}

EventsMessageFromChildOrderEventsChannel is the message expected for 'EventsMessageFromChildOrderEventsChannel' channel.

func NewEventsMessageFromChildOrderEventsChannel

func NewEventsMessageFromChildOrderEventsChannel() EventsMessageFromChildOrderEventsChannel

type EventsMessageFromChildOrderEventsChannelPayload

type EventsMessageFromChildOrderEventsChannelPayload []ChildOrderEventSchema

EventsMessageFromChildOrderEventsChannelPayload is a schema from the AsyncAPI specification required in messages

type EventsMessageFromParentOrderEventsChannel

type EventsMessageFromParentOrderEventsChannel struct {
	// Payload will be inserted in the message payload
	Payload []ParentOrderEventSchema
}

EventsMessageFromParentOrderEventsChannel is the message expected for 'EventsMessageFromParentOrderEventsChannel' channel.

func NewEventsMessageFromParentOrderEventsChannel

func NewEventsMessageFromParentOrderEventsChannel() EventsMessageFromParentOrderEventsChannel

type EventsMessageFromParentOrderEventsChannelPayload

type EventsMessageFromParentOrderEventsChannelPayload []ParentOrderEventSchema

EventsMessageFromParentOrderEventsChannelPayload is a schema from the AsyncAPI specification required in messages

type Execution

type Execution struct {
	ID                         int64   `json:"id"`
	Side                       string  `json:"side"`
	Price                      float64 `json:"price"`
	Size                       float64 `json:"size"`
	ExecDate                   string  `json:"exec_date"`
	BuyChildOrderAcceptanceID  string  `json:"buy_child_order_acceptance_id"`
	SellChildOrderAcceptanceID string  `json:"sell_child_order_acceptance_id"`
}

type ExecutionSchema

type ExecutionSchema struct {
	// Description: Buy Order Acceptance ID
	BuyChildOrderAcceptanceId string `json:"buy_child_order_acceptance_id"`

	// Description: Execution Time
	ExecDate time.Time `json:"exec_date"`

	// Description: Execution ID
	Id int64 `json:"id"`

	// Description: Execution Price
	Price float64 `json:"price"`

	// Description: Sell Order Acceptance ID
	SellChildOrderAcceptanceId string `json:"sell_child_order_acceptance_id"`

	// Description: Buy/Sell Direction (`BUY`/`SELL`, Empty String for Matching)
	Side string `json:"side"`

	// Description: Execution Quantity
	Size float64 `json:"size"`
}

ExecutionSchema is a schema from the AsyncAPI specification required in messages Description: Execution Details

type ExecutionsMessage

type ExecutionsMessage struct {
	ProductCode string      `json:"product_code"`
	Executions  []Execution `json:"data"`
}

type ExecutionsMessageFromLightningExecutionsChannel

type ExecutionsMessageFromLightningExecutionsChannel struct {
	// Payload will be inserted in the message payload
	Payload ExecutionsMessageFromLightningExecutionsChannelPayload
}

ExecutionsMessageFromLightningExecutionsChannel is the message expected for 'ExecutionsMessageFromLightningExecutionsChannel' channel.

func NewExecutionsMessageFromLightningExecutionsChannel

func NewExecutionsMessageFromLightningExecutionsChannel() ExecutionsMessageFromLightningExecutionsChannel

type ExecutionsMessageFromLightningExecutionsChannelPayload

type ExecutionsMessageFromLightningExecutionsChannelPayload struct {
	Data []ExecutionSchema `json:"data" validate:"required"`

	// Description: Market product code (example: `BTC_JPY`, `FX_BTC_JPY`, `ETH_BTC`)
	ProductCode string `json:"product_code"`
}

ExecutionsMessageFromLightningExecutionsChannelPayload is a schema from the AsyncAPI specification required in messages

type MessageHandler

type MessageHandler func(channel string, data json.RawMessage)

MessageHandler is a function type that processes messages from a specific channel

type MessageWithCorrelationID

type MessageWithCorrelationID interface {
	CorrelationID() string
	SetCorrelationID(id string)
}

type OrderBookSchema

type OrderBookSchema struct {
	// Description: Sell order list
	Asks []QuoteEntrySchema `json:"asks" validate:"required"`

	// Description: Buy order list
	Bids []QuoteEntrySchema `json:"bids" validate:"required"`

	// Description: Mid Price (Average of Best Bid and Best Ask)
	MidPrice float64 `json:"mid_price"`
}

OrderBookSchema is a schema from the AsyncAPI specification required in messages Description: Order information (Snapshot/Diff of Order Book)

type OrderEventMessage

type OrderEventMessage struct {
	ProductCode            string  `json:"product_code"`
	ChildOrderID           string  `json:"child_order_id"`
	ChildOrderAcceptanceID string  `json:"child_order_acceptance_id"`
	EventType              string  `json:"event_type"`
	EventDate              string  `json:"event_date"`
	Side                   string  `json:"side"`
	Price                  float64 `json:"price"`
	Size                   float64 `json:"size"`
	ExpireDate             string  `json:"expire_date"`
	Reason                 string  `json:"reason"`
	ExecID                 int64   `json:"exec_id"`
	Commission             float64 `json:"commission"`
}

type ParentOrderEventSchema

type ParentOrderEventSchema struct {
	// Description: Child Order Acceptance ID
	ChildOrderAcceptanceId *string `json:"child_order_acceptance_id,omitempty"`

	// Description: Child Order Type (Example: LIMIT, MARKET)
	ChildOrderType *string `json:"child_order_type,omitempty"`

	// Description: Event Occurrence Time
	EventDate time.Time `json:"event_date"`

	// Description: Event Type (`ORDER`, `ORDER_FAILED`, `CANCEL`, `TRIGGER`, `COMPLETE`, `EXPIRE`)
	EventType string `json:"event_type"`

	// Description: Order Validity Period
	ExpireDate *time.Time `json:"expire_date,omitempty"`

	// Description: Child Order Number
	ParameterIndex *int64 `json:"parameter_index,omitempty"`

	// Description: Parent Order Acceptance ID
	ParentOrderAcceptanceId string `json:"parent_order_acceptance_id"`

	// Description: Parent Order ID
	ParentOrderId string `json:"parent_order_id"`

	// Description: Parent Order Type (Example: IFD, OCO, IFDOCO, STOP)
	ParentOrderType *string `json:"parent_order_type,omitempty"`

	// Description: Price
	Price *float64 `json:"price,omitempty"`

	// Description: Product Code
	ProductCode string `json:"product_code"`

	// Description: Reason for Parent Order Failure
	Reason *string `json:"reason,omitempty"`

	// Description: Buy/Sell Type (BUY/SELL)
	Side *string `json:"side,omitempty"`

	// Description: Quantity
	Size *float64 `json:"size,omitempty"`
}

ParentOrderEventSchema is a schema from the AsyncAPI specification required in messages Description: Parent Order Event Information

type PriceLevel

type PriceLevel struct {
	Price float64 `json:"price"`
	Size  float64 `json:"size"`
}

type QuoteEntrySchema

type QuoteEntrySchema struct {
	// Description: Price
	Price float64 `json:"price"`

	// Description: Quantity
	Size float64 `json:"size"`
}

QuoteEntrySchema is a schema from the AsyncAPI specification required in messages Description: Order information on the board (Price and Quantity)

type SnapshotMessageFromLightningBoardSnapshotChannel

type SnapshotMessageFromLightningBoardSnapshotChannel struct {
	// Payload will be inserted in the message payload
	Payload SnapshotMessageFromLightningBoardSnapshotChannelPayload
}

SnapshotMessageFromLightningBoardSnapshotChannel is the message expected for 'SnapshotMessageFromLightningBoardSnapshotChannel' channel.

func NewSnapshotMessageFromLightningBoardSnapshotChannel

func NewSnapshotMessageFromLightningBoardSnapshotChannel() SnapshotMessageFromLightningBoardSnapshotChannel

type SnapshotMessageFromLightningBoardSnapshotChannelPayload

type SnapshotMessageFromLightningBoardSnapshotChannelPayload struct {
	// Description: Order information (Snapshot/Diff of Order Book)
	Data OrderBookSchema `json:"data"`

	// Description: Market product code (example: `BTC_JPY`, `FX_BTC_JPY`, `ETH_BTC`)
	ProductCode string `json:"product_code"`
}

SnapshotMessageFromLightningBoardSnapshotChannelPayload is a schema from the AsyncAPI specification required in messages

type SubscribeMessageFromSubscribeChannel

type SubscribeMessageFromSubscribeChannel struct {
	// Payload will be inserted in the message payload
	Payload SubscribeMessageFromSubscribeChannelPayload
}

SubscribeMessageFromSubscribeChannel is the message expected for 'SubscribeMessageFromSubscribeChannel' channel.

func NewSubscribeMessageFromSubscribeChannel

func NewSubscribeMessageFromSubscribeChannel() SubscribeMessageFromSubscribeChannel

type SubscribeMessageFromSubscribeChannelPayload

type SubscribeMessageFromSubscribeChannelPayload struct {
	// Description: Channel name to subscribe to
	Channel string `json:"channel"`
}

SubscribeMessageFromSubscribeChannelPayload is a schema from the AsyncAPI specification required in messages

type TickerMessage

type TickerMessage struct {
	ProductCode     string  `json:"product_code"`
	Timestamp       string  `json:"timestamp"`
	BestBid         float64 `json:"best_bid"`
	BestAsk         float64 `json:"best_ask"`
	BestBidSize     float64 `json:"best_bid_size"`
	BestAskSize     float64 `json:"best_ask_size"`
	TotalBidDepth   float64 `json:"total_bid_depth"`
	TotalAskDepth   float64 `json:"total_ask_depth"`
	Ltp             float64 `json:"ltp"`
	Volume          float64 `json:"volume"`
	VolumeByProduct float64 `json:"volume_by_product"`
}

Message type definitions

type TickerMessageFromLightningTickerChannel

type TickerMessageFromLightningTickerChannel struct {
	// Payload will be inserted in the message payload
	Payload TickerMessageFromLightningTickerChannelPayload
}

TickerMessageFromLightningTickerChannel is the message expected for 'TickerMessageFromLightningTickerChannel' channel.

func NewTickerMessageFromLightningTickerChannel

func NewTickerMessageFromLightningTickerChannel() TickerMessageFromLightningTickerChannel

type TickerMessageFromLightningTickerChannelPayload

type TickerMessageFromLightningTickerChannelPayload struct {
	// Description: Ticker Information
	Data TickerSchema `json:"data"`

	// Description: Market product code (example: `BTC_JPY`, `FX_BTC_JPY`, `ETH_BTC`)
	ProductCode string `json:"product_code"`
}

TickerMessageFromLightningTickerChannelPayload is a schema from the AsyncAPI specification required in messages

type TickerSchema

type TickerSchema struct {
	// Description: Best Ask (Best Sell Quote)
	BestAsk float64 `json:"best_ask"`

	// Description: Best Ask Quantity
	BestAskSize float64 `json:"best_ask_size"`

	// Description: Best Bid (Best Buy Quote)
	BestBid float64 `json:"best_bid"`

	// Description: Best Bid Quantity
	BestBidSize float64 `json:"best_bid_size"`

	// Description: Last Trade Price (Last Trade Price)
	Ltp float64 `json:"ltp"`

	// Description: Market Sell Quantity in Matching
	MarketAskSize float64 `json:"market_ask_size"`

	// Description: Market Buy Quantity in Matching
	MarketBidSize float64 `json:"market_bid_size"`

	// Description: Product Code
	ProductCode string `json:"product_code"`

	// Description: Market State
	State string `json:"state"`

	// Description: Tick ID
	TickId int64 `json:"tick_id"`

	// Description: Time (ISO 8601)
	Timestamp time.Time `json:"timestamp"`

	// Description: Total Sell Quantity
	TotalAskDepth float64 `json:"total_ask_depth"`

	// Description: Total Buy Quantity
	TotalBidDepth float64 `json:"total_bid_depth"`

	// Description: Transaction Volume in the Last 24 Hours
	Volume float64 `json:"volume"`

	// Description: Transaction Volume in the Last 24 Hours (Product-by-Product)
	VolumeByProduct float64 `json:"volume_by_product"`
}

TickerSchema is a schema from the AsyncAPI specification required in messages Description: Ticker Information

type UnsubscribeMessageFromUnsubscribeChannel

type UnsubscribeMessageFromUnsubscribeChannel struct {
	// Payload will be inserted in the message payload
	Payload UnsubscribeMessageFromUnsubscribeChannelPayload
}

UnsubscribeMessageFromUnsubscribeChannel is the message expected for 'UnsubscribeMessageFromUnsubscribeChannel' channel.

func NewUnsubscribeMessageFromUnsubscribeChannel

func NewUnsubscribeMessageFromUnsubscribeChannel() UnsubscribeMessageFromUnsubscribeChannel

type UnsubscribeMessageFromUnsubscribeChannelPayload

type UnsubscribeMessageFromUnsubscribeChannelPayload struct {
	// Description: Channel name to unsubscribe from
	Channel string `json:"channel"`
}

UnsubscribeMessageFromUnsubscribeChannelPayload is a schema from the AsyncAPI specification required in messages

type UserController

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

UserController is the structure that provides sending capabilities to the developer and and connect the broker with the User

func NewUserController

func NewUserController(bc extensions.BrokerController, options ...ControllerOption) (*UserController, error)

NewUserController links the User to the broker

func (*UserController) Close

func (c *UserController) Close(ctx context.Context)

Close will clean up any existing resources on the controller

func (*UserController) SendToReceiveChildOrderEventsOperation

func (c *UserController) SendToReceiveChildOrderEventsOperation(
	ctx context.Context,
	msg EventsMessageFromChildOrderEventsChannel,
) error

SendToReceiveChildOrderEventsOperation will send a EventsMessageFromChildOrderEventsChannel message on ChildOrderEvents channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SendToReceiveExecutionsOperation

func (c *UserController) SendToReceiveExecutionsOperation(
	ctx context.Context,
	msg ExecutionsMessageFromLightningExecutionsChannel,
) error

SendToReceiveExecutionsOperation will send a ExecutionsMessageFromLightningExecutionsChannel message on LightningExecutions channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SendToReceiveOrderBookDiffOperation

func (c *UserController) SendToReceiveOrderBookDiffOperation(
	ctx context.Context,
	msg DiffMessageFromLightningBoardChannel,
) error

SendToReceiveOrderBookDiffOperation will send a DiffMessageFromLightningBoardChannel message on LightningBoard channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SendToReceiveOrderBookOperation

func (c *UserController) SendToReceiveOrderBookOperation(
	ctx context.Context,
	msg SnapshotMessageFromLightningBoardSnapshotChannel,
) error

SendToReceiveOrderBookOperation will send a SnapshotMessageFromLightningBoardSnapshotChannel message on LightningBoardSnapshot channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SendToReceiveParentOrderEventsOperation

func (c *UserController) SendToReceiveParentOrderEventsOperation(
	ctx context.Context,
	msg EventsMessageFromParentOrderEventsChannel,
) error

SendToReceiveParentOrderEventsOperation will send a EventsMessageFromParentOrderEventsChannel message on ParentOrderEvents channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SendToReceiveTickerOperation

func (c *UserController) SendToReceiveTickerOperation(
	ctx context.Context,
	msg TickerMessageFromLightningTickerChannel,
) error

SendToReceiveTickerOperation will send a TickerMessageFromLightningTickerChannel message on LightningTicker channel.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SubscribeToAllChannels

func (c *UserController) SubscribeToAllChannels(ctx context.Context, as UserSubscriber) error

SubscribeToAllChannels will receive messages from channels where channel has no parameter on which the app is expecting messages. For channels with parameters, they should be subscribed independently.

func (*UserController) SubscribeToSendAuthOperation

func (c *UserController) SubscribeToSendAuthOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg AuthMessageFromAuthChannel) error,
) error

SubscribeToSendAuthOperation will receive AuthMessageFromAuthChannel messages from Auth channel.

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SubscribeToSendSubscribeOperation

func (c *UserController) SubscribeToSendSubscribeOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg SubscribeMessageFromSubscribeChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) SubscribeToSendUnsubscribeOperation

func (c *UserController) SubscribeToSendUnsubscribeOperation(
	ctx context.Context,
	fn func(ctx context.Context, msg UnsubscribeMessageFromUnsubscribeChannel) error,
) error

Callback function 'fn' will be called each time a new message is received.

NOTE: for now, this only support the first message from AsyncAPI list.

NOTE: for now, this only support the first message from AsyncAPI list. If you need support for other messages, please raise an issue.

func (*UserController) UnsubscribeFromAllChannels

func (c *UserController) UnsubscribeFromAllChannels(ctx context.Context)

UnsubscribeFromAllChannels will stop the subscription of all remaining subscribed channels

func (*UserController) UnsubscribeFromSendAuthOperation

func (c *UserController) UnsubscribeFromSendAuthOperation(
	ctx context.Context,
)

UnsubscribeFromSendAuthOperation will stop the reception of AuthMessageFromAuthChannel messages from Auth channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) UnsubscribeFromSendSubscribeOperation

func (c *UserController) UnsubscribeFromSendSubscribeOperation(
	ctx context.Context,
)

UnsubscribeFromSendSubscribeOperation will stop the reception of SubscribeMessageFromSubscribeChannel messages from Subscribe channel. A timeout can be set in context to avoid blocking operation, if needed.

func (*UserController) UnsubscribeFromSendUnsubscribeOperation

func (c *UserController) UnsubscribeFromSendUnsubscribeOperation(
	ctx context.Context,
)

UnsubscribeFromSendUnsubscribeOperation will stop the reception of UnsubscribeMessageFromUnsubscribeChannel messages from Unsubscribe channel. A timeout can be set in context to avoid blocking operation, if needed.

type UserSubscriber

type UserSubscriber interface {
	// SendAuthOperationReceived receive all AuthMessageFromAuthChannel messages from Auth channel.
	SendAuthOperationReceived(ctx context.Context, msg AuthMessageFromAuthChannel) error

	// SendSubscribeOperationReceived receive all SubscribeMessageFromSubscribeChannel messages from Subscribe channel.
	SendSubscribeOperationReceived(ctx context.Context, msg SubscribeMessageFromSubscribeChannel) error

	// SendUnsubscribeOperationReceived receive all UnsubscribeMessageFromUnsubscribeChannel messages from Unsubscribe channel.
	SendUnsubscribeOperationReceived(ctx context.Context, msg UnsubscribeMessageFromUnsubscribeChannel) error
}

UserSubscriber contains all handlers that are listening messages for User

Jump to

Keyboard shortcuts

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