Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
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) => {
"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,
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))
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()
}
startListening() {
const client = binance_api_node_1.default();
client.ws.trades(['BTCUSDT'], trade => this.onPriceUpdate('BTCUSDT', Number(trade.price)));
}
}
constructor({key, secret}) {
this.binance = Api({
apiKey: key,
apiSecret: secret
})
}