A previous release had provenance metadata, but this release does not. View details.
PyBotTrader
PyBotTrader is an experimental Python library designed to help create trading bots, particularly for retail traders. It offers tools for real-time financial analysis, including indicators like moving averages (like MA, EMA, RSI, MACD, and ROI), which update dynamically with new data. The library includes data streamers to handle sequential data from sources like CSV files or the YFinance API, and basic portfolio managers for back-testing simple buy/sell strategies. Users can define custom strategies that integrate data streams, indicators, and decision-making rules to generate trading signals. A basic trader module is included for testing strategies, making the library a versatile framework for algorithmic trading experimentation.
Example
Using this library looks like:
from pybottrader.indicators import RSI
from pybottrader.datastreamers.yfinance import YFHistory
from pybottrader.portfolios import DummyPortfolio
from pybottrader.strategies import Strategy, Position, StrategySignal
from pybottrader.traders import Trader
class SimpleRSIStrategy(Strategy):
"""A simple strategy based on the RSI indicator"""
rsi: RSI
last_flip = Position.SELL
lower_band: float
upper_band: float
def __init__(self, lower_band=30.0, upper_band=70.0):
self.rsi = RSI()
self.lower_band = lower_band
self.upper_band = upper_band
def evaluate(self, data) -> StrategySignal:
# default positio STAY
position = Position.STAY
# Update the RSI indicator
self.rsi.update(open_price=data["open"], close_price=data["close"])
# Make the decision what position to advice
if self.last_flip == Position.SELL and self.rsi[0] < self.lower_band:
position = Position.BUY
self.last_flip = Position.BUY
elif self.last_flip == Position.BUY and self.rsi[0] > self.upper_band:
position = Position.SELL
self.last_flip = Position.SELL
return StrategySignal(time=data["time"], price=data["close"], position=position)
# Apple, daily data from 2021 to 2023
datastream = YFHistory("AAPL", start="2021-01-01", end="2023-12-31")
# Start with USD 1,000
portfolio = DummyPortfolio(1000.0)
# My strategy
strategy = SimpleRSIStrategy(lower_band=25.0, upper_band=75.0)
# Putting everything together
trader = Trader(strategy, portfolio, datastream)
# A default runner, but you can implement your own loop
trader.run()
Output is shown below.
Time Pos. Price ROI Valuation Accum.ROI
2021-02-11 00:00:00-05:00 BUY 132.34 0.00% 1000.00 0.00%
2021-06-21 00:00:00-04:00 SELL 129.78 -1.93% 980.72 -1.93%
2021-09-20 00:00:00-04:00 BUY 140.43 0.00% 980.72 -1.93%
2021-10-22 00:00:00-04:00 SELL 146.08 4.02% 1020.17 2.02%
2022-05-24 00:00:00-04:00 BUY 138.48 0.00% 1020.17 2.02%
2022-07-08 00:00:00-04:00 SELL 145.07 4.76% 1068.72 6.87%
2022-09-02 00:00:00-04:00 BUY 153.93 0.00% 1068.72 6.87%
2023-01-24 00:00:00-05:00 SELL 141.05 -8.37% 979.26 -2.07%
2023-08-07 00:00:00-04:00 BUY 177.50 0.00% 979.26 -2.07%
2023-10-12 00:00:00-04:00 SELL 179.59 1.18% 990.78 -0.92%
Installation
pip install git+https://github.com/jailop/pybottrader.git
Shortly, I'm going to release more documentation and more examples.
Installation Requirements
Linux
- GCC/G++ compiler
- CMake 3.15 or higher
- Python development headers (python3-dev)
Windows
- Visual Studio 2019 or later with C++ build tools
- CMake 3.15 or higher
- Windows SDK
macOS
- Xcode Command Line Tools
- CMake 3.15 or higher
Metadata
Release files for pybottrader 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pybottrader-0.0.8.tar.gz | 2.6 MB | Without provenance | Details for pybottrader-0.0.8.tar.gz |
Release files / pybottrader-0.0.8.tar.gz
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | pybottrader-0.0.8.tar.gz |
|---|---|
| Size | 2.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea1ea6a10084c144ab17bda07de000721deea0206d0def6f500ad48654b4c615
|
|
BLAKE2b-256 checksum How to use checksums |
6f7a4fe2474ec7f1b55d0d2e6f26206313416ef17246edb980d0796cb1342bca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for pybottrader 0.0.8
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.
Loss of provenance
A previous release of these files had provenance metadata, but this release does not.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Release comparison
- Removed 0.0.6 2 files With provenance
- Added 0.0.8 1 file Without provenance
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.