DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.22k stars 2.04k forks source link

Feature req: End balance in crypto (asset) not in currency #1293

Open rountrey opened 6 years ago

rountrey commented 6 years ago

System information

Describe the problem

I've thought hard about this and to prevent me from stressing out so much on live trading and in getting my sims completed, I would like to have an option to have the end balance in crypto only. With the market like it is, constantly going up and down, I have now created a new goal in mind. That goal is to grow my crypto and to not worry about the prices of them. I'm thinking of a setting that shows the percentage increase in crypto from the start either by pressing "X" or "P", or the simulation ending.

Source code / logs

Sample sim: change "end balance" and "buy hold" value to crypto balance only instead of crypto*price but leave percentages in place.

end balance: 200.31317843 (15.06%) buy hold: 203.70404858 (17.00%) vs. buy hold: -1.66%

to

end balance: 23.012LTC (15.06%) buy hold: 20.00 (0.00%) vs. buy hold: 15.06%

I understand this would place the buy/hold at 0% but I think it would be fine.

defkev commented 6 years ago

Balance means asset + currency in currency as the profit (end balance/buy hold as well as win/loss) gets calculated against the current (the last) market price.

e.g. BTC (in USD) + USD XMR (in BTC) + BTC

infatrus commented 6 years ago

Let's assume trades with LTC-BTC asset-currency pair. Starting parameters are: 20 LTC / 0 BTC (1 LTC = 0.01 BTC) Ending parameters are: 15 LTC / 0 BTC (1 LTC = 0.015 BTC) Buy hold: 20 * 0.015 = 0.3 (50%)

So, at the end you've got 15 * 0.015 = 0.225 BTC - that means 25% loss (against no trades at all), not 12,5% gain. Profit is only virtual and depends on exchange rate. The goal of trading is multiplying asset/currency, not (temporary) balance!

Maybe that's why Zenbot usually trade with losses.

defkev commented 6 years ago

What happened to the 5 LTC?

infatrus commented 6 years ago

Disappeared during "profitable" Zenbot trades - while making 12,5% gain ;)

defkev commented 6 years ago

If you manage to lose 1/4th of your asset i'd say something is wrong with your strategy/config :smirk:

Start capital: 0.20 BTC End capital: 0,225 BTC +12.5% vs Buy/Hold (hold as you started with 0 currency): 0.3 BTC +50%

So End vs Buy/Hold -37.5%

infatrus commented 6 years ago

That's only sample, just to show that trade based on balance calculations may not be optimal, as well as summary form may be misleading when trading asset.

With most simulations (and not only sims), you can observe Zenbot "bleeding" (slower or faster) with your asset/currency and still reporting "+x.xx" in profit column (the one before last).

defkev commented 6 years ago

I absolutely agree that the profit calculation is factually incorrect, as e.g 20 LTC vs 15 LTC is in fact a 25% lose and not a 12.5% win (at a price change from 0.01 to 0.015 BTC)

BUT taking into account that the bot separates between Asset (LTC) and Currency (USD) like Cryptocurrency/Fiat i suppose (suppose) the intent behind the original implementation, which came before i started using/contributing to the project, was to trade Fiat for Coins (and vise versa) and calculate profit in Fiat (using Coin * Worth + Fiat) as the idea of trading is to increase your original investment (in Fiat)

Now before you chase me with a stick, you are of course able to trade Cryptocurrency/Cryptocurrency pairs (like LTC/BTC or whatever/BTC) but this doesn't really change the intent why you are trading in the fist place.

I suspect the vs Buy/Hold profit was added later to address just that and illustrate the other side of the same coin, which it does.

If anything you would probably need to implement two different modes of profit calculation (like asset trader vs currency trader) so people can actually choose what they are aiming to accomplish.

infatrus commented 6 years ago

Maybe it would be better to calculate profit in comparison to buy-hold?

subhead commented 3 years ago

Is there any approach to archieve this? I´m also interessted in generating more cryptos then currencies.