GithubHelp home page GithubHelp logo

dorkden / lettrade Goto Github PK

View Code? Open in Web Editor NEW

This project forked from awesometrading/lettrade

0.0 0.0 0.0 111.96 MB

A simple lightweight trading framework compatible with Stock, Forex, Crypto... markets

Home Page: https://AwesomeTrading.github.io/LetTrade/

License: GNU Affero General Public License v3.0

Shell 0.04% Python 99.96%

lettrade's Introduction

LetTrade

Documentation Code Coverage PyPI PyPI Python Version PyPI Downloads

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://[email protected]/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

Plot

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 trading
  • CCXT: [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

lettrade's People

Contributors

santatic avatar vuong184 avatar lolongcovas avatar pan-long avatar gaugau3000 avatar leifjones avatar markdregan avatar matheusfelipeog avatar yazeed avatar xataxxx avatar rikj000 avatar trebornamor avatar samgermain avatar kevinjulian avatar shusso avatar xmatthias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.