Git Product home page Git Product logo

bullets's Introduction

BullETS

GitHub Workflow Status (branch)

BullETS is a Python library designed to help with the development of algorithmic trading strategies.

Upcoming features

  • Retrieve stock data
  • Trading portfolio management
  • Backtesting framework

Installation

This section will assume you have Python installed, if not, you can download & install it from here.

We strongly recommend using a virtual environment to keep BullETS and its dependencies from interfering with your system installs.

Initializing and running a virtual environment

Windows:

# Initializing a virtual environment in the ./venv directory
py -3 -m venv venv

# Activating the virtual environment
venv\Scripts\activate.bat

Mac OS & Linux:

# Initializing a virtual environment in the ./venv directory
python3 -m venv bot-env

# Activating the virtual environment (Mac OS & Linux)
source bot-env/bin/activate

Using BullETS to develop a strategy

  1. Register an account on the FinancialModelingPrep website and retrieve your API key

  2. Create a new folder, initialize and activate a virtual environment inside (see above)

  3. Install BullETS from PyPI

pip install BullETS
  1. Code your own strategy
from bullets.strategy import Strategy, Resolution
from bullets.runner import Runner
from bullets.data_source.data_source_fmp import FmpDataSource
from datetime import datetime

# Extend the default strategy from BullETS
class MyStrategy(Strategy):
   
   # You can access the `portfolio` and the `data_source` variables to retrieve information for your strategy
   # You are also free to add your own data sources here and use them

    # Redefine this function to perform a task when the strategy starts
    def on_start(self):
        pass

    # Redefine this function to perform a task on each resolution
    def on_resolution(self):
        self.portfolio.market_order("AAPL", 5)

    # Redefine this function to perform a task at the end of the strategy
    def on_finish(self):
        pass

        
# Initialize your new strategy
if __name__ == '__main__':
    resolution = Resolution.DAILY # Define your resolution (DAILY, HOURLY or MINUTE)
    start_time = datetime(2019, 3, 5) # Define your strategy start time
    end_time = datetime(2019, 4, 22) # Define your strategy end time
    data_source = FmpDataSource("Insert your key here", resolution) # Initialize the FMP data source with your API key and resolution
    strategy = MyStrategy(resolution=resolution,
                                start_time=start_time,
                                end_time=end_time,
                                starting_balance=5000,
                                data_source=data_source)
    
    runner = Runner(strategy) # Initialize the runner, which handles the execution of your strategy
    runner.start() # Start the runner and your strategy

This section only covers the basic features to develop a strategy. BullETS has other features, such as slippage, transaction fees, and many others. Stay updated for our upcoming detailed documentation that demonstrates how to use these features.

Development mode

This section covers the installation process if you wish to contribute to the library.

  1. Clone the repo and go to the library's root directory
# Clone this repository
git clone https://github.com/AlgoETS/BullETS

# Move to the BullETS directory
cd BullETS
  1. Initialize and run a virtual environment (see above)

  2. Install BullETS in editable mode (while the virtual environment is activated)

pip install -e .
  1. Setup environment variables
    1. Make a copy of the .env.sample file and name it .env
    2. Replace the required values inside the .env file

bullets's People

Contributors

tristanfecteau avatar samimammouche avatar geukers avatar xxdemersxx8 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.