freqtrade / freqtrade

Free, open source crypto trading bot
https://www.freqtrade.io
GNU General Public License v3.0
28.54k stars 6.12k forks source link

Possible to optimize for obtaining non-base currency? #4003

Closed leifjones closed 3 years ago

leifjones commented 3 years ago

There appears to be an implied premise to Freqtrade (and it's documentation) that it is optimal to maximize amount held in the base currency / stake currency. However, if a trader has the goal of maximizing the amount held in the non-stake currency, is there a way to explicitly orient a Freqtrade bot toward that?

This butts up against an assumption inherent to using stock market trading as a model: Generally, a stock market trader who is trading Tesla/USD and Amazon/USD considers "profit" to mean higher amount of USD, not high amounts of Tesla or Amazon stock.

However, a cryptocurrency trader using the DOGE/USD pair may choose to strategize towards maximizing holdings of DOGE, not USD. Freqtrade doesn't seem to have an option to "flip" the orientation like that. What would be involved in flipping the orientation like this?

While this may seem like a "meta" question, I am seeking answers that are concrete, relating to configuration, refactoring, or strategy-writing.

xmatthias commented 3 years ago

That's a different question - and picking Doge as sample (a coin that so far caused me only losses, so i blacklist it whenever i can) doesn't really help.

Leaving personal feelings for Doge aside - freqtrade cannot really do that (not for Doge, anyway).

On binance, there's multiple alternative stake currencies (ETH, XRP, TRX) - as well as a ton of stable coins which you can use for this - as the goal is to maximize "stake_currency" - whatever that is (however, stake-currency must also be quote currency on that exchange).

The problem with using a "non-quote" currency for this is that your workflow would be "sell Doge, rebuy doge" - which is reversed from how freqtrade currently works.

I think i understand the logic as i did similar trading a few years ago (sell part of your holdings while high, rebuy when it pulls back a little to maximize "RANDCOIN") - but not with freqtrade.


Looking at pairs available for this method (you'll have DOGE/whateverquote - currently 3 pairs on Binance, nameliy DOGE/BTC, DOGE/USDT and DOGE/BUSD) available, you'd very much limit yourself to very few pairs - which will almost certainly also show almost identical moves - so i think your chance of profit is pretty low already, as you can do almost no diversification.

Without looking too much at the code (so just from memory), i'd say it's quite difficult to implement at this moment - as all calculations and logic is based around long trades. While this is also (kindof) a long trade, logic is reversed - so the calculations would have to be similar to a short trade - which we currently won't support.


To be honest, i think this is too much of a niche to implement (and mainly to maintain) in freqtrade (at least at the moment), as at a first glance, it would require a LOT of custom logic to support. It may be simpler with short possibilities in freqtrade, but as pointed out in other issues, that's kindof a long shot too - as there's quite some changes that need to happen for short-trading to be enabled and to work.

leifjones commented 3 years ago

I apologize for the Shiba Inu-shivers around DOGE! I chose a ridiculous example to playfully divert attention away from intended currency(ies).

I appreciate your thoughtful response - with your initial ideas about what's involved in preparing for an imagined "flippening" between crypto and fiat.

Can you suggest any starting points for learning about long vs short and switching orientation in Freqtrade? Or about the type of trading you did some years ago?

xmatthias commented 3 years ago

my trading was manual, simply owning a coin (don't even remember which one it was) say 1000 of that - and then selling 200 when i think it's going to go down afterwards, and then rebuying 220 or so (however much my "Profit" was).

This however was ... not doing so well during 2018, where that coin crashed pretty bad - so while then owning more of Doge (it wasn't doge) - my FIAT balance went negative very quickly.


Switching long vs. short (or rather supporting short trading) is something i can only direct new contributors away from - as it will require very deep knowledge of the internals of the bot and will be a lengthy process involving multiple PR's steering the bot towards supporting this.

Best start with other things we have open issues for - and once you know "this is done in that part of the bot" - then consider short trading again - but to get started, it'll only be frustrating because i know already that it won't be something that will give you any satisfaction in the short-term.

xmatthias commented 3 years ago

i'm going to close this here as we've got enough other issues for long/shorting, so this will provide nothing additional.

Feel free to comment below / reopen if you think differently

moinonin commented 3 years ago

One quick tip. If I understand correctly, you want to accumulate the non-stake currency. First, you want to make a good strategy that does long buys. So you buy the coin (cheaply), then you try not to sell the coin. In your strategy, use a stoploss that is ridiculously high, e.g. -10 or more neg, in the ROI table, set your minimal ROI so high that it doesn't get to sell (do NOT use 0 or -1) and leave the "populate sell indicator" blank. You can set minimal ROI to 100%. In the config, list only the coins you want to accumulate. Open many positions, like 100, of a reasonably small amounts in stake currency. Let's just say, you need a good long-buying strategy, the rest seems easy. Note: I haven't done this but only by intuition.

leifjones commented 3 years ago

@moinonin I appreciate the thoughts. At least at this time, Freqtrade doesn't allow for multiple positions per pair. Is your back-of-the-envelope approach still compatible?

moinonin commented 3 years ago

@mrsegen I totally agree with the fact that freqtrade does not allow that cumulative buying although there might be a way around sometime in future as I have seen some issues requesting stacking. That said, as a rudimentary way for now, it would be to release the assets that have been successfully acquired from the database. I have tried to test what I alluded to earlier setting minimal ROI to various values between 4 - 5% using some online risk assessment to sell at lower profits only when high risk is foreseen. This resulted in the following results:

metrics

Of course this does not address your original problem but the assumption here is you really try to hold your asset.