restfulApi

package
v0.0.0-...-057132d Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalSignature

func CalSignature(apisecret, payload string) string

func SetBItmexAPIheader

func SetBItmexAPIheader(headerParams map[string]string, a *OrderApi, httpMethod, path string, formParams map[string]interface{}, queryParams url.Values)

*

  • TODO: currently not parse queryParam

func Signature

func Signature(apisecret, method, path, query, nonce, poststr string) string

*

  • nonce: nonce or expires

Types

type APIClientImpl

type APIClientImpl struct {
}

func (APIClientImpl) CallAPI

func (c APIClientImpl) CallAPI(path string, method string,
	postBody interface{},
	headerParams map[string]string,
	queryParams url.Values,
	formParams map[string]interface{},
	fileName string,
	fileBytes []byte) (*resty.Response, error)

func (APIClientImpl) ParameterToString

func (c APIClientImpl) ParameterToString(obj interface{}, collectionFormat string) string

func (APIClientImpl) SelectHeaderAccept

func (c APIClientImpl) SelectHeaderAccept(accepts []string) string

func (APIClientImpl) SelectHeaderContentType

func (c APIClientImpl) SelectHeaderContentType(contentTypes []string) string

type APIResponse

type APIResponse struct {
	*http.Response
	Message string `json:"message,omitempty"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type OrderApi

type OrderApi struct {
	Configuration *bitmex.Configuration
}

func NewOrderApi

func NewOrderApi(configuration *bitmex.Configuration) *OrderApi

func (OrderApi) NewOrder

func (a OrderApi) NewOrder(symbol string, side string, simpleOrderQty float64, quantity float32, orderQty float32, price float64, displayQty float32, stopPrice float64, stopPx float64, clOrdID string, clOrdLinkID string, pegOffsetValue float64, pegPriceType string, type_ string, ordType string, timeInForce string, execInst string, contingencyType string, text string) *bitmex.Order

* create an order structure

func (OrderApi) OrderCancel

func (a OrderApi) OrderCancel(orderID string, clOrdID string, text string) (*bitmex.Order, *APIResponse, error)

*

  • Cancel order(s). Send multiple order IDs to cancel in bulk.
  • Either an orderID or a clOrdID must be provided. *
  • @param orderID Order ID(s).
  • @param clOrdID Client Order ID(s). See POST /order.
  • @param text Optional cancellation annotation. e.g. 'Spread Exceeded'.
  • @return []Order

func (OrderApi) OrderNew

func (a OrderApi) OrderNew(symbol string, side string, simpleOrderQty float64, quantity float32, orderQty float32, price float64, displayQty float32, stopPrice float64, stopPx float64, clOrdID string, clOrdLinkID string, pegOffsetValue float64, pegPriceType string, type_ string, ordType string, timeInForce string, execInst string, contingencyType string, text string) (*bitmex.Order, *APIResponse, error)

*

  • Create a new order.
  • This endpoint is used for placing orders. Valid order types are Market, Limit, Stop, StopLimit, MarketIfTouched,
  • LimitIfTouched, MarketWithLeftOverAsLimit, and Pegged. If no order type is provided, BitMEX will assume
  • 'Limit'. Be very careful with 'Market' and 'Stop' orders as you may be filled at
  • an unfavourable price. You can submit bulk orders by POSTing an array of orders to `/api/v1/order/bulk`.
  • Send a JSON payload with the shape: `{\"orders\": [{...}, {...}]}`, with each inner object
  • containing the same fields that would be sent to this endpoint. A note on API tools: if you want to keep
  • track of order IDs yourself, set a unique clOrdID per order. This clOrdID will come back as a property on the
  • order and any related executions (including on the WebSocket), and can be used to get or cancel the order. Max
  • length is 36 characters. To generate a clOrdID, consider setting a prefix, and incrementing a counter or
  • generating a UUID. Some UUIDs are longer than 36 characters, so use a url-safe base64 encoding. For example,
  • the prefix `'bmex_mm_'` and the UUID `'7fbd6545-bb0c-11e4-a273-6003088a7c04'`
  • creates `'bmex_mm_f71lRbsMEeSic2ADCIp8BA'`. See the [BitMEX Reference
  • Market Maker](https://github.com/BitMEX/market-maker/blob/22c75a2b6db63e20212813e9afdb845db1b09b2a/bitmex.py#L152)
  • for an example of how to use and generate clOrdIDs. *
  • @param symbol Instrument symbol. e.g. 'XBT24H'.
  • @param side Order side. Valid options: Buy, Sell. Defaults to 'Buy' unless `orderQty` or `simpleOrderQty` is negative.
  • @param simpleOrderQty Order quantity in units of the underlying instrument (i.e. Bitcoin).
  • @param quantity Deprecated: use `orderQty`.
  • @param orderQty Order quantity in units of the instrument (i.e. contracts).
  • @param price Optional limit price for 'Limit', 'StopLimit', and 'LimitIfTouched' orders.
  • @param displayQty Optional quantity to display in the book. Use 0 for a hidden order.
  • @param stopPrice Deprecated: use `stopPx`.
  • @param stopPx Optional trigger price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders. Use a price below the current price for stop-sell orders and buy-if-touched orders. Use `execInst` of 'MarkPrice' or 'LastPrice' to define the current price used for triggering.
  • @param clOrdID Optional Client Order ID. This clOrdID will come back on the order and any related executions.
  • @param clOrdLinkID Optional Client Order Link ID for contingent orders.
  • @param pegOffsetValue Optional trailing offset from the current price for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders; use a negative offset for stop-sell orders and buy-if-touched orders. Optional offset from the peg price for 'Pegged' orders.
  • @param pegPriceType Optional peg price type. Valid options: LastPeg, MidPricePeg, MarketPeg, PrimaryPeg, TrailingStopPeg, TrailingStopPeg.
  • @param type_ Deprecated: use `ordType`.
  • @param ordType Order type. Valid options: Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, Pegged. Defaults to 'Limit' when `price` is specified. Defaults to 'Stop' when `stopPx` is specified. Defaults to 'StopLimit' when `price` and `stopPx` are specified.
  • @param timeInForce Time in force. Valid options: Day, GoodTillCancel, ImmediateOrCancel, FillOrKill. Defaults to 'GoodTillCancel' for 'Limit', 'StopLimit', 'LimitIfTouched', and 'MarketWithLeftOverAsLimit' orders.
  • @param execInst Optional execution instructions. Valid options: ParticipateDoNotInitiate, AllOrNone, MarkPrice, IndexPrice, LastPrice, Close, ReduceOnly, Fixed. 'AllOrNone' instruction requires `displayQty` to be 0. 'MarkPrice' or 'LastPrice' instruction valid for 'Stop', 'StopLimit', 'MarketIfTouched', and 'LimitIfTouched' orders.
  • @param contingencyType Optional contingency type for use with `clOrdLinkID`. Valid options: OneCancelsTheOther, OneTriggersTheOther, OneUpdatesTheOtherAbsolute, OneUpdatesTheOtherProportional.
  • @param text Optional order annotation. e.g. 'Take profit'.
  • @return *Order

func (OrderApi) OrderNewBulk

func (a OrderApi) OrderNewBulk(orders []bitmex.Order) ([]bitmex.Order, *APIResponse, error)

*

  • Create multiple new orders.
  • This endpoint is used for placing bulk orders. Valid order types are Market, Limit, Stop, StopLimit,
  • MarketIfTouched, LimitIfTouched, MarketWithLeftOverAsLimit, and Pegged. Each individual order object
  • in the array should have the same properties as an individual POST /order call. This endpoint is much
  • faster for getting many orders into the book at once. Because it reduces load on BitMEX systems, this
  • endpoint is ratelimited at `ceil(0.5 * orders)`. Submitting 10 orders via a bulk order call
  • will only count as 5 requests. For now, only `application/json` is supported on this endpoint. *
  • @param orders An array of orders.
  • @return []Order
  • TODO: currently not used, input parameter should be order array

type PositionApi

type PositionApi struct {
	bitmex.AbstructAPI
	Configuration *bitmex.Configuration
}

func NewPositionApi

func NewPositionApi(configuration *bitmex.Configuration) *PositionApi

Jump to

Keyboard shortcuts

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