coinex

package module
v0.0.0-...-c020e94 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: LGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

This section is empty.

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 (*Config) Get

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

type ConfigItem

type ConfigItem struct {
	Type   string
	Key    string
	Secret string
}

type Contract

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

func (Contract) String

func (c Contract) String() string

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) (klines chan []interface{}, err error)
}

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
⌂ 换网址