Making a trading tools app in Python (Part 1)
Martin Tokman
Active Intraday Forex Trader ?? | Data Analytics & Python | Corporate Advisor | Power BI | Process Automation | Business Efficiency | Crafting Robust Data Solutions | Content Creator | Business Intelligence | SQL
Following my journey in learning Python I started to build a trading tools app. This will be my first complete software development. The plan is to make an application for managing investments and other financial tools.
This first part covers the basic functions of reading a trading journal from a csv file. The goal for now is to manage the whole application with a simple comma separate file that I exported from my original Excel journal. This is useful for me because I can practice interacting with this kind of external files, but the final version will work with a database.
Trying to resolve the logic was a challenge because I wanted to keep it as simple as possible. As usual, I tried to think of a collection of mini separate applications working together as a whole. Therefore, my approach was to create distinct functions for each process. This led to the necessity of nesting functions, which introduced an additional layer of complexity.
For this first stage my goal was to make some functions that read the csv journal and make a menu for getting a list of trades filtered by date or asset.
The general flowchart was the following:
For the main_menu_1 function, first I created a _list variable and assigned the return of list_trades_by_date function. The list_trades_by_date function opens the journal.csv file and makes a list of unique dates like a kind of dynamic menu and prints it in the console. The resulted list is returned to the main_menu_1 function as a variable called _list. Next, the function asks the user to enter the selected date and checks for the input to be in between the possible valid range of dates inside an infinite loop. If user input is invalid, it shows an error message and asks the user to input a new value.
When the user inputs a valid option, the flow calls the show_detailed_trades_list_by_date function which searches in the journal.csv file for all the trades made in the selected date. The result is printed in the console as a detailed list of trades including the following.
·????????Date
·????????Time
·????????Asset
·????????Session
·????????Entry type
·????????Stop loss
·????????Target
·????????Volume
·????????PNL
·????????Exit price 1
·????????Comments for exit price 1
·????????Exit price 2
领英推荐
·????????Comments for exit price 2
·????????Entry image
·????????Structure 1 entry image
·????????Structure 2 entry image
·????????Trade management
·????????Trade management image 1
·????????Trade management image 2
·????????Trade management image 3
·????????Trade management image 4
After this information is printed, the flow shows again the main menu and asks the user to input a value.
The flowchart of main_menu_1 function is the following:
For the main_menu_2 function, it’s the same process as the main_menu_1, but instead of searching for dates to make the selection menu, it searches for the asset, making a menu of the different assets traded in the journal. The process shows the menu and asks for the user to input the desired option. If a valid option is selected, the flow calls for the show_detailed_trades_list_by_asset function and prints the list of trades with the same data as the show_detailed_trades_list_by date of the main_menu_1 option.
The flowchart of main_menu_2 function is the following:
As the same with main_menu_1, when the list of traded assets is shown, the flow calls for the main menu again inside an infinite loop that will repeat until the exit option is selected. When this happens, the program exits showing a goodbye message.
For now, all is printed in the python console. The app is lack of a graphical interface and it will continue like this, my focus is to continue adding functionality like crud and some statistical data before I make the gui.
I will be posting new articles with the progress.
Github repository: