Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Profit reporting & PNL table #693

Closed
askmike opened this issue Apr 16, 2017 · 18 comments
Closed

Profit reporting & PNL table #693

askmike opened this issue Apr 16, 2017 · 18 comments

Comments

@askmike
Copy link
Owner

askmike commented Apr 16, 2017

Right now gekko can either paper trade (simulate) or live trade on spot markets.

This means:

  • Gekko assumes the market to be:
    • curency: safest / base currency
    • asset: asset investment vehicle
  • You can only make money buy going "long", "short" means you simply hold the base currency.
  • Every time you went long -> short you potentially made money (we can calc PnL & risk metrics for this).

Knowing this I propose we add a table to Gekko (backtester + live trader) that has all the swings (buy->sell), something like this:

 entry date -   exit date   -   exposed duration - PnL - profit
10/10/2015 - 11/10/2015 -   1 day                   - $10  - 1%
11/10/2015 - 12/10/2015 -   1 day                   - $10  - 1%
12/10/2015 - 13/10/2015 -   1 day                   - $10  - 1%

Thoughts?

@askmike
Copy link
Owner Author

askmike commented Apr 16, 2017

This is now in the develop branch:

screen shot 2017-04-16 at 21 48 39

@askmike
Copy link
Owner Author

askmike commented Apr 16, 2017

Closing this as it's implemented (at least in backtesting). If anyone has any comments feel free to comment them here!

@askmike askmike closed this as completed Apr 16, 2017
@thegamecat
Copy link

Could you label buys and sells, and always list the currency value, asset value price, date time, pnl sum, pnl trade pair.

The hard part in live is there will be occassions where part fills occur. Then this can require management, like a timeout to pull a buy, a replace buy higher, or pull altogether. In the case of a sell do you chase a sell and so on. I dont know the exact mechanics of this inside gekko today, as I mainly use an alert for now.

@askmike
Copy link
Owner Author

askmike commented Apr 17, 2017

buys and sells

A roundtrip is always one buy and then one sell! Entry is time of buy and Exit is time of sell.

and always list the currency value, asset value price, date time, pnl sum, pnl trade pair.

Will extend the chart (this data is already available, just need to add it to the chart).

The hard part in live is there will be occassions where part fills occur.

So a "roundtrip" (still looking for a better name) indicates that the portfolio went from SHORT to LONG to SHORT. It doesn't matter how many orders it took (exit time would be the either the final order execution OR a timerange). The P&L is based on the how much profit was made in total, eg. your balance after going long - your balance before going long, it doesn't matter how many orders this took.

Then this can require management, like a timeout to pull a buy, a replace buy higher, or pull altogether.

Gekko currently keeps on making new orders (every minute on default) until the full balance is flipped. I don't think we need to touch this behaviour.

@thegamecat
Copy link

Ok that all sounds reasonable. I still prefer buy and sells rather than round trips but maybe that's just me haha 😂

@askmike
Copy link
Owner Author

askmike commented Apr 17, 2017 via email

@askmike
Copy link
Owner Author

askmike commented Apr 17, 2017

@thegamecat

and always list the currency value, asset value price, date time, pnl sum, pnl trade pair.

What about this? It now shows the balance of the portfolio at entry and exit (eg. how much money you had when you BOUGHT and how much money you had when you SOLD).

screen shot 2017-04-17 at 20 45 27

@thegamecat
Copy link

I like it, maybe have a summary of what the currency / asset is. And maybe make Sum Total and TX profits?

@askmike
Copy link
Owner Author

askmike commented Apr 17, 2017

Ah that screenshot doesn't show the "global" profit report (all trades), that looks like this:

screen shot 2017-04-17 at 20 52 03

But I am about to add a few more metrics (exposure % - how much of the time you were holding the risky asset AND sharpe ratio - risk based on P&L performance).

@thegamecat
Copy link

Ok tested this and it looks good 👍

This may be a personal pet hate but would it be possible to state the asset that has changed in the balance and profit columns?

Loving the use of the Sharpe ratio :)

@thegamecat
Copy link

So after a few days of playing with this I think I've come to the conclusion that it would be better to either replace this with the log of buys and sells or have that along side it.

I don't believe the round trip gives the right level of detail.

@generalectric
Copy link
Contributor

Is it possible with live trading to get roundtrip information into the pushover plugin so we can show more than just long and short price?

@generalectric
Copy link
Contributor

generalectric commented Apr 26, 2017

OK so opening my eyes and reading the ever so helpful documentation and going over the code. Roundtrips are part of papertrader which uses simulated balance. Trader plugin has no idea about the balance until it advices and goes to manager function in which case it decides if it needs to know balance or not depending on exchange. So reading the documents, plug-ins rely on information from events. Candle events and advice events don't carry information on asset or currency balance. Should we have an event that carries information about currency and asset balances? This would be useful for plugins as well as the UI.

@ztnark
Copy link
Contributor

ztnark commented Jul 18, 2017

Along these lines, what's the best way to access the portfolio balance from a plug-in?

@askmike
Copy link
Owner Author

askmike commented Jul 18, 2017

@ztnark The profit reporting table gets its data from a "trader" and it does not care about the original datasource. If you run a backtest or a paper trader this "trader" is just a simulation (the paper trader plugin). I am working on integrating the live trader with this system, almost there but it is a lot of work. See #737.

@ztnark
Copy link
Contributor

ztnark commented Jul 18, 2017

@askmike Great! Let me know if there are any stories I could help out with.

@aitorjs
Copy link

aitorjs commented Aug 24, 2017

Which data represent the data appearing ""entry balance" and "exit balance"?

I guess is the value of the currency (for example, bitcoin) on the exchange (for example, bittrex) you are using on the moment you entry (entry balance). At the moment you exit is "exit balance". But, this data doesnt match with the strategys I try. For example: MACD on default configuration for a minute with 1 currency and asset.

At 2017-08-24 03:03 the robot exit with 4026.47006852$ as roundtrips table says. You lock on log which was the price at that time on bittrext and say: { Bid: 4148, Ask: 4148.041, Last: 4136 }. So, the data appearing on "entry balance" and "exit balance" could not be the price of bitcoin on entry or exit.

I was taking a look to the code but I cant figure out which are the values appearing on "entry balance" and "exit balance".

Thanks! ;-)

@askmike
Copy link
Owner Author

askmike commented Aug 24, 2017

Which data represent the data appearing ""entry balance" and "exit balance"?

A roundtrip is two trades: a buy and than a sell. Entry balance is total balance after the "buy" orders where fully executed. Exit balance is total balance after the "sell" orders where fully executed.


It is based on what the "trader" tells Gekko about how the signals from the strat where turned into orders. So this depends on papertrader (or backtest) VS live trader. The first one uses the same market information as the strat uses (eg. candles), the latter uses information on what price your real orders where executed at the exchange.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants