Git Product home page Git Product logo

Comments (6)

markusstephanides avatar markusstephanides commented on September 26, 2024 1

Alright thanks I will look further into it.

EDIT: It's definitely a issue with binance and not your lib, thanks though!

from node-binance-api.

jaggedsoft avatar jaggedsoft commented on September 26, 2024

Maybe related to quantity, hard to say. I would need to see the code calling the order

from node-binance-api.

markusstephanides avatar markusstephanides commented on September 26, 2024

Yes it definitely is related to quantity. The bot buys in this example and this is how I calculate the quantity, how I send the order and how I calculate the correct lot size:

let amnt = binanceBalance / ask
amnt = roundStep(amnt, "ETHBTC");
amnt -= amnt * fees;
amnt = roundStep(amnt, "ETHBTC");

binance.marketBuy("ETHBTC", amnt, callback);

function roundStep(number, symbol){
    symbol = convFromSix(symbol);
    // get symbol step size
    let stepSize = 1;
    let prec = 0;
    exchangeInfos.symbols.forEach(sy => {
        if(sy.symbol === symbol) {
            stepSize = parseFloat(sy.filters[1].stepSize);
            prec = sy.baseAssetPrecision;
        }
    });
    let finalNumber = ((number / stepSize) | 0) * stepSize;
    finalNumber = parseFloat(finalNumber.toFixed(prec));
    return finalNumber
}

from node-binance-api.

jaggedsoft avatar jaggedsoft commented on September 26, 2024

is binanceBalance your amount in BTC?
If it is let's pretend you have 1btc
ETH is currently .057354 btc
binanceBalance / .057354 = 17.4355
So for 1 btc you can afford 17.43 ETH which would come to a total of .99968 btc

Maybe instead of rounding the step you could try just using Math.floor for now

from node-binance-api.

markusstephanides avatar markusstephanides commented on September 26, 2024

Yeah binanceBalance is my BTC balance.

Maybe instead of rounding the step you could try just using Math.floor for now

I'm not sure what you mean, can you show me an example?

from node-binance-api.

jaggedsoft avatar jaggedsoft commented on September 26, 2024

I can't identify where exactly your code is messing up on the calculations, but you should double check the math so it matches the same numbers you punch in on the website

let amount = (binanceBalance / eth price).toFixed(2);
binance.marketBuy("ETHBTC", amount, callback);

This should work when called by itself, but I suspect roundstep is messing it up

from node-binance-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.