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
moneycounter-1.2.3.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file moneycounter-1.2.3.tar.gz
.
File metadata
- Download URL: moneycounter-1.2.3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a6da2825435ddc7959a4a5d3cadf29c49a8a1748f82a67fe99c315b663aeeac |
|
MD5 | 3ac682311f98b2b72d957c84d5599049 |
|
BLAKE2b-256 | a4f5589208f823495eba8e34d14f0a5d5c18eac5483002b1467e140fd44ffd41 |
Provenance
File details
Details for the file moneycounter-1.2.3-py3-none-any.whl
.
File metadata
- Download URL: moneycounter-1.2.3-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0aefd26581a49b8fc2d0b29dfe1cd8aac0090ae9a29dfa3f1dc93e9cc8acc9f |
|
MD5 | 4a43ba815c8cf5f21e99debfff41a9f9 |
|
BLAKE2b-256 | d96dc8dffab2ddf85c8cf89ebe6658e1819b0b1db18dc40befec17b547a7dab7 |