PaperTrail Live Account Filtering

I want to filter all live accounts using more than $2k margin, but this returns paper as well.

0 16 * * mon-fri quantrocket account balance --latest --fields "Account" "TotalCashValue" "Paper" --below TotalCashValue:-2000 | quantrocket flightlog log --name quantrocket.account-MARGIN-Used --level CRITICAL


Trying to add --below Paper:1 returns a non-valid filtering error. Any other fields inside "*" doesn't seem to be paper specific.

Ultimately, the goal is to cash out any live account using X% of Margin/ShortValue.

The Python API would allow this (filtering on paper, % margin, etc...). Is the best way to build unit tests and use the methods inside from quantrocket.blotter import * to place orders, or is there a more streamlined approach?

0 16 * * mon-fri quantrocket satellite exec 'pytest /codeload/unit_tests/tests/ -s'

You can use the --accounts option, or csvgrep, or a satellite script…many options.

Using --accounts won't work as that would require manual tracking of any N accounts across IB/Alpaca for personal, business, and paper.

I had to use awk to pull out the 4th column to recognize if it's 0=live or 1=paper.
awk -F, 'NR==1 {print} {OFS=","} $4==0'

For anyone else
Full countdown & PaperTrail for EOD margin catching on live accounts:
0 16 * * mon-fri quantrocket account balance --latest --fields "Account" "TotalCashValue" "Paper" --below TotalCashValue:-2000 | awk -F, 'NR==1 {print} {OFS=","} $4==0' | csvlook -I | quantrocket flightlog log --name quantrocket.account-MARGIN-Used --level CRITICAL


This tripped my Papertrail alert and sent an email correctly. FYI the Currency column is always populated regardless of omitting via --fields.