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-0.1.28.tar.gz
(8.8 kB
view hashes)
Built Distribution
Close
Hashes for moneycounter-0.1.28-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d5ea7ea20ad75d24654b8887b96a8a0c4c6403075d2964c015551f185dfaa6 |
|
MD5 | 7addf70d534e12d528e28e498c5d1271 |
|
BLAKE2b-256 | daacdebf51225a8146711637193bb9b89b0c45474c6f56359fb4c7613a00b15c |