Closed algoeng closed 5 months ago
I have thought about this, and it would be easy enough to either write everything to a CSV file or maybe a SQLite DB. The only problem is that it won't be a complete record. The best we could do is log the actions taken by thetagang (i.e., submitted an order, canceled an order, etc). IBKR is always going to be the source of truth, and for a complete log of all trades you'd need to use whatever tools provided by IBKR.
As example of where it gets tricky: we can log that an order was submitted, but we may not know if it was filled, because thetagang doesn't run continuously or do any sort of order state synchronization. We also don't have a way to access more detailed information such as the tax lots to determine when each position was entered/exited and at what price. This is a limitation of the IBKR API and I don't think there's any way to get more detailed data or trade logs.
Ah, you are right. I think I might just run a small script from cron after market close to try to get the basics (what orders were filled and what's the account value, etc). Thanks.
No action needed from Thetagang.
While the command line output is very nice, is there a good way to keep a record or log of trades? I am running via a crontab+docker. I have tried to output to a file but it comes out very narrow and so most things in the tables are not readable. Is there a way to get a more readable log? If not is there a best practice to extend and add our own extension to do other custom things, like insert the trade to a database?