cbg

package
v0.0.0-...-e0a8310 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SleepUntil

func SleepUntil(next int, dur time.Duration) time.Time

SleepUntil until the next timestamp rounded up to the next period (minutes). https://gist.github.com/msadakov/cdbbd979140ef7341fcfac970fc8a95b

Types

type BiapiSpec

type BiapiSpec struct {
	Test       bool   `json:"test"`
	RecvWindow int64  `validate:"required" yaml:"receive_window"`
	Url        string `validate:"required" yaml:"url"`
}

type BiapiSvc

type BiapiSvc struct {
	BiapiConf *BiapiSpec
	Client    *b.Client
}

func NewBiapiSvc

func NewBiapiSvc(bs *BiapiSpec, apiKey, secretKey string) *BiapiSvc

func (*BiapiSvc) BuyMarketMT

func (s *BiapiSvc) BuyMarketMT(coin, market, quantity string) (*b.CreateOrderResponse, error)

func (*BiapiSvc) CancelOrder

func (s *BiapiSvc) CancelOrder(symbol string, orderID int64) (*b.CancelOrderResponse, error)

func (*BiapiSvc) GetAccount

func (s *BiapiSvc) GetAccount() (*b.Account, error)

func (*BiapiSvc) GetBalance

func (s *BiapiSvc) GetBalance(asset string) (string, error)

func (*BiapiSvc) ListOpenOrders

func (s *BiapiSvc) ListOpenOrders(symbol string) ([]*b.Order, error)

func (*BiapiSvc) ListPrices

func (s *BiapiSvc) ListPrices(symbol string) ([]*b.SymbolPrice, error)

func (*BiapiSvc) SellCoinMT

func (s *BiapiSvc) SellCoinMT(coin, market, quantity string) (*b.CreateOrderResponse, error)

type BotSvc

type BotSvc struct {
	SpecSvc  *SpecSvc
	TaapiSvc *TaapiSvc
	EmailSvc *EmailSvc
	BiapiSvc *BiapiSvc
	StratSvc *StratSvc
	SpotSvc  *SpotSvc
	EndSvc   *EndSvc
}

func NewBotSvc

func NewBotSvc(ss *SpecSvc) *BotSvc

func (*BotSvc) Run

func (s *BotSvc) Run()

type CredSpec

type CredSpec struct {
	BiapiAk string `validate:"required" yaml:"biapi_ak"`
	BiapiSk string `validate:"required" yaml:"biapi_sk"`
	TaapiSk string `validate:"required" yaml:"taapi_sk"`
	EmUser  string `validate:"required" yaml:"em_user"`
	EmPass  string `validate:"required" yaml:"em_pass"`
	NotEm   string `validate:"required" yaml:"noti_em"`
}

type EmailSpec

type EmailSpec struct {
	Server             string `validate:"required" yaml:"server"`
	Port               int    `validate:"required" yaml:"port"`
	Name               string `validate:"required" yaml:"name"`
	ConnTimeoutSec     int    `validate:"required" yaml:"conn_timeout_sec"`
	SendTimeoutSec     int    `validate:"required" yaml:"send_timeout_sec"`
	InsecureSkipVerify bool   `validate:"required" yaml:"insecure_skip_verify"`
}

type EmailSvc

type EmailSvc struct {
	EmailSpec *EmailSpec
	Client    *sm.SMTPServer
	Username  string
	Pass      string
}

func NewEmailSvc

func NewEmailSvc(es *EmailSpec, un, pw string) *EmailSvc

func (*EmailSvc) Send

func (s *EmailSvc) Send(subject string, body string,
	to []string, cc []string, bcc []string) error

type EndSpec

type EndSpec struct {
	DummySymbol string    `validate:"required" yaml:"dummy_symbol"`
	DummyOrder  []float64 `validate:"required" yaml:"dummy_order"`
}

type EndSvc

type EndSvc struct {
	EndSpec  *EndSpec
	BiapiSvc *BiapiSvc
}

func NewEndSvc

func NewEndSvc(es *EndSpec, bs *BiapiSvc) *EndSvc

func (*EndSvc) EndByDummyOrder

func (s *EndSvc) EndByDummyOrder() (bool, error)

type Signal

type Signal string
const (
	SignalNone      Signal = "NONE"
	SignalError     Signal = "ERROR "
	SignalBuy       Signal = "BUY"
	SignalSell      Signal = "SELL"
	SignalHodl      Signal = "HODL"
	SignalLong      Signal = "LONG"
	SignalShort     Signal = "SHORT"
	SignalHasTrend  Signal = "HAS_TREND"
	SignalNoTrend   Signal = "NO_TREND"
	SignalUptrend   Signal = "UPTREND"
	SignalDowntrend Signal = "DOWNTREND"
)

type Spec

type Spec struct {
	Name      string     `validate:"required" yaml:"name"`
	Delayed   bool       `yaml:"delayed"`
	DryRun    bool       `yaml:"dry_run"`
	EmailSpec *EmailSpec `validate:"required"  yaml:"email"`
	BiapiSpec *BiapiSpec `validate:"required"  yaml:"biapi"`
	TaapiSpec *TaapiSpec `validate:"required"  yaml:"taapi"`
	StratSpec *StratSpec `validate:"required"  yaml:"strategy"`
	SpotSpec  *SpotSpec  `validate:"required"  yaml:"spot"`
	EndSpec   *EndSpec   `validate:"required"  yaml:"end"`
	CredSpec  *CredSpec  `validate:"required"  yaml:"cred"`
}

type SpecSvc

type SpecSvc struct {
	Spec Spec
}

func NewSpec

func NewSpec(s []byte) (*SpecSvc, error)

type SpotSpec

type SpotSpec struct {
	Coin            string `validate:"required" yaml:"coin"`
	Market          string `validate:"required" yaml:"market"`
	PeriodMin       int    `validate:"required" yaml:"period_min"`
	CoinPrecision   string `validate:"required" yaml:"coin_precision"`
	MarketPrecision string `validate:"required" yaml:"market_precision"`
}

type SpotSvc

type SpotSvc struct {
	SpotSpec *SpotSpec
	BiapiSvc *BiapiSvc
}

func NewSpotSvc

func NewSpotSvc(ss *SpotSpec, bs *BiapiSvc) *SpotSvc

func (*SpotSvc) BuyMarketMT

func (s *SpotSvc) BuyMarketMT(quantity string) (*binance.CreateOrderResponse, error)

func (*SpotSvc) SellCoinMT

func (s *SpotSvc) SellCoinMT(quantity string) (*binance.CreateOrderResponse, error)

type StratSpec

type StratSpec struct {
	Adx        int     `validate:"required" yaml:"adx"`
	Macd       []int   `validate:"required" yaml:"macd"`
	SuperTrend [][]int `validate:"required" yaml:"super_trend"`
}

type StratSvc

type StratSvc struct {
	StratSpec *StratSpec
	TaapiSvc  *TaapiSvc
}

func NewStratSvc

func NewStratSvc(ss *StratSpec, ts *TaapiSvc) *StratSvc

func (*StratSvc) Adx

func (s *StratSvc) Adx(coin, market, interval string, period int) Signal

func (*StratSvc) Macd

func (s *StratSvc) Macd(coin, market, interval string, conf []int) Signal

func (*StratSvc) SuperTrend

func (s *StratSvc) SuperTrend(coin, market, interval string, confs [][]int) Signal

type TaapiSpec

type TaapiSpec struct {
	Url       string `validate:"required" yaml:"url"`
	Exchange  string `validate:"required" yaml:"exchange"`
	Chart     string `validate:"required" yaml:"chart"`
	Backtrack int    `validate:"required" yaml:"backtrack"`
}

type TaapiSvc

type TaapiSvc struct {
	TaapiSpec *TaapiSpec
	SecretKey string
}

func NewTaapiSvc

func NewTaapiSvc(ts *TaapiSpec, sk string) *TaapiSvc

func (*TaapiSvc) Adx

func (s *TaapiSvc) Adx(
	coin, market, interval string,
	period int) (string, error)

func (*TaapiSvc) Macd

func (s *TaapiSvc) Macd(
	coin, market, interval string,
	fast int, slow int, signal int) (string, error)

func (*TaapiSvc) SuperTrend

func (s *TaapiSvc) SuperTrend(
	coin, market, interval string,
	period int, multiplier int) (string, error)

Jump to

Keyboard shortcuts

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