server

package
v0.0.0-...-591fa00 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarketETH Market = "ETH"

	MarketOrder OrderType = "MARKET"
	LimitOrder  OrderType = "LIMIT"
)

Variables

This section is empty.

Functions

func StartServer

func StartServer()

Types

type APIError

type APIError struct {
	Error string
}

type Exchange

type Exchange struct {
	Client *ethclient.Client

	Users map[int64]*User
	// Orders maps a user to his orders.
	Orders     map[int64][]*orderbook.Order
	PrivateKey *ecdsa.PrivateKey
	// contains filtered or unexported fields
}

func NewExchange

func NewExchange(privateKey string, client *ethclient.Client) (*Exchange, error)

type GetOrdersResponse

type GetOrdersResponse struct {
	Asks []Order
	Bids []Order
}

type Market

type Market string

type MatchedOrder

type MatchedOrder struct {
	UserID int64
	Price  float64
	Size   float64
	ID     int64
}

type Order

type Order struct {
	UserID    int64
	ID        int64
	Price     float64
	Size      float64
	Bid       bool
	Timestamp int64
}

type OrderType

type OrderType string

type OrderbookData

type OrderbookData struct {
	TotalBidVolume float64
	TotalAskVolume float64
	Asks           []*Order
	Bids           []*Order
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	UserID int64
	Type   OrderType // limit or market
	Bid    bool
	Size   float64
	Price  float64
	Market Market
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	OrderID int64
}

type PriceResponse

type PriceResponse struct {
	Price float64
}

type User

type User struct {
	ID         int64
	PrivateKey *ecdsa.PrivateKey
}

func NewUser

func NewUser(privKey string, id int64) *User

Jump to

Keyboard shortcuts

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