positions_backtester
Short Overview.
positions_backtester is a python package (py>=3.7) to backtest trading strategies (dataframe with positions) with execution costs modeling
Installation via pip:
pip install positions_backtester
How to backtest your dataframe with positions
from positions_backtester import run_backtest
df_backtest_res = run_backtest(
df_positions,
df_real_exec_prices,
is_to_neutralize=True,
const_trading_fees_percent=0.01,
)
!!! df_real_exec_prices should have the same indices as df_positions
Arguments:
- df_positions:
- pd.DataFramePositions we want to take with the frequency with which we want to change our positions
- df_real_exec_prices:
- pd.DataFramePrices by which we can buy assets at the given moment
- is_to_neutralize=True,:
- boolFlag if to have long-short equal positions
- td_trading_delay=None:
- datetime.timedeltaDelay needed to calculate the wanted positions
- td_execution_duration:
- datetime.timedeltaHow long should the execution takeExecution price will be the mean price over execution time period
- const_trading_fees_percent:
- floatBroker trading fees
Input example: df_positions_short
Output: df_backtest_res
How to create execution prices
from positions_backtester import create_df_simple_execution_prices
df_real_exec_prices = create_df_simple_execution_prices(
df_prices_full,
data_frequency="30min", # 30min, 1h, 3h, 6h, 1d
offset="-3min", # "-3min"
td_trading_delay=datetime.timedelta(minutes=3),
td_execution_duration=datetime.timedelta(minutes=2),
)
Arguments:
- df_prices_full:
- pd.DataFramePrices of assets in higher resolutionHigher resolution needed for more pricise execution evaluation
- td_trading_delay=None:
- datetime.timedeltaDelay (Time) needed to calculate the wanted positions
- td_execution_duration:
- datetime.timedeltaHow long should the execution takeExecution price will be the mean price over execution time period
Inputs:
df_prices_full
Formulas
Links
Project local Links
Contacts
License
This project is licensed under the MIT License.
Metadata
Release files for positions-backtester 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| positions_backtester-0.1.5.tar.gz | 10.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| positions_backtester-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.2 kB
Release files / positions_backtester-0.1.5.tar.gz
| Download URL | positions_backtester-0.1.5.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6bbc8de0a6a70c36f58f0c081d4db21da3eaffb6c57ec004168f36a38d288a22
|
|
BLAKE2b-256 checksum How to use checksums |
c208ed2d2751dc5f457615f232f3d2292eb41fc9d0160e719b90b2fc12c7057b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.7 Windows/10
|
Release files / positions_backtester-0.1.5-py3-none-any.whl
| Download URL | positions_backtester-0.1.5-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d371fd65ea26e6df90c428979b957464266e2c9fd4fe98da7b686494945ac4b
|
|
BLAKE2b-256 checksum How to use checksums |
7b8a6f91e77ea8d9cb38dcfcb2f103c4d31fbe86bf142a10256d8d2e2c622af0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.7 Windows/10
|
Security for positions-backtester 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.