catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Write transactions and recorded data during algorithm run

Open kooomix opened this issue 7 years ago • 8 comments

Hi,

I have set the "record" function to log information and have configured the Analyze function to output recorded and perf data into a CSV file.

As far as I could found, the Analyze function can only be executed (by default) at the end of the algorithm run.

My question is - how can I output recorded and perf data during algorithm run, say, every 30 minutes?

Thanks.

kooomix avatar Jun 04 '18 10:06 kooomix

Hi, I'm not sure I've understood your needs here, but if i've understood correctly, you can access the recorded values at any stage, locally at: ~/.catalyst/data/live_algos/{algo_namespace}/custom_signals_stats_{mode_name}.csv if this is not what you are referring to, please try to rephrase.

AvishaiW avatar Jun 06 '18 12:06 AvishaiW

Hi Avishai,

Sorry for not being clear.. What you have suggested is good for the custom recorded data. There's also the "perf" parameter in the analyze function from which I extract transactions. This function, "analyze", is being executed when the algo ends. My question is - can I somehow access / write the perf transactions data during the algorithm run, and not only at the end?

Thanks.

kooomix avatar Jun 07 '18 05:06 kooomix

so what about using context.custom_signals_stats?

AvishaiW avatar Jun 07 '18 19:06 AvishaiW

I'm not familiar with context.custom_signals_stats and didn't find much information about it. Can you refer me to a documentation or alternatively explain further how exactly to work with it?

kooomix avatar Jun 10 '18 06:06 kooomix

Sorry for being unclear. Currently there is no appropriate method to perform what you have expected therefore, this is not documented. However, if you are interested in extracting the perf info during the run of the algorithm, you can look at the following: context.custom_signals_stats argument which contains the recorded variables. In order to extract the transactions you can call context.perf_tracker.todays_performance.processed_transactions. perf_tracker contains all the performance info and specifically todays_performance contains the portfolio info.

AvishaiW avatar Jun 11 '18 09:06 AvishaiW

@kooomix I haven't tested it myself, but catalyst.api.run_algorithm() has an analyze_live parameter that you can pass in the same way as your analyze function, and it's called after every tick in live mode:

analyze_live: callable[(context, pd.DataFrame) -> None], optional
        The interactive analyze function to be used with
        the live graph clock in every tick.```

sawyercade avatar Jun 12 '18 22:06 sawyercade

@AvishaiW - Thanks for the tracker info. I have tried to experiments with the "tracker" parameter. The "context.perf_tracker.todays_performance.processed_transactions" indeed helps a bit as it enables me to extract the transactions during algo run time. Is there a variable which holds all accumulated transactions info or must I manage the data on a daily basis?

@sawyercade Analyze_live is a nice tool I might use, thanks! Note that if using the Analyze_live together with Analyze - "perf" variables turned out to be empty in Analyze(context, perf). A bug maybe?

kooomix avatar Jun 17 '18 09:06 kooomix

@AvishaiW - I have been using context.perf_tracker.todays_performance.processed_transactions and it serves me very well. I have though a question of how it behaves - I have noticed that sometimes when I "kill" the algorithm actively and then run it again (under the same namespace), some of the transactions appear to be missing, the transactions I just made before killing the algo. It also seems like this info is forever lost and can't be recovered. So my questions:

  1. How exactly transactions are being synchronized with the exchange? On which point I can know for sure transactions are well synced?
  2. In case like the one described above, does it make sense part of the transactions are lost completely?

Thanks!

kooomix avatar Sep 18 '18 08:09 kooomix