andresilvasantos / bitprophet

Node crypto trading platform for Binance exchange.
MIT License
228 stars 70 forks source link

Multiple accounts in a single instance. #32

Open bitcoiniodev opened 6 years ago

bitcoiniodev commented 6 years ago

Hello Andre

The buydip strategy is rather greedy on traffic. When I need to run two bots with the same strategy what should be the steps to prevent double data loading from exchange? Could there be easy fix or complete rewrite needed?

supershwa commented 6 years ago

Hi Mike,

If you're running two bots and want to divide the traffic, you could try this:

buydip1: {
    name: "Buy Dip 1",
    paperTrading: true,
    buyAmountMarket: 0.018,
    profitTarget: 1.4,
    maxLoss: 0.8,
    maxTradingPairs: 50,
    targetMarket: "BTC",
    targetTokens: ["ETH","LTC","VEN","TRX","BNB","XLM","NEO","ETC"] // half of the token list here
},
buydip2: {
    name: "Buy Dip 2",
    paperTrading: true,
    buyAmountMarket: 0.018,
    profitTarget: 1.4,
    maxLoss: 0.8,
    maxTradingPairs: 50,
    targetMarket: "BTC",
    targetTokens: ["EOS","BCC","ICX","ONT","IOTA","ADA","XMR","NANO"] // 2nd half of the token list here
}

This way, your "buydip1" strategy will cover the first half of the list of tokens you would like it to use, and the "buydip2" strategy would be the 2nd half of the list.

This would probably be the easiest way to accomplish your goal, and would require a little bit of time dedicated to creating the lists, but it should do what you need it to.

Hope it helps!

-supershwa

andresilvasantos commented 6 years ago

Hello Mike,

The buydip strategy is rather greedy on traffic.

Yes, the strategies that have lots of valid pairs will have high traffic consumption. We still need to rewrite that part of the code - we open a websocket that requests a 500 candlestick data each second for each pair, instead of requesting the 500 candlestick data for the first time and open a websocket that gives us the next candlestick when it is ready. I was kinda lazy that day :smile:

When I need to run two bots with the same strategy what should be the steps to prevent double data loading from exchange?

There is no double data loading right now, as we only update a pair if it is really outdated.


You can always do as @supershwa wrote, but I can't understand what would be the point to have the same strategies duplicated.

bitcoiniodev commented 6 years ago

If the bots are working on different accounts but use the same strategy - that is the case when we need to share the candles but need 2 bots

andresilvasantos commented 6 years ago

For that scenario it won't be possible to share the candles, so you'll be downloading the same data twice. You can only have one account for each instance of BitProphet. That's an issue that would be cool to address in a near future.

bitcoiniodev commented 6 years ago

- we open a websocket that requests a 500 candlestick data each second for each pair - you meant that even when strategy needs 5 minute candles they are loaded every second?

andresilvasantos commented 6 years ago

Sorry, what I said was wrong.

We don't load the data every second. With the websocket connection, the data is sent and loaded when there are changes to the price. So, if you request the 1h, 5m and 1m charts, as soon as the price changes, all three will receive new data (500 candlestick for each every time). The correct approach here, is to keep a single websocket open (1 candlestick of data for each update) and to update all three with the new data.

bitcoiniodev commented 6 years ago

Last night I succeeded to be "IP banned" by binance while running several other bots plus one bitprophet. Other bots worked fine during 2 month but now "1200 requests per minute" message arrived and my vds IP was blocked for short period (binance kindly sends timestamp "until" ). Also about 1TB of traffic eaten during two days )))

andresilvasantos commented 6 years ago

I'm running BitProphet 24/7 since March now. I never looked at the bandwidth, but that's an issue we need to take care of. I never got my IP banned, so, those 1200 req / min, are being probably used mostly by the other bots. The requests that count for that sum, are being done for each token for validation. If the token is not valid, it will be done again, but 15 minutes later. Other than that, those requests are being used for certain issued commands when the user interacts.