quant-invest-lab
Quant Invest Lab is a project aimed to provide a set of basic tools for quantitative experiments. By quantitative experiment I mean trying to build your own set of investments solution.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.7%) to scientific vocabulary
Keywords
Repository
Quant Invest Lab is a project aimed to provide a set of basic tools for quantitative experiments. By quantitative experiment I mean trying to build your own set of investments solution.
Basic Info
Statistics
- Stars: 28
- Watchers: 3
- Forks: 2
- Open Issues: 0
- Releases: 9
Topics
Metadata Files
README.md
Quant Invest Lab
Quant Invest Lab is a project aimed to provide a set of basic tools for quantitative experiments. By quantitative experiment I mean trying to build you own set of investments solution. The project is still in its early stage, but I hope it will grow in the future.
Initially this project was aimed to be a set of tools for my own experiments, but I decided to make it open source. Of courses it already exists some awesome packages, more detailed, better suited for some use cases. But I hope it will be useful for someone else (learn, practice, understand and create). Feel free to use it, modify it and contribute to it. This package is basically the package I wanted to find when I started to learn quantitative finance.
Main features
- Data: download data from external data provider without restriction on candle stick, the main provider is kucoin for now (currently only crypto data are supported).
- Backtesting: backtest your trading strategy (Long only for now but soon short and leverage) on historical data for different timeframe. Optimize you take profit, stop loss. Access full metrics of your strategy.
- Indicators: a set of indicators to help you build your strategy.
- Portfolio: a set of portfolio optimization tools to help you build your portfolio.
- Simulation: simulate your data based on real data using statistics to get a better understanding of its behavior during backtesting.
- Metrics: a set of metrics to help you evaluate your strategy through performances and risks.
Installation
To install Quant Invest Lab through pip, run the following command:
bash
pip install quant-invest-lab --upgrade
You can install it using poetry the same way :
bash
poetry add quant-invest-lab
Basic examples
Backtest a basic EMA crossover strategy
```python import pandas as pd
from quantinvestlab.backtest import ohlclongonlybacktester from quantinvestlab.dataprovider import downloadcryptohistorical_data
symbol = "BTC-USDT" timeframe = "4hour" dfBTC = downloadcryptohistoricaldata(symbol, timeframe)
Define your indicators
dfBTC["EMA20"] = dfBTC.Close.ewm(20).mean() dfBTC["EMA60"] = dfBTC.Close.ewm(60).mean()
dfBTC = dfBTC.dropna()
Define your strategy entry and exit functions
def buyfunc(row: pd.Series, prevrow: pd.Series) -> bool: return True if row.EMA20 > row.EMA60 else False
def sellfunc(row: pd.Series, prevrow: pd.Series, trading_days: int) -> bool: return True if row.EMA20 < row.EMA60 else False
Backtest your strategy
ohlclongonlybacktester( df=dfBTC, longentryfunction=buyfunc, longexitfunction=sellfunc, timeframe=timeframe, initial_equity=1000, )
```
Optimize a portfolio (mean-variance)
```python from quantinvestlab.portfolio import MonteCarloPortfolio, ConvexPortfolio, RiskParityPortfolio from quantinvestlab.dataprovider import buildmulticryptodataframe
symbols = set( [ "BNB-USDT", "BTC-USDT", "NEAR-USDT", "ETH-USDT", "SOL-USDT", "EGLD-USDT", "ALGO-USDT", "FTM-USDT", "ADA-USDT", ] )
closes = buildmulticryptodataframe(symbols) returns = closes.pctchange().dropna()
cvx_ptf = ConvexPortfolio(returns)
cvxptf.fit("sharpe", "max", maxasset_weight=0.2) # maximize sharpe ratio with a max weight of 20% per asset
cvxptf.getallocation()
or
mc_ptf = MonteCarloPortfolio(returns)
mcptf.fit(nportfolios=20000, plot=True)
mcptf.getallocation("sharpe", "max") # maximize sharpe ratio
```
Next steps
- Create official docs and add more examples
- Short, leverage and margin backtesting
- Add more data provider (Stock, bonds...)
- Make montecarlo candle data generation process more realistic ## Disclaimer This package is only for educational purpose or experimentation it is not intended to be used in production. I am not responsible for any loss of money you may have using this package. Use it at your own risk.
Owner
- Name: Baptiste ZLOCH
- Login: BaptisteZloch
- Kind: user
- Location: Gif-sur-Yvette
- Company: CentraleSupelec
- Website: www.zlochteamastro.com
- Repositories: 2
- Profile: https://github.com/BaptisteZloch
I'm currently student at CentraleSupelec with Computer Science specialization and a huge interest in Quantative Trading.
Citation (CITATION.CFF)
cff-version: 1.2.0
message: If you use this software, please cite it using the following DOI.
title: Quant Invest Lab
version: 0.2.1
authors:
- name: Baptiste Zloch
email: bzloch@hotmail.fr
license: MIT
GitHub Events
Total
- Watch event: 4
Last Year
- Watch event: 4
Packages
- Total packages: 1
-
Total downloads:
- pypi 128 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 13
- Total maintainers: 1
pypi.org: quant-invest-lab
Quant Invest Lab is a python package to help you to do some quantitative experiments, while trying to learn or build quantitative investment solutions. This project was initially my own set of functionnalities but I decided to build a package for that and sharing it as open source project.
- Homepage: https://github.com/BaptisteZloch/Quant-Invest-Lab
- Documentation: https://quant-invest-lab.readthedocs.io/
- License: MIT
-
Latest release: 0.2.11
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- 106 dependencies
- black ^23.3.0 develop
- ipykernel ^6.23.0 develop
- mkdocs ^1.4.3 develop
- mkdocs-material ^9.1.14 develop
- mkdocs-material-extensions ^1.1.1 develop
- mkdocstrings ^0.21.2 develop
- mkdocstrings-python ^1.0.0 develop
- beautifulsoup4 ^4.12.2
- bokeh ^3.2.2
- emd-signal ^1.4.0
- fitter ^1.5.2
- kucoin-python ^1.0.11
- matplotlib ^3.7.1
- nbformat ^5.8.0
- numpy ^1.23.5
- pandas ^1.5.3
- plotly ^5.14.1
- python >=3.9,<3.12
- pywavelets ^1.4.1
- scikit-learn ^1.2.2
- scipy ^1.10.1
- seaborn ^0.12.2
- statsmodels ^0.14.0
- ta ^0.10.2
- tqdm ^4.64.1