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.3.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.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moneycounter-1.4.3.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.3.tar.gz
Algorithm Hash digest
SHA256 26091fb07ade88dd3c36ccafd58bd82b3982e07ddafa92ffee6090770213d214
MD5 6d03688ce708858745404b16ff1aecc6
BLAKE2b-256 2285350078c0564f8106c992e9e597795ac743cf3e0cbb7cd7d3a06d375268d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moneycounter-1.4.3-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.12.3

File hashes

Hashes for moneycounter-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72d24653f04a9cd046cceec6a1098f53f189e8d9d44dc1c6f3b578393fbd2902
MD5 08e692a948816bd5b664a60ec17ce2c7
BLAKE2b-256 b3a6ace21aa9b25640fd56b661da7bac19dfd657a4287dc05fdf31b088f72a8c

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