ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.37k stars 824 forks source link

Value Limit #902

Open CooleRnax opened 5 years ago

CooleRnax commented 5 years ago

Problem: Currently running multiple bots with different symbols on single account doesn't work correctly. Wallet-limit doesn't solve this problem so we need new limits.

This feature should allow to:

Ideally this features should be available from GUI without restarting the bot.

ctubio commented 5 years ago

:koala: so remove --wallet-limit argument and replace it by 2 new quoting parameters

xloem commented 5 years ago

I can't believe I didn't see this issue. I've just implemented this for myself over the past two days. Work seems to be stable over today, but still testing to see if balance diverges from reality after lots of changes. I'll reopen PR.

EDIT: PR does not implement gui adjustment

ctubio commented 5 years ago

i just don't understand why is not working correctly currently

with a single param, if you have 6 BTC, and you are trading BTC/EUC, BTC/ETH and BTC/XRP, you can setup all 3 bots with --wallet-limit=2

in this case, each bot will be allowed to trade up to 2 BTC, that is, if price of BTC in EUR is 100, you may start with BTC=2 and EUR=0, and after a few trades end up with BTC=0 and EUR=200.

otherwise, if we have 2 param, i need to know the price of the BTC in EUR to set the --wallet-limit-quote, as well as the price of ETH and XRP.. and also that price to calculate the limit is not a fixed value, it changes over time.

soo, if you ask me, it makes more sense to just set --wallet-limit, to define your wallet capacity, than recalculating manually prices nonstop (that can be done by the app in realtime)

in other words, i dont think that is a good idea to define the wallet limit as X dollars and X houses and X cars and X televisions; i just wanna define it as X dollars because is called "base" currency for a reason (because is what your economy is based at, called also accounting currency or reporting currency; is the monetary unit used to report transactions/profit/losses/limits and any other financial statement).

anyway i try hard to understand your point of view :S please if you consider explain your problem with other words cos i already forgot what we talk on irc and here we only have "doesn't work correctly"

thanks for your time'¡!

CooleRnax commented 5 years ago

@ctubio My first idea was % based limit. This way manual adjustments over time are not needed. But unfortunately, you rejected it.

So I came up with not so elegant solution as base and quote limits. As periodic manual adjustments are needed I suggest gui variable.

The main thing here is that we are limiting VALUE, not just BASE currency. This way each bot behave as independent instance, this is very useful when you use % based settings in the bot.

When I trade for example BTC/USD LTC/USD ETH/USD, I value my account in USD, not ETH. So I take all USD split it by 3, and get 3 independent instance. That's why BASE limit is not good for my case.

ctubio commented 5 years ago

many thanks'' let me reread https://github.com/ctubio/Krypto-trading-bot/issues/883 to see if i can understand this "% based limit", otherwise will go for the 2 param solution

:koala: related PR at https://github.com/ctubio/Krypto-trading-bot/pull/913

ctubio commented 5 years ago

yea i think we will discard https://github.com/ctubio/Krypto-trading-bot/issues/883 cos not only needs to read all wallets from all currencies (a doable thing that requires 1 call in most exchanges) but also need to know the fair values of all currencies to know the total final amount where to apply the % for each wallet (that is, too many calls :S)

let me merge #913 with lil mods to allow editable limits from the UI instead of from params

hope you agree'¡

CooleRnax commented 5 years ago

@ctubio From my point of view it is not too hard to implement. You can use ccxt library, it has unified api calls across all exchanges. And every N minutes send 2 requests. Get balance - single request Get all tickers at once - single request Do some calculations That's it

ctubio commented 5 years ago

iSee, instead of fair values from market levels, just read the tickers xD ok letme rethink cos then we have again a single call :D

CooleRnax commented 5 years ago

@ctubio The only problem I see, if we will run a lot of bot from single ip or single api key, we might face api rate limiting if we call too often or at the same time. So we will need error handling and N minutes as adjustable variable to do less calls if needed.

ctubio commented 5 years ago

soo.. in the UI, you wanna have 1 more quoting parameter? named "wallet %" (or similar) on each bot?

and since all bots known the total funds, just apply the % value like a limit for that bot?

like if we have 10 BTC, and 100 EUR and 100 ETH, and tickers in both markets are 100, we have in total:

so for market BTC/EUR, if % is set to 33%, the max values could be:

for market BTC/ETH, if % is set to 10%, the max values could be:

with the consideration that the quote currency if possible cannot be limited, for example if we have again 10 BTC and 100 EUR and 100 ETH, if limit is 50%, we will have a wallet in BTC/EUR of 5 BTC and 100 EUR (cos what we attempt to reduce first is the base currency)

do you agree? or you were thinking in more than 1 new quoting parameter? (i hope not xD)

about api calls noworry cos we are already getting this data and ignoring it i think in most exchanges. otherwise i will test/fix or reconsider as always the deletion of dummy exchanges :D

CooleRnax commented 5 years ago

Everything seems fine! Single quoting parameter is even better, if you can handle everything under the hood.

ctubio commented 5 years ago

coOl'' :koala: many thanks for insist on this'' (i will use that feature sure :D hope for it soOn)

CooleRnax commented 5 years ago

@ctubio doing my best thanks for maintaining and developing such a great bot!

ctubio commented 5 years ago

btw if possible can you share what exhange/s are you using? i will try hard to not delete them xD

CooleRnax commented 5 years ago

@ctubio pmed you in irc