scrtlabs / catalyst

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

Live stats report the wrong number of transactions per open position #171

Closed lacabra closed 6 years ago

lacabra commented 6 years ago

Catalyst 0.4.4:

When I hold several positions, and place a new order, the number of transactions gets copied on all positions, instead of only the one that I just bought. Sample output (you need to scroll right...)

[2018-01-18 22:09:19.664010] INFO: algo: handling bar 2018-01-18 22:08:00+00:00
[2018-01-18 22:10:12.081229] INFO: algo: [2018-01-18 22:08:00] buy signal: TradingPair(51197 [cnd_btc]) - Price:1.471e-05, Stop:1.2477e-05
[2018-01-18 22:10:18.566963] INFO: algo: completed bar 2018-01-18 22:08:00+00:00, total execution errors 0
[2018-01-18 22:10:18.660443] INFO: exchange_algorithm: statistics for the last 1 minutes:
                                                                                                                                     symbol         amount  cost_basis  last_sale_price
period_close              starting_cash ending_cash portfolio_value pnl         long_exposure short_exposure orders transactions                                                       
2018-01-18 22:09:00+00:00 1             0.56879395  0.98927946      -0.01072054 0.4204855     0              1      1               fun_btc  3424.58768342  0.00000975       0.00000956
                                                                                                                    1              dash_btc     0.21930113  0.07608261       0.07433000
                                                                                                                    1               amb_btc   547.14306834  0.00006101       0.00005663
                                                                                                                    1             waves_btc    21.92982456  0.00076084       0.00074450
                                                                                                                    1               rdn_btc    36.81695347  0.00045319       0.00043503
                                                                                                                    1               lun_btc     5.41125541  0.00308339       0.00295660
                                                                                                                    1              nuls_btc    31.58599603  0.00052824       0.00050589
                                                                                                                    1               elf_btc   134.58225668  0.00012398       0.00011964
                                                                                                                    1               mtl_btc    79.63386421  0.00041939       0.00040200
                                                                                                                    1               bts_btc   516.17832085  0.00003233       0.00003112
                                                                                                                    1               icx_btc    23.12015893  0.00072029       0.00069100
                                                                                                                    1               vib_btc   529.66534383  0.00003143       0.00003214
                                                                                                                    1               brd_btc   118.91724923  0.00014011       0.00013887
                                                                                                                    1              vibe_btc   602.44740472  0.00008241       0.00008137
                                                                                                                    1               xvg_btc  1564.58063821  0.00001062       0.00001014
                                                                                                                    1               xrp_btc   114.33070418  0.00014576       0.00013900
                                                                                                                    1               zrx_btc   111.19615526  0.00015017       0.00014776
                                                                                                                    1               cdt_btc  1706.61013371  0.00000977       0.00000942
                                                                                                                    1               tnb_btc  1763.15201315  0.00000948       0.00000962
                                                                                                                    1               ark_btc    28.43053575  0.00058694       0.00056930
                                                                                                                    1               cnd_btc  1208.83561879  0.00001326       0.00001325

In the example above, instead of reporting one new transaction for cnd_btc, it reports one new transaction for every position I have open.

fredfortier commented 6 years ago

Good catch. We need to either include "transaction" in the index of the DataFrame of make if specific to each position. Currently, the number of transactions is global to the frame and apparently not in the index.

fredfortier commented 6 years ago

Grouped into the header for now. We could break these down by positions if we wanted to.

screenshot 2018-01-25 17 41 27
fredfortier commented 6 years ago

In release 0.5.2