2. Modules
Each section of this document provides the source code documentation of each
component of TradingMate.
2.1. TradingMate
2.2. Model
The Model
module contains the business logic and the data management of
TradingMate.
2.2.1. Holding
-
class
Model.Holding.
Holding
(symbol, quantity, open_price=None)[source]
-
add_quantity
(value)[source]
Add or subtract (if value is negative) the value to the holding quantity
2.2.2. Portfolio
2.2.3. DatabaseHandler
-
class
Model.DatabaseHandler.
DatabaseHandler
(config, trading_log_path)[source]
Handles the IO operation with the database to handle persistent data
-
add_trade
(trade)[source]
Add a trade to the database
-
get_db_filepath
()[source]
Return the database filepath
-
get_trades_list
()[source]
Return the list of trades stored in the db
-
get_trading_log_name
()[source]
Return the trading log database name
-
read_data
(filepath=None)[source]
Read the trade history from the json database and return the list of trades
-
remove_last_trade
()[source]
Remove the last trade from the trade history
-
write_data
(filepath=None)[source]
Write the trade history to the database
2.2.4. StockPriceGetter
2.3. UI
The UI
module contains the components that compose the User Interface
of TradingMate.
2.3.1. DataInterface
-
class
UI.DataInterface.
DataInterface
(client, data_callback)[source]
Thread that periodically requests the most recent data from TradingMate
server notify the parent object through a callback function
-
task
()[source]
The task done by this thread - override in subclasses
2.3.2. TradingMateClient
-
class
UI.TradingMateClient.
TradingMateClient
(server)[source]
Client interface to the TradingMate business logic
-
delete_last_trade_event
(portfolio_id)[source]
Request last trade deletion to the server
-
get_portfolios
()[source]
Get the loaded portfolios
-
get_settings_event
()[source]
Request server to fetch TradingMate settings
-
is_portfolio_auto_refreshing
(portfolio_id)[source]
Return True if portfolio has data auto refresh enabled, False otherwise
-
manual_refresh_event
(portfolio_id)[source]
Request server to refresh portfolio data
-
new_trade_event
(new_trade, portfolio_id)[source]
Push new trade notification to the server
-
open_portfolio_event
(filepath)[source]
Request server to open a portfolio
-
save_portfolio_event
(portfolio_id, filepath)[source]
Request server to save a portfolio
-
save_settings_event
(settings)[source]
Request server to save the settings
-
set_auto_refresh_event
(value, portfolio_id)[source]
Set server to automatically update data for the portfolio
-
stop
()[source]
Handle stop event
-
unsaved_changes
()[source]
Request if open portfolios have unsaved changes and return True
2.3.3. GTK
The gtk
module contains the gtk components and widgets of the
graphical interface
2.3.3.1. UIHandler
2.3.3.2. ConfirmDialog
2.3.3.3. MessageDialog
2.3.3.4. PortfolioPage
2.3.3.5. SettingsWindow
2.4. Utils
The Utils
module contains all the utlity components.
2.4.1. ConfigurationManager
-
class
Utils.ConfigurationManager.
ConfigurationManager
(config_path)[source]
Class that loads the configuration and credentials json files exposing
static methods to provide the configurable parameters
-
get_alpha_vantage_api_key
()[source]
Get the alphavantage api key
-
get_alpha_vantage_base_url
()[source]
Get the alphavantage API base URI
-
get_alpha_vantage_polling_period
()[source]
Get the alphavantage configured polling period
-
get_credentials_path
()[source]
Get the filepath of the credentials file
-
get_editable_config
()[source]
Get a dictionary containing the editable configuration parameters
-
get_trading_database_path
()[source]
Get the filepath of the trading log file
-
save_settings
(config)[source]
Save the edited configuration settings
2.4.2. TaskThread
-
class
Utils.TaskThread.
TaskThread
[source]
Thread that executes a task every N seconds
-
cancel_timeout
()[source]
Cancel the timeout and run the task
-
enable
(enabled)[source]
Disable/enable this thread
-
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.
-
setInterval
(interval)[source]
Set the number of seconds we sleep between executing our task
-
shutdown
()[source]
Stop this thread
-
task
()[source]
The task done by this thread - override in subclasses
2.4.3. Trade
-
class
Utils.Trade.
Trade
(date_string, action, quantity, symbol, price, fee, sdr, notes)[source]
2.4.4. Utils
-
class
Utils.Utils.
Actions
[source]
An enumeration.
-
class
Utils.Utils.
Messages
[source]
An enumeration.
-
class
Utils.Utils.
Markets
[source]
An enumeration.