All Projects β†’ ilcardella β†’ Tradingbot

ilcardella / Tradingbot

Licence: mit
Autonomous stocks trading script

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tradingbot

TerminalStocks
Pure terminal stock ticker for Windows.
Stars: ✭ 88 (-11.11%)
Mutual labels:  trading, stock-market
trading sim
πŸ“ˆπŸ“† Backtest trading strategies concurrently using historical chart data from various financial exchanges.
Stars: ✭ 21 (-78.79%)
Mutual labels:  trading, stock-market
TradingView-Machine-Learning-GUI
Let Python optimize the best stop loss and take profits for your TradingView strategy.
Stars: ✭ 396 (+300%)
Mutual labels:  trading, stock-market
cira
Cira algorithmic trading made easy. A Façade library for simpler interaction with alpaca-trade-API from Alpaca Markets.
Stars: ✭ 21 (-78.79%)
Mutual labels:  trading, stock-market
Robin stocks
This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at
Stars: ✭ 967 (+876.77%)
Mutual labels:  trading, stock-market
tstock
πŸ“ˆA command line tool to view stock charts in the terminal.
Stars: ✭ 498 (+403.03%)
Mutual labels:  trading, stock-market
tuneta
Intelligently optimizes technical indicators and optionally selects the least intercorrelated for use in machine learning models
Stars: ✭ 77 (-22.22%)
Mutual labels:  trading, stock-market
Deep Learning Machine Learning Stock
Stock for Deep Learning and Machine Learning
Stars: ✭ 240 (+142.42%)
Mutual labels:  trading, stock-market
Sibyl
Platform for backtesting and live-trading intraday Stock/ETF/ELW using recurrent neural networks
Stars: ✭ 32 (-67.68%)
Mutual labels:  trading, stock-market
Algotrader
Simple algorithmic stock and option trading for Node.js.
Stars: ✭ 468 (+372.73%)
Mutual labels:  trading, stock-market
TradeByte
πŸ’Έ TradeByte - Stocks Trading Simulation WebApp
Stars: ✭ 30 (-69.7%)
Mutual labels:  trading, stock-market
Alice blue
Official Python library for Alice Blue API trading
Stars: ✭ 60 (-39.39%)
Mutual labels:  trading, stock-market
Alpaca Backtrader Api
Alpaca Trading API integrated with backtrader
Stars: ✭ 246 (+148.48%)
Mutual labels:  trading, stock-market
web trader
πŸ“Š Python Flask game that consolidates data from Nasdaq, allowing the user to practice buying and selling stocks.
Stars: ✭ 21 (-78.79%)
Mutual labels:  trading, stock-market
Ta Rs
Technical analysis library for Rust language
Stars: ✭ 248 (+150.51%)
Mutual labels:  trading, stock-market
nordnet
Uonfficial wrapper for financial data api from the Scandinavian broker Nordnet
Stars: ✭ 13 (-86.87%)
Mutual labels:  trading, stock-market
Stock market indicators
A small Python library with most common stock market indicators
Stars: ✭ 162 (+63.64%)
Mutual labels:  trading, stock-market
Deep Rl Trading
playing idealized trading games with deep reinforcement learning
Stars: ✭ 228 (+130.3%)
Mutual labels:  trading, stock-market
Quantdom
Python-based framework for backtesting trading strategies & analyzing financial markets [GUI ]
Stars: ✭ 449 (+353.54%)
Mutual labels:  trading, stock-market
Pandas Ta
Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 130+ Indicators
Stars: ✭ 962 (+871.72%)
Mutual labels:  trading, stock-market

TradingBot

Build Status Documentation Status Docker Pulls

This is an attempt to create an autonomous market trading script using the IG REST API and any other available data source for market prices.

TradingBot is meant to be a "forever running" process that keeps analysing the markets taking actions whether some conditions are met. It is halfway from an academic project and a real useful piece of software, I guess I will see how it goes :)

The main goal of this project is to provide the capability to write a custom trading strategy with the minimum effort. TradingBot handles all the boring stuff.

All the credits for the WeightedAvgPeak strategy goes to GitHub user @tg12.

Dependencies

  • Python 3.6+
  • Poetry (only for development)
  • Docker (optional)

View file pyproject.toml for the full list of required python packages.

Install

First if you have not done yet, install python:

sudo apt-get update
sudo apt-get install python3

Clone this repo and install TradingBot by running the following command from the repository root folder

make install-system

Setup

Login to your IG Dashboard

  • Obtain an API KEY from the settings panel
  • If using the demo account, create demo credentials
  • Take note of your spread betting account ID (demo or real)
  • (Optional) Visit AlphaVantage website: https://www.alphavantage.co and request a free api key
  • Insert these info in a file called .credentials

This must be in json format

{
    "username": "username",
    "password": "password",
    "api_key": "apikey",
    "account_id": "accountId",
    "av_api_key": "apiKey"
}
  • Copy the .credentials file into the ${HOME}/.TradingBot/config folder
  • Revoke permissions to read the file
cd config
sudo chmod 600 ${HOME}/.TradingBot/config/.credentials

Market source

There are different ways to define which markets to analyse with TradinbgBot. You can select your preferred option in the configuration file under the market_source section:

  • Local file

You can create a file epic_ids.txt containg IG epics of the companies you want to monitor. You need to copy this file into the ${HOME}/.TradingBot/data folder.

  • Watchlist

You can use an IG watchlist, TradingBot will analyse every market added to the selected watchlist

  • API

TradingBot navigates the IG markets dynamically using the available API call to fetch epic ids.

Configuration file

The configuration file is in the config folder and it contains several configurable parameter to personalise how TradingBot work. It is important to setup this file appropriately in order to avoid unexpected behaviours.

Start TradingBot

You can start TradingBot with

trading_bot

You can start it in detached mode letting it run in the background with

nohup trading_bot >/dev/null 2>&1 &

Close all the open positions

trading_bot --close-positions [-c]

Stop TradingBot

To stop a TradingBot instance running in the background

ps -ef | grep trading_bot | xargs kill -9

Uninstall

You can use pip to uninstall TradingBot:

sudo pip3 uninstall TradingBot

Development

The Makefile is the entrypoint for any development action. Poetry handles the dependency management and the pyproject.toml contains the required python packages.

Install poetry and create the virtual environment:

cd /path/to/repository
make install

Test

You can run the test from the workspace with:

make test

Documentation

The Sphinx documentation contains further details about each TradingBot module with source code documentation of each class member. Explanation is provided regarding how to create your own Strategy and how to integrate it with the system.

Read the documentation at:

https://tradingbot.readthedocs.io

You can build it locally with:

make docs

The generated html files will be in docs/_build/html.

Automate

NOTE: TradingBot monitors the market opening hours and suspend the trading when the market is closed. Generally you should NOT need a cron job!

You can set up the crontab job to run and kill TradinBot at specific times. The only configuration required is to edit the crontab file adding the preferred schedule:

crontab -e

As an example this will start TradingBot at 8:00 in the morning and will stop it at 16:35 in the afternoon, every week day (Mon to Fri):

00 08 * * 1-5 trading_bot
35 16 * * 1-5 kill -9 $(ps | grep trading_bot | grep -v grep | awk '{ print $1 }')

NOTE: Remember to set the correct timezone in your machine!

Docker

You can run TradingBot in a Docker container.

The Docker images are configured with a default TradingBot configuration and it does not have any .credentials files. You must mount these files when running the Docker container

Pull

The Docker images are available in the official Docker Hub. Currently TradingBot supports both amd64 and arm64 architectures. You can pull the Docker image directly from the Docker Hub. Latest version:

docker pull ilcardella/tradingbot:latest

Tagged version:

docker pull ilcardella/tradingbot:v2.0.0

Build

You can build the Docker image yourself using the Dockerfile in the docker folder:

cd /path/to/repo
make docker

Run

As mentioned above, it's important that you configure TradingBot before starting it. Once the image is available you can run TradingBot in a Docker container mounting the configuration files:

docker run -d \
    -v /path/to/trading_bot.toml:/.TradingBot/config/trading_bot.toml \
    -v /path/to/.credentials:/.TradingBot/config/.credentials \
    tradingbot:latest

You can also mount the log folder to store the logs on the host adding -v /host/folder:/.TradingBot/log

Contributing

Any contribution or suggestion is welcome, please follow the suggested workflow.

Pull Requests

To add a new feature or to resolve a bug, create a feature branch from the master branch.

Commit your changes and if possible add unit/integration test cases. Eventually push your branch and create a Pull Request against master.

If you instead find problems or you have ideas and suggestions for future improvements, please open an Issue. Thanks for the support!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].