Documentation

Index

Constants

const (
	CandleSize       = 8 * 8
	Second           = 1000
	Minute           = 60 * Second
	DefaultTimeFrame = 5
	TimeFrame        = DefaultTimeFrame * Minute
)

const PriceConstant = 100000000

const (
	TradeSize = 1 + 3*crypto.DigestSize + 3*crypto.PublicKeySize + 8 + 8 + 8
)

Variables

var (
	WavesID            = crypto.Digest{}
	WavesIssuerAddress = proto.Address{}
	WavesAssetInfo     = AssetInfo{ID: WavesID, Name: "WAVES", IssuerAddress: WavesIssuerAddress, Decimals: 8, Reissuable: false, Supply: 10000000000000000}
)

Functions

func FromBurnWithProofs

func FromBurnWithProofs(scheme byte, tx *proto.BurnWithProofs) (AssetChange, AccountChange, error)

func FromBurnWithSig

func FromBurnWithSig(scheme byte, tx *proto.BurnWithSig) (AssetChange, AccountChange, error)

func FromIssueWithProofs

func FromIssueWithProofs(scheme byte, tx *proto.IssueWithProofs) (IssueChange, AccountChange, error)

func FromIssueWithSig

func FromIssueWithSig(scheme byte, tx *proto.IssueWithSig) (IssueChange, AccountChange, error)

func FromReissueWithProofs

func FromReissueWithProofs(scheme byte, tx *proto.ReissueWithProofs) (AssetChange, AccountChange, error)

func FromReissueWithSig

func FromReissueWithSig(scheme byte, tx *proto.ReissueWithSig) (AssetChange, AccountChange, error)

func ScaleTimeFrame

func ScaleTimeFrame(tf uint32, scale int) uint32

func StartOfTheDayMilliseconds

func StartOfTheDayMilliseconds(ts uint64) uint64

func TimeFrameFromTimestampMS

func TimeFrameFromTimestampMS(ts uint64) uint32

func TimeFromMilliseconds

func TimeFromMilliseconds(ms uint64) time.Time

func TimestampMSFromTimeFrame

func TimestampMSFromTimeFrame(tf uint32) uint64

Types

type Account

type Account struct {
	Address proto.Address
	Alias   proto.Alias
}

func (*Account) SetFromPublicKey

func (a *Account) SetFromPublicKey(scheme byte, pk crypto.PublicKey) error

func (*Account) SetFromRecipient

func (a *Account) SetFromRecipient(r proto.Recipient) error

type AccountChange

type AccountChange struct {
	Account      Account
	Asset        crypto.Digest
	In           uint64
	Out          uint64
	MinersReward bool
}

func FromExchangeWithProofs

func FromExchangeWithProofs(scheme byte, tx *proto.ExchangeWithProofs) ([]AccountChange, error)

func FromExchangeWithSig

func FromExchangeWithSig(scheme byte, tx *proto.ExchangeWithSig) ([]AccountChange, error)

func FromMassTransferWithProofs

func FromMassTransferWithProofs(scheme byte, tx *proto.MassTransferWithProofs) ([]AccountChange, error)

func FromTransferWithProofs

func FromTransferWithProofs(scheme byte, tx *proto.TransferWithProofs, miner crypto.PublicKey) ([]AccountChange, error)

func FromTransferWithSig

func FromTransferWithSig(scheme byte, tx *proto.TransferWithSig, miner crypto.PublicKey) ([]AccountChange, error)

type AliasBind

type AliasBind struct {
	Alias   proto.Alias
	Address proto.Address
}

func FromCreateAliasWithProofs

func FromCreateAliasWithProofs(scheme byte, tx *proto.CreateAliasWithProofs) (AliasBind, error)

func FromCreateAliasWithSig

func FromCreateAliasWithSig(scheme byte, tx *proto.CreateAliasWithSig) (AliasBind, error)

type AssetChange

type AssetChange struct {
	AssetID       crypto.Digest
	SetReissuable bool
	Reissuable    bool
	SetSponsored  bool
	Sponsored     bool
	Issued        uint64
	Burned        uint64
}

func FromSponsorshipWithProofs

func FromSponsorshipWithProofs(tx *proto.SponsorshipWithProofs) AssetChange

type AssetID

type AssetID crypto.Digest

func (AssetID) MarshalJSON

func (v AssetID) MarshalJSON() ([]byte, error)

type AssetInfo

type AssetInfo struct {
	ID            crypto.Digest
	Name          string
	IssuerAddress proto.Address
	Decimals      uint8
	Reissuable    bool
	Supply        uint64
}

type ByCandlesTimestampBackward

type ByCandlesTimestampBackward []CandleInfo

func (ByCandlesTimestampBackward) Len

func (a ByCandlesTimestampBackward) Len() int

func (ByCandlesTimestampBackward) Less

func (a ByCandlesTimestampBackward) Less(i, j int) bool

func (ByCandlesTimestampBackward) Swap

func (a ByCandlesTimestampBackward) Swap(i, j int)

type ByMarkets

type ByMarkets []MarketInfo

func (ByMarkets) Len

func (a ByMarkets) Len() int

func (ByMarkets) Less

func (a ByMarkets) Less(i, j int) bool

func (ByMarkets) Swap

func (a ByMarkets) Swap(i, j int)

type BySymbols

type BySymbols []Substitution

func (BySymbols) Len

func (a BySymbols) Len() int

func (BySymbols) Less

func (a BySymbols) Less(i, j int) bool

func (BySymbols) Swap

func (a BySymbols) Swap(i, j int)

type ByTickers

type ByTickers []TickerInfo

func (ByTickers) Len

func (a ByTickers) Len() int

func (ByTickers) Less

func (a ByTickers) Less(i, j int) bool

func (ByTickers) Swap

func (a ByTickers) Swap(i, j int)

type Candle

type Candle struct {
	Open         uint64
	High         uint64
	Low          uint64
	Close        uint64
	Average      uint64
	Volume       uint64
	MinTimestamp uint64
	MaxTimestamp uint64
}

func NewCandleFromTimeFrame

func NewCandleFromTimeFrame(tf uint32) Candle

func NewCandleFromTimestamp

func NewCandleFromTimestamp(ts uint64) Candle

func (*Candle) Combine

func (c *Candle) Combine(x Candle)

func (*Candle) MarshalBinary

func (c *Candle) MarshalBinary() ([]byte, error)

func (*Candle) UnmarshalBinary

func (c *Candle) UnmarshalBinary(data []byte) error

func (*Candle) UpdateFromTrade

func (c *Candle) UpdateFromTrade(t Trade)

type CandleInfo

type CandleInfo struct {
	Timestamp   uint64  `json:"timestamp"`
	Open        Decimal `json:"open"`
	High        Decimal `json:"high"`
	Low         Decimal `json:"low"`
	Close       Decimal `json:"close"`
	Average     Decimal `json:"vwap"`
	Volume      Decimal `json:"volume"`
	PriceVolume Decimal `json:"priceVolume"`
	Confirmed   bool    `json:"confirmed"`
}

func CandleInfoFromCandle

func CandleInfoFromCandle(candle Candle, amountAssetDecimals, priceAssetDecimals uint, timeFrameScale int) CandleInfo

func EmptyCandleInfo

func EmptyCandleInfo(amountAssetDecimals, priceAssetDecimals uint, timestamp uint64) CandleInfo

type Decimal

type Decimal struct {
	// contains filtered or unexported fields
}

func NewDecimal

func NewDecimal(value uint64, scale uint) *Decimal

func NewDecimalFromString

func NewDecimalFromString(s string) (*Decimal, error)

func (Decimal) MarshalJSON

func (d Decimal) MarshalJSON() ([]byte, error)

func (*Decimal) Rescale

func (d *Decimal) Rescale(scale uint) *Decimal

func (*Decimal) Scale

func (d *Decimal) Scale() int

func (*Decimal) String

func (d *Decimal) String() string

func (*Decimal) ToInfiniteDecimal

func (d *Decimal) ToInfiniteDecimal(infinite bool) InfiniteDecimal

func (*Decimal) UnmarshalJSON

func (d *Decimal) UnmarshalJSON(value []byte) error

func (*Decimal) Value

func (d *Decimal) Value() int

type InfiniteDecimal

type InfiniteDecimal struct {
	Decimal
	Infinite bool
}

func (InfiniteDecimal) MarshalJSON

func (d InfiniteDecimal) MarshalJSON() ([]byte, error)

func (*InfiniteDecimal) String

func (d *InfiniteDecimal) String() string

func (*InfiniteDecimal) UnmarshalJSON

func (d *InfiniteDecimal) UnmarshalJSON(value []byte) error

type IssueChange

type IssueChange struct {
	AssetID    crypto.Digest
	Name       string
	Issuer     crypto.PublicKey
	Decimals   uint8
	Reissuable bool
	Quantity   uint64
}

type Market

type Market struct {
	FirstTradeTimestamp uint64
	LastTradeTimestamp  uint64
	TotalTradesCount    int
}

func (*Market) MarshalBinary

func (md *Market) MarshalBinary() ([]byte, error)

func (*Market) UnmarshalBinary

func (md *Market) UnmarshalBinary(data []byte) error

func (*Market) UpdateFromTrade

func (md *Market) UpdateFromTrade(t Trade)

type MarketID

type MarketID struct {
	AmountAsset crypto.Digest
	PriceAsset  crypto.Digest
}

func (*MarketID) MarshalBinary

func (id *MarketID) MarshalBinary() ([]byte, error)

func (*MarketID) UnmarshalBinary

func (id *MarketID) UnmarshalBinary(data []byte) error

type MarketInfo

type MarketInfo struct {
	TickerInfo
	TotalTrades   int    `json:"totalTrades"`
	FirstTradeDay uint64 `json:"firstTradeDay"`
	LastTradeDay  uint64 `json:"lastTradeDay"`
}

func NewMarketInfo

func NewMarketInfo(ticker TickerInfo, md Market) MarketInfo

type Substitution

type Substitution struct {
	Symbol  string  `json:"symbol"`
	AssetID AssetID `json:"assetID"`
}

type Symbols

type Symbols struct {
	// contains filtered or unexported fields
}

func NewSymbolsFromFile

func NewSymbolsFromFile(name string, oracle proto.Address, scheme byte) (*Symbols, error)

func (*Symbols) All

func (s *Symbols) All() []Substitution

func (*Symbols) Count

func (s *Symbols) Count() int

func (*Symbols) ParseTicker

func (s *Symbols) ParseTicker(ticker string) (crypto.Digest, error)

func (*Symbols) Token

func (s *Symbols) Token(id crypto.Digest) (string, bool)

func (*Symbols) UpdateFromOracle

func (s *Symbols) UpdateFromOracle(conn *grpc.ClientConn) error

type TickerInfo

type TickerInfo struct {
	Symbol                       string          `json:"symbol"`
	AmountAssetID                AssetID         `json:"amountAssetID"`
	AmountAssetName              string          `json:"amountAssetName"`
	AmountAssetDecimals          byte            `json:"amountAssetDecimals"`
	AmountAssetTotalSupply       Decimal         `json:"amountAssetTotalSupply"`
	AmountAssetMaxSupply         InfiniteDecimal `json:"amountAssetMaxSupply"`
	AmountAssetCirculatingSupply Decimal         `json:"amountAssetCirculatingSupply"`
	PriceAssetID                 AssetID         `json:"priceAssetID"`
	PriceAssetName               string          `json:"priceAssetName"`
	PriceAssetDecimals           byte            `json:"priceAssetDecimals"`
	PriceAssetTotalSupply        Decimal         `json:"priceAssetTotalSupply"`
	PriceAssetMaxSupply          InfiniteDecimal `json:"priceAssetMaxSupply"`
	PriceAssetCirculatingSupply  Decimal         `json:"priceAssetCirculatingSupply"`
	DayOpen                      Decimal         `json:"24h_open"`
	DayHigh                      Decimal         `json:"24h_high"`
	DayLow                       Decimal         `json:"24h_low"`
	DayClose                     Decimal         `json:"24h_close"`
	DayVWAP                      Decimal         `json:"24h_vwap"`
	DayVolume                    Decimal         `json:"24h_volume"`
	DayPriceVolume               Decimal         `json:"24h_priceVolume"`
	Timestamp                    uint64          `json:"timestamp"`
}

func NewTickerInfo

func NewTickerInfo(symbol string, amountAsset, priceAsset AssetInfo, amountAssetIssuerBalance, priceAssetIssuerBalance uint64, candle Candle) TickerInfo

type Trade

type Trade struct {
	AmountAsset   crypto.Digest
	PriceAsset    crypto.Digest
	TransactionID crypto.Digest
	OrderType     proto.OrderType
	Buyer         proto.Address
	Seller        proto.Address
	Matcher       proto.Address
	Price         uint64
	Amount        uint64
	Timestamp     uint64
}

func NewTradeFromExchangeWithProofs

func NewTradeFromExchangeWithProofs(scheme byte, tx *proto.ExchangeWithProofs) (Trade, error)

func NewTradeFromExchangeWithSig

func NewTradeFromExchangeWithSig(scheme byte, tx *proto.ExchangeWithSig) (Trade, error)

func (*Trade) MarshalBinary

func (t *Trade) MarshalBinary() ([]byte, error)

func (*Trade) UnmarshalBinary

func (t *Trade) UnmarshalBinary(data []byte) error

type TradeInfo

type TradeInfo struct {
	Timestamp uint64          `json:"timestamp"`
	ID        crypto.Digest   `json:"id"`
	Confirmed bool            `json:"confirmed"`
	OrderType proto.OrderType `json:"type"`
	Price     Decimal         `json:"price"`
	Amount    Decimal         `json:"amount"`
	Buyer     proto.Address   `json:"buyer"`
	Seller    proto.Address   `json:"seller"`
	Matcher   proto.Address   `json:"matcher"`
}

TradeInfo is an API representation of the Trade

func NewTradeInfo

func NewTradeInfo(trade Trade, amountAssetPrecision, priceAssetPrecision uint) TradeInfo

type TradesByTimestampBackward

type TradesByTimestampBackward []TradeInfo

func (TradesByTimestampBackward) Len

func (a TradesByTimestampBackward) Len() int

func (TradesByTimestampBackward) Less

func (a TradesByTimestampBackward) Less(i, j int) bool

func (TradesByTimestampBackward) Swap

func (a TradesByTimestampBackward) Swap(i, j int)