Documentation ¶
Index ¶
- func CreatePushConnection(addr, publicKey string, token string, logger *zap.Logger) (*zmqPushConnection, error)
- func StartNewClient(logger *zap.Logger, push pushConnecter, xsub xsubConnecter) *zmqTrader
- type ClientOrderId
- type ErrorResponse
- type MockTrader
- func (m *MockTrader) CancelOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderReport, error)
- func (m *MockTrader) GetOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderModel, error)
- func (m *MockTrader) GetSnapshot(ctx context.Context, userID uint64) ([]OrderModel, error)
- func (m *MockTrader) IsReady() bool
- func (m *MockTrader) NewOrder(ctx context.Context, userID uint64, order *RequestOrderNew) (*OrderReport, []Trade, error)
- func (m *MockTrader) Ready() chan bool
- func (m *MockTrader) ReplaceOrder(ctx context.Context, userID uint64, req RequestOrderReplace) (*OrderReport, error)
- func (m *MockTrader) SetReady(val bool)
- func (m *MockTrader) SetupFixtures()
- func (m *MockTrader) StartHttpServer(addr string)
- func (m *MockTrader) Unsubscribe(userID uint64)
- type OrderModel
- type OrderReport
- type OrderSide
- type OrderStatus
- type OrderTimeInForce
- type OrderType
- type ReportType
- type RequestOrderNew
- type RequestOrderReplace
- type Trade
- type Trader
- type UserWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePushConnection ¶
func CreatePushConnection(addr, publicKey string, token string, logger *zap.Logger) (*zmqPushConnection, error)
CreatePushConnection create connection, connect, handle status and run send handles
func StartNewClient ¶
StartNewClient create trading trader and init it
Types ¶
type ClientOrderId ¶
type ClientOrderId [32]byte
func ClientOrderIdGenerate ¶
func ClientOrderIdGenerate() ClientOrderId
func ClientOrderIdGenerateFast ¶
func ClientOrderIdGenerateFast(id int) ClientOrderId
func ClientOrderIdStrToType ¶
func ClientOrderIdStrToType(val string) (ClientOrderId, error)
func (ClientOrderId) MarshalJSON ¶
func (co ClientOrderId) MarshalJSON() ([]byte, error)
func (ClientOrderId) String ¶
func (co ClientOrderId) String() string
func (*ClientOrderId) UnmarshalJSON ¶
func (co *ClientOrderId) UnmarshalJSON(data []byte) error
type ErrorResponse ¶
type ErrorResponse uint8
const ( ErrorUnknown ErrorResponse = iota ErrorDuplicateClientOrder ErrorNotFoundOrder ErrorExceedsLimit ErrorNotChanged ErrorBadQuantity ErrorBadPrice ErrorTradingNotStarted ErrorNoExpireTime ErrorTooLateToEnter )
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type MockTrader ¶
type MockTrader struct {
// contains filtered or unexported fields
}
func NewMockTrader ¶
func NewMockTrader(logger *zap.Logger) *MockTrader
func (*MockTrader) CancelOrder ¶
func (m *MockTrader) CancelOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderReport, error)
func (*MockTrader) GetOrder ¶
func (m *MockTrader) GetOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderModel, error)
func (*MockTrader) GetSnapshot ¶
func (m *MockTrader) GetSnapshot(ctx context.Context, userID uint64) ([]OrderModel, error)
func (*MockTrader) IsReady ¶
func (m *MockTrader) IsReady() bool
func (*MockTrader) NewOrder ¶
func (m *MockTrader) NewOrder(ctx context.Context, userID uint64, order *RequestOrderNew) (*OrderReport, []Trade, error)
func (*MockTrader) Ready ¶
func (m *MockTrader) Ready() chan bool
func (*MockTrader) ReplaceOrder ¶
func (m *MockTrader) ReplaceOrder(ctx context.Context, userID uint64, req RequestOrderReplace) (*OrderReport, error)
func (*MockTrader) SetReady ¶
func (m *MockTrader) SetReady(val bool)
func (*MockTrader) SetupFixtures ¶
func (m *MockTrader) SetupFixtures()
func (*MockTrader) StartHttpServer ¶
func (m *MockTrader) StartHttpServer(addr string)
func (*MockTrader) Unsubscribe ¶
func (m *MockTrader) Unsubscribe(userID uint64)
type OrderModel ¶
type OrderModel struct { OrderID uint64 LatestOrderID uint64 ClientOrderID ClientOrderId Type OrderType TimeInForce OrderTimeInForce Side OrderSide OrderStatus OrderStatus PostOnly bool Symbol string Price string StopPrice string ExpireTime uint64 Quantity string LastQuantity uint64 LastPrice string LeavesQuantity uint64 CumQuantity string AveragePrice string Created uint64 Timestamp uint64 }
type OrderReport ¶
type OrderReport struct { OrderModel ReportType ReportType OriginalClientOrderID ClientOrderId Timestamp uint64 TradeID uint64 FeeAmount string FeeInstrument string }
type OrderSide ¶
type OrderSide uint8
func OrderSideStrToType ¶
func (OrderSide) MarshalJSON ¶
func (*OrderSide) UnmarshalJSON ¶
type OrderStatus ¶
type OrderStatus uint8
const ( OrderStatusNew OrderStatus = iota OrderStatusSuspended OrderStatusPartiallyFilled OrderStatusFilled OrderStatusCanceled OrderStatusRejected OrderStatusExpired )
func OrderStatusStrToType ¶
func OrderStatusStrToType(value string) (OrderStatus, error)
func (OrderStatus) MarshalJSON ¶
func (os OrderStatus) MarshalJSON() ([]byte, error)
func (OrderStatus) String ¶
func (os OrderStatus) String() string
func (*OrderStatus) UnmarshalJSON ¶
func (os *OrderStatus) UnmarshalJSON(data []byte) error
type OrderTimeInForce ¶
type OrderTimeInForce uint8
const ( OrderTimeInForceGTC OrderTimeInForce = iota // good till cancel. cancel only by user request of full filled OrderTimeInForceIOC // immediate or cancel. can be partially filled and then final status expired OrderTimeInForceFOK // fill or kill. fully filled or expired OrderTimeInForceDAY // Day. automatically expired at the end of the day (00 UTC) OrderTimeInForceGTD // good till date. automatically expired on a specified time )
func OrderTimeInForceStrToType ¶
func OrderTimeInForceStrToType(value string) (OrderTimeInForce, error)
func (OrderTimeInForce) MarshalJSON ¶
func (tif OrderTimeInForce) MarshalJSON() ([]byte, error)
func (OrderTimeInForce) String ¶
func (tif OrderTimeInForce) String() string
func (*OrderTimeInForce) UnmarshalJSON ¶
func (tif *OrderTimeInForce) UnmarshalJSON(data []byte) error
type OrderType ¶
type OrderType uint8
func OrderTypeStrToType ¶
func (OrderType) MarshalJSON ¶
func (*OrderType) UnmarshalJSON ¶
type ReportType ¶
type ReportType uint8
const ( ReportTypeNew ReportType = iota ReportTypeSuspended ReportTypeCanceled ReportTypeRejected ReportTypeExpired ReportTypeTrade ReportTypeStatus ReportTypeReplaced )
func (ReportType) MarshalJSON ¶
func (rt ReportType) MarshalJSON() ([]byte, error)
func (ReportType) String ¶
func (rt ReportType) String() string
func (*ReportType) UnmarshalJSON ¶
func (rt *ReportType) UnmarshalJSON(data []byte) error
type RequestOrderNew ¶
type RequestOrderNew struct { ClientOrderID ClientOrderId `json:"clientOrderId"` Type OrderType `json:"type"` Side OrderSide `json:"side"` TimeInForce OrderTimeInForce `json:"timeInForce"` PostOnly bool `json:"participateDoNotInitiate"` Symbol string `json:"symbol"` Quantity string `json:"quantity"` Price string `json:"price,omitempty"` StopPrice string `json:"stopPrice,omitempty"` ExpireTime uint64 `json:"expireTime,omitempty"` Login string `json:"login,omitempty"` WaitComplete bool }
type RequestOrderReplace ¶
type RequestOrderReplace struct { ClientOrderID ClientOrderId RequestClientOrderID ClientOrderId Quantity string Price string }
type Trader ¶
type Trader interface { Unsubscribe(userID uint64) GetSnapshot(ctx context.Context, userID uint64) ([]OrderModel, error) GetOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderModel, error) //NewOrder(ctx context.Context, userID uint64, order *RequestOrderNew) (*OrderReport, error) NewOrder(ctx context.Context, userID uint64, order *RequestOrderNew) (*OrderReport, []Trade, error) CancelOrder(ctx context.Context, userID uint64, clientOrderID ClientOrderId) (*OrderReport, error) ReplaceOrder(ctx context.Context, userID uint64, req RequestOrderReplace) (*OrderReport, error) IsReady() bool Ready() chan bool }
type UserWatcher ¶
type UserWatcher struct {
// contains filtered or unexported fields
}
func NewUserWatcher ¶
func NewUserWatcher(trader Trader, duration time.Duration) *UserWatcher
func (*UserWatcher) Touch ¶
func (w *UserWatcher) Touch(userID uint64)
Source Files ¶
- call.go
- canary.go
- clientorderid.go
- cluster-trader.go
- dsn.go
- error.go
- messages.go
- mock-trader.go
- order-side.go
- order-status.go
- order-timeinforce.go
- order-type.go
- order.go
- orders-container.go
- report-type.go
- requests.go
- trader.go
- user-watcher.go
- zmq-monitor.go
- zmq-push-connecter.go
- zmq-push.go
- zmq-trader.go
- zmq-xsub-connecter.go
- zmq-xsub.go
Click to show internal directories.
Click to hide internal directories.