Skip to main content

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

PyPI Page

$ 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) `$

Release files for moneycounter 1.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moneycounter 1.4.4
File Size Uploaded
moneycounter-1.4.4.tar.gz 146.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moneycounter 1.4.4
File Interpreter ABI Platform
moneycounter-1.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 152.2 kB

Release files / moneycounter-1.4.4.tar.gz

Download URL moneycounter-1.4.4.tar.gz
Size 146.7 kB
Tags Source
SHA-256 checksum
How to use checksums
519f244d13cdce5aed29252f717704eeea10fde51f6b54b28ce3c64ef4206c3e
BLAKE2b-256 checksum
How to use checksums
0bc3d0c2be79eda83697ecfb9fcf00d02a4ebfc6e7351f0f42f9eccf1bde42ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / moneycounter-1.4.4-py3-none-any.whl

Download URL moneycounter-1.4.4-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a45d024a23ef3a7aee6096dc71da1c4e5d7e268568711a6ce7087cea41747cb
BLAKE2b-256 checksum
How to use checksums
70886ea4cf106df20944b0658913bca8c3c1d44bbf09ebe1c8ca33292e623232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

1.4.4 This release

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.3.1

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.1.1

2 release files

0.1.28

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.7

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page