server

package
v0.0.0-...-82616d5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MarketOrder OrderType = "MARKET"
	LimitOrder  OrderType = "LIMIT"

	MarketETH Market = "ETH"
)

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 its 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(privateKey string, id int64) *User

Jump to

Keyboard shortcuts

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