common

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedExchanges = map[ExchangeID]Exchange{}
View Source
var SupportedTokens map[string]Token

Functions

func BigToFloat

func BigToFloat(b *big.Int, decimal int64) float64

func GetTimepoint

func GetTimepoint() uint64

func TimeToTimepoint

func TimeToTimepoint(t time.Time) uint64

func TimepointToTime

func TimepointToTime(t uint64) time.Time

Types

type ActivityID

type ActivityID struct {
	Timepoint uint64
	EID       string
}

func NewActivityID

func NewActivityID(t uint64, id string) ActivityID

func StringToActivityID

func StringToActivityID(id string) (ActivityID, error)

func (ActivityID) MarshalText

func (self ActivityID) MarshalText() ([]byte, error)

func (ActivityID) String

func (self ActivityID) String() string

func (*ActivityID) UnmarshalText

func (self *ActivityID) UnmarshalText(b []byte) error

type ActivityRecord

type ActivityRecord struct {
	Action      string
	ID          ActivityID
	Destination string
	Params      map[string]interface{}
	Result      map[string]interface{}
	Status      string
	Timestamp   Timestamp
}

type AddressConfig

type AddressConfig struct {
	Tokens    map[string]token    `json:"tokens"`
	Exchanges map[string]exchange `json:"exchanges"`
	Bank      string              `json:"bank"`
	Reserve   string              `json:"reserve"`
	Network   string              `json:"network"`
	Wrapper   string              `json:"wrapper"`
}

func GetAddressConfigFromFile

func GetAddressConfigFromFile(path string) (AddressConfig, error)

type AllBalanceResponse

type AllBalanceResponse struct {
	Version    Version
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       map[string]BalanceResponse
}

type AllEBalanceResponse

type AllEBalanceResponse struct {
	Version    Version
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       map[ExchangeID]EBalanceEntry
}

type AllOrderEntry

type AllOrderEntry map[ExchangeID]OrderEntry

type AllOrderResponse

type AllOrderResponse struct {
	Version    Version
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       AllOrderEntry
}

type AllPriceResponse

type AllPriceResponse struct {
	Version    Version
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       map[TokenPairID]OnePrice
}

type AllRateEntry

type AllRateEntry struct {
	Valid      bool
	Error      string
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       map[TokenPairID]RateEntry
}

type AllRateResponse

type AllRateResponse struct {
	Version    Version
	Valid      bool
	Error      string
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       map[TokenPairID]RateResponse
}

type BalanceEntry

type BalanceEntry struct {
	Valid      bool
	Error      string
	Timestamp  Timestamp
	ReturnTime Timestamp
	Balance    RawBalance
}

func (BalanceEntry) ToBalanceResponse

func (self BalanceEntry) ToBalanceResponse(decimal int64) BalanceResponse

type BalanceResponse

type BalanceResponse struct {
	Valid      bool
	Error      string
	Timestamp  Timestamp
	ReturnTime Timestamp
	Balance    float64
}

type EBalanceEntry

type EBalanceEntry struct {
	Valid            bool
	Error            string
	Timestamp        Timestamp
	ReturnTime       Timestamp
	AvailableBalance map[string]float64
	LockedBalance    map[string]float64
	DepositBalance   map[string]float64
}

type Exchange

type Exchange interface {
	ID() ExchangeID
	Address(token Token) (address ethereum.Address, supported bool)
	Withdraw(token Token, amount *big.Int, address ethereum.Address, timepoint uint64) (string, error)
	Trade(tradeType string, base Token, quote Token, rate float64, amount float64, timepoint uint64) (id string, done float64, remaining float64, finished bool, err error)
	CancelOrder(id ActivityID) error
	MarshalText() (text []byte, err error)
}

func GetExchange

func GetExchange(id string) (Exchange, error)

func MustGetExchange

func MustGetExchange(id string) Exchange

type ExchangeID

type ExchangeID string

type ExchangePrice

type ExchangePrice struct {
	Valid      bool
	Error      string
	Timestamp  Timestamp
	Bids       []PriceEntry
	Asks       []PriceEntry
	ReturnTime Timestamp
}

type OnePrice

type OnePrice map[ExchangeID]ExchangePrice

type OnePriceResponse

type OnePriceResponse struct {
	Version    Version
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       OnePrice
}

type Order

type Order struct {
	ID          string `standard id across multiple exchanges`
	Base        string
	Quote       string
	OrderId     string
	Price       float64
	OrigQty     float64 `original quantity`
	ExecutedQty float64 `matched quantity`
	TimeInForce string
	Type        string `market or limit`
	Side        string `buy or sell`
	StopPrice   string
	IcebergQty  string
	Time        uint64
}

type OrderEntry

type OrderEntry struct {
	Valid      bool
	Error      string
	Timestamp  Timestamp
	ReturnTime Timestamp
	Data       []Order
}

type PriceEntry

type PriceEntry struct {
	Quantity float64
	Rate     float64
}

type RateEntry

type RateEntry struct {
	Rate        *big.Int
	ExpiryBlock *big.Int
	Balance     *big.Int
}

type RateResponse

type RateResponse struct {
	Valid       bool
	Error       string
	Timestamp   Timestamp
	ReturnTime  Timestamp
	Rate        float64
	ExpiryBlock int64
	Balance     float64
}

type RawBalance

type RawBalance big.Int

func (RawBalance) MarshalJSON

func (self RawBalance) MarshalJSON() ([]byte, error)

func (*RawBalance) ToFloat

func (self *RawBalance) ToFloat(decimal int64) float64

func (*RawBalance) UnmarshalJSON

func (self *RawBalance) UnmarshalJSON(text []byte) error

type Timestamp

type Timestamp string

func GetTimestamp

func GetTimestamp() Timestamp

type Token

type Token struct {
	ID      string
	Address string
	Decimal int64
}

func GetToken

func GetToken(id string) (Token, error)

func MustGetToken

func MustGetToken(id string) Token

func (Token) IsETH

func (self Token) IsETH() bool

func (Token) MarshalText

func (self Token) MarshalText() (text []byte, err error)

type TokenPair

type TokenPair struct {
	Base  Token
	Quote Token
}

func MustCreateTokenPair

func MustCreateTokenPair(base, quote string) TokenPair

func NewTokenPair

func NewTokenPair(base, quote string) (TokenPair, error)

func (*TokenPair) PairID

func (self *TokenPair) PairID() TokenPairID

type TokenPairID

type TokenPairID string

func NewTokenPairID

func NewTokenPairID(base, quote string) TokenPairID

type Version

type Version uint64

Jump to

Keyboard shortcuts

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