rest

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

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Url - LNMarkets rest API Endpoint
	Url = "https://api.lnmarkets.com"
	// Version - LNMarkets API Version Number
	Version = "v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMarginRequest

type AddMarginRequest struct {
	Amount int64  `json:"amount"`
	Pid    string `json:"pid"`
}

type AddMarginResponse

type AddMarginResponse struct {
	Pid            string `json:"pid"`
	ID             int    `json:"id"`
	Type           string `json:"type"`
	TakeprofitWi   string `json:"takeprofit_wi"`
	Takeprofit     int    `json:"takeprofit"`
	StoplossWi     string `json:"stoploss_wi"`
	Stoploss       int    `json:"stoploss"`
	Side           string `json:"side"`
	Quantity       int    `json:"quantity"`
	Price          int    `json:"price"`
	Pl             int    `json:"pl"`
	MarketWi       string `json:"market_wi"`
	MarketFilledTs string `json:"market_filled_ts"`
	MarginWi       string `json:"margin_wi"`
	Margin         int    `json:"margin"`
	Liquidation    int    `json:"liquidation"`
	Leverage       int    `json:"leverage"`
	CreationTs     string `json:"creation_ts"`
}

type BidAndOfferHistoryResponse

type BidAndOfferHistoryResponse struct {
	Data []struct {
		Time  int64 `json:"time"`
		Bid   int   `json:"bid"`
		Offer int   `json:"offer"`
	} `json:"data"`
}

type CancelAllResponse

type CancelAllResponse struct {
	Data []struct {
		Pid       string `json:"pid"`
		ExitPrice int    `json:"exit_price"`
		ClosedTs  string `json:"closed_ts"`
		Closed    bool   `json:"closed"`
		Pl        int    `json:"pl"`
	} `json:"data"`
}

type CancelResponse

type CancelResponse struct {
	Pid string `json:"pid"`
}

type CarryFeesHistoryResponse

type CarryFeesHistoryResponse struct {
	Data []struct {
		Fixing string `json:"fixing"`
		Index  int    `json:"index"`
	} `json:"data"`
}

type CashInResponse

type CashInResponse struct {
	Amount int    `json:"amount"`
	Pid    string `json:"pid"`
}

type CloseAllResponse

type CloseAllResponse CancelAllResponse

type CloseResponse

type CloseResponse struct {
	Pid       string `json:"pid"`
	ExitPrice int    `json:"exit_price"`
	ClosedTs  string `json:"closed_ts"`
	Closed    bool   `json:"closed"`
	Pl        int    `json:"pl"`
}

type FixingHistoryResponse

type FixingHistoryResponse struct {
	Data []struct {
		Ts              int64   `json:"ts"`
		ID              string  `json:"id"`
		FixingPrice     int     `json:"fixing_price"`
		FeePercentValue float64 `json:"fee_percent_value"`
	} `json:"data"`
}

type IndexHistoryResponse

type IndexHistoryResponse struct {
	Data []struct {
		Time  int64 `json:"time"`
		Index int   `json:"index"`
	} `json:"data"`
}

type InstrumentResponse

type InstrumentResponse struct {
	MaxPositionsCount int     `json:"max_positions_count"`
	MaxMargin         int     `json:"max_margin"`
	MaxLeverage       int     `json:"max_leverage"`
	CarryFees         float64 `json:"carry_fees"`
}

type LNMarkets

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

LNMarkets - object wraps API

func New

func New(key, secret, passphrase, timestamp string) *LNMarkets

func (*LNMarkets) AddMargin

func (api *LNMarkets) AddMargin(amount int64, pid string) (*AddMarginResponse, error)

AddMargin - Add margin to a running position.

func (*LNMarkets) Cancel

func (api *LNMarkets) Cancel(pid string) (*CancelResponse, error)

Cancel - Cancel the position linked to the given pid. Only works on positions that are not currently filled.

func (*LNMarkets) CancelAll

func (api *LNMarkets) CancelAll() (*CancelAllResponse, error)

CancelAll - Cancel all open positions.

func (*LNMarkets) CarryFeesHistory

func (api *LNMarkets) CarryFeesHistory(from int64, to int64, limit int64) (*CarryFeesHistoryResponse, error)

CarryFeesHistory - Retrieves carry fees for user.

func (*LNMarkets) CashIn

func (api *LNMarkets) CashIn(pid string) (*CashInResponse, error)

CashIn - Retrieves part of one running positions PL.

func (*LNMarkets) Close

func (api *LNMarkets) Close() (*CloseResponse, error)

Close - Close the user position. The PL will be calculated against the current bid or offer depending on the side of the position.

func (*LNMarkets) CloseAll

func (api *LNMarkets) CloseAll() (*CloseAllResponse, error)

CloseAll - Close every user position. The PL will be calculated against the current bid or offer depending on the side of the position.

func (*LNMarkets) NewPosition

func (api *LNMarkets) NewPosition(t OrderType, s OrderSide, p float64, m int, sl, tp, q, l float64) (*NewPositionResponse, error)

NewPosition - Send the order form parameters to add a new position in database. If type="l", the property price must be included in the request to know when the position should be filled. You can choose to use the margin or the quantity as a parameter, the other will be calculated with the one you chose.

func (*LNMarkets) Positions

func (api *LNMarkets) Positions() (*PositionsResponse, error)

Positions - Fetch users positions.

func (*LNMarkets) Ticker

func (api *LNMarkets) Ticker() (*TickerResponse, error)

Ticker - Retrieves the futures ticker.

func (*LNMarkets) User

func (api *LNMarkets) User() (*UserResponse, error)

User - Get the user account Information.

type LNMarketsResponse

type LNMarketsResponse struct {
	Result interface{}
	Error  struct {
		Error interface{} `json:"error"`
	}
}

type NewPositionRequest

type NewPositionRequest struct {
	Type       OrderType `json:"type"`
	Side       OrderSide `json:"side"`
	Price      float64   `json:"price"`
	Margin     int       `json:"margin"`
	Stoploss   float64   `json:"stoploss"`
	Takeprofit float64   `json:"takeprofit"`
	Quantity   float64   `json:"quantity"`
	Leverage   float64   `json:"leverage"`
}

type NewPositionResponse

type NewPositionResponse struct {
	Pid            string  `json:"pid"`
	ID             int     `json:"id"`
	Type           string  `json:"type"`
	TakeprofitWi   string  `json:"takeprofit_wi"`
	Takeprofit     float64 `json:"takeprofit"`
	StoplossWi     string  `json:"stoploss_wi"`
	Stoploss       float64 `json:"stoploss"`
	Side           string  `json:"side"`
	Quantity       float64 `json:"quantity"`
	Price          float64 `json:"price"`
	Pl             float64 `json:"pl"`
	MarketWi       string  `json:"market_wi"`
	MarketFilledTs string  `json:"market_filled_ts"`
	MarginWi       string  `json:"margin_wi"`
	Margin         int     `json:"margin"`
	Liquidation    float64 `json:"liquidation"`
	Leverage       float64 `json:"leverage"`
	CreationTs     string  `json:"creation_ts"`
}

type OrderSide

type OrderSide string
const (
	OrderSideBuy  OrderSide = "b"
	OrderSideSell OrderSide = "s"
)

Order sides

type OrderType

type OrderType string
const (
	OrderTypeLimit  OrderType = "l"
	OrderTypeMarket OrderType = "m"
)

Order types

type PositionsResponse

type PositionsResponse struct {
	Positions []struct {
		Pid            string `json:"pid"`
		ID             int    `json:"id"`
		Type           string `json:"type"`
		TakeprofitWi   string `json:"takeprofit_wi"`
		Takeprofit     int    `json:"takeprofit"`
		StoplossWi     string `json:"stoploss_wi"`
		Stoploss       int    `json:"stoploss"`
		Sign           int    `json:"sign"`
		Side           string `json:"side"`
		Quantity       int    `json:"quantity"`
		Price          int    `json:"price"`
		Pl             int    `json:"pl"`
		MarketWi       string `json:"market_wi"`
		MarketFilledTs int64  `json:"market_filled_ts"`
		MarginWi       string `json:"margin_wi"`
		Margin         int    `json:"margin"`
		Liquidation    int    `json:"liquidation"`
		Leverage       int    `json:"leverage"`
		ExitPrice      int    `json:"exit_price"`
		CreationTs     int64  `json:"creation_ts"`
		ClosedTs       int64  `json:"closed_ts"`
		Closed         bool   `json:"closed"`
		Canceled       bool   `json:"canceled"`
		SumCarryFees   int    `json:"sum_carry_fees"`
	} `json:"positions"`
}

type TickerResponse

type TickerResponse struct {
	Bid   float64 `json:"bid"`
	Offer float64 `json:"offer"`
	Index float64 `json:"index"`
}

type UpdateResponse

type UpdateResponse struct {
	Pid   string  `json:"pid"`
	Type  string  `json:"type"`
	Value float64 `json:"value"`
}

type UserResponse

type UserResponse struct {
	UID              string `json:"uid"`
	Balance          int    `json:"balance"`
	AccountType      string `json:"account_type"`
	Username         string `json:"username"`
	Linkingpublickey string `json:"linkingpublickey"`
}

Jump to

Keyboard shortcuts

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