Skip to content

Commit

Permalink
fix(trader): crash error: can't access .minQty of 'undefined'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJoeSchr committed Jan 27, 2021
1 parent 32cc0d8 commit 0b214a7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions trader.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ socket.on('buy_signal', async (signal) => {
}
else {
const alt = signal.pair.replace('BTC','')
if (minimums[alt+'BTC'].minQty) {
if (minimums[alt+'BTC'] && minimums[alt+'BTC'].minQty) {
const buy_amount = new BigNumber(user_payload[tresult].buy_amount)
const btc_qty = buy_amount.dividedBy(signal.price)
const qty = bnb_client.roundStep(btc_qty, minimums[alt+'BTC'].stepSize)
Expand Down Expand Up @@ -358,7 +358,7 @@ socket.on('sell_signal', async (signal) => {
}
else {
const alt = signal.pair.replace('BTC','')
if (minimums[alt+'BTC'].minQty) {
if (minimums[alt+'BTC'] && minimums[alt+'BTC'].minQty) {
const buy_amount = new BigNumber(user_payload[tresult].buy_amount)
const btc_qty = buy_amount.dividedBy(signal.price)
const qty = bnb_client.roundStep(btc_qty, minimums[alt+'BTC'].stepSize)
Expand Down Expand Up @@ -444,7 +444,7 @@ socket.on('sell_signal', async (signal) => {
}
else {
const alt = signal.pair.replace('BTC','')
if (minimums[alt+'BTC'].minQty) {
if (minimums[alt+'BTC'] && minimums[alt+'BTC'].minQty) {
const qty = trading_qty[signal.pair+signal.stratid]
///
const traded_sell_signal = {
Expand Down Expand Up @@ -522,7 +522,7 @@ socket.on('close_traded_signal', async (signal) => {
}
else {
const alt = signal.pair.replace('BTC','')
if (minimums[alt+'BTC'].minQty) {
if (minimums[alt+'BTC'] && minimums[alt+'BTC'].minQty) {
const qty = signal.qty
///
if (margin_pairs.includes(alt+"BTC")) {
Expand Down Expand Up @@ -583,7 +583,7 @@ socket.on('close_traded_signal', async (signal) => {
}
else {
const alt = signal.pair.replace('BTC','')
if (minimums[alt+'BTC'].minQty) {
if (minimums[alt+'BTC'] && minimums[alt+'BTC'].minQty) {
const qty = trading_qty[signal.pair+signal.stratid]
console.log("QTY ==> " + qty + " - " + alt + "BTC")
bnb_client.mgMarketBuy(alt + "BTC", Number(qty), (error, response) => {
Expand Down

0 comments on commit 0b214a7

Please sign in to comment.