coinex

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: LGPL-3.0 Imports: 11 Imported by: 1

README

coinex

The futures coin api。This package only implement fetures exchange of crypto coin. If you want a more common package, see gocryptotrader

Exchange Support

Exchange REST API Streaming API
Bitmex Yes Yes
OKex No No

Cheers to

Bitmex Websocket refer to gocryptotrader

Bitmex RESTful API use go-swagger

Bitmex Auth refer to ccxt

Documentation

Index

Constants

View Source
const (
	Long  = 1
	Short = 2
)

Variables

View Source
var (
	ErrNotImpl = errors.New("not implement")
)

Functions

This section is empty.

Types

type BaseExchanger

type BaseExchanger interface {
	Buy(price float64, amount float64) (*Order, error)
	Sell(price float64, amount float64) (*Order, error)
}

type Config

type Config struct {
	Exchanges map[string]ConfigItem
	Proxy     string
}

func LoadConfigFile

func LoadConfigFile(cfg string) (configs Config, err error)

func LoadConfigs

func LoadConfigs() (configs Config, err error)

func LoadViperConfig added in v1.0.5

func LoadViperConfig(cfg *viper.Viper) (configs Config, err error)

func (*Config) Get

func (c *Config) Get(name string) (key, secret string)

func (*Config) GetConfig added in v1.0.2

func (c *Config) GetConfig(name string) (key, secret, passphrase string)

type ConfigItem

type ConfigItem struct {
	Type       string
	Key        string
	Secret     string
	Passphrase string
}

type Contract

type Contract struct {
	Symbol string
	Name   string
	Expiry time.Time
}

func (Contract) String

func (c Contract) String() string

type DataDownload added in v1.0.2

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

func NewDataDownload added in v1.0.2

func NewDataDownload(start, end time.Time, binDuration time.Duration, paramFunc NewParamFunc, downFunc DownFunc, onceCount int32, nDuration time.Duration, nLimit int) (d *DataDownload)

func (*DataDownload) Error added in v1.0.5

func (d *DataDownload) Error() error

func (*DataDownload) IsFinish added in v1.0.2

func (d *DataDownload) IsFinish() (bFinish bool)

func (*DataDownload) Run added in v1.0.2

func (d *DataDownload) Run(errChan chan error)

func (*DataDownload) SetFinish added in v1.0.2

func (d *DataDownload) SetFinish(nFinish int32)

func (*DataDownload) SetMaxRetry added in v1.0.5

func (d *DataDownload) SetMaxRetry(maxRetry int)

func (*DataDownload) Start added in v1.0.2

func (d *DataDownload) Start(err chan error) (dataCh chan []interface{})

type DownFunc added in v1.0.2

type DownFunc func(DownParam) ([]interface{}, bool, error)

type DownParam added in v1.0.2

type DownParam interface {
	SetStart(start *int32)
	SetCount(count *int32)
	SetStartTime(startTime *time.Time)
	SetEndTime(endTime *time.Time)
}

type Downloader added in v1.0.5

type Downloader interface {
	Start() chan []interface{}
	Error() error
}

type FuturesBaseExchanger

type FuturesBaseExchanger interface {
	BaseExchanger
	OpenLong(price float64, amount float64) (*Order, error)
	CloseLong(price float64, amount float64) (*Order, error)
	OpenShort(price float64, amount float64) (*Order, error)
	CloseShort(price float64, amount float64) (*Order, error)
	OpenLongMarket(amount float64) (*Order, error)
	CloseLongMarket(amount float64) (*Order, error)
	OpenShortMarket(amount float64) (*Order, error)
	CloseShortMarket(amount float64) (*Order, error)
}

type FuturesExchanger

type FuturesExchanger interface {
	FuturesBaseExchanger

	Contracts() ([]Contract, error)
	Positions() ([]Position, error)
	ContractBalances() (map[Contract]Balance, error)

	Depth(int) (Orderbook, error)
	Ticker() (Ticker, error)

	SetSymbol(symbol string) error
	SetContract(contract string) error
	SetLever(lever float64) error

	KlineRecent(count int32, binSize string) (klines []*Candle, err error)
	Kline(start, end time.Time, nLimit int, binSize string) (klines []*Candle, err error)
	KlineChan(start, end time.Time, bSize string) (data chan []interface{}, err chan error)
}

type NewParamFunc added in v1.0.2

type NewParamFunc func() DownParam

type Position

type Position struct {
	Info        Contract // 合约信息
	Type        int      // 合约类型,Long: 多头,Short: 空头
	Hold        float64  // 持有仓位
	Price       float64  //开仓价格
	ProfitRatio float64  // 盈利比例,正数表示盈利,负数表示亏岁
}

Jump to

Keyboard shortcuts

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