scrtlabs / catalyst

An Algorithmic Trading Library for Crypto-Assets in Python
http://enigma.co
Apache License 2.0
2.48k stars 724 forks source link

Question about trade log from perf df - is BTC amount reported correctly? #297

Open mkcity opened 6 years ago

mkcity commented 6 years ago

Dear Catalyst Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

See the trade log below (as obtained from the perf df). The algo buys 6.052787e-02 BTC. Then, it uses that BTC to buy EMC2 at 0.000096. Then, it sells that EMC2 at 0.000102, making around 6% profit. Then, I immediately proceed to sell all my BTC using the order_target_percent(context.btc, 0) command, but as you can see from the report below, it only sells 6.052787e-02 BTC? This is the same amount that I bought originally (first trade in the log), but this amount should be up 6% BTC?

2017-12-09 23:22:00+00:00 TradingPair(374465 [btc_usdt]) 6.052787e-02 14452.445100 2017-12-10 04:00:00+00:00 TradingPair(751929 [emc2_btc]) 8.061685e+06 0.000096 2017-12-10 04:50:00+00:00 TradingPair(751929 [emc2_btc]) -8.061685e+06 0.000102 2017-12-10 04:50:00+00:00 TradingPair(374465 [btc_usdt]) -6.052787e-02 13448.655000

Here is how you can reproduce this issue on your machine:

Reproduction Steps

  1. In an algo, buy BTC_USDT, then buy something else with that BTC
  2. Sell what you bought in #1 at a profit
  3. Now sell all your BTC and look at the results in perf. How much BTC did you sell? The same amount that you bought? Or the amount you bought * profit percent? ...

What steps have you taken to resolve this already?

Don't know how to test this.

Anything else?

Thank you

Sincerely, mk

AvishaiW commented 6 years ago

Hi, seems like this occurs when running order_target_percent while owing a variety of assets in your portfolio. i'm looking into this..

AvishaiW commented 6 years ago

after giving another look at this issue, I noticed that you are using several base currencies, which is currently not supported by catalyst, we look to enhance this in the future, and I'll make sure to emphasise this in the docs.

mkcity commented 6 years ago

You are right. I noticed that using different base currencies messes up a lot of things.

The problem is that it seems like it works. You don't get any errors. If you log/print your orders, everything seems to work. You even see the transactions in perf. But only upon close inspection do you see that it doesn't work correctly.

THank you for clarifying.