Skip to main content

Making Finance easy in Python!

Project description

Package for analyzing and visualizing financial time-series data

Developed by Poonam Deshmukh (c) 2023.


Requirements

pyfin_trading would need the following libraries to be installed

  • pandas
  • numpy
  • yfinance
  • datetime

Installation

You can install it via pip:

pip install pyfin-trading

Modules

  • stock_data
  • stats
  • indicators

1. stock_data

This module majorly helps with getting stock data and can be accessed as follows:

from pyfin_trading import stock_data as sd

df = sd.get_data(ticker, start_date, end_date, interval)


- Input ticker symbol along with its corresponding exchange.
- Format for start_date & end_date must be "%Y-%m-%d"
- By default end_date is set to today
- Interval can take values like "1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "1d", "5d", "1wk", "1mo", "3mo"
  where m = minute, h = hour, d = day, wk = week, mo = month
- By default interval is set to "1d"

Example

df = sd.get_data("ITC.NS", "2023-11-06")

This will return ITC's data from NSE spanning from 6th Nov 2023 to present day with interval set to daily

2. stats

It helps with calculating returns as well as some financial ratios:

from pyfin_trading import stats as st

returns = st.calculate_returns(df) # Calculates Daily & Cumulative Returns
st.beta(df, market, interval)
st.volatility(df, trading_days = 252) # Calculates SD & Annualized Volatility
st.sharpe(df, risk, trading_days = 252) # Sharpe Ratio
st.sortino(df, risk, trading_days = 252) # Sortino Ratio
st.alpha(df, market, interval, beta, risk)
st.treynor(df, beta, risk, trading_days = 252) # Treynor Ratio
st.info(df, market, interval, risk, trading_days = 252) # Information Ratio


- By default Nifty 50 is used as a proxy for the market i.e. "^NSEI"

3. indicators

For calculating technical indicators:

from pyfin_trading import indicators as pt

pt.sma(df, sma_period = 15) 
pt.ema(df, ema_period = 15, adjust = False)
pt.rsi(df, rsi_period = 14)
pt.connors_rsi(df, rsi_period = 14, updown_length = 2)
pt.stoch(df, k = 14, d = 3) # Stochastic Oscillator
pt.bollinger_bands(df, sma_period = 20, std_dev = 2) # Bollinger Bands
pt.aroon(df, aroon_period = 25) # Aroon Oscillator
pt.macd(df, short_period = 12, long_period = 26, signal = 9, adjust = False) # Moving Average Convergence Divergence
pt.ichimoku_cloud(df, conversion = 9, base = 26, lead_b = 52) # Ichimoku Cloud

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

pyfin_trading-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pyfin_trading-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pyfin_trading-1.0.0.tar.gz.

File metadata

  • Download URL: pyfin_trading-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for pyfin_trading-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7ef6d806fbeba9dc7bfd9beb3535942091a0efee907ba820a3550a4e3bccb36c
MD5 c027fa3142a4f729a07ca9a05e531c78
BLAKE2b-256 e67674db70f780b72950324de5f0c68d6ec839bdfe32e655eed814d3a76615c1

See more details on using hashes here.

File details

Details for the file pyfin_trading-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfin_trading-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 612510050ea358ad486483c55fb587384e46d5f393bb773234ea6cb16a1a8454
MD5 ec0fc55bbb7928f055081b958b495eec
BLAKE2b-256 e6c746bd979e23527578eb70cd19e741cabeba3632a84fba999066fe8a5740f4

See more details on using hashes here.

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