913 lines
31 KiB
Go
913 lines
31 KiB
Go
package ccxt
|
|
|
|
type Krakenfutures struct {
|
|
*krakenfutures
|
|
Core *krakenfutures
|
|
}
|
|
|
|
func NewKrakenfutures(userConfig map[string]interface{}) Krakenfutures {
|
|
p := &krakenfutures{}
|
|
p.Init(userConfig)
|
|
return Krakenfutures{
|
|
krakenfutures: p,
|
|
Core: p,
|
|
}
|
|
}
|
|
|
|
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
|
|
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchMarkets
|
|
* @description Fetches the available trading markets from the exchange, Multi-collateral markets are returned as linear markets, but can be settled in multiple currencies
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instruments
|
|
* @param {object} [params] exchange specific params
|
|
* @returns An array of market structures
|
|
*/
|
|
func (this *Krakenfutures) FetchMarkets(params ...interface{}) ([]MarketInterface, error) {
|
|
res := <- this.Core.FetchMarkets(params...)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewMarketInterfaceArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchOrderBook
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-orderbook
|
|
* @description Fetches a list of open orders in a market
|
|
* @param {string} symbol Unified market symbol
|
|
* @param {int} [limit] Not used by krakenfutures
|
|
* @param {object} [params] exchange specific params
|
|
* @returns An [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchOrderBook(symbol string, options ...FetchOrderBookOptions) (OrderBook, error) {
|
|
|
|
opts := FetchOrderBookOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchOrderBook(symbol, limit, params)
|
|
if IsError(res) {
|
|
return OrderBook{}, CreateReturnError(res)
|
|
}
|
|
return NewOrderBook(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchTickers
|
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-tickers
|
|
* @param {string[]} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an array of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchTickers(options ...FetchTickersOptions) (Tickers, error) {
|
|
|
|
opts := FetchTickersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchTickers(symbols, params)
|
|
if IsError(res) {
|
|
return Tickers{}, CreateReturnError(res)
|
|
}
|
|
return NewTickers(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchOHLCV
|
|
* @see https://docs.futures.kraken.com/#http-api-charts-candles
|
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
* @param {string} timeframe the length of time each candle represents
|
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
*/
|
|
func (this *Krakenfutures) FetchOHLCV(symbol string, options ...FetchOHLCVOptions) ([]OHLCV, error) {
|
|
|
|
opts := FetchOHLCVOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var timeframe interface{} = nil
|
|
if opts.Timeframe != nil {
|
|
timeframe = *opts.Timeframe
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchOHLCV(symbol, timeframe, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOHLCVArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchTrades
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
|
|
* @see https://docs.futures.kraken.com/#http-api-history-market-history-get-public-execution-events
|
|
* @description Fetch a history of filled trades that this account has made
|
|
* @param {string} symbol Unified CCXT market symbol
|
|
* @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
|
|
* @param {int} [limit] Total number of trades, cannot exceed 100
|
|
* @param {object} [params] Exchange specific params
|
|
* @param {int} [params.until] Timestamp in ms of latest trade
|
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
* @param {string} [params.method] The method to use to fetch trades. Can be 'historyGetMarketSymbolExecutions' or 'publicGetHistory' default is 'historyGetMarketSymbolExecutions'
|
|
* @returns An array of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchTrades(symbol string, options ...FetchTradesOptions) ([]Trade, error) {
|
|
|
|
opts := FetchTradesOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchTrades(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewTradeArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#createOrder
|
|
* @description Create an order on the exchange
|
|
* @see https://docs.kraken.com/api/docs/futures-api/trading/send-order
|
|
* @param {string} symbol unified market symbol
|
|
* @param {string} type 'limit' or 'market'
|
|
* @param {string} side 'buy' or 'sell'
|
|
* @param {float} amount number of contracts
|
|
* @param {float} [price] limit order price
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {bool} [params.reduceOnly] set as true if you wish the order to only reduce an existing position, any order which increases an existing position will be rejected, default is false
|
|
* @param {bool} [params.postOnly] set as true if you wish to make a postOnly order, default is false
|
|
* @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
|
|
* @param {float} [params.triggerPrice] the price that a stop order is triggered at
|
|
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
|
|
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
|
|
* @param {string} [params.triggerSignal] for triggerPrice, stopLossPrice and takeProfitPrice orders, the trigger price type, 'last', 'mark' or 'index', default is 'last'
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) CreateOrder(symbol string, typeVar string, side string, amount float64, options ...CreateOrderOptions) (Order, error) {
|
|
|
|
opts := CreateOrderOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var price interface{} = nil
|
|
if opts.Price != nil {
|
|
price = *opts.Price
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CreateOrder(symbol, typeVar, side, amount, price, params)
|
|
if IsError(res) {
|
|
return Order{}, CreateReturnError(res)
|
|
}
|
|
return NewOrder(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#createOrders
|
|
* @description create a list of trade orders
|
|
* @see https://docs.kraken.com/api/docs/futures-api/trading/send-batch-order
|
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) CreateOrders(orders []OrderRequest, options ...CreateOrdersOptions) ([]Order, error) {
|
|
|
|
opts := CreateOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CreateOrders(orders, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#editOrder
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-edit-order
|
|
* @description Edit an open order on the exchange
|
|
* @param {string} id order id
|
|
* @param {string} symbol Not used by Krakenfutures
|
|
* @param {string} type Not used by Krakenfutures
|
|
* @param {string} side Not used by Krakenfutures
|
|
* @param {float} amount Order size
|
|
* @param {float} [price] Price to fill order at
|
|
* @param {object} [params] Exchange specific params
|
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) EditOrder(id string, symbol string, typeVar string, side string, options ...EditOrderOptions) (Order, error) {
|
|
|
|
opts := EditOrderOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var amount interface{} = nil
|
|
if opts.Amount != nil {
|
|
amount = *opts.Amount
|
|
}
|
|
|
|
var price interface{} = nil
|
|
if opts.Price != nil {
|
|
price = *opts.Price
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.EditOrder(id, symbol, typeVar, side, amount, price, params)
|
|
if IsError(res) {
|
|
return Order{}, CreateReturnError(res)
|
|
}
|
|
return NewOrder(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#cancelOrder
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-order
|
|
* @description Cancel an open order on the exchange
|
|
* @param {string} id Order id
|
|
* @param {string} symbol Not used by Krakenfutures
|
|
* @param {object} [params] Exchange specific params
|
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) CancelOrder(id string, options ...CancelOrderOptions) (map[string]interface{}, error) {
|
|
|
|
opts := CancelOrderOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CancelOrder(id, symbol, params)
|
|
if IsError(res) {
|
|
return map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#cancelOrders
|
|
* @description cancel multiple orders
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
|
|
* @param {string[]} ids order ids
|
|
* @param {string} [symbol] unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
*
|
|
* EXCHANGE SPECIFIC PARAMETERS
|
|
* @param {string[]} [params.clientOrderIds] max length 10 e.g. ["my_id_1","my_id_2"]
|
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) CancelOrders(ids []string, options ...CancelOrdersOptions) ([]Order, error) {
|
|
|
|
opts := CancelOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CancelOrders(ids, symbol, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#cancelAllOrders
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-cancel-all-orders
|
|
* @description Cancels all orders on the exchange, including trigger orders
|
|
* @param {str} symbol Unified market symbol
|
|
* @param {dict} [params] Exchange specific params
|
|
* @returns Response from exchange api
|
|
*/
|
|
func (this *Krakenfutures) CancelAllOrders(options ...CancelAllOrdersOptions) ([]Order, error) {
|
|
|
|
opts := CancelAllOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CancelAllOrders(symbol, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#cancelAllOrdersAfter
|
|
* @description dead man's switch, cancel all orders after the given timeout
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-dead-man-39-s-switch
|
|
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} the api result
|
|
*/
|
|
func (this *Krakenfutures) CancelAllOrdersAfter(timeout int64, options ...CancelAllOrdersAfterOptions) (map[string]interface{}, error) {
|
|
|
|
opts := CancelAllOrdersAfterOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.CancelAllOrdersAfter(timeout, params)
|
|
if IsError(res) {
|
|
return map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchOpenOrders
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-get-open-orders
|
|
* @description Gets all open orders, including trigger orders, for an account from the exchange api
|
|
* @param {string} symbol Unified market symbol
|
|
* @param {int} [since] Timestamp (ms) of earliest order. (Not used by kraken api but filtered internally by CCXT)
|
|
* @param {int} [limit] How many orders to return. (Not used by kraken api but filtered internally by CCXT)
|
|
* @param {object} [params] Exchange specific parameters
|
|
* @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchOpenOrders(options ...FetchOpenOrdersOptions) ([]Order, error) {
|
|
|
|
opts := FetchOpenOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchOpenOrders(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchClosedOrders
|
|
* @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
|
|
* @description Gets all closed orders, including trigger orders, for an account from the exchange api
|
|
* @param {string} symbol Unified market symbol
|
|
* @param {int} [since] Timestamp (ms) of earliest order.
|
|
* @param {int} [limit] How many orders to return.
|
|
* @param {object} [params] Exchange specific parameters
|
|
* @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchClosedOrders(options ...FetchClosedOrdersOptions) ([]Order, error) {
|
|
|
|
opts := FetchClosedOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchClosedOrders(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchCanceledOrders
|
|
* @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
|
|
* @description Gets all canceled orders, including trigger orders, for an account from the exchange api
|
|
* @param {string} symbol Unified market symbol
|
|
* @param {int} [since] Timestamp (ms) of earliest order.
|
|
* @param {int} [limit] How many orders to return.
|
|
* @param {object} [params] Exchange specific parameters
|
|
* @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchCanceledOrders(options ...FetchCanceledOrdersOptions) ([]Order, error) {
|
|
|
|
opts := FetchCanceledOrdersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchCanceledOrders(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewOrderArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchMyTrades
|
|
* @description fetch all trades made by the user
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-data-get-your-fills
|
|
* @param {string} symbol unified market symbol
|
|
* @param {int} [since] *not used by the api* the earliest time in ms to fetch trades for
|
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchMyTrades(options ...FetchMyTradesOptions) ([]Trade, error) {
|
|
|
|
opts := FetchMyTradesOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchMyTrades(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewTradeArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchBalance
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-wallets
|
|
* @description Fetch the balance for a sub-account, all sub-account balances are inside 'info' in the response
|
|
* @param {object} [params] Exchange specific parameters
|
|
* @param {string} [params.type] The sub-account type to query the balance of, possible values include 'flex', 'cash'/'main'/'funding', or a market symbol * defaults to 'flex' *
|
|
* @param {string} [params.symbol] A unified market symbol, when assigned the balance for a trading market that matches the symbol is returned
|
|
* @returns A [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchBalance(params ...interface{}) (Balances, error) {
|
|
res := <- this.Core.FetchBalance(params...)
|
|
if IsError(res) {
|
|
return Balances{}, CreateReturnError(res)
|
|
}
|
|
return NewBalances(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchFundingRates
|
|
* @description fetch the current funding rates for multiple markets
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-tickers
|
|
* @param {string[]} symbols unified market symbols
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {Order[]} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchFundingRates(options ...FetchFundingRatesOptions) (FundingRates, error) {
|
|
|
|
opts := FetchFundingRatesOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchFundingRates(symbols, params)
|
|
if IsError(res) {
|
|
return FundingRates{}, CreateReturnError(res)
|
|
}
|
|
return NewFundingRates(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchFundingRateHistory
|
|
* @description fetches historical funding rate prices
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-historical-funding-rates-historical-funding-rates
|
|
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
* @param {object} [params] extra parameters specific to the api endpoint
|
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchFundingRateHistory(options ...FetchFundingRateHistoryOptions) ([]FundingRateHistory, error) {
|
|
|
|
opts := FetchFundingRateHistoryOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var since interface{} = nil
|
|
if opts.Since != nil {
|
|
since = *opts.Since
|
|
}
|
|
|
|
var limit interface{} = nil
|
|
if opts.Limit != nil {
|
|
limit = *opts.Limit
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchFundingRateHistory(symbol, since, limit, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewFundingRateHistoryArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchPositions
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
|
|
* @description Fetches current contract trading positions
|
|
* @param {string[]} symbols List of unified symbols
|
|
* @param {object} [params] Not used by krakenfutures
|
|
* @returns Parsed exchange response for positions
|
|
*/
|
|
func (this *Krakenfutures) FetchPositions(options ...FetchPositionsOptions) ([]Position, error) {
|
|
|
|
opts := FetchPositionsOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchPositions(symbols, params)
|
|
if IsError(res) {
|
|
return nil, CreateReturnError(res)
|
|
}
|
|
return NewPositionArray(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchLeverageTiers
|
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-instrument-details-get-instruments
|
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
*/
|
|
func (this *Krakenfutures) FetchLeverageTiers(options ...FetchLeverageTiersOptions) (LeverageTiers, error) {
|
|
|
|
opts := FetchLeverageTiersOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchLeverageTiers(symbols, params)
|
|
if IsError(res) {
|
|
return LeverageTiers{}, CreateReturnError(res)
|
|
}
|
|
return NewLeverageTiers(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#transferOut
|
|
* @description transfer from futures wallet to spot wallet
|
|
* @param {str} code Unified currency code
|
|
* @param {float} amount Size of the transfer
|
|
* @param {dict} [params] Exchange specific parameters
|
|
* @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
*/
|
|
func (this *Krakenfutures) TransferOut(code string, amount interface{}, options ...TransferOutOptions) (TransferEntry, error) {
|
|
|
|
opts := TransferOutOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.TransferOut(code, amount, params)
|
|
if IsError(res) {
|
|
return TransferEntry{}, CreateReturnError(res)
|
|
}
|
|
return NewTransferEntry(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#transfer
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-wallet-transfer
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-withdrawal-to-spot-wallet
|
|
* @description transfers currencies between sub-accounts
|
|
* @param {string} code Unified currency code
|
|
* @param {float} amount Size of the transfer
|
|
* @param {string} fromAccount 'main'/'funding'/'future', 'flex', or a unified market symbol
|
|
* @param {string} toAccount 'main'/'funding', 'flex', 'spot' or a unified market symbol
|
|
* @param {object} [params] Exchange specific parameters
|
|
* @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
*/
|
|
func (this *Krakenfutures) Transfer(code string, amount float64, fromAccount string, toAccount string, options ...TransferOptions) (TransferEntry, error) {
|
|
|
|
opts := TransferOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.Transfer(code, amount, fromAccount, toAccount, params)
|
|
if IsError(res) {
|
|
return TransferEntry{}, CreateReturnError(res)
|
|
}
|
|
return NewTransferEntry(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#setLeverage
|
|
* @description set the level of leverage for a market
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-set-the-leverage-setting-for-a-market
|
|
* @param {float} leverage the rate of leverage
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} response from the exchange
|
|
*/
|
|
func (this *Krakenfutures) SetLeverage(leverage int64, options ...SetLeverageOptions) (map[string]interface{}, error) {
|
|
|
|
opts := SetLeverageOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbol interface{} = nil
|
|
if opts.Symbol != nil {
|
|
symbol = *opts.Symbol
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.SetLeverage(leverage, symbol, params)
|
|
if IsError(res) {
|
|
return map[string]interface{}{}, CreateReturnError(res)
|
|
}
|
|
return res.(map[string]interface{}), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchLeverages
|
|
* @description fetch the set leverage for all contract and margin markets
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-the-leverage-setting-for-a-market
|
|
* @param {string[]} [symbols] a list of unified market symbols
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchLeverages(options ...FetchLeveragesOptions) (Leverages, error) {
|
|
|
|
opts := FetchLeveragesOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var symbols interface{} = nil
|
|
if opts.Symbols != nil {
|
|
symbols = *opts.Symbols
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchLeverages(symbols, params)
|
|
if IsError(res) {
|
|
return Leverages{}, CreateReturnError(res)
|
|
}
|
|
return NewLeverages(res), nil
|
|
}
|
|
/**
|
|
* @method
|
|
* @name krakenfutures#fetchLeverage
|
|
* @description fetch the set leverage for a market
|
|
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-the-leverage-setting-for-a-market
|
|
* @param {string} symbol unified market symbol
|
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
*/
|
|
func (this *Krakenfutures) FetchLeverage(symbol string, options ...FetchLeverageOptions) (Leverage, error) {
|
|
|
|
opts := FetchLeverageOptionsStruct{}
|
|
|
|
for _, opt := range options {
|
|
opt(&opts)
|
|
}
|
|
|
|
var params interface{} = nil
|
|
if opts.Params != nil {
|
|
params = *opts.Params
|
|
}
|
|
res := <- this.Core.FetchLeverage(symbol, params)
|
|
if IsError(res) {
|
|
return Leverage{}, CreateReturnError(res)
|
|
}
|
|
return NewLeverage(res), nil
|
|
} |