evepraisal

package module
v0.0.0-...-2fa03ef Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 12 Imported by: 0

README

Evepraisal

Evepraisal is a bulk-price estimator for Eve Online.

Docker Instructions (production)

The following was tested on Ubuntu Server 18.10

  • Install docker.io
  $ sudo apt install docker.io
  • Install docker-compose
  $ sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  $ sudo chmod +x /usr/local/bin/docker-compose
  • Download Dockerfile, docker-compose.yml, and evepraisal.toml to a directory
  $ wget https://raw.githubusercontent.com/evepraisal/go-evepraisal/master/Dockerfile
  $ wget https://raw.githubusercontent.com/evepraisal/go-evepraisal/master/docker-compose.yml
  $ wget https://raw.githubusercontent.com/evepraisal/go-evepraisal/master/evepraisal.toml
  • build, and bring the container up
  $ docker-compose up

Instructions (development)

The following was tested on Ubuntu Server 18.10

  • Install golang 1.11
  ~$ curl https://dl.google.com/go/go1.11.10.linux-amd64.tar.gz | tar xz
  ~$ sudo mv go /usr/local
  ~$ echo 'export GOROOT=/usr/local/go' >>~/.profile
  ~$ echo 'export GOPATH=$HOME/go' >>~/.profile
  ~$ echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >>~/.profile
  ~$ echo 'export GO111MODULE=on' >>~/.profile
  ~$ source ~/.profile
  • Install build requirements
  ~$ sudo apt install git gcc musl-dev make
  • Download and build evepraisal
  ~$ mkdir -p $GOPATH/src/github.com/evepraisal/go-evepraisal
  ~$ cd $GOPATH/src/github.com/evepraisal/go-evepraisal
  ~/go/src/github.com/evepraisal/go-evepraisal$ git clone https://github.com/evepraisal/go-evepraisal.git .
  ~/go/src/github.com/evepraisal/go-evepraisal$ make setup
  ~/go/src/github.com/evepraisal/go-evepraisal$ make build
  • Run evepraisal
  ~/go/src/github.com/evepraisal/go-evepraisal$ ./target/evepraisal-linux-amd64

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAppraisalNotFound is returned whenever an appraisal by a given ID can't be found
	ErrAppraisalNotFound = errors.New("Appraisal not found")
)
View Source
var (
	// ErrNoValidLinesFound is returned when the appraisal text finds no items
	ErrNoValidLinesFound = fmt.Errorf("No valid lines found")
)

Functions

func AppraisalIDToUint64

func AppraisalIDToUint64(appraisalID string) uint64

AppraisalIDToUint64 returns a Uint64 appraisal ID for the given string version appraisalID. This is used to make nicer/smaller appraisal IDs

func NewContextMultiParser

func NewContextMultiParser(typeDB typedb.TypeDB, parserList []parsers.Parser) parsers.Parser

NewContextMultiParser implements a parser that knows about what types exist. This makes it much more powerful and prevents accidentally parsing one format as another

func Uint64ToAppraisalID

func Uint64ToAppraisalID(aID uint64) string

Uint64ToAppraisalID returns a string AppraisalID for the given Uint64 representation

Types

type App

type App struct {
	AppraisalDB         AppraisalDB
	TypeDB              typedb.TypeDB
	PriceDB             PriceDB
	Parser              parsers.Parser
	WebContext          WebContext
	NewRelicApplication newrelic.Application
}

App holds references to all of the app state that's needed. This is typically created in the 'evepraisal' package.

func (*App) PopulateItems

func (app *App) PopulateItems(appraisal *Appraisal)

PopulateItems will populate appraisal items with type and price information

func (*App) PricesForItem

func (app *App) PricesForItem(market string, item AppraisalItem) (Prices, error)

PricesForItem will look up market prices for the given item in the given market

func (*App) StringToAppraisal

func (app *App) StringToAppraisal(market string, s string, pricePercentage float64) (*Appraisal, error)

StringToAppraisal is the big function that everything is based on. It returns a full appraisal at the given market with a string of the appraisal contents (and pricePercentage).

type Appraisal

type Appraisal struct {
	ID              string           `json:"id,omitempty"`
	Created         int64            `json:"created"`
	Kind            string           `json:"kind"`
	MarketName      string           `json:"market_name"`
	Totals          Totals           `json:"totals"`
	Items           []AppraisalItem  `json:"items"`
	Raw             string           `json:"raw"`
	ParserLines     map[string][]int `json:"parser_lines,omitempty"`
	Unparsed        map[int]string   `json:"unparsed"`
	User            *User            `json:"user,omitempty"`
	Private         bool             `json:"private"`
	PrivateToken    string           `json:"private_token,omitempty"`
	PricePercentage float64          `json:"price_percentage,omitempty"`
	Live            bool             `json:"live"`
	ExpireTime      *time.Time       `json:"expire_time,omitempty"`
	ExpireMinutes   int64            `json:"expire_minutes,omitempty"`
}

Appraisal represents an appraisal (duh?). This is what is persisted and returned to users. See cleanAppraisal to see what is never returned to the user

func (*Appraisal) CreatedTime

func (appraisal *Appraisal) CreatedTime() time.Time

CreatedTime is the time that the appraisal was created (needed because the time is actually stored as a int64/unix timestamp)

func (*Appraisal) IsExpired

func (appraisal *Appraisal) IsExpired(now time.Time, lastUsed time.Time) bool

IsExpired returns true if an appraisal is expired and should be deleted. Can be caused by ExpireTime or ExpireMinutes

func (*Appraisal) Summary

func (appraisal *Appraisal) Summary() string

Summary returns a string summary that is logged

func (*Appraisal) UsingPercentage

func (appraisal *Appraisal) UsingPercentage() bool

UsingPercentage returns if a custom percentage is specified for the appraisal

type AppraisalDB

type AppraisalDB interface {
	PutNewAppraisal(appraisal *Appraisal) error
	GetAppraisal(appraisalID string, updateUsedTime bool) (*Appraisal, error)
	LatestAppraisals(count int, kind string) ([]Appraisal, error)
	LatestAppraisalsByUser(user User, count int, kind string, after string) ([]Appraisal, error)
	TotalAppraisals() (int64, error)
	IncrementTotalAppraisals() error
	DeleteAppraisal(appraisalID string) error
	Close() error
}

AppraisalDB allows for creating, deleting and retreiving appraisals

type AppraisalItem

type AppraisalItem struct {
	Name       string  `json:"name"`
	TypeID     int64   `json:"typeID"`
	TypeName   string  `json:"typeName"`
	TypeVolume float64 `json:"typeVolume"`
	Quantity   int64   `json:"quantity"`
	Prices     Prices  `json:"prices"`
	Extra      struct {
		Fitted     bool    `json:"fitted,omitempty"`
		Dropped    bool    `json:"dropped,omitempty"`
		Destroyed  bool    `json:"destroyed,omitempty"`
		Location   string  `json:"location,omitempty"`
		PlayerName string  `json:"player_name,omitempty"`
		Routed     bool    `json:"routed,omitempty"`
		Volume     float64 `json:"volume,omitempty"`
		Distance   string  `json:"distance,omitempty"`
		BPC        bool    `json:"bpc,omitempty"`
		BPCRuns    int64   `json:"bpcRuns,omitempty"`
	} `json:"meta,omitempty"`
}

AppraisalItem represents a single type of item and details the name, quantity, prices, etc. for the appraisal.

func (AppraisalItem) BuyISKVolume

func (i AppraisalItem) BuyISKVolume() float64

BuyISKVolume is used to give ISK per volume using the representative buy price

func (AppraisalItem) BuyPrice

func (i AppraisalItem) BuyPrice() float64

func (AppraisalItem) BuyTotal

func (i AppraisalItem) BuyTotal() float64

BuyTotal is used to give a representative buy total for an item

func (AppraisalItem) RepresentativePrice

func (i AppraisalItem) RepresentativePrice() float64

RepresentativePrice is used to give a representative price for an item. This is used for sorting.

func (AppraisalItem) SellISKVolume

func (i AppraisalItem) SellISKVolume() float64

SellISKVolume is used to give ISK per volume using the representative sell price

func (AppraisalItem) SellPrice

func (i AppraisalItem) SellPrice() float64

func (AppraisalItem) SellTotal

func (i AppraisalItem) SellTotal() float64

SellTotal is used to give a representative sell total for an item

func (AppraisalItem) SingleRepresentativePrice

func (i AppraisalItem) SingleRepresentativePrice() float64

SingleRepresentativePrice is used to give a representative price for a single item

func (AppraisalItem) TotalVolume

func (i AppraisalItem) TotalVolume() float64

type MarketItemPrices

type MarketItemPrices struct {
	Market string
	TypeID int64
	Prices Prices
}

type PriceDB

type PriceDB interface {
	GetPrice(market string, typeID int64) (Prices, bool)
	UpdatePrices([]MarketItemPrices) error
	Close() error
}

PriceDB holds prices for eve online items. Something else should update them

type PriceStats

type PriceStats struct {
	Average    float64 `json:"avg"`
	Max        float64 `json:"max"`
	Median     float64 `json:"median"`
	Min        float64 `json:"min"`
	Percentile float64 `json:"percentile"`
	Stddev     float64 `json:"stddev"`
	Volume     int64   `json:"volume"`
	OrderCount int64   `json:"order_count"`
}

PriceStats has results of statistical functions used to combine a bunch of orders into easier to process numbers

type Prices

type Prices struct {
	All      PriceStats `json:"all"`
	Buy      PriceStats `json:"buy"`
	Sell     PriceStats `json:"sell"`
	Updated  time.Time  `json:"updated"`
	Strategy string     `json:"strategy"`
}

Prices represents prices for an item

func (Prices) Add

func (prices Prices) Add(p Prices) Prices

Add adds the given Prices to the current Prices and returns a new Prices

func (Prices) Mul

func (prices Prices) Mul(multiplier float64) Prices

Mul multiplies the Prices with the given factor

func (Prices) Set

func (prices Prices) Set(price float64) Prices

Set returns a new Prices object with the given price set in all applicable stats

func (Prices) String

func (prices Prices) String() string

String returns a nice string version of the prices

func (Prices) Sub

func (prices Prices) Sub(p Prices) Prices

Sub subtracts the given Prices to the current Prices and returns a new Prices

type Totals

type Totals struct {
	Buy    float64 `json:"buy"`
	Sell   float64 `json:"sell"`
	Volume float64 `json:"volume"`
}

Totals represents sums of all prices/volumes for all items in the appraisal

type Transaction

type Transaction interface {
	NoticeError(error) error
	End() error
}

Transaction is used to signal the normal or abnormal end to a given event

type TransactionLogger

type TransactionLogger interface {
	StartTransaction(identifier string) Transaction
	StartWebTransaction(identifier string, w http.ResponseWriter, r *http.Request) Transaction
}

TransactionLogger is used to log general events and HTTP requests

type User

type User struct {
	CharacterName      string
	CharacterOwnerHash string
}

User is information about a logged-in user. Currently, this is only stored in the user's session but may be used as keys in a user settings database

type WebContext

type WebContext interface {
	HTTPHandler() http.Handler
	Reload() error
}

WebContext holds HTTP handlers and stuff

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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