Pre-release
This release is a pre-release and may not be stable for production use.
LetTrade
A lightweight trading framework compatible with Stock, Forex, Crypto... markets
Find more at Documentation
Installation
Stable version
pip install lettrade[all]
Developing version
pip install 'lettrade[all] @ git+https://git@github.com/AwesomeTrading/LetTrade.git@main'
Example
from lettrade.all import DataFeed, ForexBackTestAccount, Strategy, let_backtest
class SmaCross(Strategy):
ema1_window = 9
ema2_window = 21
def indicators(self, df: DataFeed):
df.i.ema(name="ema1", window=self.ema1_window, inplace=True, plot=True)
df.i.ema(name="ema2", window=self.ema2_window, inplace=True, plot=True)
df.i.crossover("ema1", "ema2", inplace=True, plot=True)
df.i.crossunder("ema1", "ema2", inplace=True, plot=True)
def next(self, df: DataFeed):
if df.l.crossover[-1] >= 100:
self.exit_positions()
self.buy(size=0.1)
elif df.l.crossunder[-1] <= -100:
self.exit_positions()
self.sell(size=0.1)
if __name__ == "__main__":
lt = let_backtest(
strategy=SmaCross,
datas="example/data/data/EURUSD_5m-0_1000.csv",
account=ForexBackTestAccount,
)
lt.run()
lt.plot()
# Strategy <class '__main__.SmaCross'>
Start 2024-05-13 21:15:00+00:00
End 2024-05-17 08:30:00+00:00
Duration 3 days 11:15:00
Start Balance 10000.0
Equity [$] 10003.16
Equity Peak [$] 10013.54
PL [$] 3.16
PL [%] 0.03
Buy & Hold PL [%] 0.63
Max. Drawdown [%] -0.5
Avg. Drawdown [%] -0.15
Max. Drawdown Duration 1 days 16:15:00
Avg. Drawdown Duration 0 days 12:30:00
# Positions 34
Win Rate [%] 0.38
Fee [$] -1.34
Best Trade [%] 29.36
Worst Trade [%] -18.14
SQN 0.07
Kelly Criterion 0.01392
Profit Factor 1.037781
Start a strategy
More examples can be found in example/
Download data
python -m example.data.yfinance
Backtest strategy
python -m example.strategy.backtest_sma_cross
Live Trading
Official
MetaTrader: Support MetaTrader 5 Terminal tradingCCXT: [WIP] Support most of cryptocurrency exchange from CCXT library
Development
Set up conda environment
conda create -y -n LetTrade python=3.12
conda activate LetTrade
pip install -r requirements-dev.txt
Metadata
Release files for lettrade 0.0.10b5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lettrade-0.0.10b5.tar.gz | 109.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lettrade-0.0.10b5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 253.7 kB
Release files / lettrade-0.0.10b5.tar.gz
| Download URL | lettrade-0.0.10b5.tar.gz |
|---|---|
| Size | 109.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11c228c724e579b92e980d611a6b3b57370f57b55f681b1f0f509d8d60687560
|
|
BLAKE2b-256 checksum How to use checksums |
9a596b0143d3ed83a551961595664191097f1c3ac54b69f2012940fbb528630c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|
Release files / lettrade-0.0.10b5-py3-none-any.whl
| Download URL | lettrade-0.0.10b5-py3-none-any.whl |
|---|---|
| Size | 144.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cf9682cd551257f325ca788f7fd0afcdca7408677cafa47656db20cf17baad0
|
|
BLAKE2b-256 checksum How to use checksums |
f25e0b83faecd69a1357e228a39eb696f0620fc412941e46de473c27c17fb797
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.4
|