Capital Market in Python
Project description
capon
Capital Market in Python
Author | Version | Demo |
---|---|---|
Gialdetti |
capon
is a python package for easily obtain and analyze real-time stock data. Provides stock metadata and features.
In addition, it offers simple APIs to track your personal stock portfolios and its updated status.
Installing
Install and update using pip:
$ pip install capon
A simple example
Track your personal stock portfolio with real-time data.
a) Define my holdings
from capon import Portfolio, Lot
my_portfolio = Portfolio([
Lot('2020-03-20', 'AMZN', 2, 1888.86),
Lot('2020-03-20', 'TSLA', 8, 451.40),
Lot('2020-03-23', 'GOOGL', 3, 1037.89),
Lot('2020-03-23', 'AMC', 1041, 2.88),
Lot('2020-03-27', 'ZM', 20, 150.29),
])
b) Sync with real-time stock data to find current status.
latest = my_portfolio.status()
display(latest)
total_cost, total_value = latest.sum()[['cost', 'value']]
print(f'Total cost: {total_cost:,.2f}; Market value: {total_value:,.2f}')
print(f'Total gain: {total_value-total_cost:+,.2f} ({total_value/total_cost-1:+,.2%})')
c) Plot it
import plotly.express as px
px.bar(latest.sort_values('gain_pct', ascending=False),
x='symbol', y='gain_pct', color='gain_pct',
text='gain_pct', hover_data=['gain'],
color_continuous_scale=px.colors.diverging.PiYG, color_continuous_midpoint=0,
title='My Holdings')
d). Plot historical data
performance = my_portfolio.performance()
px.line(performance, x='timestamp', y='gain_pct', color='symbol')
Testing
After installation, you can launch the test suite:
$ pytest
Help and Support
Examples
Theme | MyBinder | Colab |
---|---|---|
My Stock Portfolio Performance |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
capon-0.0.1.tar.gz
(4.8 kB
view details)
Built Distribution
capon-0.0.1-py3-none-any.whl
(17.6 kB
view details)
File details
Details for the file capon-0.0.1.tar.gz
.
File metadata
- Download URL: capon-0.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee4425b57c1437555eff77358be2c99ef1c8015ae9a3a92ad94fa835fa4518c0 |
|
MD5 | 41d2cbb985a3ad90403e08116532963e |
|
BLAKE2b-256 | 1fbf5a0e85a9d81273166f278952ba763c9d609894137dcd3a55f0a9808b7bb3 |
Provenance
File details
Details for the file capon-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: capon-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dfc0b8144d8cdef81f06e3e2de96cd6e0d8439a393d2ad1368ea44768293e91 |
|
MD5 | 738d61e07bb959e77d61e41837d920d1 |
|
BLAKE2b-256 | 0562d3da105e51f97226c461231beecd0fa3b96db0b44eb1dc2625f2c1581e81 |