Helpers for cross-sectional strategies: calendar triggers, ranking and screening, and orders that target a fraction of the portfolio.
Helpers for cross-sectional strategies: calendar triggers, ranking and screening, and orders that target a fraction of the portfolio.
(equal-weights permnos){permno 1/n} for the given securities.
{permno 1/n} for the given securities.
(new-period? unit)True on the first trading day in the dataset of a new :week, :month, :quarter or :year, and on the first day of the run (the date init-portfolio started from), so a strategy invests at once.
True on the first trading day in the dataset of a new :week, :month, :quarter or :year, and on the first day of the run (the date init-portfolio started from), so a strategy invests at once.
(order-target-percent permno weight & {:keys [whole-shares?] :as opts})Orders permno so that it becomes weight (a fraction, negative for a
short) of today's equity at today's price. Like order, it fills at the
next close; the trade is the difference to the holding then. Options:
:whole-shares? true rounds toward zero, and the options of order.
Returns the target quantity, or nil when there is no price today.
Orders `permno` so that it becomes `weight` (a fraction, negative for a short) of today's equity at today's price. Like `order`, it fills at the next close; the trade is the difference to the holding then. Options: :whole-shares? true rounds toward zero, and the options of `order`. Returns the target quantity, or nil when there is no price today.
(portfolio-equity)The portfolio's equity as last valued (today's close once next-date has run).
The portfolio's equity as last valued (today's close once next-date has run).
(rank-by f & {:keys [universe ascending]})[[permno value] ...] for the securities where (f permno) is a finite number, highest value first. Options: :universe, the securities to rank (today's securities by default); :ascending true for lowest first.
[[permno value] ...] for the securities where (f permno) is a finite number, highest value first. Options: :universe, the securities to rank (today's securities by default); :ascending true for lowest first.
(rebalance weights & {:as opts})Targets the portfolio weights ({permno fraction of equity}); what they
leave over stays in cash. Every holding not in weights is closed.
Takes the options of order-target-percent. Returns {permno target
quantity} for the orders placed.
Targets the portfolio `weights` ({permno fraction of equity}); what they
leave over stays in cash. Every holding not in `weights` is closed.
Takes the options of order-target-percent. Returns {permno target
quantity} for the orders placed.(target-quantity permno weight whole-shares?)Shares of permno worth weight of today's equity at today's price, or
nil without a price. With whole-shares? the count is rounded toward zero.
Shares of `permno` worth `weight` of today's equity at today's price, or nil without a price. With `whole-shares?` the count is rounded toward zero.
(top-n f n & opts)The n securities with the highest (f permno), or the lowest with
:ascending true; takes the options of rank-by.
The `n` securities with the highest (f permno), or the lowest with :ascending true; takes the options of rank-by.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |