fcoin

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPOT     = "spot"
	ASSETS   = "assets"
	EXCHANGE = "exchange"
)
View Source
const (

	/*Rest Endpoint*/
	Endpoint              = "https://api.testnet.fmex.com"
	GET_ACCOUNTS          = "/v3/contracts/accounts"
	PLACE_ORDER           = "/v3/contracts/orders"
	CANCEL_ORDER          = "/v3/contracts/orders/%s/cancel"
	GET_POSITION          = "/v3/contracts/positions"
	GET_DEPTH             = "/v2/market/depth/L20/%s"
	GET_TICKER            = "/v2/market/ticker/%s"
	GET_UNFINISHED_ORDERS = "/v3/contracts/orders/open"
)
View Source
const (
	FCoinWSTicker        = "ticker.%s"
	FCoinWSOrderBook     = "depth.L%d.%s"
	FCoinWSOrderBookL20  = "depth.L20.%s"
	FCoinWSOrderBookL150 = "depth.L150.%s"
	FCoinWSOrderBookFull = "depth.full.%s"
	FCoinWSTrades        = "trade.%s"
	FCoinWSKLines        = "candle.%s.%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Currency  Currency
	Avaliable float64
	Frozen    float64
	Finances  float64
	Lock      float64
	Total     float64
}

type FCoin

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

func NewFCoin

func NewFCoin(client *http.Client, apikey, secretkey string) *FCoin

func NewWithConfig added in v1.1.0

func NewWithConfig(c *APIConfig) *FCoin

func (*FCoin) AssetTransfer

func (fc *FCoin) AssetTransfer(currency Currency, amount, from, to string) (bool, error)

from, to: assets, spot

func (*FCoin) CancelOrder

func (fc *FCoin) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*FCoin) GetAccount

func (fc *FCoin) GetAccount() (*Account, error)

func (*FCoin) GetAssets

func (fc *FCoin) GetAssets() ([]Asset, error)

func (*FCoin) GetDaysOrderHistorys

func (fc *FCoin) GetDaysOrderHistorys(currency CurrencyPair, start time.Time, days int64) ([]Order, error)

func (*FCoin) GetDepth

func (fc *FCoin) GetDepth(size int, currency CurrencyPair) (*Depth, error)

func (*FCoin) GetExchangeName

func (fc *FCoin) GetExchangeName() string

func (*FCoin) GetHoursOrderHistorys

func (fc *FCoin) GetHoursOrderHistorys(currency CurrencyPair, start time.Time, hours int64) ([]Order, error)

func (*FCoin) GetKlineRecords

func (fc *FCoin) GetKlineRecords(currency CurrencyPair, period, size, since int) ([]Kline, error)

func (*FCoin) GetOneOrder

func (fc *FCoin) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

func (*FCoin) GetOrderHistorys

func (fc *FCoin) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)

func (*FCoin) GetOrderHistorys2 added in v1.0.5

func (fc *FCoin) GetOrderHistorys2(currency CurrencyPair, currentPage, pageSize int, states ...string) ([]Order, error)

func (*FCoin) GetServerTime added in v1.0.4

func (fc *FCoin) GetServerTime() (int64, error)

func (*FCoin) GetTicker

func (fc *FCoin) GetTicker(currencyPair CurrencyPair) (*Ticker, error)

func (*FCoin) GetTradeSymbol added in v1.0.5

func (fc *FCoin) GetTradeSymbol(currencyPair CurrencyPair) (*TradeSymbol, error)

func (*FCoin) GetTradeSymbol2 added in v1.0.5

func (fc *FCoin) GetTradeSymbol2(currencyPair CurrencyPair) (*TradeSymbol2, error)

func (*FCoin) GetTradeSymbols

func (fc *FCoin) GetTradeSymbols() ([]TradeSymbol, error)

交易符号

func (*FCoin) GetTradeSymbols2 added in v1.0.3

func (fc *FCoin) GetTradeSymbols2() ([]TradeSymbol2, error)

func (*FCoin) GetTrades

func (fc *FCoin) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

非个人,整个交易所的交易记录

func (*FCoin) GetUnfinishOrders

func (fc *FCoin) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*FCoin) LimitBuy

func (fc *FCoin) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoin) LimitSell

func (fc *FCoin) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoin) MarketBuy

func (fc *FCoin) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoin) MarketSell

func (fc *FCoin) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoin) PlaceOrder added in v1.0.5

func (fc *FCoin) PlaceOrder(orderType OrderType, orderSide, amount, price string, pair CurrencyPair, isMargin bool) (*Order, error)

ORDERTYPE:limit, market, fok, ioc

type FCoinMargin added in v1.0.5

type FCoinMargin struct {
	*FCoin
}

func NewFcoinMargin added in v1.0.6

func NewFcoinMargin(client *http.Client, apikey, secretkey string) *FCoinMargin

func (*FCoinMargin) AssetTransferIn added in v1.0.5

func (fm *FCoinMargin) AssetTransferIn(currency Currency, amount, from string, to CurrencyPair) (bool, error)

currency币种名称:usdt、btc、eth from资产来源账户类型: exchange: 交易账户; assets: 资产账户 to目标账户类型: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt

func (*FCoinMargin) AssetTransferOut added in v1.0.5

func (fm *FCoinMargin) AssetTransferOut(currency Currency, amount string, from CurrencyPair, to string) (bool, error)

currency币种名称:usdt、btc、eth from资产来源账户类型: exchange: 交易账户; assets: 资产账户 to目标账户类型: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt

func (*FCoinMargin) Borrow added in v1.0.5

func (fm *FCoinMargin) Borrow(parameter BorrowParameter) (*MarginOrder, error)

func (*FCoinMargin) GetAccount added in v1.0.6

func (fm *FCoinMargin) GetAccount() (*Account, error)

func (*FCoinMargin) GetExchangeName added in v1.0.6

func (fm *FCoinMargin) GetExchangeName() string

func (*FCoinMargin) GetMarginAccount added in v1.0.5

func (fm *FCoinMargin) GetMarginAccount(currency CurrencyPair) (*MarginAccount, error)

func (*FCoinMargin) GetOneLoan added in v1.0.5

func (fm *FCoinMargin) GetOneLoan(borrowId string) (*MarginOrder, error)

func (*FCoinMargin) GetOrderHistorys added in v1.0.5

func (fm *FCoinMargin) GetOrderHistorys(currency CurrencyPair, currentPage, pageSize int) ([]Order, error)

func (*FCoinMargin) GetOrderHistorys2 added in v1.0.6

func (fm *FCoinMargin) GetOrderHistorys2(currency CurrencyPair, currentPage, pageSize int, states ...string) ([]Order, error)

states:submitted,partial_filled,partial_canceled,filled,canceled

func (*FCoinMargin) GetUnfinishLoans added in v1.0.5

func (fm *FCoinMargin) GetUnfinishLoans(currency CurrencyPair) ([]*MarginOrder, error)

func (*FCoinMargin) GetUnfinishOrders added in v1.0.5

func (fm *FCoinMargin) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*FCoinMargin) LimitBuy added in v1.0.5

func (fm *FCoinMargin) LimitBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoinMargin) LimitSell added in v1.0.5

func (fm *FCoinMargin) LimitSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoinMargin) MarketBuy added in v1.0.5

func (fm *FCoinMargin) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoinMargin) MarketSell added in v1.0.5

func (fm *FCoinMargin) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*FCoinMargin) Repayment added in v1.0.5

func (fm *FCoinMargin) Repayment(parameter RepaymentParameter) (repaymentId string, err error)

type FCoinWs

type FCoinWs struct {
	*WsBuilder
	sync.Once
	// contains filtered or unexported fields
}

func NewFCoinWs

func NewFCoinWs(client *http.Client) *FCoinWs

func (*FCoinWs) SetCallbacks

func (fcWs *FCoinWs) SetCallbacks(
	tickerCallback func(*Ticker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade),
	klineCallback func(*Kline, int),
)

func (*FCoinWs) SubscribeDepth

func (fcWs *FCoinWs) SubscribeDepth(pair CurrencyPair, size int) error

func (*FCoinWs) SubscribeKline

func (fcWs *FCoinWs) SubscribeKline(pair CurrencyPair, period int) error

func (*FCoinWs) SubscribeTicker

func (fcWs *FCoinWs) SubscribeTicker(pair CurrencyPair) error

func (*FCoinWs) SubscribeTrade

func (fcWs *FCoinWs) SubscribeTrade(pair CurrencyPair) error

type FMexSwap added in v1.0.6

type FMexSwap struct {
	*FCoin
	// contains filtered or unexported fields
}

func NewFMexSwap added in v1.0.6

func NewFMexSwap(config *APIConfig) *FMexSwap

func (*FMexSwap) AdaptTradeStatus added in v1.0.6

func (fm *FMexSwap) AdaptTradeStatus(status int) TradeStatus

func (*FMexSwap) FutureCancelOrder added in v1.0.6

func (fm *FMexSwap) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*FMexSwap) GetContractValue added in v1.0.6

func (fm *FMexSwap) GetContractValue(currencyPair CurrencyPair) (float64, error)

*

func (*FMexSwap) GetDeliveryTime added in v1.0.6

func (fm *FMexSwap) GetDeliveryTime() (int, int, int, int)

func (*FMexSwap) GetExchangeName added in v1.0.6

func (fm *FMexSwap) GetExchangeName() string

func (*FMexSwap) GetExchangeRate added in v1.0.6

func (fm *FMexSwap) GetExchangeRate() (float64, error)

func (*FMexSwap) GetFee added in v1.0.6

func (fm *FMexSwap) GetFee() (float64, error)

func (*FMexSwap) GetFutureDepth added in v1.0.6

func (fm *FMexSwap) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*FMexSwap) GetFutureEstimatedPrice added in v1.0.6

func (fm *FMexSwap) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*FMexSwap) GetFutureIndex added in v1.0.6

func (fm *FMexSwap) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*FMexSwap) GetFutureOrder added in v1.0.6

func (fm *FMexSwap) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

*

func (*FMexSwap) GetFutureOrders added in v1.0.6

func (fm *FMexSwap) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

*

func (*FMexSwap) GetFuturePosition added in v1.0.6

func (fm *FMexSwap) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*FMexSwap) GetFutureTicker added in v1.0.6

func (fm *FMexSwap) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*FMexSwap) GetFutureUserinfo added in v1.0.6

func (fm *FMexSwap) GetFutureUserinfo() (*FutureAccount, error)

func (*FMexSwap) GetHistoricalFunding added in v1.0.6

func (fm *FMexSwap) GetHistoricalFunding(contractType string, currencyPair CurrencyPair, page int) ([]HistoricalFunding, error)

func (*FMexSwap) GetKlineRecords added in v1.0.6

func (fm *FMexSwap) GetKlineRecords(contract_type string, currency CurrencyPair, period, size, since int) ([]FutureKline, error)

func (*FMexSwap) GetTrades added in v1.0.6

func (fm *FMexSwap) GetTrades(contract_type string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*FMexSwap) GetUnfinishFutureOrders added in v1.0.6

func (fm *FMexSwap) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*FMexSwap) PlaceFutureOrder added in v1.0.6

func (fm *FMexSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice, leverRate int) (string, error)

type MarginOrder added in v1.0.5

type MarginOrder struct {
	Currency             Currency
	Amount               float64 // borrow amount
	BorrowTime           int64   // borrow time, ms
	RepaymentTime        int64   // repayment time, ms
	LendingFee           float64 // LendingFee
	LoanRate             float64 // loan rate
	LoanFeeStartTime     int64   // charge from start time
	LastRepayTime        int64   // last repay time
	LoanBillId           string
	NextLoanFeeStartTime int64
	State                string //账单状态. submitted 已提交; 2 confirmed 已确认; 5 finished 还款完成
	UnPaidAmount         float64
	UnPaidLendingFee     float64
}

* 杠杆交易区借币, pair : 操作的交易对 currency: 需要借的币种 amount : 借的金额

type RawTicker added in v1.0.4

type RawTicker struct {
	Ticker
	SellAmount   float64
	BuyAmount    float64
	LastTradeVol float64
}

type TradeSymbol

type TradeSymbol struct {
	Name          string `json:"name"`
	BaseCurrency  string `json:"base_currency"`
	QuoteCurrency string `json:"quote_currency"`
	PriceDecimal  int    `json:"price_decimal"`
	AmountDecimal int    `json:"amount_decimal"`
	Tradeable     bool   `json:"tradable"`
}

type TradeSymbol2 added in v1.0.3

type TradeSymbol2 struct {
	TradeSymbol
	Category           string  `json:"category"`
	LeveragedMultiple  int     `json:"leveraged_multiple"`
	MarketOrderEnabled bool    `json:"market_order_enabled"`
	LimitAmountMin     float64 `json:"limit_amount_min"`
	LimitAmountMax     float64 `json:"limit_amount_max"`
	MainTag            string  `json:"main_tag"`
	DailyOpenAt        string  `json:"daily_open_at"`
	DailyCloseAt       string  `json:"daily_close_at"`
}

Jump to

Keyboard shortcuts

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