models

package
v0.0.0-...-377db7b Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2018 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CandleGranularity1M  = 60
	CandleGranularity5M  = 300
	CandleGranularity15M = 900
	CandleGranularity1H  = 3600
	CandleGranularity6H  = 21600
	CandleGranularity1D  = 86400
)
View Source
const (
	MixinAssetId   = "c94ac88f-4671-3976-b60a-09064f1811e8"
	BitcoinAssetId = "c6d0c728-2624-429b-8e0d-d9d19b6592fa"
	USDTAssetId    = "815b0b1a-2764-3736-8faa-42d694fa620a"
)
View Source
const (
	VerificationCategoryPhone = "PHONE"
	VerificationCategoryEmail = "EMAIL"
)

Variables

This section is empty.

Functions

func CreateOrUpdateCandle

func CreateOrUpdateCandle(ctx context.Context, base, quote string, price, amount number.Decimal, createdAt time.Time) error

func CreateOrUpdateMarket

func CreateOrUpdateMarket(ctx context.Context, base, quote string, price, volume, total, change, quoteUSD float64) error

func ReadProperty

func ReadProperty(ctx context.Context, key string) (string, error)

func ReadPropertyAsTime

func ReadPropertyAsTime(ctx context.Context, key string) (time.Time, error)

func ValidateAndEncryptPassword

func ValidateAndEncryptPassword(ctx context.Context, password string) (string, error)

func ValidateEmailFormat

func ValidateEmailFormat(ctx context.Context, email string) (string, error)

func ValidatePhoneNumberFormat

func ValidatePhoneNumberFormat(ctx context.Context, phone string) (string, error)

func WriteProperty

func WriteProperty(ctx context.Context, key, value string) error

func WriteTimeProperty

func WriteTimeProperty(ctx context.Context, key string, value time.Time) error

Types

type Candle

type Candle struct {
	Base        string
	Quote       string
	Granularity int64
	Point       int64
	Open        float64
	Close       float64
	High        float64
	Low         float64
	Volume      float64
	Total       float64
}

func MarketCandles

func MarketCandles(ctx context.Context, base, quote string, granularity, limit int64) ([]*Candle, error)

type FavoriteMarket

type FavoriteMarket struct {
	UserId string
	Base   string
	Quote  string
}

type Key

type Key struct {
	UserId           string
	SessionId        string
	SessionKey       string
	PinToken         string
	EncryptedPIN     string
	EncryptionHeader []byte
	OceanKey         string
	CreatedAt        time.Time

	DecryptedPIN string
}

func (*Key) MixinToken

func (k *Key) MixinToken(ctx context.Context, uri string) (string, error)

func (*Key) OceanToken

func (k *Key) OceanToken(ctx context.Context) (string, error)

type Market

type Market struct {
	Base     string
	Quote    string
	Price    float64
	Volume   float64
	Total    float64
	Change   float64
	QuoteUSD float64

	IsLikedBy bool
}

func AggregateCandlesAsStats

func AggregateCandlesAsStats(ctx context.Context, base, quote string) (*Market, error)

func AllMarkets

func AllMarkets() []*Market

func GetMarket

func GetMarket(ctx context.Context, base, quote string) (*Market, error)

func ListActiveMarkets

func ListActiveMarkets(ctx context.Context, user *User) ([]*Market, error)

func ListMarkets

func ListMarkets(ctx context.Context, user *User) ([]*Market, error)

func (*Market) BaseSymbol

func (m *Market) BaseSymbol() string

func (*Market) QuoteSymbol

func (m *Market) QuoteSymbol() string

type OrderAction

type OrderAction struct {
	TraceId string `json:"trace_id"`
	Quote   string `json:"quote"`
	Base    string `json:"base"`
	Side    string `json:"side"`
	Price   string `json:"price"`
	Amount  string `json:"amount"`
	Funds   string `json:"funds"`
	Type    string `json:"type"`
}

type PoolKey

type PoolKey struct {
	UserId           string
	SessionId        string
	SessionKey       string
	PinToken         string
	EncryptedPIN     string
	EncryptionHeader []byte
	OceanKey         string
	CreatedAt        time.Time

	PlainPIN string
}

func GeneratePoolKey

func GeneratePoolKey(ctx context.Context) (*PoolKey, error)

type Property

type Property struct {
	Key       string
	Value     string
	UpdatedAt time.Time
}

type Session

type Session struct {
	UserId        string
	SessionId     string
	Secret        string
	RemoteAddress string
	ActiveAt      time.Time
	CreatedAt     time.Time
}

type User

type User struct {
	UserId            string
	Email             spanner.NullString
	Phone             spanner.NullString
	MixinId           spanner.NullString
	IdentityId        spanner.NullString
	FullName          string
	EncryptedPassword string
	ActiveAt          time.Time
	CreatedAt         time.Time

	SessionId string
	Key       *Key
}

func AuthenticateWithToken

func AuthenticateWithToken(ctx context.Context, jwtToken string) (*User, error)

func CreateOrResetUser

func CreateOrResetUser(ctx context.Context, verificationId, password, sessionSecret string) (*User, error)

func CreateSession

func CreateSession(ctx context.Context, receiver, password string, secret string) (*User, error)

func (*User) CancelOrder

func (current *User) CancelOrder(ctx context.Context, id string) error

func (*User) ConnectMixin

func (current *User) ConnectMixin(ctx context.Context, authorizationCode string) (*User, error)

func (*User) CreateOrder

func (current *User) CreateOrder(ctx context.Context, o *OrderAction) error

func (*User) CreateWithdrawal

func (current *User) CreateWithdrawal(ctx context.Context, assetId string, amount number.Decimal, traceId, memo string) error

func (*User) DislikeMarket

func (user *User) DislikeMarket(ctx context.Context, base, quote string) error

func (*User) LikeMarket

func (user *User) LikeMarket(ctx context.Context, base, quote string) (*FavoriteMarket, error)

func (*User) MixinIdentityNumber

func (current *User) MixinIdentityNumber() string

func (*User) UpdateName

func (current *User) UpdateName(ctx context.Context, name string) (*User, error)

type Verification

type Verification struct {
	VerificationId string
	Category       string
	Receiver       string
	Code           string
	Provider       string
	CreatedAt      time.Time
	VerifiedAt     spanner.NullTime
}

func CreateVerification

func CreateVerification(ctx context.Context, category, receiver string, recaptcha string) (*Verification, error)

func DoVerification

func DoVerification(ctx context.Context, id, code string) (*Verification, error)

Jump to

Keyboard shortcuts

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