TradingMate’s documentation¶
Introduction¶
TradingMate is an autonomous trading system that uses customised strategies to trade in the London Stock Exchange market. This documentation provides an overview of the system, explaining how to create new trading strategies and how to integrate them with TradingMate. Explore the next sections for a detailed documentation of each module too.
System Overview¶
TradingMate is a portfolio manager with the goal to help traders to record their trades and deals in the stock market providing useful statistics and metrics to help backtest and review trade performance. It offers a simple user interface that provide information about the current asset value, the overall profit/loss indicator and the trade history.
TradingMate¶
TradingMate is the main entiy used to initialised all the components. It is the link between the user interface and the data.
TODO
Modules¶
Each section of this document provides the source code documentation of each component of TradingMate.
TradingMate¶
-
class
TradingMate.
TradingMate
[source]¶ Main class that handles the interaction between the User Interface and the underlying business logic of the whole application
-
on_open_portfolio_event
(filepath)[source]¶ Callback function to handle request to open a new portfolio file
-
Model¶
The Model
module contains the business logic and the data management of
TradingMate.
Holding¶
Portfolio¶
-
class
Model.Portfolio.
Portfolio
(name, config)[source]¶ -
-
compute_avg_holding_open_price
(symbol, trades_list)[source]¶ Return the average price paid to open the current positon of the requested stock. Starting from the end of the history log, find the BUY transaction that led to to have the current quantity, compute then the average price of these transactions
-
get_holding_list
()[source]¶ Return a list of Holding instances held in the portfolio sorted alphabetically
-
DatabaseHandler¶
-
class
Model.DatabaseHandler.
DatabaseHandler
(config)[source]¶ Handles the IO operation with the database to handle persistent data
UI¶
The UI
module contains the components that compose the User Interface
of TradingMate.
AddTradeDialogWindow¶
Utils¶
The Utils
module contains all the utlity components.
ConfigurationManager¶
TaskThread¶
-
class
Utils.TaskThread.
TaskThread
[source]¶ Thread that executes a task every N seconds
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
Changelog¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
TradingMate¶
TradingMate is a portfolio manager for stocks traders. It lets you record all your trades with a simple and basic interface, showing the current status of your assets and the overall profit (or loss!)
Dependencies¶
Python 3.4+
AlphaVantage: https://www.alphavantage.co/
View file requirements.txt
for the full list of python dependencies.
Install¶
After cloning this repo, to install TradingMate simply run:
./trading_mate_ctrl install
(This will require super-user access)
The required dependencies will be installed and all necessary files installed in /opt/TradingMate by default. It is recommended to add this path to your PATH environment variable.
Setup¶
TradingMate uses AlphaVantage to fetch markets data online:
Visit AlphaVantage website:
https://www.alphavantage.co
Request a free api key
Insert these info in a file called
.credentials
This must be in json format .. code-block:: guess- {
“av_api_key”: “apiKey”
}
Copy the
.credentials
file in the$HOME/.TradingMate/data
folderRevoke permissions to read the file by others .. code-block:: guess
cd $HOME/.TradingMate/data sudo chmod 600 .credentials
### Configuration file
The config.json
file is in the $HOME/.TradingMate/config
folder and it contains several parameters to personalise how TradingMate works.
These are the descriptions of each parameter:
general/trading_log_path: The absolute path of the trading log where the history of your trades are saved
general/credentials_filepath: File path of the .credentials file
alpha_vantage/api_base_uri: Base URI of AlphaVantage API
alpha_vantage/polling_period_sec: The polling period to query AlphaVantage for stock prices
Run¶
TradingMate can be controlled by the trading_mate_ctrl
shell script.
The script provides commands to perform different actions:
Start TradingMate¶
./trading_mate_ctrl start
Stop TradingMate¶
Closing the main window will stop the whole application. You can also use the command:
./trading_mate_ctrl stop
Test¶
Test can’t run with the installed script. You can run the test from a “workspace” environment with:
./trading_mate_ctrl test
You can run the test in Docker containers against different python versions:
./trading_mate_ctrl test_docker
Documentation¶
The Sphinx documentation contains further details about each TradingMate module with source code documentation of each component.
Read the documentation at:
https://tradingmate.readthedocs.io
You can build it locally from the “workspace” root folder:
./trading_mate_ctrl docs
The generated html files will be under doc/_build/html
.
Contributing¶
I appreciate any help so if you have suggestions or issues open an Issue for discussion. If you can contribute please just open a pull request with your changes. Thanks for all the support!