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

transactions data lost when restarting live algorithm binance #471

Open kooomix opened 6 years ago

kooomix commented 6 years ago

I have restarted my algorithm (using the same namespace) and found out that the transactions list (_context.perf_tracker.todays_performance.processedtransactions) is empty... while the context.portfolio remained updated...

I don't know how to reproduce... But if sharing some files from the _.catalyst/data/livealgos can help with finding out the possible reason, let me know and i'll provide it.

Note that there was no action done manually through the exchange account - all transactions have been done directly from the algo.

Thanks

superluminance commented 6 years ago

@kooomix first of all, thanks for mentioning context.perf_tracker.todays_performance.processed_transactions. That's a field I've been looking for.

I am trying to understand why you want to keep transactions when algo restarts. Coming here from #467, my guess is that you want to have the algo picks up previous orders placed by the same algo before restarting. It will be a nice feature to add. As far as I know, however, it is not supported. To work around this, I put a cancel_all() function inside analyze(), so that all working orders get cancelled when algo turns off. In a disconnection, however, I have to manually cancel orders on the exchanges.

On the other hand, keep tracking of process_transactions when algo restarts isn't that useful in practice IMO. Normally one only cares the transactions happen in the current session. The portfolio keeps updating because it has a remaining position and average fill price (cost_basis) recorded. (under .catalyst/data/live_algos/frame_stats/*.p). The transactions data, however, is left empty for some reason. (not true, see correction below)

Please also note that no manual action doesn't necessary means the algo should manage all orders / transactions. There could be multiple algos trading the same products on the same exchanges. Catalyst is designed in a way to distinguish them, managing orders and calculating positions / pnls independently.

kooomix commented 6 years ago

First - transactions are usually being kept when I restart the algorithm, it happens in an inconsistent way that a restart causes data to be released, and would be great to know the reason for that in order to understand better how to system works.

As for the need - originally, the purpose was reporting - I wanted to have the ability to have ongoing transactions data (that I periodically keep in files) in order to generate myself performance and other reports. context.perf_tracker.todays_performance.processed_transactions is a very convenient way as it kept all historical transactions and didn't require to much manipulations. Then, as you identified correctly, the need came also from the orders issue.

So, if to sum it up - assuming the orders issue will be solved for me as you offered on the other thread, I just need to ability to have ongoing updated transactions data for ongoing reporting purposes.

Thanks!

superluminance commented 6 years ago

double checked. The transactions data is recorded in *.p file.

kooomix commented 6 years ago

I have no "/frame_stats" folder under "live_algos" or under the algo namespaces names as well.