What this is. A Python script that converts a TradeZella CSV export into the STB Bulk Import format, writing straight to your Google Sheet (or
.xlsxif credentials are not set up).Who it is for. Traders on Mac or Windows who use TradeZella and SmartTraderAI.
Do this first. Follow Step 0, or watch the demo.
Automates converting a TradeZella CSV export into the STB Bulk Import format.
Default behavior: writes directly to your Google Sheet.
Falls back to .xlsx if Google credentials are not yet configured.
Note on TradeZella export filenames: TradeZella names exports using a timestamp, e.g.
trades_20260218124033.csv. The script accepts anytrades_*.csvfilename β no renaming needed before running it.
Watch the Demo Video: View on YouTube
or Download the Screen Recording here Note: GitHub's web preview restricts "raw" embedded local video for security and performance reasons, whereas VS Code allows them because it runs in a local environment. To view the demo, please click the links to download/open the video file directly, or view this readme in a Markdown-capable editor like VS Code.
| File | Purpose |
|---|---|
tradezella_to_stb.py |
Core Python script β works on Windows & Mac |
automator_drop_handler.sh |
macOS Automator drag-and-drop app script |
STB_Import_Template.xlsx |
STB import template β keep in same folder |
service_account.json |
(you create this) Google Cloud credentials |
Optional but recommended. Keeps all files in one place. If you prefer to organise files your own way, just make sure
tradezella_to_stb.py,STB_Import_Template.xlsx, andservice_account.jsonare always in the same folder.
Open Terminal (Spotlight β type "Terminal" β Enter) and run:
mkdir -p ~/TradeZella_STBMove your downloaded files in:
mv ~/Downloads/tradezella_to_stb.py ~/TradeZella_STB/
mv ~/Downloads/automator_drop_handler.sh ~/TradeZella_STB/
mv ~/Downloads/STB_Import_Template.xlsx ~/TradeZella_STB/Verify everything is there:
ls ~/TradeZella_STB/Open Command Prompt (Windows + R β type cmd β Enter):
mkdir %USERPROFILE%\TradeZella_STB
Move files in (or drag them in File Explorer):
move %USERPROFILE%\Downloads\tradezella_to_stb.py ^
%USERPROFILE%\TradeZella_STB\
move %USERPROFILE%\Downloads\STB_Import_Template.xlsx ^
%USERPROFILE%\TradeZella_STB\
Verify:
dir %USERPROFILE%\TradeZella_STB\
These four packages are required. The install method differs slightly depending on your setup.
Modern macOS with Homebrew protects the system Python from global package installs. The solution is a virtual environment β a self-contained Python space just for this project. You only do this once.
cd ~/TradeZella_STB
python3 -m venv venv
source venv/bin/activate
pip install pandas openpyxl gspread google-authYour terminal prompt will show (venv) when the environment is active.
Every time you open a new Terminal window to run the script manually, reactivate it first:
cd ~/TradeZella_STB
source venv/bin/activateThe Automator app handles this automatically β you never need to activate the venv manually when using drag-and-drop.
Since Homebrew manages its own Python environment, use the
--break-system-packages --user flags to install safely into
your home directory:
pip3 install pandas openpyxl gspread google-auth \
--break-system-packages --userNote on PATH warnings: You may see warnings that scripts were installed to
/Users/yourname/Library/Python/3.x/binwhich is not on PATH. These are safe to ignore β the packages themselves are installed correctly and the script will work fine.
pip install pandas openpyxl gspread google-auth
If pip is not found, use:
python -m pip install pandas openpyxl gspread google-auth
This lets the script push trades directly into your live Google Sheet.
Google Sheet Template: https://docs.google.com/spreadsheets/d/1SonfR5bUHj_xXqJpSQ6ajpkSi2lV0zdP5z7GBEbyMzs/edit?usp=sharing
- Go to console.cloud.google.com
- Click the project dropdown β "New Project"
- Name it (e.g.
TradeZella STB) β Create
- Left sidebar β "APIs & Services" β "Library"
- Search "Google Sheets API" β Enable
- Search "Google Drive API" β Enable
- Left sidebar β "APIs & Services" β "Credentials"
- "+ Create Credentials" β "Service Account"
- Name it (e.g.
stb-importer) β Create and Continue β Done - Click the service account β "Keys" tab
- "Add Key" β "Create new key" β JSON β Create
- Rename the downloaded file to
service_account.json - Move it into your working folder:
Mac:
mv ~/Downloads/service_account.json ~/TradeZella_STB/Windows:
move %USERPROFILE%\Downloads\service_account.json ^
%USERPROFILE%\TradeZella_STB\
- Open
service_account.jsonin any text editor - Copy the
"client_email"value (looks likestb-importer@your-project.iam.gserviceaccount.com) - Open your STB Google Sheet β Share
- Paste the email β role Editor β Send
- Copy the ID from your Google Sheet URL:
https://docs.google.com/spreadsheets/d/YOUR_ID_HERE/edit - Open
tradezella_to_stb.pyin any text editor - Find this line near the top:
SPREADSHEET_ID = "YOUR_SPREADSHEET_ID_HERE"
- Replace
YOUR_SPREADSHEET_ID_HEREwith your actual ID (keep the quotes)
- Export trades from TradeZella as
.csv(any filename is fine) - Open Command Prompt in your folder
(File Explorer β click address bar β type
cmdβ Enter) - Run:
python tradezella_to_stb.py trades_20260218124033.csv- Google Sheets configured β trades append to your live sheet β
- Not yet configured β
STB_Import_Merged_YYYYMMDD.xlsxis created in the same folder β upload it manually
| Flag | What it does |
|---|---|
--sheets |
Force Google Sheets output |
--xlsx |
Force .xlsx file output |
--sheet-id YOUR_ID |
Override spreadsheet ID without editing script |
--tab "Sheet1" |
Specify a different tab name |
--output myfile.xlsx |
Custom output filename (xlsx mode) |
Create run_merge.bat in your folder:
@echo off
cd /d "%~dp0"
python tradezella_to_stb.py %1
pauseDrag any CSV onto run_merge.bat to run without opening Command Prompt.
The recommended method is the Automator app β a desktop icon you drag CSV files onto. No Terminal needed after setup.
One-time setup (~5 minutes):
-
Confirm
~/TradeZella_STB/contains:tradezella_to_stb.pySTB_Import_Template.xlsxservice_account.json(after Google Cloud setup)venv/folder (after Python package install)
-
Open Automator (Spotlight β "Automator" β Enter)
-
Choose "Application" as the document type
-
Search for "Run Shell Script" β drag it into the workflow
-
Set "Pass input:" to
as arguments(critical β this is how the CSV path reaches the script) -
Delete all default code in the text box
-
Paste the entire contents of
automator_drop_handler.sh -
File β Save β name it
TradeZella to STBβ save to Desktop
Daily use:
- Export trades from TradeZella as
.csv - Drag the
.csvonto TradeZella to STB on your Desktop - Result:
- Google Sheets configured β trades appear in your sheet β
- Not configured β
.xlsxfile saved next to your CSV and opens automatically β
You can drop multiple CSV files at once.
cd ~/TradeZella_STB
source venv/bin/activate
python3 tradezella_to_stb.py ~/Downloads/trades_20260218124033.csv| TradeZella | β | STB Template | Notes |
|---|---|---|---|
| Open Date | β | Trading Date | |
| Entry Model | β | Entry Model | Blank β other (specify) |
| (hardcoded) | β | Currency | Always USD |
| Net P&L | β | Profit / Loss | |
| Status + Net P&L | β | Outcome | green / red / breakeven |
| Emotions | β | Emotions | Multi-select, passed through as-is |
| Did Emotions Affect Decisions? | β | Did emotions affect decisions? | yes / no |
| Was Emotionally Stable? | β | Was emotionally stable? | yes / no |
| Profit Target Did You Respect It? | β | Profit target - did you respect it? | |
| Stop Loss Did You Respect It? | β | Stop loss - did you respect it? | |
| Entry Logic Explanation | β | Entry logic explanation | |
| How Did The Trade Play Out? | β | How did the trade play out? | |
| Notes For Coaches | β | Notes for coaches | |
| (not in TradeZella) | β | Screenshot URLs | Left blank |
| Problem | Fix |
|---|---|
ModuleNotFoundError: pandas |
Run the venv setup steps in the Python install section |
externally-managed-environment |
Use the virtual environment method β see Python install section |
SPREADSHEET_ID is not set |
Edit SPREADSHEET_ID at the top of tradezella_to_stb.py |
service_account.json not found |
Move it into the same folder as the script |
403 PERMISSION_DENIED |
Share the Google Sheet with the client_email from your JSON (Editor) |
gspread.exceptions.APIError |
Enable both Sheets API and Drive API in Google Cloud Console |
| Automator does nothing | Check "Pass input: as arguments" is set in the workflow |
| Automator can't find Python | Run which python3 in Terminal and update SCRIPT_DIR in the Automator script |
| Python not found on Mac | Install from python.org or brew install python3 |
| Template not found | Confirm STB_Import_Template.xlsx is in the same folder as the script |
Noticed something? Open an issue or a pull request against main; Christopher reads them and a person with the role merges. Not on GitHub? Reach Christopher through his contact page.
The front door follows the living README standard. Copy it, improve it.