项目作者: libertas-primordium

项目描述 :
A full-featured Bittrex v3 REST-API client for Node.js
高级语言: JavaScript
项目地址: git://github.com/libertas-primordium/bittrex-rest-client.git
创建时间: 2021-03-01T20:08:24Z
项目社区:https://github.com/libertas-primordium/bittrex-rest-client

开源协议:MIT License

下载


bittrex-rest-client

Forked from Andrew Barba’s bittrex-node


Description:

  • Upgraded to Bittrex v3 API specification
  • Now includes methods for fetching chart candles via REST API
  • 100% unit-test coverage
  • Heavily documented
  • Promise based with async/await
  • All public methods have thorough JSdoc comments for quick reference and parameter auto-fill in modern code editors.

I think I’ve included all of the functionality that most traders and developers will need, but if there is a particular API endpoint that I have overlooked which you need, open a new issue and I will add it.


There are no plans to incorporate the websocket API into this repository, as the REST API has use cases beyond trading.


Usage:

Initialize Client

This package is now available as an NPM module, and can be added to your project with:

  1. $ npm install bittrex-rest-client

Then call it in your code as a dependency:

  1. const { BittrexClient } = require('bittrex-rest-client')

And initialize a new instance:

  1. const client = new BittrexClient({
  2. apiKey: process.env.KEY, // pass API creds from .env file in project directory
  3. apiSecret: process.env.SECRET,
  4. timeout: 3000 // Optional, specify timeout for web requests, in milliseconds.
  5. })

Public Requests

  1. await client.markets() //List all available markets on the exchange.
  2. await client.currencies() //List all available currencies on the exchange.
  3. await client.ticker(marketSymbol) //Get current ticker quote.
  4. await client.marketSummaries() //List 24-hour summaries for all available markets.
  5. await client.marketSummary() //Get 24-hour summary for specified market.
  6. await client.marketTrades(marketSymbol) //Get list of most recently executed trades for specified market.
  7. await client.orderBook(marketSymbol,depth=25)//Get orderbook for specified market.
  8. await client.getCandlesRecent(marketSymbol,candleInterval,candleType='TRADE') //Retrieve most recent candles for specified market.
  9. await client.getCandlesHistorical(marketSymbol,candleInterval,year,month=1,day=1,candleType='TRADE') //Retrieve candles from historical period for specified market.

Trading

  1. await client.sendOrder(marketSymbol,direction,type,{quantity,ceiling,limit}={},timeInForce='IMMEDIATE_OR_CANCEL',clientOrderId=uuid(),useAwards=false) // Send a new order to the exchange.
  2. await client.getOpenOrders(marketSymbol)//List open orders.
  3. await client.cancelOrder(clientOrderId,marketSymbol) //Cancel an open order.
  4. await client.getOrderHistory(marketSymbol,nextPageToken,previousPageToken,pageSize,startDate,endDate) //Retrieve a list of closed orders.

Account Management

  1. await client.balances(currencySymbol) //Retrieve current balance for specified currencySymbol or a list of all balances.
  2. await client.getNewDepositAddress(currencySymbol) //Request new deposit address.
  3. await client.getaddresses(currencySymbol) //retrieve deposit address for specified currency or all currencies.
  4. await client.withdrawalHistory(open,{currencySymbol,status}) //Get list of withdrawals.
  5. await client.depositHistory(currencySymbol,pending) //Get list of deposits.
  6. await client.requestWithdrawal(currencySymbol,quantity,cryptoAddress,{cryptoAdressTag,clientWithdrawalId}) // Request a new withdrawal
  7. await client.cancelWithdrawal(withdrawalId) //Cancel a pending withdrawal request.

Note on testing

Be careful testing on a live account.
All tests will pass assuming a valid API key/secret with all permissions enabled. The trading method is tested in a manner that will not result in trades being filled. The withdrawal method attempts to make a 50BTC withdrawal, and expects to receive an ‘INSUFFICIENT_FUNDS’ error. You can change the test paramaters of course in test/index.js.


Nobody paid me to do this, so if my work saves you time or money, consider sending a tip!

  1. BTC: 1EHkFQBk9LB2Zm3RcP7EeVLqUUDaEFpNxx
  2. LTC: Lht9v7E9bxPMAmU2TUeVx2SJZu2AW32LSW
  3. ETH: 0xaba31e526ca98a2a659d69b30adc2da8f3eaaa2d
  4. DOGE: DC8xePEAyC2PeGQUqF51abrF8m7BMuVVoS
  5. XMR: 41tnfGBpCt527q9aqdAjU914gcyJ8Fk2K9vGHHxswgF1hPgouanA2WFbQKimLBMt3zESnkuBWcn29NMiVAC1k4CxRMAdqB6

Licence

This software is made available under the MIT licence.

Copyright (c) 2018 AndrewBarba;
Copyright (c) 2021 libertas-primordium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.