valuable

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

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ObjectType = "stock"
)

Variables

View Source
var Stocks = make(map[string]*Stock)
View Source
var ValuablesLock = lock.NewLock("valuables")

Functions

func DeleteStock

func DeleteStock(s *Stock)

func StartStockStimulation

func StartStockStimulation()

Types

type PriceChange

type PriceChange interface {
	GetTargetPrice() int64
	// contains filtered or unexported methods
}

Some thing that can take in a stock and change the current price

type RandomPrice

type RandomPrice struct {
	RunPercent            float64 `json:"run_percent"`
	TargetPrice           int64   `json:"target_price"`
	PercentToChangeTarget float64 `json:"change_percent"`
	Volatility            float64 `json:"volatility"`
	RandomNoise           float64
}

Random Price implements priceChange

func (*RandomPrice) GetTargetPrice

func (randPrice *RandomPrice) GetTargetPrice() int64

type Stock

type Stock struct {
	objects.Stock
	PriceChanger  PriceChange                   `json:"-"`
	UpdateChannel *duplicator.ChannelDuplicator `json:"-"`
	// contains filtered or unexported fields
}

Stock type for storing the stock information

func GetAllStocks

func GetAllStocks() []*Stock

func MakeStock

func MakeStock(s objects.Stock) (*Stock, error)

func NewStock

func NewStock(tickerID, name string, startPrice int64, runInterval time.Duration) (*Stock, error)

func (*Stock) ChangeDetected

func (stock *Stock) ChangeDetected() reflect.Type

func (*Stock) GetLock

func (stock *Stock) GetLock() *lock.Lock

func (*Stock) GetName

func (stock *Stock) GetName() string

func (*Stock) GetUpdateChannel

func (stock *Stock) GetUpdateChannel() *duplicator.ChannelDuplicator

func (*Stock) GetValue

func (stock *Stock) GetValue() int64

func (*Stock) Update

func (s *Stock) Update()

type Valuable

type Valuable interface {
	GetId() string
	GetName() string
	GetValue() float64
	GetLock() *lock.Lock
	GetUpdateChannel() *duplicator.ChannelDuplicator
	Update()
}

* Valuable was an old thing that i used to abstract stocks one more level but just became cumbersome

Jump to

Keyboard shortcuts

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