BrokerQL - select * from market;

Use SQL to instantly query your online brokers (IBKR and more). Open source CLI. No DB required.

Download

Query like it's 1992

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 |
  +-----------+------+

SQL? Really?

Yes, SQL. It is an elegant and powerful tool that makes working with multiple APIs simple. SQL levels the playing field for your team, easily integrates with other systems and accelerates delivery.
> 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 |
  +------------+--------+--------+--------+--------+

Explore, connect and join data.

Painlessly join live order data with internal or external data sets to create new trading ideas.
> 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 |
  +--------+--------+-------+

The market is a live database.

Stop building and maintaining out-of-sync watchlists and point-in-time market snapshots; BrokerQL's live tables give you the current quote of any stock right now.

You've got questions, BrokerQL has answers.

Which positions are making money?

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

Which positions may have large drawback?

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