Use SQL to instantly query your online brokers (IBKR and more). Open source CLI. No DB required.
Stop hacking around with scripts; get real work done with the data access standard that's been rocking it for 4 decades.
> select
account, count(*) as cnt
from
positions
group by
account;
+-----------+------+
| account | cnt |
+-----------+------+
| U11739578 | 5 |
| U11788663 | 5 |
+-----------+------+
> select oca_group, orders.symbol,
max(last) as last, max(lmt_price) as LMT,
max(aux_price) as STP
from orders join quotes
on (orders.symbol = quotes.symbol)
where account = 'U11739578' and oca_group != ''
group by 1,2 order by 2;
+------------+--------+--------+--------+--------+
| oca_group | symbol | last | lmt | stp |
+------------+--------+--------+--------+--------+
| 813817692 | ADBE | 621.72 | 677.59 | 600.2 |
| 1526460408 | MHO | 104.78 | 114.99 | 102.12 |
| 267224038 | MSFT | 378.46 | 417.15 | 369.65 |
+------------+--------+--------+--------+--------+
> select symbol, last,
round((last/close-1)*100, 2) as `% chg`
from quotes where
ask < bid * 1.001
order by `% chg` desc limit 3;
+--------+--------+-------+
| symbol | last | % chg |
+--------+--------+-------+
| AMZN | 147.13 | 2.24 |
| DELL | 75.0 | 1.87 |
| ADBE | 621.23 | 1.68 |
+--------+--------+-------+
select p.*, q.last,
(q.last - p.avg_cost) * position as pnl
from positions p join quotes q
on (p.symbol = q.symbol)
where pnl > 0
select p.symbol, q.last, o.aux_price
from positions p join orders o
on (p.symbol = o.symbol and o.order_type = 'STP')
join quotes q on (p.symbol = q.symbol)
where o.aux_price < q.last * 0.9