How to use the binance-api-node.default function in binance-api-node

To help you get started, we’ve selected a few binance-api-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsappme / node-binance-trader / trader.js View on Github external
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////

const app = express()
app.get('/', (req, res) => res.send(""))
app.listen(process.env.PORT || 8003, () => console.log('NBT auto trader running.'.grey))

//////////////////////////////////////////////////////////////////////////////////

let trading_pairs = {}
let buy_prices = {}
let user_payload = []

//////////////////////////////////////////////////////////////////////////////////

const binance_client = binance({
    apiKey: 'replace_with_your_Binance_apiKey',
    apiSecret: 'replace_with_your_Binance_apiSecret',
})

//////////////////////////////////////////////////////////////////////////////////
const nbt_vers = "0.2.0"
// Retrieve previous open trades //
axios.get('https://bitcoinvsaltcoins.com/api/useropentradedsignals?key=' + bva_key )
.then( (response) => {
    response.data.rows.map( s => {
        trading_pairs[s.pair+s.stratid] = true
        buy_prices[s.pair+s.stratid] = new BigNumber(s.buy_price)
    })
    console.log("Open Trades:", _.values(trading_pairs).length)
})
.catch( (e) => {
github stockmlbot / DataSynchronizer / src / exchange / ws_exchanges / binance_ws.js View on Github external
"use strict"

const util = require("../../utils")
const Emitter = require("../../emitter/emitter")

// Binance things
const exchange_name = "binance"
const default_interval = 60

const Binance = require("binance-api-node").default
const client = new Binance()
// Binance things

const open_socket = async (symbol, interval = default_interval) => {
  interval = util.interval_toString(interval)

  let socket_candle = await client.ws.candles(symbol, interval, (candle) => {
    Emitter.emit("CandleUpdate", exchange_name, interval, candle)

    if (candle.isFinal == true) {
      Emitter.emit("CandleUpdateFinal", exchange_name, interval, candle)
    }
  })

  let socket_trades = await client.ws.aggTrades(symbol, (trade) => {
    trade = {
      time: trade.eventTime,
github jsappme / node-binance-trader / index.js View on Github external
let stop_price = 0.00
let loss_price = 0.00
let sell_price = 0.00
let buy_amount = 0.00
let stepSize = 0
let tickSize = 8
let tot_cancel = 0
let pair = ""
let buying_method = ""
let selling_method = ""
let init_buy_filled = false

//////////////////////////////////////////////////////////////////////////////////

// Binance API initialization //
const client = binance({apiKey: APIKEY, apiSecret: APISECRET, useServerTime: true})

const conf = new Configstore('nbt')
let base_currency = conf.get('nbt.base_currency')?conf.get('nbt.base_currency'):"USDT"
let budget = conf.get('nbt.budget')?parseFloat(conf.get('nbt.budget')):1.00
let fixed_buy_price = conf.get('nbt.fixed_buy_price')?parseFloat(conf.get('nbt.fixed_buy_price')):0.00
let currency_to_buy = conf.get('nbt.currency_to_buy')?conf.get('nbt.currency_to_buy'):"BTC"
let profit_pourcent = conf.get('nbt.profit_pourcent')?conf.get('nbt.profit_pourcent'):0.80
let loss_pourcent = conf.get('nbt.loss_pourcent')?conf.get('nbt.loss_pourcent'):0.40
let trailing_pourcent = conf.get('nbt.trailing_pourcent')?conf.get('nbt.trailing_pourcent'):0.40

clear()

console.log(chalk.yellow(figlet.textSync('_N_B_T_', { horizontalLayout: 'fitted' })))
console.log(' ')
console.log(" 🐬 ".padEnd(10) + '                   ' + " 🐬 ".padStart(11))
console.log(" 🐬 ".padEnd(10) + chalk.bold.underline.cyan('Node Binance Trader') + " 🐬 ".padStart(11))
github jsappme / node-binance-trader / server.js View on Github external
console.log("Connecting to the Postgresql db...")
    pg_client = new Client({
        ssl: pg_connectionSSL,
        connectionString: pg_connectionString,
    })
    pg_client.connect()
}
//////////////////////////////////////////////////////////////////////////////////

const server = express()
    .use((req, res) => res.sendFile(INDEX) )
    .listen(PORT, () => console.log(`NBT server running on port ${ PORT }`))

//////////////////////////////////////////////////////////////////////////////////

const binance_client = binance()

//////////////////////////////////////////////////////////////////////////////////

async function run() {
    //pairs = await get_pairs()
    //pairs = pairs.slice(0, tracked_max)
    pairs.unshift('BTCUSDT')
    pairs.unshift('ETHBTC')
    console.log(" ")
    console.log("Total pairs: " + pairs.length)
    console.log(" ")
    console.log(JSON.stringify(pairs))
    console.log(" ")
    await sleep(wait_time)
    await trackData()
}
github cryptocontrol / algo-trading-server / dist / exchanges / Binance.js View on Github external
startListening() {
        const client = binance_api_node_1.default();
        client.ws.trades(['BTCUSDT'], trade => this.onPriceUpdate('BTCUSDT', Number(trade.price)));
    }
}
github passabilities / crypto-exchange / src / exchanges / binance.js View on Github external
constructor({key, secret}) {
    this.binance = Api({
      apiKey: key,
      apiSecret: secret
    })

  }

binance-api-node

A node API wrapper for Binance

MIT
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis

Popular binance-api-node functions

Similar packages