Skip to main content

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

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

Project details


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.4.4.tar.gz (146.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moneycounter-1.4.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file moneycounter-1.4.4.tar.gz.

File metadata

  • Download URL: moneycounter-1.4.4.tar.gz
  • Upload date:
  • Size: 146.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for moneycounter-1.4.4.tar.gz
Algorithm Hash digest
SHA256 519f244d13cdce5aed29252f717704eeea10fde51f6b54b28ce3c64ef4206c3e
MD5 10315f97db06ba667acc849713076c4b
BLAKE2b-256 0bc3d0c2be79eda83697ecfb9fcf00d02a4ebfc6e7351f0f42f9eccf1bde42ea

See more details on using hashes here.

File details

Details for the file moneycounter-1.4.4-py3-none-any.whl.

File metadata

  • Download URL: moneycounter-1.4.4-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for moneycounter-1.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4a45d024a23ef3a7aee6096dc71da1c4e5d7e268568711a6ce7087cea41747cb
MD5 4f586db2f610bdb61f856cf6af978d0e
BLAKE2b-256 70886ea4cf106df20944b0658913bca8c3c1d44bbf09ebe1c8ca33292e623232

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page