Improved profit and loss reporting
#1
The PnL reporting in Gekko is based on 'round trips'. This is nice because it keeps things simple, but is also limiting Gekko's capabilities. To enable more advanced strategies in Gekko that can trade parts of the balance, a more flexible PnL reporting is needed.

This thread is to continue the discussion of the suggested proposal here.

As an example of this implementation, a stand alone cli-application is available here.

What  do we want PnL reporting in Gekko to look like in the future? Please share your views here, what is the best way forward?
  Reply
#2
To follow up on the discussion here: https://github.com/askmike/gekko/issues/...-379536861

Quote:When trading, selling is just as risky as buying. The situation is symmetrical, selling one currency is the same as buying the other. The risks are that the price goes up further after you've sold, or goes down even lower after you've bought.

I should make it more clear on what set of assumptions Gekko is build, but "selling one currency is the same as buying the other." is definitely not true from Gekko's perspective: how can you measure risk and exposure to some market if you consider both things on that market to be dangerous to hold? All of Gekko's risk and exposure metrics (and the whole roundtrip system) is based on the assumption (in case of BTC/USD) that USD is your benchmark and you are trying to trade BTC in order to increase the amount of USD you have, but holding USD is never risky. Yes USD can technically lose value through inflation or compared against the euro, but that's out of scope for Gekko.

Quote:The risks are that the price goes up further after you've sold, or goes down even lower after you've bought.

The first one is definitely not a risk, if that happens you don't lose any money. I also would never say strategies that fail to sell at the top are bad.

Quote:Trading a partial balance helps mitigating this risk. It allows you to 'walk into' your position. When you've bought some and the price unexpectedly drops, you can buy some more. This brings the average price at which you bought, closer to the bottom price.

Very true, I 100% agree with the benefits. I don't think we should not build this because it's a bad feature. I just think that's it is a very hard feature to properly build in a way where everyone will understand what is going on (and like how it is displayed).

Quote:I have nothing fancy in mind for the interface. Simply a table for each traded currency pair as above in the OP. And maybe one overview table that shows all traded currency pairs and a summary of the result.

I am not talking about complex UI elements, I think it's very hard to create one simple table that has all the information and is understandable by everyone. Note that PnL is a concept that is usually only used when doing more advanced stuff like trading on leverage or future trading. For the reason that it all of a sudden you are abstracting all your trades away into new concepts.

Quote:Every trade is managed and reported as a leveraged position. Even though the leverage is 1x

As soon as Gekko starts reporting 1x leverage and/or short trades while trading the spot on exchanges like bitfinex and poloniex (exchanges that offer both spot and margin trading) it's going to be extremely confusing for everyone. Also remember that leverage is very hard to grasp for new traders (the majority of people opening tickets and asking questions about gekko).
  Reply
#3
A first GUI version of the PnL reporting is available for anyone interested to try out, here in this pull request.

At first I made a command line version only. Soon I realized that I could not see my P&L and average open position on the go, on my mobile. So I needed to run this on my server, which requires a GUI. The backend is still a verbatim copy of the command line tool. This means the integration with the existing gekko code can be somewhat improved.

  •     * Currently it reads API keys from environment variables, just like the command line tool. It does not make use of Gekko's mechanism for managing API keys.
  •     * It uses its own module for interfacing with the exchange. It is probably nicer to merge the new functions for fetching trades into the existing exchange interfaces in Gekko, to keep this code organized in the place where it belongs.
  •     * It is only tested with the Kraken exchange. Adding support for more exchanges should be fairly straight forward.
  Reply
#4
At first I had made a command line version of my PnL calculation. Soon I realized that I could not see my average open position on my mobile, on the go. So I had to run this my server, which requires a GUI.
For who is interested to have a look or develop it further, it is available in my pull request here. It is essentially a verbatim copy of my command line tool, with a GUI page on top of it.
This means the integration with the rest of the Gekko code can be improved.
  •     * API keys need to be set using environment variables. It is not using Gekko's existing functionality for managing API keys.
  •     * The new functions for fetching the trades from the exchange are in their own module. They could be merged into the existing exchange interfaces to keep this code organized in the place where it belongs.
  •     * Since I don't have accounts on every exchange, it is not tested for other exchanges besides Kraken. Adding support for more exchanges should be fairly straight forward.
I think Gekko is really great, so I've decided to give this back, instead of keeping it to myself, as a way  to say thanks. I hope others find it useful too or make it better!
  Reply
#5
(04-08-2018, 12:52 PM)askmike Wrote: To follow up on the discussion here: https://github.com/askmike/gekko/issues/...-379536861

Quote:When trading, selling is just as risky as buying. The situation is symmetrical, selling one currency is the same as buying the other. The risks are that the price goes up further after you've sold, or goes down even lower after you've bought.

Not completely correct. If you sell an asset empty (meaning actually going short) the price of this asset could go up without any limit whereas if you buy an asset (meaning actually going long) the price of the underlying asset can only go down to zero. So in the trading world a real short trade is considered a lot riskier than a long trade. This means that all trades have to be based on a portfolio management system, consisting of at least a risk defining procedure as well as a money management tool which defines the position size to trade next.

Quote:Trading a partial balance helps mitigating this risk. It allows you to 'walk into' your position. When you've bought some and the price unexpectedly drops, you can buy some more. This brings the average price at which you bought, closer to the bottom price.

This kind of thinking when trading at any market is very dangerous. It is called DCA or dollar cost averaging and a lot of the trading bot programmers especially those who actually try to sell their trading bot software are using DCA as a marketing tool.
In the real trading world cost averaging on the way down will kill your portfolio at a given point in the future since it contains a deadly misconception. It assumes, that an asset falling right now will eventually recover. But in the real world it does not need to do this it can fall until it hits zero.
As a high profile example from the real world take the Enron stock in the nineties or take Lehmann Brothers stock back in 2008. A lot of people thought that a huge bank like Lehmann Brothers would not stop existing so they bought even more stock when that thing was in free fall. We all know how that ended.
So, yes DCA can be a tool in Gekko but it needs to be in an advanced mode and needs to carry a serious warning tag.

But in general i agree that Gekko needs some kind of advanced mode where experienced traders can go and set their money management profile and their risk levels.
  Reply
#6
I am not talking about complex UI elements, I think it's very hard to create one simple table that has all the information and is understandable by everyone. Note that PnL is a concept that is usually only used when doing more advanced stuff like trading on leverage or future trading best water flosser. For the reason that it all of a sudden you are abstracting all your trades away into new concepts.
  Reply
#7
(09-09-2018, 10:36 PM)BotsEdge Wrote:
(04-08-2018, 12:52 PM)askmike Wrote: To follow up on the discussion here: https://github.com/askmike/gekko/issues/...-379536861

Quote:When trading, selling is just as risky as buying. The situation is symmetrical, selling one currency is the same as buying the other. The risks are that the price goes up further after you've sold, or goes down even lower after you've bought.

Not completely correct. If you sell an asset empty (meaning actually going short) the price of this asset could go up without any limit whereas if you buy an asset (meaning actually going long) the price of the underlying asset can only go down to zero. So in the trading world a real short trade is considered a lot riskier than a long trade. This means that all trades have to be based on a portfolio management system, consisting of at least a risk defining procedure as well as a money management tool which defines the position size to trade next.

Quote:Trading a partial balance helps mitigating this risk. It allows you to 'walk into' your position. When you've bought some and the price unexpectedly drops, you can buy some more. This brings the average price at which you bought, closer to the bottom price.

This kind of thinking when trading at any market is very dangerous. It is called DCA or dollar cost averaging and a lot of the trading bot programmers especially those who actually try to sell their trading bot software are using DCA as a marketing tool.
In the real trading world cost averaging on the way down will kill your portfolio at a given point in the future since it contains a deadly misconception. It assumes, that an asset falling right now will eventually recover. But in the real world it does not need to do this it can fall until it hits zero.
As a high profile example from the real world take the Enron stock in the nineties or take Lehmann Brothers stock back in 2008. A lot of people thought that a huge bank like Lehmann Brothers would not stop existing so they bought even more stock when that thing was in free fall. We all know how that ended.
So, yes DCA can be a tool in Gekko but it needs to be in an advanced mode and needs to carry a serious warning tag.

But in general i agree that Gekko needs some kind of advanced mode where experienced traders can go and set their money management profile and their risk levels.

It would be nice to be able to create math that trades more agresivly or more carefullly when it knows it reached a portofolio of x% above its invested money. And to trade less risky when there is y% left of the investment.
I think its quite benneficial to know your actual portofolio for a lot thinkering with trading math.
Clear readable data is always handy
[....Resistance is futile...]
  Reply


Forum Jump:


Users browsing this thread: