npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-cobinhood

v0.2.8

Published

nodejs cobinhood api client

Downloads

18

Readme

NPM

Node-Cobinhood NPM downloads

node-cobinhood is a nodejs api wrapper of cobinhood restful api and websocket. node-cobinhood provides an easier way to access cobinhood exchange.

Getting Started

You should get an api key of cobinhood first. Put your api key in one of example and try it!

Client Instance

With api key, you can create a client with following code.

const Client = require('node-cobinhood')
let client = new Client({ key: `your api key` })

Then you can access cobinhood exchange throgh RESTFUL API or Websocket.

Disable Websocket

If you don't want to connect ws, specify in constructor.

const Client = require('node-cobinhood')
let client = new Client({ key: `your api key`, disableWS: true })

Enums

  • order side
    • bid
    • ask
  • order type
    • limit
    • market
    • limit_stop
    • market_stop
  • ledger type
    • exchange
    • margin
    • funding
  • candle timeframe
    • 1m
    • 5m
    • 15m
    • 30m
    • 1h
    • 3h
    • 6h
    • 12h
    • 1D
    • 7D
    • 14D
    • 1M

RESTFUL API

You can access cobinhood exchange with such client method below. RESTFUL API will returns a promise object.

  • listOrders()
  • listTradingPairs()
  • listCurrencies()
  • listOrderbookPrecisions(pair)
    • pair: trading pair
  • listFundingbookPrecisions(currency)
    • currency: currency
  • placeLimitOrder(pair, side, price, size, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • price: price, string or decimal object
    • size: size, string or decimal object
    • source: "exchange" or "margin"
  • placeMarketOrder(pair, side, size, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • size: size, string or decimal object
    • source: "exchange" or "margin"
  • placeLimitStopOrder(pair, side, price, size, stopPrice, source)
    • pair trading pair
    • side: "bid" or "ask"
    • price: price string or decimal object
    • size: size, string or decimal object
    • stopPrice: stop price, string or decimal object
    • source: "exchange" or "margin"
  • placeMarketStopOrder(pair, side, size, stopPrice, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • size: size, string or decimal object
    • stopPrice: stop price, string or decimal object
    • source: "exchange" or "margin"
  • cancelOrder(id)
    • id: order id
  • modifyOrder(id, price, size)
    • id: order id
    • price: price, string or decimal object
    • size: size, string or decimal object
  • getOrder(id)
    • id: order id
  • getBalance()
  • transferBalance(currency, from, to, amount)
    • currency: currency
    • from: balance ledger type, for example "exchange", "margin"
    • to: balance ledger type, for example "exchange", "margin"
    • amount: amount, string or decimal object
  • getOrderbook(pair, precision, limit)
    • pair: trading pair
    • precision: trading pair support precision, for example new Decimal("1e-7") or "1E-7"
    • limit: limits number of entries of asks/bids list, beginning from the best price for both sides
  • listTrades(pair)
    • pair: trading pair
  • getTicker(pair)
    • pair: trading pair
  • getTimeframe(pair, start, end, timeframe)
    • pair: trading pair
    • start: start time, need Date object
    • end: end time, need Date object
    • timeframe: candle timeframe, for example "1h", "15m"
  • getTradesHistory(pair, limit, page)
    • pair: trading pair
    • limit: limits number of trades per page
    • page: pagination
  • getTradesOfOrder(id)
    • id: order id
  • listPositions()
  • getPosition(pair)
    • pair: trading pair
  • closePosition(pair)
    • pair: trading pair
  • claimPosition(pair, size)
    • pair: trading pair
    • size: size, must be positive, string or decimal object
  • getFundingbook(currency, precision, limit)
    • currency: currency
    • precision: currency support precision, for example new Decimal("1e-7") or "1E-7"
    • limit: limits number of entries of asks/bids list, beginning from the best price for both sides
  • getLoanTicker(currency)
    • currency: currency
  • listFundings()
  • getFunding(id)
    • id: funding id
  • placeLimitFunding(currency, side, interestRate, period, size)
    • currency: currency
    • side: "bid" or "ask"
    • interestRate: daily interest rate(%), string or decimal object
    • period: bid / ask days (2 ~ 30)
    • size: size, string or decimal object
  • cancelFunding(id)
    • id: funding id
  • listLoans()
  • getLoan(id)
    • id: loan id
  • closeLoan(id)
    • id: loan id

Websocket

Upon client created, websocket is connecting, so you should call client close if you don't need it. Client provides some websocket events. You can listen events to know the situation.

Events

  • open
    • When websocket connected, it will be fired.
  • close
    • When websocket closed, it will be fired.
  • error
    • When websocket error, it will be fired.
  • reconnecting
    • When websocket reconnecting, it will be fired.
  • reconnected
    • When websocket reconnected, it will be fired.

Subscribes

You can subscribe websocket update with such client method below. Subscription function will returns a promise object.

  • subscribeOrder(fn)
    • fn: callback function
  • subscribeTicker(pair, fn)
    • pair: trading pair, for example "COB-ETH"
    • fn: callback function
  • subscribePublicTrade(pair, fn)
    • pair: trading pair, for example "COB-ETH"
    • fn: callback function
  • subscribeOrderbook(pair, precision, fn)
    • pair: trading pair, for example "COB-ETH"
    • precision: trading pair support precision, for example new Decimal("1e-7") or "1E-7"
    • fn: callback function
  • subscribeCandle(pair, timeframe, fn)
    • pair: trading pair, for example "COB-ETH"
    • timeframe: candle timeframe, for example "1h", "15m"
    • fn: callback function
  • subscribeFundingbook(currency, precision, fn)
    • currency: currency, for example "USDT"
    • precision: currency support precision, for example new Decimal("1e-7") or "1E-7"
    • fn: callback function
  • subscribeLoanTicker(currency, fn)
    • currency: currency, for example "USDT"
    • fn: callback function
  • subscribePublicLoan(currency, fn)
    • currency: currency, for example "USDT"
    • fn: callback function
  • subscribeAuthLoan(currency, fn)
    • currency: currency, for example "USDT"
    • fn: callback function
  • subscribeFunding(fn)
    • fn: callback function

Trading

You can also trade with websocket. The api is almost same with restful version but response is same with websocket update.

  • placeLimitOrderWS(pair, side, price, size, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • price: price, string or decimal object
    • size: size, string or decimal object
    • source: "exchange" or "margin"
  • placeMarketOrderWS(pair, side, size, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • size: size, string or decimal object
    • source: "exchange" or "margin"
  • placeLimitStopOrderWS(pair, side, price, size, stopPrice, source)
    • pair trading pair
    • side: "bid" or "ask"
    • price: price string or decimal object
    • size: size, string or decimal object
    • stopPrice: stop price, string or decimal object
    • source: "exchange" or "margin"
  • placeMarketStopOrderWS(pair, side, size, stopPrice, source)
    • pair: trading pair
    • side: "bid" or "ask"
    • size: size, string or decimal object
    • stopPrice: stop price, string or decimal object
    • source: "exchange" or "margin"
  • cancelOrderWS(id)
    • id: order id
  • modifyOrderWS(id, price, size)
    • id: order id
    • price: price, string or decimal object
    • size: size, string or decimal object