fintypes

package
v0.0.0-...-85ff41b Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

README

FinTypes

Financial industry common types & functions.

Type Description
Kline K线 -
Period K线周期 -
Pair 交易对 -
Currency 货币 -
Account 账户 -
Order 订单 -
Depth 深度 -
Asset 资产 -
Fiat 法币 -
Coin 加密货币 -
Stock 股票 -
Index 指数 -
Precious Metal 贵金属 -

Documentation

Index

Constants

View Source
const (
	ExprOpen   = "O"
	ExprHigh   = "H"
	ExprLow    = "L"
	ExprClose  = "C"
	ExprVolume = "V"
)
View Source
const (
	ExApiGetKline = ExApi("ExApiGetKline")
	ExApiGetFill  = ExApi("ExApiGetFill")
)
View Source
const (
	OrderIdDelimiter = ":"

	OrderStatusError OrderStatus = ""
	// Pending is a status before 'new', indicates that the order has not been successfully created,
	// only some exchanges use it, like Kraken.
	OrderStatusPending           OrderStatus = "pending"
	OrderStatusNew               OrderStatus = "new"
	OrderStatusPartiallyFilled   OrderStatus = "partially_filled"
	OrderStatusFilled            OrderStatus = "filled"
	OrderStatusPartiallyCanceled OrderStatus = "partially_canceled" // binance没有这个状态,huobi有
	OrderStatusCanceled          OrderStatus = "canceled"
	OrderStatusCanceling         OrderStatus = "canceling"
	OrderStatusRejected          OrderStatus = "rejected"
	OrderStatusExpired           OrderStatus = "expired"

	OrderSideError     OrderSide = ""
	OrderSideBuyLong   OrderSide = "buy"
	OrderSideSellShort OrderSide = "sell"

	OrderTypeError            OrderType = ""
	OrderTypeLimit            OrderType = "limit"
	OrderTypeMarket           OrderType = "market"
	OrderTypeStopLossLimit    OrderType = "stop_loss_limit"    // Stop loss limit order.
	OrderTypeTakeProfitLimit  OrderType = "take_profit_limit"  // Take profit limit order.
	OrderTypeStopLossMarket   OrderType = "stop_loss_market"   // Stop loss market order.
	OrderTypeTakeProfitMarket OrderType = "take_profit_market" // Take profit market order.

	TradeIntentError  TradeIntent = ""
	TradeIntentOpen   TradeIntent = "open"   // 开仓进场
	TradeIntentReduce TradeIntent = "reduce" // 减仓
	TradeIntentAdd    TradeIntent = "add"    // 加仓
	TradeIntentClose  TradeIntent = "close"  // 平仓离场
	TradeIntentAdjust TradeIntent = "adjust" // 调整限价单/止盈止损单的点位

	TradeIncomeError  TradeIncome = ""
	TradeIncomeLoss   TradeIncome = "loss"   // 止损
	TradeIncomeProfit TradeIncome = "profit" // 止盈
)
View Source
const (
	PairErr = Pair("")

	PairIErr   = PairI("")
	PairMErr   = PairM("")
	PairPErr   = PairP("")
	PairIMErr  = PairIM("")
	PairMPErr  = PairMP("")
	PairIPErr  = PairIP("")
	PairIMPErr = PairIMP("")
)

Variables

View Source
var (

	// famous quote coins
	BTC  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Bitcoin", "BTC", "", true})
	LTC  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Litecoin", "LTC", "", true})
	ETH  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Ethereum", "ETH", "", true})
	EOS  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "EOS", "EOS", "", true})
	ZRX  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "0x", "ZRX", "", true})
	BNB  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "BinanceCoin", "BNB", "", true})
	ETC  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Ethereum-Classic", "ETC", "", true})
	TRX  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Tron", "TRX", "", true})
	DOGE = mustEnrollAsset(AssetSetting{AssetTypeCoin, "DogeCoin", "DOGE", "", true})
	XLM  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Stellar", "XLM", "", true})
	XRP  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Ripple", "XRP", "", true})

	// famous common coins
	AION = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Aion", "AION", "", false})
	WAN  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "WanCoin", "WAN", "", false})
	FSN  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Fusion", "FSN", "", false})
	HOLO = mustEnrollAsset(AssetSetting{AssetTypeCoin, "HoloToken", "HOT", "", false})
	DCR  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Decred", "DCR", "", false})
	POA  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "POA-Network", "POA", "", false})
	DFN  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Dfinity", "DFN", "", false})
	AE   = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Aeternity", "AE", "", false})
	DOT  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Polkadot", "DOT", "", false})
	ADA  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Cardano", "ADA", "", false})
	RHOC = mustEnrollAsset(AssetSetting{AssetTypeCoin, "RChain", "RHOC", "", false})
	ICX  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "ICON", "ICX", "", false})
	NANO = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Nano", "NANO", "", false})
	ZEC  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "ZenCash", "ZEC", "", false})
	GRIN = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Grin", "GRIN", "", false})

	// stable coins
	USDC = mustEnrollAsset(AssetSetting{AssetTypeCoin, "USD-Coin", "USDC", "USD", true})
	USDT = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Tether", "USDT", "USD", true})
	USDS = mustEnrollAsset(AssetSetting{AssetTypeCoin, "StableUSD", "USDS", "USD", true})
	TUSD = mustEnrollAsset(AssetSetting{AssetTypeCoin, "TrueUSD", "TUSD", "USD", true})
	PAX  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "Paxos-Standard-Token", "PAX", "USD", true})
	DAI  = mustEnrollAsset(AssetSetting{AssetTypeCoin, "DAI", "DAI", "USD", true})
	BUSD = mustEnrollAsset(AssetSetting{AssetTypeCoin, "BinanceUSD", "BUSD", "USD", true})
	BKRW = mustEnrollAsset(AssetSetting{AssetTypeCoin, "BinanceKRW", "BKRW", "KRW", true})
	BIDR = mustEnrollAsset(AssetSetting{AssetTypeCoin, "BinanceIDR", "BIDR", "IDR", true})

	// G10 currencies
	USD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.USD.String(), "", "", true}) // US Dollar ($)
	EUR = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.EUR.String(), "", "", true}) // Euro (€)
	JPY = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.JPY.String(), "", "", true}) // Japanese Yen (¥)
	GBP = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.GBP.String(), "", "", true}) // British Pound Sterling (£)
	CHF = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.CHF.String(), "", "", true}) // Swiss Franc (CHF)
	AUD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.AUD.String(), "", "", true}) // Australian Dollar, AUD (A$)
	NZD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.NZD.String(), "", "", true}) // New Zealand Dollar (NZ$)
	CAD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.CAD.String(), "", "", true}) // Canadian Dollar, CAD (C$)
	SEK = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.SEK.String(), "", "", true}) // Swedish Krona (SEK)
	NOK = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.NOK.String(), "", "", true}) // Norwegian Krone (NOK)

	//  non-famous quote currencies
	NGN = mustEnrollAsset(AssetSetting{AssetTypeFiat, "NGN", "", "", true})                 // Nigerian Naira (NGN)
	TRY = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.TRY.String(), "", "", true}) // Turkish Lira, TRY(₺)

	// Additional common currencies
	BRL = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.BRL.String(), "", "", false}) // Brazilian Real (R$)
	CNY = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.CNY.String(), "", "", false}) // Chinese Yuan (CN¥)
	DKK = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.DKK.String(), "", "", false}) // Danish Krone (DKK)
	INR = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.INR.String(), "", "", false}) // Indian Rupee (Rs.)
	RUB = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.RUB.String(), "", "", false}) // Russian Ruble (RUB)
	HKD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.HKD.String(), "", "", false}) // Hong Kong Dollar (HK$)
	IDR = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.IDR.String(), "", "", false}) // Indonesian Rupiah (IDR)
	KRW = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.KRW.String(), "", "", false}) // South Korean Won (₩)
	MXN = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.MXN.String(), "", "", false}) // Mexican Peso (MX$)
	PLN = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.PLN.String(), "", "", false}) // Polish Zloty (PLN)
	SAR = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.SAR.String(), "", "", false}) // Saudi Riyal (SAR)
	THB = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.THB.String(), "", "", false}) // Thai Baht (฿)
	TWD = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.TWD.String(), "", "", false}) // New Taiwan dollar, TWD (NT$)
	ZAR = mustEnrollAsset(AssetSetting{AssetTypeFiat, currency.ZAR.String(), "", "", false}) // South African Rand (ZAR)

	// precious metal
	XAU = mustEnrollAsset(AssetSetting{AssetTypeMetal, "xau", "", "", false}) // gold
	XAG = mustEnrollAsset(AssetSetting{AssetTypeMetal, "xag", "", "", false}) // silver
	XPT = mustEnrollAsset(AssetSetting{AssetTypeMetal, "xpt", "", "", false}) // platinum
	XPD = mustEnrollAsset(AssetSetting{AssetTypeMetal, "xpd", "", "", false}) // Palladium
)

famous assets

View Source
var (
	KlineDeepCopy  = false // if set it true, will cost about 2.5x time than false
	KInternalExprs = []string{ExprOpen, ExprHigh, ExprLow, ExprClose, ExprVolume}
)
View Source
var (
	ErrFunctionNotSupported = gerrors.Errorf("function not supported")
	AllSupportedExs         = []Platform{Binance}
)
View Source
var (
	IndexDJI, _  = NewAsset("i.dji")  // Dow Jones Industrial Average (^DJI)
	IndexSP, _   = NewAsset("i.sp")   // S&P 500 (^GSPC)
	IndexIXIC, _ = NewAsset("i.ixic") // NASDAQ Composite (^IXIC)
	IndexNYA, _  = NewAsset("i.nya")  // NYSE Composite (^NYA)
	IndexRUT, _  = NewAsset("i.rut")  // Russell 2000 (^RUT)
	IndexVIX, _  = NewAsset("i.vix")  // CBOE Volatility Index (^VIX)
	IndexSHH, _  = NewAsset("i.shh")  // SSE Composite Index (000001.SS), 上证指数
)
View Source
var (
	MarginError    = Margin("")
	MarginNo       = enrollNewMargin("no")       // 无杠杆
	MarginIsolated = enrollNewMargin("isolated") // 逐仓
	MarginCross    = enrollNewMargin("cross")    // 全仓
)
View Source
var (
	MarketError  Market = ""
	MarketSpot          = enrollNewMarket("spot")
	MarketFuture        = enrollNewMarket("future")
	MarketPerp          = enrollNewMarket("perp") // Perpetual Swap
	MarketOption        = enrollNewMarket("option")
)
View Source
var (
	NASDAQOpenDate, _ = gtime.NewDate(1971, 2, 4)
	NYSEOpenDate, _   = gtime.NewDate(1817, 3, 8)
	AMEXOpenDate, _   = gtime.NewDate(1971, 2, 8) // https://www.loc.gov/rr/business/amex/amex.html
	SSEOpenDate, _    = gtime.NewDate(1990, 12, 19)
	SZSEOpenDate, _   = gtime.NewDate(1991, 7, 3)
	HKEXOpenDate, _   = gtime.NewDate(1891, 2, 3) // https://www.ximalaya.com/shangye/22958651/178058751
	TwOpenDate, _     = gtime.NewDate(1962, 2, 9)

	PlatformUnknown = Platform("")
	PlatformOpen    = enrollPlatform("open", PlatformInfo{Support: []AssetType{AssetTypeCoin, AssetTypeStock, AssetTypeIndex, AssetTypeMetal}, OpenDate: 0})  // fake platform for internet finance data like gold price
	PlatformIndex   = enrollPlatform("index", PlatformInfo{Support: []AssetType{AssetTypeCoin, AssetTypeStock, AssetTypeIndex, AssetTypeMetal}, OpenDate: 0}) // fake platform for all indexes

	// 第三方金融数据平台
	CryptoCompare = enrollPlatform("cryptocompare", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	DataHub       = enrollPlatform("datahub", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	YahooFinance  = enrollPlatform("yahoofinance", PlatformInfo{Support: []AssetType{AssetTypeCoin, AssetTypeStock}, OpenDate: 0})
	GoogleFinance = enrollPlatform("googlefinance", PlatformInfo{Support: []AssetType{AssetTypeCoin, AssetTypeStock}, OpenDate: 0})
	CoinMarketCap = enrollPlatform("coinmarketcap", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	CoinGecko     = enrollPlatform("coingecko", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})

	// 国内加密货币市场
	Binance = enrollPlatform("binance", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	Huobi   = enrollPlatform("huobi", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	Okex    = enrollPlatform("okex", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	Gate    = enrollPlatform("gate", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})

	// 美国证券市场
	Nasdaq = enrollPlatform("nasdaq", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: NASDAQOpenDate})
	Nyse   = enrollPlatform("nyse", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: NYSEOpenDate})
	Amex   = enrollPlatform("amex", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: AMEXOpenDate}) // belongs to NYSE now

	// 中国期货市场
	Shfe = enrollPlatform("shfe", PlatformInfo{Support: []AssetType{AssetTypeUnknown}, OpenDate: gtime.NewDatePanic(1990, 11, 26)}) // 上海期货交易所
	Czce = enrollPlatform("czce", PlatformInfo{Support: []AssetType{AssetTypeUnknown}, OpenDate: gtime.NewDatePanic(1990, 10, 12)}) // 郑州商品交易所
	Dce  = enrollPlatform("dce", PlatformInfo{Support: []AssetType{AssetTypeUnknown}, OpenDate: gtime.NewDatePanic(1993, 2, 28)})   // 大连商品交易所

	// 国外加密货币市场
	Kraken  = enrollPlatform("kraken", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	Deribit = enrollPlatform("deribit", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	UniSwap = enrollPlatform("uniswap", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})
	Ftx     = enrollPlatform("ftx", PlatformInfo{Support: []AssetType{AssetTypeCoin}, OpenDate: 0})

	// 中国证券市场
	Szse = enrollPlatform("szse", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: SZSEOpenDate}) // Shen Zhen Stock Exchange
	Sse  = enrollPlatform("sse", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: SSEOpenDate})   // Shanghai Stock Exchange
	Hkex = enrollPlatform("hkex", PlatformInfo{Support: []AssetType{AssetTypeStock}, OpenDate: HKEXOpenDate}) // Hong Kong Exchange

)
View Source
var (
	AssetNil = Asset("")
)
View Source
var (
	PricePiercing = gdecimal.NewFromInt(-1)
)

Functions

func CurrencyCodesHistorical

func CurrencyCodesHistorical() []currency.Unit

func CurrencyCodesNow

func CurrencyCodesNow() []currency.Unit

func CurrencyGetSymbol

func CurrencyGetSymbol(unit currency.Unit) string

Returns $ like UTF8 string

func CurrencyIsFiat

func CurrencyIsFiat(unit currency.Unit) bool

func CurrencyIsMetal

func CurrencyIsMetal(unit currency.Unit) bool

func CurrencyIsTest

func CurrencyIsTest(unit currency.Unit) bool

func CurrencyParse

func CurrencyParse(s string) (currency.Unit, error)

Support ISO currency name and symbol 注意,有些常见的Symbol是简化的不完整版本,会在多个法币的完整Symbol中出现,比如¥和$

func FindSamePairs

func FindSamePairs(pairs map[Platform][]Pair) map[Pair][]Platform

find same Pairs between exchanges

func FixCoinName

func FixCoinName(name string) string

Fix coin name like "bytom"

func FixCoinSymbol

func FixCoinSymbol(symbol string) string

Fix coin symbols like "BTM*"

func FixNameSymbol

func FixNameSymbol(s string) string

Fix error coin names like "Ethereum (ETH)" or "FileCoin [Future]", they are data source error.

func GetTotalAmount

func GetTotalAmount(input []OrderBook) gdecimal.Decimal

获取挂单中币的总量

func GetTotalPrice

func GetTotalPrice(input []OrderBook) gdecimal.Decimal

获取挂单中(如果都成交)基准货币的总量

func IsTradeSymbolFiat

func IsTradeSymbolFiat(sym string) bool

func NewPairExt

func NewPairExt(p Pair, period *Period, market *Market, platform *Platform) pairExt

func PairExtsEqual

func PairExtsEqual(a []pairExt, b []pairExt) bool

func PairExtsInclude

func PairExtsInclude(src []pairExt, find pairExt) bool

func PairExtsSort

func PairExtsSort(src []pairExt)

func PairMPEqual

func PairMPEqual(a []PairMP, b []PairMP) bool

func PairMPInclude

func PairMPInclude(src []PairMP, find PairMP) bool

func PairMPSort

func PairMPSort(src []PairMP)

func ParsePairExtString

func ParsePairExtString(s string) (Pair, *Period, *Market, *Platform, error)

TODO 也许需要提高性能

func RoundPeriodEarlier

func RoundPeriodEarlier(dotTime time.Time, period Period, prc PeriodRoundConfig) time.Time

根据给定时间和周期值,计算它归属于哪个OpenTime的周期 get kline dot open time by dotTime

func SyncXAxis

func SyncXAxis(ks1, ks2 *CandleSticks, fillIfNotExist Bar)

Types

type AR

type AR struct {
	LHS
	RHS
}

K Association Rule

func (*AR) IsLong

func (ar *AR) IsLong() bool

func (*AR) IsShort

func (ar *AR) IsShort() bool

func (*AR) PatternRHS

func (ar *AR) PatternRHS() PatternRHS

type ARs

type ARs struct {
	Items []AR
}

K Association Rules

func (*ARs) Parse

func (ars *ARs) Parse() *Patterns

type Account

type Account struct {
	Balances []Balance
}

func NewEmptyAccount

func NewEmptyAccount() *Account

func NewTestAccount

func NewTestAccount(assets []string, totalInUSD gdecimal.Decimal, ticks Ticks) (*Account, error)

func (*Account) AddAccount

func (a *Account) AddAccount(toAdd Account)

func (*Account) AddFree

func (a *Account) AddFree(ap AssetProperty, toAdd gdecimal.Decimal)

增加余额,如果已经有相关条目就着做加法,如果没有则新增

func (*Account) AddLock

func (a *Account) AddLock(ap AssetProperty, toAdd gdecimal.Decimal)

func (*Account) Borrow

func (a *Account) Borrow(tm time.Time, margin Margin, asset string, amount gdecimal.Decimal) error

只支持现货杠杆

func (*Account) ExchangeToUSD

func (a *Account) ExchangeToUSD(ticks Ticks, ignorePairsNotFound bool) (*AssetAmount, error)

换算成USD 计算的用途是统计回报的相关指标

func (*Account) GetAmountByName

func (a *Account) GetAmountByName(asset string) AssetAmount

根据资产名称获取总数量

func (*Account) GetAmountByProperty

func (a *Account) GetAmountByProperty(ap AssetProperty) AssetAmount

根据资产属性(market、margin、名称等等)获取数量

func (*Account) JsonString

func (a *Account) JsonString() string

func (*Account) Lock

func (a *Account) Lock(market Market, margin Margin, asset string, amount gdecimal.Decimal) error

func (*Account) RemoveZeroMembers

func (a *Account) RemoveZeroMembers()

清除为0的成员,用于Transfer等操作之后清除没必要显示的成员

func (*Account) Repay

func (a *Account) Repay(tm time.Time, interestRateDaily gdecimal.Decimal, margin Margin, asset string, toRepay gdecimal.Decimal) error

func (*Account) SetAmount

func (a *Account) SetAmount(ap AssetProperty, amount AssetAmount)

upsert new balance item

func (*Account) SetFreeAmount

func (a *Account) SetFreeAmount(ap AssetProperty, freeAmount gdecimal.Decimal)

upsert free amount

func (*Account) SetLockedAmount

func (a *Account) SetLockedAmount(ap AssetProperty, lockedAmount gdecimal.Decimal)

upsert locked amount

func (*Account) String

func (a *Account) String() string

func (*Account) Transfer

func (a *Account) Transfer(asset string, amount gdecimal.Decimal, from, to SubAcc) error

func (*Account) Unlock

func (a *Account) Unlock(ap AssetProperty, amount gdecimal.Decimal) error

type AccountAddress

type AccountAddress string

example: buffett@gmail.com@binance

const (
	AccountAddressNull AccountAddress = ""
)

func NewAccountAddress

func NewAccountAddress(email string, platform Platform) AccountAddress

func ParseAccountAddress

func ParseAccountAddress(s string) (AccountAddress, error)

func (AccountAddress) Email

func (tai AccountAddress) Email() string

func (AccountAddress) MarshalJSON

func (tai AccountAddress) MarshalJSON() ([]byte, error)

func (AccountAddress) Platform

func (tai AccountAddress) Platform() Platform

func (AccountAddress) String

func (tai AccountAddress) String() string

func (*AccountAddress) UnmarshalJSON

func (tai *AccountAddress) UnmarshalJSON(b []byte) error

type AccountSnapshot

type AccountSnapshot struct {
	Time   time.Time
	Asset  Asset       `json:"Asset, omitempty"` // 计算Total时用的的Fiat,通常是USD
	Total  AssetAmount // 统计得来的法币总值,用于回测计算收益指标等
	Detail Account
}

func (*AccountSnapshot) Add

func (as *AccountSnapshot) Add(toAdd AccountSnapshot)

type Asset

type Asset string

func AllFiats

func AllFiats() []Asset

func AllIndexes

func AllIndexes() []Asset

func AllMetals

func AllMetals() []Asset

func AllQuoteAssets

func AllQuoteAssets() []Asset

func AllQuoteCoins

func AllQuoteCoins() []Asset

func AllStableCoins

func AllStableCoins() []Asset

func NewAsset

func NewAsset(sdn string) (Asset, error)

sdn: self desc name

func NewCoin

func NewCoin(name, symbol string, plt Platform) Asset

func NewCoinWithSymbol

func NewCoinWithSymbol(symbol string, plt Platform) Asset

func NewStock

func NewStock(symbol string, exchange Platform) Asset

func ParseFiat

func ParseFiat(s string) (Asset, error)

Support ISO currency name and symbol 注意,有些常见的Symbol是简化的不完整版本,会在多个法币的完整Symbol中出现,比如¥和$

func StableCoinsByFiat

func StableCoinsByFiat(anchorFiat Asset) []Asset

func (Asset) Against

func (a Asset) Against(quote Asset) Pair

func (Asset) Equal

func (a Asset) Equal(cmp Asset) bool

func (Asset) MarshalJSON

func (a Asset) MarshalJSON() ([]byte, error)

func (Asset) Name

func (a Asset) Name() string

can't find name from stock type Asset

func (Asset) String

func (a Asset) String() string

func (Asset) Symbol

func (a Asset) Symbol() string

func (Asset) ToCoin

func (a Asset) ToCoin() (platform Platform, name, symbol string, ok bool)

func (Asset) ToFiat

func (a Asset) ToFiat() (string, bool)

func (Asset) ToFiatUnit

func (a Asset) ToFiatUnit() (currency.Unit, bool)

func (Asset) ToIndex

func (a Asset) ToIndex() (string, bool)

func (Asset) ToMetal

func (a Asset) ToMetal() (string, bool)

func (Asset) ToStock

func (a Asset) ToStock() (exchange Platform, symbol string, ok bool)

func (Asset) TradeSymbol

func (a Asset) TradeSymbol() string

Trade symbol of assets, in fiat Trade Symbol is Name but not symbol

func (Asset) Type

func (a Asset) Type() AssetType

func (*Asset) UnmarshalJSON

func (a *Asset) UnmarshalJSON(b []byte) error

type AssetAmount

type AssetAmount struct {
	// 沿用现货的成员
	Free     gdecimal.Decimal `json:"Free"`     // available,可操作买卖,但不一定可以提现
	Locked   gdecimal.Decimal `json:"Locked"`   //
	Borrowed gdecimal.Decimal `json:"Borrowed"` // to repay, only available in margin account
	Interest gdecimal.Decimal `json:"Interest"` // only available in margin account
}

资产数量

func (*AssetAmount) Add

func (b *AssetAmount) Add(toAdd AssetAmount)

func (*AssetAmount) Net

func (b *AssetAmount) Net() gdecimal.Decimal

净值

func (*AssetAmount) ToRepay

func (b *AssetAmount) ToRepay() gdecimal.Decimal

需要还的

type AssetProperty

type AssetProperty struct {
	Market           Market // 属于哪个市场
	Margin           Margin
	CustomSubAccName string // 自定义子账户名称
	Asset            string
}

资产属性

func NewAP

func NewAP(market Market, margin Margin, asset string) AssetProperty

type AssetSetting

type AssetSetting struct {
	AssetType   AssetType
	Name        string
	Symbol      string
	AnchorFiat  string
	UsedAsQuote bool
}

type AssetType

type AssetType string
const (
	AssetTypeUnknown AssetType = "unknown"
	AssetTypeFiat    AssetType = "fiat"
	AssetTypeMetal   AssetType = "metal"
	AssetTypeStock   AssetType = "stock"
	AssetTypeIndex   AssetType = "index"
	AssetTypeCoin    AssetType = "coin"
)

type Balance

type Balance struct {
	AssetProperty          // 资产属性
	AssetAmount            // 资产数量
	BorrowHist    []Borrow // 现货杠杆才有,用于回测
}

余额记录,一个特定市场特定杠杆类型下特定资产对应一个BTBalance

func (*Balance) Add

func (b *Balance) Add(toAdd Balance) error

func (*Balance) AssetPropertyEquals

func (b *Balance) AssetPropertyEquals(ap AssetProperty) bool

func (*Balance) BorrowedByHist

func (b *Balance) BorrowedByHist() gdecimal.Decimal

func (*Balance) InterestByHist

func (b *Balance) InterestByHist(tm time.Time, interestRateDaily gdecimal.Decimal) gdecimal.Decimal

func (*Balance) IsZero

func (b *Balance) IsZero() bool

func (Balance) Len

func (b Balance) Len() int

按borrows的时间排序

func (Balance) Less

func (b Balance) Less(i, j int) bool

func (Balance) Swap

func (b Balance) Swap(i, j int)

func (*Balance) VerifyAssetProperty

func (b *Balance) VerifyAssetProperty(ap AssetProperty) error

验证资产种类,如果Market、Margin、CustomSubAccName、Asset不同则返回错误

type Bar

type Bar struct {
	T          time.Time          `json:"_id" bson:"_id" csv:"_id"`                         // Statistic begin time.
	O          gdecimal.Decimal   `json:"O,omitempty" bson:"O,omitempty" csv:"O,omitempty"` // Open price.
	L          gdecimal.Decimal   `json:"L,omitempty" bson:"L,omitempty" csv:"L,omitempty"` // Lowest price.
	H          gdecimal.Decimal   `json:"H,omitempty" bson:"H,omitempty" csv:"H,omitempty"` // Highest price.
	C          gdecimal.Decimal   `json:"C,omitempty" bson:"C,omitempty" csv:"C,omitempty"` // Close price.
	V          gdecimal.Decimal   `json:"V,omitempty" bson:"V,omitempty" csv:"V,omitempty"` // Volume in unit asset, always. It is 'BTC' in 'BTC/USD' pair.
	E          *time.Time         `json:"E,omitempty" bson:"E,omitempty" csv:"E,omitempty"` // Close time, it is useful in last entry in candle sticks.
	Indicators map[string]float64 `json:"Indicators,omitempty" bson:"Indicators,omitempty" csv:"Indicators,omitempty"`
}

func (*Bar) ExprValue

func (d *Bar) ExprValue(expr string) (gdecimal.Decimal, bool)

TODO: 需要吗

func (*Bar) ExprValueFloat64

func (d *Bar) ExprValueFloat64(expr string) (float64, bool)

func (Bar) GetId

func (d Bar) GetId() (gdecimal.Decimal, error)

func (Bar) GetTime

func (d Bar) GetTime() (time.Time, error)

func (*Bar) IsCrossLine

func (d *Bar) IsCrossLine() bool

TODO: 需要吗

func (*Bar) IsNegativeLine

func (d *Bar) IsNegativeLine() bool

TODO: 需要吗

func (*Bar) IsPositiveLine

func (d *Bar) IsPositiveLine() bool

TODO: 需要吗

type Borrow

type Borrow struct {
	Time      time.Time        // 借入时间
	Principal gdecimal.Decimal // 本金
}

一条现货杠杆借贷记录

func (*Borrow) Interest

func (b *Borrow) Interest(tm time.Time, interestRateDaily gdecimal.Decimal) gdecimal.Decimal

某一笔借款的利息

type CandleSticks

type CandleSticks struct {
	Pair  PairIMP // 原始K线的周期
	Items []Bar   // 原始K线数据
	// contains filtered or unexported fields
}

Bar items for Global

func NewAndCopyBasicInfo

func NewAndCopyBasicInfo(src *CandleSticks) *CandleSticks

func NewKline

func NewKline(pair PairIMP, dots []Bar) *CandleSticks

func (*CandleSticks) AcrossDays

func (k *CandleSticks) AcrossDays() float64

func (*CandleSticks) BeforeEqualClosest

func (k *CandleSticks) BeforeEqualClosest(tm time.Time) (item *Bar, exists bool)

TODO 用sort.Search改造? 找出在指定时间tm之前,且与tm时间间隔最小的Kline条目

func (*CandleSticks) CleanHMS

func (k *CandleSticks) CleanHMS(loc *time.Location) *CandleSticks

func (*CandleSticks) Clone

func (k *CandleSticks) Clone() *CandleSticks

todo: test required note: 使用 nk := *k; return nk 这样是无法深度拷贝k的

func (*CandleSticks) Close

func (k *CandleSticks) Close(i int) float64

func (*CandleSticks) CloseRaw

func (k *CandleSticks) CloseRaw(i int) gdecimal.Decimal

func (*CandleSticks) CloseValues

func (k *CandleSticks) CloseValues() []float64

func (*CandleSticks) Closes

func (k *CandleSticks) Closes() []gdecimal.Decimal

func (*CandleSticks) DetectPeriod

func (k *CandleSticks) DetectPeriod() Period

func (*CandleSticks) ExprValues

func (k *CandleSticks) ExprValues(expr string) ([]float64, error)

func (*CandleSticks) Exprs

func (k *CandleSticks) Exprs() []string

func (*CandleSticks) ExprsOfIndExpr

func (k *CandleSticks) ExprsOfIndExpr(ie ta.IndExpr) []string

是否有指标表达式的值,比如Kline中有MACD(12,9,3).Mid,ie=MACD(12,9,3),那么就返回true

func (*CandleSticks) First

func (k *CandleSticks) First() (Bar, bool)

func (*CandleSticks) FirstDay

func (k *CandleSticks) FirstDay(tz *time.Location) gtime.Date

func (*CandleSticks) FirstTime

func (k *CandleSticks) FirstTime(defIfEmpty time.Time) time.Time

First T

func (*CandleSticks) FirstTimeEx

func (k *CandleSticks) FirstTimeEx() (last *time.Time, exists bool)

Min time in records

func (*CandleSticks) GetDoc

func (k *CandleSticks) GetDoc(i int) TimeDoc

func (*CandleSticks) GetName

func (k *CandleSticks) GetName() string

func (*CandleSticks) HasDuplicatedKeys

func (k *CandleSticks) HasDuplicatedKeys() ([]time.Time, bool)

func (*CandleSticks) HasExpr

func (k *CandleSticks) HasExpr(expr string) bool

func (*CandleSticks) HasTime

func (k *CandleSticks) HasTime(tm time.Time) bool

func (*CandleSticks) High

func (k *CandleSticks) High(i int) float64

func (*CandleSticks) HighRaw

func (k *CandleSticks) HighRaw(i int) gdecimal.Decimal

func (*CandleSticks) HighValues

func (k *CandleSticks) HighValues() []float64

func (*CandleSticks) Highs

func (k *CandleSticks) Highs() []gdecimal.Decimal

func (*CandleSticks) IndexEqual

func (k *CandleSticks) IndexEqual(t time.Time) (int, Bar, bool)

search index whose T == t

func (*CandleSticks) IndicatorExps

func (k *CandleSticks) IndicatorExps() []string

func (*CandleSticks) IsConsequentDayLine

func (k *CandleSticks) IsConsequentDayLine() bool

func (*CandleSticks) IsTimeOverlappingAreaEqual

func (k *CandleSticks) IsTimeOverlappingAreaEqual(cmp *CandleSticks) (equal bool)

compare data of same timestamp items, time different items between them are ignored

func (*CandleSticks) Last

func (k *CandleSticks) Last() (Bar, bool)

func (*CandleSticks) LastClose

func (k *CandleSticks) LastClose(defIfEmpty gdecimal.Decimal) gdecimal.Decimal

func (*CandleSticks) LastCloseTime

func (k *CandleSticks) LastCloseTime(defTime time.Time) time.Time

最后一根Bar的收线时间,用于判断最后一根线是否及时,尤其是K线周期比较大时,这个数据可以表示最后一根Bar的时效性 如果没有记录E,则使用T代替E

func (*CandleSticks) LastDay

func (k *CandleSticks) LastDay(tz *time.Location) gtime.Date

func (*CandleSticks) LastExprValue

func (k *CandleSticks) LastExprValue(expr string) (float64, error)

func (*CandleSticks) LastExprs

func (k *CandleSticks) LastExprs() []string

func (*CandleSticks) LastLow

func (k *CandleSticks) LastLow(defIfEmpty gdecimal.Decimal) gdecimal.Decimal

func (*CandleSticks) LastTime

func (k *CandleSticks) LastTime(defIfEmpty time.Time) time.Time

Last open time T

func (*CandleSticks) LastTimeEx

func (k *CandleSticks) LastTimeEx() (last *time.Time, exists bool)

Max time in records

func (*CandleSticks) Len

func (k *CandleSticks) Len() int

func (*CandleSticks) Less

func (k *CandleSticks) Less(i, j int) bool

func (*CandleSticks) Low

func (k *CandleSticks) Low(i int) float64

func (*CandleSticks) LowRaw

func (k *CandleSticks) LowRaw(i int) gdecimal.Decimal

func (*CandleSticks) LowValues

func (k *CandleSticks) LowValues() []float64

func (*CandleSticks) Lows

func (k *CandleSticks) Lows() []gdecimal.Decimal

func (*CandleSticks) MaxIndex

func (k *CandleSticks) MaxIndex() int

func (*CandleSticks) MaxIndexLT

func (k *CandleSticks) MaxIndexLT(t time.Time) int

search max index whose T < t, index whose T == t is NOT included

func (*CandleSticks) MaxIndexLTE

func (k *CandleSticks) MaxIndexLTE(t time.Time) int

TODO test required search max index whose T <= t, index whose T == t is included

func (*CandleSticks) Merge

func (k *CandleSticks) Merge() Bar

func (*CandleSticks) MinIndexGT

func (k *CandleSticks) MinIndexGT(t time.Time) int

search min index whose T > t, index whose T == t is NOT included

func (*CandleSticks) MinIndexGTE

func (k *CandleSticks) MinIndexGTE(t time.Time) int

search min index whose T is >= t, index whose T == t is included if result <= k.Len() - 1 && k.items[result].T == t, there is a dot whose time is t otherwise not found, but result still means which index is mostly close to t

func (*CandleSticks) Open

func (k *CandleSticks) Open(i int) float64

func (*CandleSticks) OpenRaw

func (k *CandleSticks) OpenRaw(i int) gdecimal.Decimal

func (*CandleSticks) OpenValues

func (k *CandleSticks) OpenValues() []float64

func (*CandleSticks) Opens

func (k *CandleSticks) Opens() []gdecimal.Decimal

func (*CandleSticks) RemoveTail

func (k *CandleSticks) RemoveTail(n int) *CandleSticks

func (*CandleSticks) Set

func (k *CandleSticks) Set(newKs *CandleSticks)

func (*CandleSticks) SetIndicatorValue

func (k *CandleSticks) SetIndicatorValue(indExpr ta.IndExpr, subItemName string, values []float64) error

func (*CandleSticks) SliceAfter

func (k *CandleSticks) SliceAfter(gt time.Time) *CandleSticks

select item which time before 'lte'

func (*CandleSticks) SliceAfterEqual

func (k *CandleSticks) SliceAfterEqual(gte time.Time) *CandleSticks

select item which time before or equal 'lte'

func (*CandleSticks) SliceBefore

func (k *CandleSticks) SliceBefore(lt time.Time) *CandleSticks

TODO: test required select item which time before or equal 'lte'

func (*CandleSticks) SliceBeforeEqual

func (k *CandleSticks) SliceBeforeEqual(lte time.Time) *CandleSticks

TODO: test required select item which time before or equal 'lte'

func (*CandleSticks) SliceBetween

func (k *CandleSticks) SliceBetween(gt, lt time.Time) *CandleSticks

TODO test required fixme 有问题

func (*CandleSticks) SliceBetweenEqual

func (k *CandleSticks) SliceBetweenEqual(gte, lte time.Time) *CandleSticks

TODO test required

func (*CandleSticks) SliceBetweenId

func (k *CandleSticks) SliceBetweenId(gte, lte int) *CandleSticks

func (*CandleSticks) SliceHead

func (k *CandleSticks) SliceHead(n int) *CandleSticks

func (*CandleSticks) SliceTail

func (k *CandleSticks) SliceTail(n int) *CandleSticks

func (*CandleSticks) Sort

func (k *CandleSticks) Sort()

func (*CandleSticks) SortClose

func (k *CandleSticks) SortClose()

func (*CandleSticks) SortCloseReverse

func (k *CandleSticks) SortCloseReverse()

func (*CandleSticks) SortHigh

func (k *CandleSticks) SortHigh()

func (*CandleSticks) SortHighReverse

func (k *CandleSticks) SortHighReverse()

func (*CandleSticks) SortLow

func (k *CandleSticks) SortLow()

func (*CandleSticks) SortLowReverse

func (k *CandleSticks) SortLowReverse()

func (*CandleSticks) SortOpen

func (k *CandleSticks) SortOpen()

func (*CandleSticks) SortOpenReverse

func (k *CandleSticks) SortOpenReverse()

func (*CandleSticks) String

func (k *CandleSticks) String() string

func (*CandleSticks) Swap

func (k *CandleSticks) Swap(i, j int)

func (*CandleSticks) TA

func (k *CandleSticks) TA() *KTA

func (*CandleSticks) Time

func (k *CandleSticks) Time(i int) time.Time

implement TimeSeries and Series(in github.com/iwat) interface

func (*CandleSticks) TimeOverlappingArea

func (k *CandleSticks) TimeOverlappingArea(cmp *CandleSticks) (exist bool, begin, end time.Time)

func (*CandleSticks) Times

func (k *CandleSticks) Times() []time.Time

func (*CandleSticks) ToBar

func (k *CandleSticks) ToBar() Bar

func (*CandleSticks) ToChartTemplate

func (k *CandleSticks) ToChartTemplate(indExprs ...string) (*ghtml.ChartTemplate, error)

TODO: test required 转换为chart模板,方便绘图

func (*CandleSticks) ToPeriod

func (k *CandleSticks) ToPeriod(newPeriod Period, config PeriodRoundConfig) (*CandleSticks, error)

转换周期,但不缓存转换之后的数据 NOTE: 如果交易所中间维护,中间空缺的数据会被忽略,而不是填充空数据 FIXME: 如果最后一个周期数据尚未Close,那最后一根线会画出来吗?

func (*CandleSticks) ToPeriodPartly

func (k *CandleSticks) ToPeriodPartly(lastConverted *CandleSticks, newPeriod Period, config PeriodRoundConfig) error

局部周期转换,只转换lastConverted的最后一个时间(包含)往后的数据 lastConverted is input and output config TODO: test required

func (*CandleSticks) ToPeriodWithTail

func (k *CandleSticks) ToPeriodWithTail(newPeriod Period, config PeriodRoundConfig, tail int) (*CandleSticks, error)

just convert last tail dots in newPeriod

func (*CandleSticks) Update

func (k *CandleSticks) Update(time time.Time, itemName string, value gdecimal.Decimal) (updatedCount int)

func (*CandleSticks) Upsert

func (k *CandleSticks) Upsert(toUpsert *CandleSticks)

func (*CandleSticks) UpsertDot

func (k *CandleSticks) UpsertDot(dot Bar)

func (*CandleSticks) Volume

func (k *CandleSticks) Volume(i int) float64

func (*CandleSticks) VolumeRaw

func (k *CandleSticks) VolumeRaw(i int) gdecimal.Decimal

func (*CandleSticks) VolumeValues

func (k *CandleSticks) VolumeValues() []float64

func (*CandleSticks) Volumes

func (k *CandleSticks) Volumes() []gdecimal.Decimal

type CandleSticksConverter

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

type CustomPairParse

type CustomPairParse = func(s string) (Pair, error)

type Depth

type Depth struct {
	Time time.Time `json:"T"` // T
	DepthRawData
}

Depth = open order books.

func (*Depth) MarketBuyDetect

func (d *Depth) MarketBuyDetect(quoteAmount gdecimal.Decimal) DepthTolerance

拉盘探测,能拉多高

func (*Depth) MarketBuyDetectEx

func (d *Depth) MarketBuyDetectEx(quoteAmount gdecimal.Decimal, slippageAllowed gdecimal.Decimal, precision int, lot gdecimal.Decimal) DepthTolerance

拉盘探测,能拉多高 note: 如果不给出Prec,可能导致模拟成交的时候由于除法除不尽导致结果不精确而稍稍大于绝对精确值的情况,从而产生连锁反应 FIXME: precision 确定一下是unit的precision吗,同理也给marketSell确认一下

func (*Depth) MarketSellDetect

func (d *Depth) MarketSellDetect(unitAmount gdecimal.Decimal) DepthTolerance

砸盘探测,能砸多深

func (*Depth) MarketSellDetectEx

func (d *Depth) MarketSellDetectEx(unitAmount, slippageAllowed gdecimal.Decimal) DepthTolerance

砸盘探测,能砸多深

func (*Depth) ParseBuyOnePrice

func (d *Depth) ParseBuyOnePrice() gdecimal.Decimal

func (*Depth) ParseBuyerTotal

func (d *Depth) ParseBuyerTotal() (avgPrice, totalAmount gdecimal.Decimal)

func (*Depth) ParseSellOnePrice

func (d *Depth) ParseSellOnePrice() gdecimal.Decimal

func (*Depth) ParseSellerTotal

func (d *Depth) ParseSellerTotal() (avgPrice, totalAmount gdecimal.Decimal)

func (*Depth) Sort

func (d *Depth) Sort()

func (Depth) String

func (d Depth) String() string

type DepthRawData

type DepthRawData struct {
	Sells OrderBookList `json:"Sells"` // Asks
	Buys  OrderBookList `json:"Buys"`  // Bids
}

Raw depth data without timestamp. Useful in remake new Depth like struct.

func (*DepthRawData) Equal

func (drd *DepthRawData) Equal(cmp *DepthRawData) bool

func (*DepthRawData) GetMaxBuy

func (drd *DepthRawData) GetMaxBuy() (price, amount gdecimal.Decimal, err error)

func (*DepthRawData) GetMinSell

func (drd *DepthRawData) GetMinSell() (price, amount gdecimal.Decimal, err error)

type DepthTolerance

type DepthTolerance struct {
	UnitDealAmount  gdecimal.Decimal
	QuoteDealAmount gdecimal.Decimal
	Price1          gdecimal.Decimal
	PriceReach      gdecimal.Decimal // 上/下探价格, -1 means 击穿
}

盘口承受力

func (*DepthTolerance) Equal

func (dt *DepthTolerance) Equal(cmp DepthTolerance) bool

func (*DepthTolerance) Verify

func (dt *DepthTolerance) Verify() error

verify price and unit amount

type Dir

type Dir string
const (
	TADirectionDown       Dir = "down"
	TADirectionUp         Dir = "up"
	TADirectionNotSureYet Dir = "not_sure_yet"
)

type DirWT

type DirWT struct {
	Time time.Time
	Dir  Dir
}

direction with time

type DoubleDir

type DoubleDir string

type ExApi

type ExApi string

type ExProperty

type ExProperty struct {
	Name                  Platform
	Email                 string // optional
	MaxDepth              int
	MaxFills              int
	IgnorePairs           []string        // custom step 1, ignore invalid/test pairs
	CustomToStdPairs      map[string]Pair // custom step 2, hard to parse special pairs: like [USDTCHF]:USDT/CHF
	CustomPairParse       CustomPairParse // custom step 3
	Periods               map[Period]string
	OrderStatus           map[OrderStatus]string
	OrderTypes            map[OrderType]string
	OrderSides            map[OrderSide]string
	RateLimits            map[ExApi]time.Duration
	MarketEnabled         map[Market]bool
	Clock                 gtime.Clock
	IsBackTestEx          bool
	TradeBeginTime        time.Time
	BarCountLimitSinceNow *int // how many bar provided by exchange since now, if it is nil means no limit -- you can get first bar from exchange open
}

PairDelimiter string // pair separator PairDelimiterLeftTail []string PairDelimiterRightHead []string PairNormalOrder bool // whether is ISO order —— unit first quote second PairUpperCase bool PairsSeparator string // separator between multiple pairs in api request CustomPairPreCrop CustomPairPreCrop // custom step 3 StdToCustomHeadTailMap map[string]string // custom step 4, [StdSym]CustomSym like: BTC

func (ExProperty) MinPeriod

func (cc ExProperty) MinPeriod() Period

func (ExProperty) SupportedPeriods

func (cc ExProperty) SupportedPeriods() []Period

type Fill

type Fill struct {
	Id      int64            `json:"Id" bson:"_id"`
	Time    time.Time        `json:"T" bson:"T"`
	Price   gdecimal.Decimal `json:"Price" bson:"Price"`
	UnitQty gdecimal.Decimal `json:"UnitQty" bson:"UnitQty"`
	Side    string           `json:"Side" bson:"Side"` // "buy", "sell", "auction"...
}

QuoteQty decimals.Decimal `json:"QuoteQty" bson:"QuoteQty"` BuyerMaker bool `json:"BuyerMaker" bson:"BuyerMaker"` // binance use it only

type FillOption

type FillOption struct {
	BeginTime    time.Time
	TimeDuration time.Duration

	BeginId int64
	IdLimit int64
}

func (FillOption) VerifyBinance

func (fo FillOption) VerifyBinance() error

type HighlyRelevant

type HighlyRelevant struct {
	Items []PairMP
}

type Irrelevant

type Irrelevant struct {
	Lows []LowlyRelevant
}

type KForm

type KForm int // ABC 3位数字表示,分别代表上影线震幅,实体线震幅,下影线震幅,正负代表是阴线还是阳线
const (
	KFormUnknown KForm = 0
	KFormOne     KForm = 0
)

type KTA

type KTA CandleSticks

func (*KTA) Break

func (kta *KTA) Break(breakUp bool, beginInclude bool, begin time.Time, endInclude bool, end time.Time, priceInclude bool, price gdecimal.Decimal) (time.Time, bool)

func (*KTA) CleanupIndicators

func (kta *KTA) CleanupIndicators()

func (*KTA) Crosses

func (kta *KTA) Crosses(exp1, exp2 string, n int) ([]TACross, error)

exp1: slow expression exp2: fast expression

func (*KTA) FirstHeavyVolumePriceRose

func (kta *KTA) FirstHeavyVolumePriceRose(gt time.Time, pricePercent float64, volumeCmpDays int, lowGt *float64) (Bar, bool)

从前往后找放量上涨 pricePercent 价格上涨幅度 volumeCmpDays 成交量大于之前多少天 lowGt low价必须大于这个值,相当于给出一条最低线,忽略低于这条线的大阳线

func (*KTA) K

func (kta *KTA) K() *CandleSticks

func (*KTA) LastDirReversalExprValue

func (kta *KTA) LastDirReversalExprValue(exp string, gt *time.Time) (float64, error)

最后一个方向反转处的某表达式的值 适用于Donchian Channel

func (*KTA) LastDirs

func (kta *KTA) LastDirs(exp string, directionSize int, gt *time.Time) ([]DirWT, error)

某表达式(比如DonChian Channel)最后的涨跌趋势,持平的点忽略不计

func (*KTA) LastHeavyVolumePriceRose

func (kta *KTA) LastHeavyVolumePriceRose(gt time.Time, pricePercent float64, volumeCmpDays int) (Bar, bool)

从后往前找放量上涨 pricePercent 价格上涨幅度 volumeCmpDays 成交量大于之前多少天

func (*KTA) ReverseCross1

func (kta *KTA) ReverseCross1(exp1, exp2 string) (*TACross, error)

func (*KTA) ReverseCrosses

func (kta *KTA) ReverseCrosses(exp1, exp2 string, n int) ([]TACross, error)

从后往前 exp1: slow expression exp2: fast expression n: how much cross do you want, n <= 0: ignore it

func (*KTA) UpdateIndicators

func (kta *KTA) UpdateIndicators(indicatorExpr ...string) error

NOTE: 能否把已经计算过的缓存起来?很难,因为有些指数是和之前的值相关联的,你无法核实之前的值是否改动过

type KlineProviderInfo

type KlineProviderInfo struct {
	//SupportedPairs        []PairIMP
	SupportedPairs        []PairM
	MinPeriod             Period
	KlineRequestRateLimit time.Duration
	FirstTrade            time.Time
}

type LHS

type LHS struct {
	Form KForm
}

associated rules antecedent 目前只使用了K线形态

type Leverage

type Leverage struct {
	BuySideFixed             []gdecimal.Decimal
	BuySideSmoothMinStepMax  []gdecimal.Decimal
	SellSideFixed            []gdecimal.Decimal
	SellSideSmoothMinStepMax []gdecimal.Decimal
}

func (*Leverage) BuySideMaxLeverage

func (l *Leverage) BuySideMaxLeverage() gdecimal.Decimal

func (*Leverage) SellSideMaxLeverage

func (l *Leverage) SellSideMaxLeverage() gdecimal.Decimal

func (*Leverage) SetFixedFloat64

func (l *Leverage) SetFixedFloat64(buySide bool, fixLeverages ...float64)

func (*Leverage) SetSmoothFloat64

func (l *Leverage) SetSmoothFloat64(buySide bool, min float64, step float64, max float64)

func (*Leverage) SupportLeverage

func (l *Leverage) SupportLeverage(buySide bool) bool

func (*Leverage) Verify

func (l *Leverage) Verify() error

type LowlyRelevant

type LowlyRelevant struct {
	Mids []ModeratelyRelevant
}

type Margin

type Margin string

func ParseMargin

func ParseMargin(s string) (Margin, error)

func (Margin) Verify

func (m Margin) Verify() error

type Market

type Market string

func ParseMarket

func ParseMarket(s string) (Market, error)

func (Market) IsContract

func (m Market) IsContract() bool

func (Market) Verify

func (m Market) Verify() error

type MarketInfo

type MarketInfo struct {
	UnrecognizedPairs []string
	Infos             map[PairM]PairInfo
}

func (*MarketInfo) AvailableSymbols

func (mi *MarketInfo) AvailableSymbols() []string

func (*MarketInfo) GetMakerFee

func (mi *MarketInfo) GetMakerFee(pm PairM) (gdecimal.Decimal, bool)

func (*MarketInfo) GetTakerFee

func (mi *MarketInfo) GetTakerFee(pm PairM) (gdecimal.Decimal, bool)

func (*MarketInfo) PairIMPs

func (mi *MarketInfo) PairIMPs(period Period, platform Platform) []PairIMP

func (*MarketInfo) PairMs

func (mi *MarketInfo) PairMs() []PairM

func (*MarketInfo) Pairs

func (mi *MarketInfo) Pairs() []Pair

all trading pairs, if some pair exist in different markets(spot,margin...), only one be kept

func (*MarketInfo) PairsAllowedFilter

func (mi *MarketInfo) PairsAllowedFilter(allowedSymbols []string) []Pair

func (*MarketInfo) PairsIncludeFilter

func (mi *MarketInfo) PairsIncludeFilter(includeSymbols []string, excludeSymbols []string) []Pair

func (*MarketInfo) SupportMargin

func (mi *MarketInfo) SupportMargin(pair Pair) bool

func (*MarketInfo) Verify

func (mi *MarketInfo) Verify() error

type ModeratelyRelevant

type ModeratelyRelevant struct {
	Highs []HighlyRelevant
}

type Order

type Order struct {
	Id         OrderId
	Time       time.Time
	Market     Market
	Margin     Margin
	Leverage   int // FIXME change to decimal
	Pair       Pair
	Side       OrderSide
	Type       OrderType
	Status     OrderStatus
	StopPrice  gdecimal.Decimal // 止盈止损触发价,限价单才有 FIXME 如果该用*会导致程序崩溃
	Price      gdecimal.Decimal
	Amount     gdecimal.Decimal // initial total amount in unit, unit always
	AvgPrice   gdecimal.Decimal // Binance貌似不提供AvgPrice
	DealAmount gdecimal.Decimal // filled amount in unit, NOT quote,PaperEx在撮合的时候是这么理解的,如果以后要改,也要修正paperEx
	Fee        gdecimal.Decimal // Binance貌似不提供Fee
}

func FilterOrders

func FilterOrders(src []Order, market Market, target Pair) []Order

func (Order) String

func (od Order) String() string

type OrderBook

type OrderBook struct {
	Price  gdecimal.Decimal `json:"Price"`
	Amount gdecimal.Decimal `json:"Amount"`
}

func RemoveInvalidOrders

func RemoveInvalidOrders(input []OrderBook) []OrderBook

删除挂单价格或者数量为0的单子

type OrderBookList

type OrderBookList []OrderBook

func (OrderBookList) Len

func (obl OrderBookList) Len() int

func (OrderBookList) Less

func (obl OrderBookList) Less(i, j int) bool

func (OrderBookList) Swap

func (obl OrderBookList) Swap(i, j int)

type OrderId

type OrderId string

func NewOrderId

func NewOrderId(market Market, margin Margin, pair Pair, strId string) OrderId

func (OrderId) Margin

func (id OrderId) Margin() Margin

func (OrderId) Market

func (id OrderId) Market() Market

func (OrderId) MarshalJSON

func (id OrderId) MarshalJSON() ([]byte, error)

func (OrderId) Pair

func (id OrderId) Pair() Pair

func (OrderId) StrId

func (id OrderId) StrId() string

func (OrderId) String

func (id OrderId) String() string

func (*OrderId) UnmarshalJSON

func (id *OrderId) UnmarshalJSON(b []byte) error

func (OrderId) Verify

func (id OrderId) Verify() error

type OrderList

type OrderList []Order

func (OrderList) Len

func (ol OrderList) Len() int

func (OrderList) Less

func (ol OrderList) Less(i, j int) bool

func (OrderList) Swap

func (ol OrderList) Swap(i, j int)

type OrderSide

type OrderSide string

func (OrderSide) CustomFormat

func (tt OrderSide) CustomFormat(config *ExProperty) string

func (OrderSide) IsBuy

func (tt OrderSide) IsBuy() bool

func (OrderSide) IsSell

func (tt OrderSide) IsSell() bool

func (OrderSide) String

func (tt OrderSide) String() string

func (OrderSide) Verify

func (tt OrderSide) Verify() error

type OrderStatus

type OrderStatus string

func (OrderStatus) End

func (ts OrderStatus) End() bool

FIXME 如果部分完成后取消了,这个订单的状态是什么

func (OrderStatus) String

func (ts OrderStatus) String() string

type OrderType

type OrderType string

func (OrderType) CustomFormat

func (tt OrderType) CustomFormat(config *ExProperty) string

func (OrderType) IsLimit

func (tt OrderType) IsLimit() bool

func (OrderType) IsMarket

func (tt OrderType) IsMarket() bool

func (OrderType) IsStopLimit

func (tt OrderType) IsStopLimit() bool

Is stop loss limit or take profit limit order. On the front page of some platforms, there is no distinction between 'stop loss limit' and 'take profit limit', but rather a 'stop limit' order to express.

func (OrderType) String

func (tt OrderType) String() string

func (OrderType) Verify

func (tt OrderType) Verify() error

type Pair

type Pair string // BTC/USDT

TODO test pairExt

func NewPair

func NewPair(unit, quote string) Pair

func ParsePair

func ParsePair(s string) (Pair, error)

parse ISO standard pair string

func ParsePairCustom

func ParsePairCustom(s string, config *ExProperty) (Pair, error)

func (Pair) CustomFormat

func (p Pair) CustomFormat(config *ExProperty) string

TODO 修整这个函数

func (Pair) First

func (p Pair) First() string

func (Pair) Format

func (p Pair) Format(split string, upper bool) string

func (Pair) FormatISO

func (p Pair) FormatISO() string

func (Pair) MarshalJSON

func (p Pair) MarshalJSON() ([]byte, error)

func (Pair) Quote

func (p Pair) Quote() string

get first asset in ISO trade pair format

func (Pair) Second

func (p Pair) Second() string

func (Pair) SetI

func (p Pair) SetI(period Period) PairI

func (Pair) SetM

func (p Pair) SetM(market Market) PairM

func (Pair) SetP

func (p Pair) SetP(platform Platform) PairP

func (Pair) String

func (p Pair) String() string

func (Pair) Unit

func (p Pair) Unit() string

get first asset in ISO trade pair format

func (Pair) Verify

func (p Pair) Verify() error

type PairI

type PairI string // Pair with Interval

TODO test pairExt

func (PairI) I

func (pi PairI) I() Period

func (PairI) Pair

func (pi PairI) Pair() Pair

func (PairI) SetI

func (pi PairI) SetI(i Period) PairI

func (PairI) SetM

func (pi PairI) SetM(m Market) PairIM

func (PairI) SetP

func (pi PairI) SetP(p Platform) PairIP

func (PairI) String

func (pi PairI) String() string

func (PairI) Verify

func (pi PairI) Verify() error

type PairIM

type PairIM string // Pair with Interval & Market

TODO test pairExt

func (PairIM) I

func (pim PairIM) I() Period

func (PairIM) M

func (pim PairIM) M() Market

func (PairIM) Pair

func (pim PairIM) Pair() Pair

func (PairIM) SetI

func (pim PairIM) SetI(i Period) PairIM

func (PairIM) SetM

func (pim PairIM) SetM(m Market) PairIM

func (PairIM) SetP

func (pim PairIM) SetP(p Platform) PairIMP

func (PairIM) String

func (pim PairIM) String() string

func (PairIM) Verify

func (pim PairIM) Verify() error

type PairIMP

type PairIMP string // Pair with Interval, Market & Platform

TODO test pairExt

func ParsePairIMP

func ParsePairIMP(s string) (PairIMP, error)

func (PairIMP) I

func (pimp PairIMP) I() Period

func (PairIMP) M

func (pimp PairIMP) M() Market

func (PairIMP) P

func (pimp PairIMP) P() Platform

func (PairIMP) Pair

func (pimp PairIMP) Pair() Pair

func (PairIMP) PairMP

func (pimp PairIMP) PairMP() PairMP

func (PairIMP) SetI

func (pimp PairIMP) SetI(i Period) PairIMP

func (PairIMP) SetM

func (pimp PairIMP) SetM(m Market) PairIMP

func (PairIMP) SetP

func (pimp PairIMP) SetP(p Platform) PairIMP

func (PairIMP) String

func (pimp PairIMP) String() string

func (PairIMP) Verify

func (pimp PairIMP) Verify() error

type PairIP

type PairIP string // Pair with Interval & Platform

TODO test pairExt

func (PairIP) I

func (pip PairIP) I() Period

func (PairIP) P

func (pip PairIP) P() Platform

func (PairIP) Pair

func (pip PairIP) Pair() Pair

func (PairIP) SetI

func (pip PairIP) SetI(i Period) PairIP

func (PairIP) SetM

func (pip PairIP) SetM(m Market) PairIMP

func (PairIP) SetP

func (pip PairIP) SetP(p Platform) PairIP

func (PairIP) String

func (pip PairIP) String() string

func (PairIP) Verify

func (pip PairIP) Verify() error

type PairInfo

type PairInfo struct {
	// spot only
	Enabled        bool
	UnitPrecision  int              // precision of unit amount? No, seems useless
	QuotePrecision int              // precision of quote price? No, seems useless
	UnitMin        gdecimal.Decimal // unit min trade amount, mostly it is the same as LostStep
	UnitStep       gdecimal.Decimal // unit min step amount, min trade amount in unit, same as amount in SetPosition()
	QuoteStep      gdecimal.Decimal // quote min movement

	// shared
	Leverage              Leverage
	MarginIsolatedEnabled bool
	MarginCrossEnabled    bool
	MakerFee              gdecimal.Decimal // fee of depth maker, 挂单等吃费率
	TakerFee              gdecimal.Decimal // fee of depth taker, 主动吃单费率

	// contract only
	MaintMarginPercent    gdecimal.Decimal
	RequiredMarginPercent gdecimal.Decimal
}

币安的永续合约说明,可以辅助完善PairInfo https://binance.zendesk.com/hc/zh-cn/articles/360033161972-%E5%90%88%E7%BA%A6%E7%BB%86%E5%88%99 MinNotional decimals.Decimal // notional = price * amount

type PairM

type PairM string // Pair with Market

TODO test pairExt

func (PairM) M

func (pm PairM) M() Market

func (PairM) Pair

func (pm PairM) Pair() Pair

func (PairM) SetI

func (pm PairM) SetI(i Period) PairIM

func (PairM) SetM

func (pm PairM) SetM(m Market) PairM

func (PairM) SetP

func (pm PairM) SetP(p Platform) PairMP

func (PairM) String

func (pm PairM) String() string

func (PairM) Verify

func (pm PairM) Verify() error

type PairMP

type PairMP string // Pair with Market & Platform

TODO test pairExt

func (PairMP) M

func (pmp PairMP) M() Market

func (PairMP) P

func (pmp PairMP) P() Platform

func (PairMP) Pair

func (pmp PairMP) Pair() Pair

func (PairMP) PairM

func (pmp PairMP) PairM() PairM

func (PairMP) PairP

func (pmp PairMP) PairP() PairP

func (PairMP) SetI

func (pmp PairMP) SetI(i Period) PairIMP

func (PairMP) SetM

func (pmp PairMP) SetM(m Market) PairMP

func (PairMP) SetP

func (pmp PairMP) SetP(p Platform) PairMP

func (PairMP) String

func (pmp PairMP) String() string

func (PairMP) Verify

func (pmp PairMP) Verify() error

type PairP

type PairP string // Pair with Platform

TODO test pairExt

func IndexToPairP

func IndexToPairP(index Asset) PairP

index is special trade pair

func (PairP) P

func (pp PairP) P() Platform

func (PairP) Pair

func (pp PairP) Pair() Pair

func (PairP) SetI

func (pp PairP) SetI(i Period) PairIP

func (PairP) SetM

func (pp PairP) SetM(m Market) PairMP

func (PairP) SetP

func (pp PairP) SetP(p Platform) PairP

func (PairP) String

func (pp PairP) String() string

func (PairP) Verify

func (pp PairP) Verify() error

type Pattern

type Pattern struct {
	PatternLHS
	PatternRHS
}

type PatternLHS

type PatternLHS struct {
	Forms [3]KForm
}

type PatternRHS

type PatternRHS struct {
	LongTimes  int
	ShockTimes int
	ShortTimes int
}

type Patterns

type Patterns struct {
	Items map[PatternLHS]PatternRHS
}

func NewPatterns

func NewPatterns() *Patterns

func (*Patterns) Best

func (ps *Patterns) Best()

func (*Patterns) Join

func (ps *Patterns) Join(newPattern *Patterns) *Patterns

func (*Patterns) MaxLongTimes

func (ps *Patterns) MaxLongTimes() int

func (*Patterns) MaxShockTimes

func (ps *Patterns) MaxShockTimes() int

func (*Patterns) MaxShortTimes

func (ps *Patterns) MaxShortTimes() int

type Period

type Period string
const (
	PeriodError       Period = ""
	Period1Min        Period = "1min"
	Period3Min        Period = "3min"
	Period5Min        Period = "5min"
	Period15Min       Period = "15min"
	Period30Min       Period = "30min"
	Period1Hour       Period = "1hour"
	Period2Hour       Period = "2hour"
	Period4Hour       Period = "4hour"
	Period6Hour       Period = "6hour"
	Period8Hour       Period = "8hour"
	Period12Hour      Period = "12hour"
	Period1Day        Period = "1day"
	Period1Week       Period = "1week"
	Period1MonthFUZZY Period = "1mon"
	Period1YearFUZZY  Period = "1year"
)

func DurationToPeriod

func DurationToPeriod(d time.Duration) Period

func ParsePeriod

func ParsePeriod(s string) (Period, error)

func (Period) CustomFormat

func (p Period) CustomFormat(config *ExProperty) (string, error)

func (Period) MarshalJSON

func (p Period) MarshalJSON() ([]byte, error)

func (Period) String

func (p Period) String() string

func (Period) ToDuration

func (p Period) ToDuration() time.Duration

func (Period) ToDurationExact

func (p Period) ToDurationExact(t time.Time, tz *time.Location) time.Duration

对于Period1MonthFUZZY和Period1YearFUZZY也能精确计算

func (Period) ToSeconds

func (p Period) ToSeconds() int64

func (*Period) UnmarshalJSON

func (p *Period) UnmarshalJSON(b []byte) error

type PeriodRoundConfig

type PeriodRoundConfig struct {
	Location  time.Location // FIXME 按下面的说法是不是不需要Location?
	WeekBegin time.Weekday
	// 本身time.Round是和时区无关的,都是依据UTC进行Round的,但是金融市场中根据Period进行RoundPeriod时,某些Period(周)就需要参考时区了,同一时刻不同时区可能属于不同的Weekday
	// 当然,如果偏要以当地时间的0点作为Round的起点,那么就要把UseLocalZeroOClockAsDayBeginning设置为true
	// 以2019-09-01 09:00:00 +0800 CST 为例,Round24小时,标准结果应该等于2019-09-01 08:00:00 +0800 CST,这个是Go标准库的执行结果
	// 要遵循Go标准库time.Round的思路,就需要把UseLocalZeroOClockAsDayBeginning设置为false
	UseLocalZeroOClockAsDayBeginning bool // false: use UTC zero clock
}

func (PeriodRoundConfig) String

func (cc PeriodRoundConfig) String() string

type Platform

type Platform string

func AllStockExchanges

func AllStockExchanges() []Platform

func ParsePlatform

func ParsePlatform(name string) (Platform, error)

func RemoveDuplicatePlatforms

func RemoveDuplicatePlatforms(platforms []Platform) []Platform

func (*Platform) Info

func (p *Platform) Info() PlatformInfo

func (Platform) IsSupported

func (p Platform) IsSupported() bool

Check whether supported exchange or n ot.

func (Platform) MarshalJSON

func (p Platform) MarshalJSON() ([]byte, error)

func (Platform) String

func (p Platform) String() string

func (*Platform) UnmarshalJSON

func (p *Platform) UnmarshalJSON(data []byte) error

type PlatformInfo

type PlatformInfo struct {
	Support  []AssetType
	OpenDate gtime.Date
}

type Portfolio

type Portfolio struct {
	RelevantSet *Irrelevant `json:"RelevantSet,omitempty"`
	DirectSet   []PairMP    `json:"DirectSet,omitempty"`
}

func (Portfolio) String

func (p Portfolio) String() string

func (Portfolio) Targets

func (p Portfolio) Targets() []PairMP

func (Portfolio) Verify

func (p Portfolio) Verify() error

type RHS

type RHS struct {
	Shock map[int]int // map[PeriodSize]ShockScale[-3,3]
}

associated rules consequent

type Since

type Since struct {
	Time *time.Time
	Id   *int64
}

type SubAcc

type SubAcc string

* 子账户

SubAcc的形式: ::spot:: ::spot::cross customSubAcc::spot::cross

func NewSubAccAddr

func NewSubAccAddr(subAccName string, market Market, margin Margin) SubAcc

func (SubAcc) Parse

func (sa SubAcc) Parse() (sap SubAccParsed, err error)

func (SubAcc) String

func (sa SubAcc) String() string

func (SubAcc) Verify

func (sa SubAcc) Verify() error

type SubAccParsed

type SubAccParsed struct {
	Name   string
	Market Market
	Margin Margin
}

* 子账户

SubAcc的形式: ::spot:: ::spot::cross customSubAcc::spot::cross

func ParseSubAcc

func ParseSubAcc(s string) (sap SubAccParsed, err error)

type TACross

type TACross struct {
	Time      time.Time
	Direction Dir
}

func TACrossesSort

func TACrossesSort(src []TACross) []TACross

type TACrosses

type TACrosses []TACross

func (TACrosses) Len

func (ccs TACrosses) Len() int

func (TACrosses) Less

func (ccs TACrosses) Less(i, j int) bool

func (TACrosses) Swap

func (ccs TACrosses) Swap(i, j int)

type Tick

type Tick struct {
	Time   time.Time        `json:"time"`
	Last   gdecimal.Decimal `json:"last"` // 最新成交价, binance has Last only
	Buy    gdecimal.Decimal `json:"buy"`  // 买一价
	Sell   gdecimal.Decimal `json:"sell"` // 卖一价
	High   gdecimal.Decimal `json:"high"` // 最高价
	Low    gdecimal.Decimal `json:"low"`  // 最低价
	Volume gdecimal.Decimal `json:"vol"`  // 最近的24小时成交量
}

In some exchange, it won't return H/L/V, even returns T & Last only, like binance They will be filled with -1

func (Tick) String

func (t Tick) String() string

type Ticks

type Ticks struct {
	Items map[PairM]gdecimal.Decimal
}

In some exchange, it won't return H/L/V, even returns T & Last only, like binance They will be filled with -1

func TicksToPrices

func TicksToPrices(ticks map[PairM]Tick) Ticks

func (Ticks) GetUSDPrice

func (t Ticks) GetUSDPrice(market Market, unit string) (gdecimal.Decimal, error)

Query fiat price of some asset. unit: which asset's fiat price need to query.

type TimeDoc

type TimeDoc interface {
	GetId() (gdecimal.Decimal, error)
	GetTime() (time.Time, error)
}

type TimeSeries

type TimeSeries interface {
	GetName() string
	GetInterval() (time.Duration, error)
	GetDoc(i int) TimeDoc
	Len() int
	Swap(i, j int)
	Less(i, j int) bool
}

type TradeIncome

type TradeIncome string

type TradeIntent

type TradeIntent string // 交易意图

Jump to

Keyboard shortcuts

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