Using the alpaca.market API, listen for any event updates. Depending on the events, it'll log the action that occured. This repository also uses the ledger API to add the transaction entries to the ledger notebook.
You will need a pre-existing ledger notebook to do this. In order to get a ledger notebook, create one by running the ledger API example and then update the notebook filename with the your notebook filename.