GithubHelp home page GithubHelp logo

bdburdett / lean Goto Github PK

View Code? Open in Web Editor NEW

This project forked from quantconnect/lean

0.0 0.0 0.0 505.69 MB

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)

Home Page: https://lean.io

License: Apache License 2.0

Shell 0.02% Python 6.08% C# 93.62% CSS 0.04% HTML 0.07% Batchfile 0.01% Jupyter Notebook 0.17% Dockerfile 0.01%

lean's Introduction

alt tag

Build Status     Regression Tests     LEAN Forum     Slack Chat

Lean Home | Documentation | Download Zip | Docker Hub | Nuget | Get Connected


Introduction

Lean Engine is an open-source algorithmic trading engine built for easy strategy research, backtesting and live trading. We integrate with common data providers and brokerages so you can quickly deploy algorithmic trading strategies.

The core of the LEAN Engine is written in C#; but it operates seamlessly on Linux, Mac and Windows operating systems. It supports algorithms written in Python 3.8 or C#. Lean drives the web-based algorithmic trading platform QuantConnect.

Proudly Sponsored By

Want your company logo here? Sponsor LEAN to be part of radically open algorithmic-trading innovation.

QuantConnect is Hiring!

Join the team and solve some of the most difficult challenges in quantitative finance. If you are passionate about algorithmic trading we'd like to hear from you. The below roles are open in our Seattle, WA office. When applying, make sure to mention you came through GitHub:

  • C# Engineer: Contribute remotely to the core of LEAN through the open-source project LEAN.

  • UX Developer: Collaborate with QuantConnect to develop a world-leading online experience for a community of developers from all over the world.

System Overview

alt tag

The Engine is broken into many modular pieces which can be extended without touching other files. The modules are configured in config.json as set "environments". Through these environments, you can control LEAN to operate in the mode required.

The most important plugins are:

  • Result Processing (IResultHandler)

    Handle all messages from the algorithmic trading engine. Decide what should be sent, and where the messages should go. The result processing system can send messages to a local GUI, or the web interface.

  • Datafeed Sourcing (IDataFeed)

    Connect and download the data required for the algorithmic trading engine. For backtesting this sources files from the disk, for live trading, it connects to a stream and generates the data objects.

  • Transaction Processing (ITransactionHandler)

    Process new order requests; either using the fill models provided by the algorithm or with an actual brokerage. Send the processed orders back to the algorithm's portfolio to be filled.

  • Realtime Event Management (IRealtimeHandler)

    Generate real-time events - such as the end of day events. Trigger callbacks to real-time event handlers. For backtesting, this is mocked-up a works on simulated time.

  • Algorithm State Setup (ISetupHandler)

    Configure the algorithm cash, portfolio and data requested. Initialize all state parameters required.

These are all configurable from the config.json file in the Launcher Project.

Developing with Visual Studio Code Dev Containers

Creating a consistent environment is important for trading using Visual Studio Code Dev Containers makes it easy to get started. Following this step by step setup can create an isolated, simplified workflow that can be used cross platform.

The Dev Containers extension lets you use a Docker container as a full-featured development environment. The extension starts (or attaches to) a development container running the quantconnect/research:latest image.

A full explanation of developing Lean with Visual Studio Code Dev Containers can be found in the VS Code Integration project. You can also follow this guide which provides step-by-step instructions to set up and use Dev Containers with QuantConnect's Lean in Visual Studio Code.

Prerequisites

  1. Install Docker Desktop for your operating system (Windows, macOS, or Linux).
  2. Install Visual Studio Code.
  3. Install the "Remote - Containers" extension in VS Code:
    • Open VS Code.
    • Click on the Extensions icon in the Activity Bar on the side of the window.
    • Search for "Remote - Containers" and click the Install button.

Getting Started

  1. Clone the Lean repository:
  1. Open the Lean folder in VS Code:
  • Launch Visual Studio Code.
  • Click on "File" > "Open Folder" and navigate to the Lean folder you just cloned. Click "Open".
  1. Set up the Dev Container:
  • Once the Lean folder is open in VS Code, you should see a notification in the bottom right corner that says "Folder contains a dev container configuration file. Reopen folder to develop in a container". Click on "Reopen in Container".
  • If you don't see the notification, you can manually reopen the folder in the container by pressing F1 or Ctrl+Shift+P to open the Command Palette, then search for "Remote-Containers: Reopen in Container" and hit Enter.
  • VS Code will now start building the Docker container. This may take a few minutes, especially the first time. Once the container is built, VS Code will automatically attach to it, and you'll be able to develop within the container.
  1. Start developing with Lean:
  • After VS Code attaches to the container, you'll see the file explorer update to show the contents of the Lean project within the container.
  • You can now edit the code, run, debug, and perform any other development tasks directly within the container.

For more information and details, you can refer to the VS Code Integration project in the Lean repository.

Developing with Lean CLI

QuantConnect recommends using Lean CLI for local algorithm development. This is because it is a great tool for working with your algorithms locally while still being able to deploy to the cloud and have access to Lean data. It is also able to run algorithms on your local machine with your data through our official docker images.

Reference QuantConnects documentation on Lean CLI here

Installation Instructions

This section will cover how to install lean locally for you to use in your own environment.

Refer to the following readme files for a detailed guide regarding using your local IDE with Lean:

To install locally, download the zip file with the latest master and unzip it to your favorite location. Alternatively, install Git and clone the repo:

git clone https://github.com/QuantConnect/Lean.git
cd Lean

macOS

Visual Studio will automatically start to restore the Nuget packages. If not, in the menu bar, click Project > Restore NuGet Packages.

  • In the menu bar, click Run > Start Debugging.

Alternatively, run the compiled dll file. First, in the menu bar, click Build > Build All, then:

cd Lean/Launcher/bin/Debug
dotnet QuantConnect.Lean.Launcher.dll

Linux (Debian, Ubuntu)

  • Install dotnet 6:
  • Compile Lean Solution:
dotnet build QuantConnect.Lean.sln
  • Run Lean:
cd Launcher/bin/Debug
dotnet QuantConnect.Lean.Launcher.dll
  • Interactive Brokers set up details

Make sure you fix the ib-tws-dir and ib-controller-dir fields in the config.json file with the actual paths to the TWS and the IBController folders respectively.

If after all you still receive connection refuse error, try changing the ib-port field in the config.json file from 4002 to 4001 to match the settings in your IBGateway/TWS.

Windows

  • Install Visual Studio
  • Open QuantConnect.Lean.sln in Visual Studio
  • Build the solution by clicking Build Menu -> Build Solution (this should trigger the Nuget package restore)
  • Press F5 to run

Python Support

A full explanation of the Python installation process can be found in the Algorithm.Python project.

Local-Cloud Hybrid Development.

Seamlessly develop locally in your favorite development environment, with full autocomplete and debugging support to quickly and easily identify problems with your strategy. For more information please see the CLI Home.

Issues and Feature Requests

Please submit bugs and feature requests as an issue to the Lean Repository. Before submitting an issue please read others to ensure it is not a duplicate.

Getting Connected To The Community

Joining QuantConnect and becoming part of its thriving community is an excellent way to enhance your algorithmic trading skills, collaborate with like-minded individuals, stay updated on the latest developments in the world of quantitative finance, and build a skill that is in high demand. To get started, sign up for a free account on the QuantConnect website. The easiest way is to use your google or facebook account. Once you're registered, you'll have access to the various channels below but make sure you are signed in. From here you will be able to interact with the platform, enabling you to develop, backtest, and deploy algorithmic trading strategies seamlessly.

To engage with the community, join the LEAN Forum where you can ask questions, share your knowledge, and learn from others. The mailing list for the project can be found on here and is a great way to request assistance with your installations and setup questions.You can also contribute to the open-source Lean repository on GitHub by submitting bug reports, feature requests, or even code contributions. Remember that all accepted pull requests are eligible for a 2-month free Prime subscription on QuantConnect.

For real-time discussions from contributors and collaborators alike, join the Slack and or the Discord to connect with other users and the QuantConnect team. By actively participating in the community, you'll gain valuable insights, receive support on your trading strategies, and contribute to the ongoing innovation of algorithmic trading.

Welcome to QuantConnect, and we look forward to your contributions to our ever-growing community!

Contributors and Pull Requests

Contributions are warmly very welcomed but we ask you to read the existing code to see how it is formatted, commented and ensure contributions match the existing style. All code submissions must include accompanying tests. Please see the contributor guide lines. All accepted pull requests will get a 2mo free Prime subscription on QuantConnect. Once your pull-request has been merged write to us at [email protected] with a link to your PR to claim your free live trading. QC <3 Open Source.

A huge thank-you all our contributors!

Acknowledgements

The open-sourcing of QuantConnect would not have been possible without the support of the Pioneers. The Pioneers formed the core 100 early adopters of QuantConnect who subscribed and allowed us to launch the project into open source.

Ryan H, Pravin B, Jimmie B, Nick C, Sam C, Mattias S, Michael H, Mark M, Madhan, Paul R, Nik M, Scott Y, BinaryExecutor.com, Tadas T, Matt B, Binumon P, Zyron, Mike O, TC, Luigi, Lester Z, Andreas H, Eugene K, Hugo P, Robert N, Christofer O, Ramesh L, Nicholas S, Jonathan E, Marc R, Raghav N, Marcus, Hakan D, Sergey M, Peter McE, Jim M, INTJCapital.com, Richard E, Dominik, John L, H. Orlandella, Stephen L, Risto K, E.Subasi, Peter W, Hui Z, Ross F, Archibald112, MooMooForex.com, Jae S, Eric S, Marco D, Jerome B, James B. Crocker, David Lypka, Edward T, Charlie Guse, Thomas D, Jordan I, Mark S, Bengt K, Marc D, Al C, Jan W, Ero C, Eranmn, Mitchell S, Helmuth V, Michael M, Jeremy P, PVS78, Ross D, Sergey K, John Grover, Fahiz Y, George L.Z., Craig E, Sean S, Brad G, Dennis H, Camila C, Egor U, David T, Cameron W, Napoleon Hernandez, Keeshen A, Daniel E, Daniel H, M.Patterson, Asen K, Virgil J, Balazs Trader, Stan L, Con L, Will D, Scott K, Barry K, Pawel D, S Ray, Richard C, Peter L, Thomas L., Wang H, Oliver Lee, Christian L..

lean's People

Contributors

adalyatnazirov avatar adam-may avatar alexcatarino avatar c-sellers avatar derekmelchin avatar devalkeralia avatar espirulina avatar gsalaz98 avatar halldorandersen avatar ilshatgaripov avatar jameschch avatar jaredbroad avatar jay-jay-d avatar jhonabreul avatar jingwu74 avatar jmerle avatar kaffeebrauer avatar lixiang618 avatar louisszeto avatar marinovsky avatar martin-molinero avatar mattmast avatar mchandschuh avatar mushketyk avatar quant1729 avatar quietjoy avatar rjra2611 avatar simonsonjack avatar smartchris84 avatar stefanoraggi 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.