server

package
v0.0.0-...-9de8c49 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuyOrder

type BuyOrder struct {
	Username string `json:"username"`
	Ticker   string `json:"ticker"`
	Amount   int64  `json:"amount"`
}

type SellOrder

type SellOrder struct {
	Username string `json:"username"`
	Ticker   string `json:"ticker"`
	Amount   int64  `json:"amount"`
}

type Server

type Server struct {
	TickTime time.Duration
	Ticker   *time.Ticker
	DB       *sql.DB
	Stocks   map[string]*stocks.Stock
}

func NewServer

func NewServer(ticktime time.Duration) *Server

func (*Server) AddNewUser

func (s *Server) AddNewUser(username string, startingMoney float64)

func (*Server) AddStockPrice

func (s *Server) AddStockPrice(st *stocks.Stock)

func (*Server) AddToUserBalance

func (s *Server) AddToUserBalance(username string, money float64)

func (*Server) AddToUserStockAmount

func (s *Server) AddToUserStockAmount(username string, ticker string, amount int64)

func (*Server) BuyStock

func (s *Server) BuyStock(username string, ticker string, amount int64)

func (*Server) CloseDB

func (s *Server) CloseDB()

func (*Server) GetCurrentStockPrice

func (s *Server) GetCurrentStockPrice(tr string) float64

func (*Server) GetStockPrices

func (s *Server) GetStockPrices(st *stocks.Stock) []TimePricePair

func (*Server) GetStockPricesByTicker

func (s *Server) GetStockPricesByTicker(tr string) []TimePricePair

func (*Server) GetUserBalance

func (s *Server) GetUserBalance(username string) float64

func (*Server) GetUserBalances

func (s *Server) GetUserBalances() map[string]float64

func (*Server) GetUserStockAmount

func (s *Server) GetUserStockAmount(username string, ticker string) int64

func (*Server) GetUserSummaries

func (s *Server) GetUserSummaries() map[string](map[string]int64)

func (*Server) IsStockPresentForUser

func (s *Server) IsStockPresentForUser(username string, ticker string) bool

func (*Server) NewStockTable

func (s *Server) NewStockTable(st *stocks.Stock)

func (*Server) SellStock

func (s *Server) SellStock(username string, ticker string, amount int64)

func (*Server) Start

func (s *Server) Start()

type TimePricePair

type TimePricePair struct {
	Time  int64
	Price float64
}

Jump to

Keyboard shortcuts

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