Skip to content

Commit

Permalink
Update Kyle's Lamba calculation and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mgao6767 committed Dec 18, 2023
1 parent 7d45909 commit 828fe71
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/source/measures/kyle_lambda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Kyle's Lambda for stock :math:`i` as the slope coefficient
.. math::
:label: kylelambda_regression
r_{i,n} = \delta_{i} + \lambda_{i}\cdot S_{i,n} + \varepsilon_{i,t}
r_{i,n} = \lambda_{i}\cdot S_{i,n} + \varepsilon_{i,t}
where for the :math:`n`-th five-minute period, :math:`r_{i,n}` is the
(percentage) stock return and :math:`S_{i,n}` is the signed square-root dollar
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "frds"
version = "2.3.1"
version = "2.3.2"
authors = [{ name = "Mingze Gao", email = "[email protected]" }]
description = "Financial Research Data Services"
readme = "README.md"
Expand Down
12 changes: 6 additions & 6 deletions src/frds/measures/_kyle_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def kyle_lambda(returns: np.ndarray, signed_dollar_volume: np.ndarray) -> float:
.. note::
The return value is the estimated coefficient of :math:`\lambda` in equation
:math:numref:`kylelambda_regression` multiplied by 1,000,000. Otherwise, the
value would be too small and may cause issues.
:math:numref:`kylelambda_regression` multiplied by 1,000,000.
"""
returns = np.asarray(returns)
signed_dollar_volume = np.asarray(signed_dollar_volume)
coeff, _ = np.polyfit(signed_dollar_volume, returns, 1)
return coeff * 1_000_000
y = np.asarray(returns)
x = np.asarray(signed_dollar_volume)
x = x[:, np.newaxis]
a, _, _, _ = np.linalg.lstsq(x, y, rcond=None)
return a[0] * 1_000_000

0 comments on commit 828fe71

Please sign in to comment.