data

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CandleSize       = 8 * 8
	Second           = 1000
	Minute           = 60 * Second
	DefaultTimeFrame = 5
	TimeFrame        = DefaultTimeFrame * Minute
)
View Source
const PriceConstant = 100000000
View Source
const (
	TradeSize = 1 + 3*crypto.DigestSize + 3*crypto.PublicKeySize + 8 + 8 + 8
)

Variables

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

Functions

func FromBurnV1

func FromBurnV1(scheme byte, tx proto.BurnV1) (AssetChange, AccountChange, error)

func FromBurnV2

func FromBurnV2(scheme byte, tx proto.BurnV2) (AssetChange, AccountChange, error)

func FromIssueV1

func FromIssueV1(scheme byte, tx proto.IssueV1) (IssueChange, AccountChange, error)

func FromIssueV2

func FromIssueV2(scheme byte, tx proto.IssueV2) (IssueChange, AccountChange, error)

func FromReissueV1

func FromReissueV1(scheme byte, tx proto.ReissueV1) (AssetChange, AccountChange, error)

func FromReissueV2

func FromReissueV2(scheme byte, tx proto.ReissueV2) (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 FromExchangeV1

func FromExchangeV1(scheme byte, tx proto.ExchangeV1) ([]AccountChange, error)

func FromExchangeV2

func FromExchangeV2(scheme byte, tx proto.ExchangeV2) ([]AccountChange, error)

func FromMassTransferV1

func FromMassTransferV1(scheme byte, tx proto.MassTransferV1) ([]AccountChange, error)

func FromTransferV1

func FromTransferV1(scheme byte, tx proto.TransferV1, miner crypto.PublicKey) ([]AccountChange, error)

func FromTransferV2

func FromTransferV2(scheme byte, tx proto.TransferV2, miner crypto.PublicKey) ([]AccountChange, error)

type AliasBind

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

func FromCreateAliasV1

func FromCreateAliasV1(scheme byte, tx proto.CreateAliasV1) (AliasBind, error)

func FromCreateAliasV2

func FromCreateAliasV2(scheme byte, tx proto.CreateAliasV2) (AliasBind, error)

type AssetChange

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

func FromSponsorshipV1

func FromSponsorshipV1(tx proto.SponsorshipV1) 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 (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 added in v0.3.0

func NewSymbolsFromFile(name string, oracle proto.Address) (*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 added in v0.3.0

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

func (*Symbols) UpdateFromOracle added in v0.3.0

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 NewTradeFromExchangeV1

func NewTradeFromExchangeV1(scheme byte, tx proto.ExchangeV1) (Trade, error)

func NewTradeFromExchangeV2

func NewTradeFromExchangeV2(scheme byte, tx proto.ExchangeV2) (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 (TradesByTimestampBackward) Less

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

func (TradesByTimestampBackward) Swap

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

Jump to

Keyboard shortcuts

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