data

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 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.WavesAddress{}
	WavesAssetInfo     = AssetInfo{ID: WavesID, Name: "WAVES", IssuerAddress: WavesIssuerAddress, Decimals: 8, Reissuable: false, Supply: 10000000000000000}
)

Functions

func FromBurnWithProofs added in v0.5.0

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

func FromBurnWithSig added in v0.5.0

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

func FromIssueWithProofs added in v0.5.0

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

func FromIssueWithSig added in v0.5.0

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

func FromReissueWithProofs added in v0.5.0

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

func FromReissueWithSig added in v0.5.0

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.WavesAddress
	Alias   proto.Alias
}

func (*Account) SetFromAddress added in v0.10.0

func (a *Account) SetFromAddress(scheme byte, address proto.Address) error

SetFromAddress set address to Account trying to convert proto.Address interface to proto.WavesAddress structure.

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 added in v0.5.0

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

func FromExchangeWithSig added in v0.5.0

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

func FromMassTransferWithProofs added in v0.5.0

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

func FromTransferWithProofs added in v0.5.0

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

func FromTransferWithSig added in v0.5.0

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

type AliasBind

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

func FromCreateAliasWithProofs added in v0.5.0

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

func FromCreateAliasWithSig added in v0.5.0

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 added in v0.5.0

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.WavesAddress
	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.WavesAddress, 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 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.WavesAddress
	Seller        proto.WavesAddress
	Matcher       proto.WavesAddress
	Price         uint64
	Amount        uint64
	Timestamp     uint64
}

func NewTradeFromExchangeWithProofs added in v0.5.0

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

func NewTradeFromExchangeWithSig added in v0.5.0

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.WavesAddress `json:"buyer"`
	Seller    proto.WavesAddress `json:"seller"`
	Matcher   proto.WavesAddress `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