Skip to content

tacyarg/bybit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bybit

Simple and easy to use bybit API abstraction defined using the official documentation.

Official API Documentation: https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md

Initialize & Use

Below is a short guide on how to use the client.

Register your APIKEY

Configure/Init Client

const client = require('bybit')({
  baseURL: 'https://api.bybit.com',
  key: '',
  secret: '',
})

Call Something

client
  .get('/order/list', params)
  .then(console.log)
  .catch(console.error)

Interface

Methods provided by the client.

listActiveOrders

List your Active orders.

  • options - Optional api params
client
  .listOrders([options])
  .then(console.log)
  .catch(console.error)

getActiveOrder

Get a previously created Active order.

  • id - Order ID. The unique order ID returned to you when the corresponding order was created.
  • options - Optional api params
client
  .getOrder(id, [options])
  .then(console.log)
  .catch(console.error)

cancelActiveOrder

Canel a previously created Active order.

  • id - Order ID. The unique order ID returned to you when the corresponding order was created.
client
  .cancelOrder(id)
  .then(console.log)
  .catch(console.error)

createOrder

Create a new order.

client
  .createOrder({
    side: 'Buy',
    symbol: 'BTCUSD',
    order_type: 'Limit',
    time_in_force: 'GoodTillCancel',
    price: 10000,
    qty: 100000,
  })
  .then(console.log)
  .catch(console.error)

limitBuy

Create a limit buy order.

  • price - Order Price
  • qty - Number of Contracts
  • options - Optional api params
client
  .limitBuy(price, qty, [options])
  .then(console.log)
  .catch(console.error)

limitSell

Create a limit sell order.

  • price - Order Price
  • qty - Number of Contracts
  • options - Optional api params
client
  .limitSell(price, qty, [options])
  .then(console.log)
  .catch(console.error)

marketBuy

Create a market buy order.

  • qty - Number of Contracts
  • options - Optional api params
client
  .marketBuy(qty, [options])
  .then(console.log)
  .catch(console.error)

marketSell

Create a market sell order.

  • qty - Number of Contracts
  • options - Optional api params
client
  .marketSell(qty, [options])
  .then(console.log)
  .catch(console.error)

createConditionalOrder

Create a new order.

  • options - Optional api params
client
  .createConditionalOrder([options])
  .then(console.log)
  .catch(console.error)

listConditionalOrders

List conditional orders.

  • options - Optional api params
client
  .listConditionalOrders([options])
  .then(console.log)
  .catch(console.error)

getConditionalOrder

Get a previously created Conditional order.

  • options - Optional api params
client
  .getOrder('order_id', [options])
  .then(console.log)
  .catch(console.error)

cancelConditionalOrder

Canel a previously created Conditional order.

  • id - Order ID. The unique order ID returned to you when the corresponding order was created.
client
  .cancelOrder(id)
  .then(console.log)
  .catch(console.error)

listMyLeverage

List symbol leverage settings.

client
  .listMyLeverage()
  .then(console.log)
  .catch(console.error)

setMyLeverage

Set symbol leverage setting.

  • symbol - Contract type
  • leverage - Leverage value
client
  .setMyLeverage(symbol, leverage)
  .then(console.log)
  .catch(console.error)

listMyPositions

List your positions.

client
  .listMyPositions()
  .then(console.log)
  .catch(console.error)

updatePositionMargin

Update position margin allocation.

  • symbol - Contract type
  • margin - margin value
client
  .updatePositionMargin(symbol, margin)
  .then(console.log)
  .catch(console.error)

getFundingRate

Get the current funding rate. Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC

  • symbol - Contract type
client
  .getFundingRate(symbol)
  .then(console.log)
  .catch(console.error)

getMyFundingFee

Get the provious funding fee. Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC

  • symbol - Contract type
client
  .getMyFundingFee(symbol)
  .then(console.log)
  .catch(console.error)

getMyPredictedFunding

Get your predictied funding rate and fee.

  • symbol - Contract type
client
  .getMyPredictedFunding(symbol)
  .then(console.log)
  .catch(console.error)

listOrderTrades

List trades placed to fill and order.

  • id - order id
client
  .listOrderTrades(symbol)
  .then(console.log)
  .catch(console.error)

getOrderbookSnapshot

Get the current state of the orderbook.

  • symbol - Contract type
client
  .getOrderbookSnapshot(symbol)
  .then(console.log)
  .catch(console.error)

listTickers

List all available ticker data. ( price, ect... )

client
  .listTickers()
  .then(console.log)
  .catch(console.error)

getTicker

get current ticker data.

  • symbol - Contract type
client
  .listTickers(symbol)
  .then(console.log)
  .catch(console.error)