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.2.tar.gz (10.0 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.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for moneycounter-1.4.2.tar.gz
Algorithm Hash digest
SHA256 da8449d102e65754cf4eeaefa36927379eda5ffc3f19ac84caf0e81f063bb9e5
MD5 149a42085db24a1cd9bc31e38fc78ed8
BLAKE2b-256 7b6848c80abe289993658a4ef15cdaa22be7813ee5914731a71f63c46256b23d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moneycounter-1.4.2-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

Hashes for moneycounter-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32bce45ef93527486b08953cc54eb90cfdad036f7658ea45f8f60891f82b1487
MD5 34190da5038ad1ff3d7653230810b8c3
BLAKE2b-256 c7b407b0d278d2746f22dfc50cdc0b4438f3b49acaeb35e2ca1bb4b7195b6155

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