Portfolio Analytics Utilities
Project description
Money Counter
Portfolio analytics utilities
This is the beginning of a work in progress. I expect it will be in pretty good shape early in 2023 and then evolve from there.
This is a supporting package for a larger project I am working on and should be useful to others as is.
Installation
$ pip install moneycounter
Prerequisite Trades Data Frame
A trades dataframe has these columns:
columns = Index(['dt', 'q', 'p', 'cs', 't', 'a'], dtype='object')
It must be ordered by dt.
Where:
| Column | Description |
|---|---|
dt |
execution time as datetime.datetime |
q |
quantity traded, signed with negative as a sale |
p |
execution price |
cs |
contract size, typically 1.0 |
t |
ticker |
a |
account |
Example Calculations
from datetime import date
from moneycounter import pnl, realized_gains, wap_calc
# Calculate realized, unrealized and total pnl from trades dataframe.
realized, unrealized, total = pnl(df, price=price)
# Calculate weighted average price of open positions from trades data frame.
wap = wap_calc(df)
# Calculate realized gains from trades data frame.
realized = realized_gains(df)
$` \phi = c * Q * (p - p_wap) `$
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moneycounter-1.4.1.tar.gz.
File metadata
- Download URL: moneycounter-1.4.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ca7d37066751a152db410d582cb1f4cc107deb031faf617872690a2a60142d
|
|
| MD5 |
73ffe41dd2b4f802c12e132059bffa2b
|
|
| BLAKE2b-256 |
25e1be2517818c2bfbf696864a1427957ee40f0cb3550a99b04e542e16d86291
|
File details
Details for the file moneycounter-1.4.1-py3-none-any.whl.
File metadata
- Download URL: moneycounter-1.4.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b89e0e15491eab080e057ee20a5e14bb87b0980cc402efa15e88b105b17f0e
|
|
| MD5 |
44161492fbada41fdb562d2edc13ed89
|
|
| BLAKE2b-256 |
0febc636dc1c0616d1c68f34491af38115d3c112e52108e67fe94a7f7bb1d557
|