ronaldlam / Autotrageur

Automated arbitrageur
2 stars 1 forks source link

Implement ability to export and import state for bot #179

Closed jaonewguy closed 6 years ago

jaonewguy commented 6 years ago

For #177

Discussion points:

  1. I'm highly incentivized to go with a SQLAlchemy approach now for all DB interaction and the bot. It'll take care of SQL Injection risk and also make the code easier to maintain.
  2. Thinking of another object or namedtuple for the FCFCheckpoint object to contain some sort of 'state' plain data object. Could also make it a delegate and have it perform actions under the hood if we want to go that route. That way we won't have to fiddle with __dict__.
  3. Decided that feeding in the previous config_id by hand through the cmd would be easiest. But I could see it being a problem should we choose to automate the starting of bots in the future (along with all the other input params). Starting to see more and more of a need for a middle layer for that.

Updated schema: https://github.com/ronaldlam/Autotrageur/wiki/Database-Schema

ronaldlam commented 6 years ago

About the discussion points:

  1. I think that's fine.
  2. See the comment, why can't we directly deserialize back into the object? It looks like pickle will do that stuff for you from reading the docs, though there may be unforeseen things I don't understand there.
  3. I think this may eventually need more options... but will serve fine as is for now. I'm imagining maybe a UI that reads from the DB to let you select either the configs or the run that you want to recover from, along with when that particular run ended. Maybe even with past price and trade data... This doesn't really require us to change the implementation in the bot though, I imagine this as a layer on top, controlling the execution of the bot, and monitoring its output while it runs.
jaonewguy commented 6 years ago

Won't go with SQLAlchemy approach in this changelist. Tests will also come once the code is polished up.

jaonewguy commented 6 years ago

If we're going with the dryrun functionality as well, we need to save the DryRunExchange's to keep the balances properly. Might need dry_e1 and dry_e2 in autotrageur.py as instance vars too...

Oh shit I didn't see this, will address in a followup commit

jaonewguy commented 6 years ago

Or maybe a followup PR as this one is getting quite large...