Lightweight trading framwork
Project description
LetTrade
A lightweight trading framework compatible with Stock, Forex, Crypto... markets
Find more at Documentation
Installation
[!WARNING]
LetTrade is under heavy construction, features and functions may be changed.Using Developing version to get latest update.
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.positions_exit()
self.buy(size=0.1)
elif df.l.crossunder[-1] <= -100:
self.positions_exit()
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lettrade-0.0.10b4.tar.gz
(107.7 kB
view details)
Built Distribution
lettrade-0.0.10b4-py3-none-any.whl
(140.4 kB
view details)
File details
Details for the file lettrade-0.0.10b4.tar.gz
.
File metadata
- Download URL: lettrade-0.0.10b4.tar.gz
- Upload date:
- Size: 107.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44a8e134efb8ddd4d4b641166662ac00dcdbae4b451f56748b9878763841659a |
|
MD5 | ecca95d13605bd69a7fdc261404364c0 |
|
BLAKE2b-256 | e1845a496eafe00de4f7de0dd622f2378b5e402d8267280ccda4ab90680d69f8 |
File details
Details for the file lettrade-0.0.10b4-py3-none-any.whl
.
File metadata
- Download URL: lettrade-0.0.10b4-py3-none-any.whl
- Upload date:
- Size: 140.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edc64ec9fdb26aa2dfc177c1902bd85c3c234b5f6aebdb9a446d73bf904e29e9 |
|
MD5 | af3482564d634382ca683abaa018fbdd |
|
BLAKE2b-256 | 5639be5ca87fc3e11aea7a60e32d9fee38f92b7ac3cdcfb09711ee677f25fa6e |