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

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

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

Uploaded Source

Built Distribution

moneycounter-0.1.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moneycounter-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.11

File hashes

Hashes for moneycounter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5efc70f8514c77647d0961f29269768443709fa8f2f6c36001d26c89d9e1279b
MD5 906d0a7a7d5c563cb73db94e9ed79297
BLAKE2b-256 a32ce69f6cde55a848899e23dbfc7549173e713fdcef786ad422baa0858f47ca

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for moneycounter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec66f3a6f6f2891c9a323117489ab2f48d506eda68e2b3a947d627bb33848883
MD5 da0103c00aefe64ed11b019da294f31d
BLAKE2b-256 4d781435f8c9ad9c49605968b0fff9b4a46dcfdab7f657cdf9ed26137fb527b0

See more details on using hashes here.

Provenance

Supported by

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