Automated trading systems need to run continuously, maintain a stable network connection, recover after failures, and remain available even when your local computer is turned off. A virtual private server is one of the simplest ways to provide this environment.
In this guide, we will deploy a Python trading bot on an Ubuntu VPS from scratch. We will prepare the operating system, create an isolated Python environment, configure exchange credentials, test the bot, run it as a background service, enable automatic startup, configure logging, and apply several basic security measures.
The same deployment approach can be used for cryptocurrency bots, market monitoring applications, algorithmic trading systems, arbitrage scripts, alert services, and other Python applications that need to operate continuously.
How a Python Trading Bot Works on a VPS
A trading bot usually consists of several components:
- Python application — contains the strategy and trading logic.
- Exchange or broker API — provides market data and allows the application to manage orders.
- Python libraries — provide API clients, data processing tools, indicators, logging, and other functionality.
- Configuration and API keys — store parameters required to connect to the trading platform.
- VPS — keeps the application running independently from your local computer.
- systemd — supervises the bot process and can restart it automatically if it stops unexpectedly.
- system journal — stores application output and errors for troubleshooting.
The final architecture will look approximately like this:
│ HTTPS / WebSocket
▼
▼
This architecture separates the trading application from your personal computer and provides a controlled Linux environment for continuous execution.
What You Need
Before starting, prepare:
- an Ubuntu VPS;
- SSH access to the server;
- a Python trading bot or Python project;
- an account with the exchange or broker used by the bot;
- API credentials if private API operations are required;
- basic knowledge of Linux terminal commands.
For a lightweight bot that processes several trading pairs, a small VPS is usually sufficient as a starting point.
| Workload | Suggested Starting Configuration |
|---|---|
| Simple monitoring or trading bot | 1 vCPU, 1–2 GB RAM |
| Bot using pandas and multiple markets | 2 vCPU, 2–4 GB RAM |
| Several bots or data-processing services | 2–4+ vCPU, 4–8+ GB RAM |
These values are starting points rather than strict requirements. CPU and memory consumption depend heavily on the strategy, number of markets, frequency of requests, libraries, database usage, and amount of historical data processed.
Step 1. Deploy an Ubuntu VPS
Create a virtual server with Ubuntu installed.
For most Python projects, a current Ubuntu LTS release is a convenient choice because it provides stable package repositories and long-term security updates.
After deployment, you should receive:
- the public IP address of the VPS;
- a root password or configured SSH key;
- SSH access to the operating system.
It is preferable to use SSH key authentication instead of relying exclusively on passwords.
Step 2. Connect to the VPS via SSH
On Linux or macOS, open Terminal.
On modern Windows systems, SSH can also be used directly from PowerShell or Windows Terminal.
Connect to the server:
ssh root@SERVER_IPReplace:
SERVER_IPwith the actual public IP address of your VPS.
For example:
ssh root@192.0.2.10If you are connecting to the server for the first time, SSH may ask you to confirm the server fingerprint.
Type:
yesThen authenticate using your password or SSH key.
Step 3. Update Ubuntu
Before installing the application, update information about available packages:
apt updateInstall available updates:
apt upgrade -yThis reduces the chance of deploying the application on top of outdated system packages.
You can check the operating system version with:
lsb_release -aor:
cat /etc/os-releaseStep 4. Create a Dedicated User for the Trading Bot
Running an Internet-connected application permanently as `root` is unnecessary and increases the potential impact of a compromised process.
Create a separate system user:
adduser --disabled-password --gecos "" tradingbotWe will use this account to own and execute the application files.
Create a directory for the project:
mkdir -p /opt/trading-botGive ownership to the new user:
chown -R tradingbot:tradingbot /opt/trading-botThe project will now be located at:
/opt/trading-botStep 5. Install Python and Required Tools
Install Python, virtual environment support, pip, Git, and curl:
apt install -y python3 python3-venv python3-pip git curlCheck the installed Python version:
python3 --versionCheck Git:
git --versionUsing a Python virtual environment is especially important on current Ubuntu installations because it keeps project dependencies separate from packages managed by the operating system.
Step 6. Create a Python Virtual Environment
Switch to the application user:
sudo -iu tradingbotMove to the project directory:
cd /opt/trading-botCreate a virtual environment:
python3 -m venv venvActivate it:
source venv/bin/activateThe shell prompt should now contain something similar to:
(venv)Upgrade pip inside the virtual environment:
python -m pip install --upgrade pipPackages installed while the environment is active will remain isolated from Ubuntu's system Python installation.
Step 7. Upload the Trading Bot
There are several ways to transfer your project to the VPS.
Option 1. Clone the Project from Git
If the project is stored in Git:
cd /opt
git clone YOUR_REPOSITORY trading-botFor an existing /opt/trading-bot directory, you can alternatively initialize or clone the repository into another directory and move the required files afterward.
For private repositories, use an SSH deploy key or another secure authentication mechanism instead of storing your personal account credentials directly on the server.
Option 2. Copy Files with SCP
From your local computer:
scp -r ./trading-bot/* tradingbot@SERVER_IP:/opt/trading-bot/Option 3. Create the Script Directly on the VPS
For a small test project, create a file:
nano /opt/trading-bot/bot.pyYou can then paste your Python code into it.
Step 8. Install Python Dependencies
A production project should normally describe its dependencies in a requirements.txt file.
For example:
ccxt
python-dotenvInstall them:
cd /opt/trading-bot
source venv/bin/activate
pip install -r requirements.txtFor demonstration purposes, we will use CCXT, a Python library that provides a unified interface for many cryptocurrency exchange APIs.
You can also install the packages directly:
pip install ccxt python-dotenvCheck that CCXT can be imported:
python -c "import ccxt; print(ccxt.**version**)"Step 9. Create a Test Trading Bot
If you already have your own bot, you can skip this section.
Otherwise, create:
nano /opt/trading-bot/bot.pyAdd the following example:
import logging
import os
import time
import ccxt
from dotenv import load_dotenv
load_dotenv("/opt/trading-bot/.env")
EXCHANGE_ID = os.getenv("EXCHANGE_ID", "kraken")
SYMBOL = os.getenv("SYMBOL", "BTC/USD")
POLL_INTERVAL = int(os.getenv("POLL_INTERVAL", "30"))
API_KEY = os.getenv("EXCHANGE_API_KEY")
API_SECRET = os.getenv("EXCHANGE_API_SECRET")
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s | %(levelname)s | %(message)s"
)
def create_exchange():
exchange_class = getattr(ccxt, EXCHANGE_ID)
config = {
"enableRateLimit": True,
}
if API_KEY:
config["apiKey"] = API_KEY
if API_SECRET:
config["secret"] = API_SECRET
return exchange_class(config)
def main():
exchange = create_exchange()
logging.info("Connecting to exchange: %s", EXCHANGE_ID)
exchange.load_markets()
if SYMBOL not in exchange.markets:
raise RuntimeError(
f"Symbol {SYMBOL} is not available on {EXCHANGE_ID}"
)
logging.info("Bot started. Monitoring %s", SYMBOL)
while True:
try:
ticker = exchange.fetch_ticker(SYMBOL)
last_price = ticker.get("last")
logging.info(
"%s last price: %s",
SYMBOL,
last_price
)
except ccxt.NetworkError as error:
logging.warning(
"Network error: %s",
error
)
except ccxt.ExchangeError as error:
logging.error(
"Exchange error: %s",
error
)
except Exception:
logging.exception(
"Unexpected error"
)
time.sleep(POLL_INTERVAL)
if **name** == "**main**":
main()
This script does not place orders. It connects to the selected exchange, loads available markets, periodically requests ticker data, and writes the result to the log.
The parameter:
"enableRateLimit": Trueenables CCXT's built-in request throttling mechanism. Your application should still follow the limits and API rules imposed by the selected exchange.
For a real project, replace the monitoring section with your own strategy, order-management code, risk controls, database integration, or other application logic.
Step 10. Store Configuration and API Keys Separately
Do not hardcode API credentials directly inside bot.py.
Instead, create an environment file:
nano /opt/trading-bot/.envAdd:
EXCHANGE_ID=kraken
SYMBOL=BTC/USD
POLL_INTERVAL=30
EXCHANGE_API_KEY=
EXCHANGE_API_SECRET=
Replace the exchange, trading pair, and credentials with values required by your application.
For example, another exchange might use:
SYMBOL=BTC/USDTSave the file.
Exit back to the root user:
exitChange its ownership:
chown root:tradingbot /opt/trading-bot/.envRestrict permissions:
chmod 640 /opt/trading-bot/.envVerify:
ls -l /opt/trading-bot/.envThe file should not be readable by unrelated system users.
If you use Git, also make sure .env is excluded from the repository:
echo ".env" >> /opt/trading-bot/.gitignoreNever commit production API keys to a Git repository.
Deploy Your Trading Infrastructure on Serverspace
A trading bot does not require your personal computer to remain online when it runs on a cloud VPS. This is especially useful for strategies that monitor markets continuously, process scheduled signals, or communicate with trading APIs throughout the day.
With Serverspace, you can deploy an Ubuntu VPS and independently select the amount of CPU, RAM, and storage required by your application. This makes it possible to start with a lightweight configuration and increase resources later if the bot begins processing more markets, running additional workers, or storing larger datasets.
Serverspace also provides cloud infrastructure in multiple geographic locations, allowing you to choose a server location appropriate for your workload.
For Python applications, the VPS gives you full control over the environment: you can install your own Python packages, databases, monitoring tools, Docker containers, schedulers, and other components required by the trading system.
Deploy an Ubuntu VPS in Serverspace, connect through SSH, and use the steps below to turn your Python script into a continuously running service.
Step 11. Test the Bot Manually
Before configuring automatic startup, verify that the application works normally from the command line.
Run:
sudo -u tradingbot /opt/trading-bot/venv/bin/python /opt/trading-bot/bot.pyIf the configuration is correct, the output should look similar to:
2026-08-09 18:30:00 | INFO | Connecting to exchange: kraken
2026-08-09 18:30:01 | INFO | Bot started. Monitoring BTC/USD
2026-08-09 18:30:01 | INFO | BTC/USD last price: 123456.7The actual price will depend on current market data.
Stop the application with:
Ctrl+CDo not proceed to automatic startup until the bot works correctly when started manually.
Step 12. Configure the Bot as a systemd Service
Starting the script manually is useful during development, but the process will terminate if:
- the SSH session is closed incorrectly;
- the process crashes;
- the VPS reboots;
- the application encounters an unrecoverable error.
A better approach is to let `systemd` supervise the application.
Create a new service:
nano /etc/systemd/system/trading-bot.serviceAdd:
[Unit]
Description=Python Trading Bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=tradingbot
Group=tradingbot
WorkingDirectory=/opt/trading-bot
EnvironmentFile=/opt/trading-bot/.env
ExecStart=/opt/trading-bot/venv/bin/python /opt/trading-bot/bot.py
Restart=on-failure
RestartSec=10
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Let's examine the most important parameters.
User and Group
User=tradingbot
Group=tradingbotThe application runs under the dedicated account instead of root
WorkingDirectory
WorkingDirectory=/opt/trading-botSets the project's working directory.
EnvironmentFile
EnvironmentFile=/opt/trading-bot/.envLoads configuration variables before the process starts.
ExecStart
ExecStart=/opt/trading-bot/venv/bin/python /opt/trading-bot/bot.pyUses Python directly from the project's virtual environment.
Restart
Restart=on-failureTells systemd to restart the application when the process terminates because of a failure.
RestartSec
RestartSec=10Adds a delay before another startup attempt.
This is particularly useful for applications that depend on external APIs because immediately restarting a failed process in a tight loop can create unnecessary requests.
Step 13. Enable Automatic Startup
Tell systemd to reload unit files:
systemctl daemon-reloadEnable the trading bot at system startup:
systemctl enable trading-botStart it:
systemctl start trading-botCheck the service:
systemctl status trading-botA successful service normally shows:
Active: active (running)You can also perform both operations at once:
systemctl enable --now trading-botStep 14. View Trading Bot Logs
Because the process is managed by `systemd`, its standard output and errors can be inspected through journalctl.
Display the latest messages:
journalctl -u trading-botFollow the logs in real time:
journalctl -u trading-bot -fDisplay messages generated since the beginning of the current day:
journalctl -u trading-bot --since todayShow the latest 100 entries:
journalctl -u trading-bot -n 100Show only errors:
journalctl -u trading-bot -p errThis is usually the first place to check if the service has stopped or cannot connect to an external API.
Press:
Ctrl+Cto leave real-time log monitoring.
Step 15. Test Automatic Recovery
It is useful to verify that systemd actually supervises the process.
Find the current Python process:
ps aux | grep bot.pyYou should see something similar to:
tradingbot 12345 ... /opt/trading-bot/venv/bin/python /opt/trading-bot/bot.pyTerminate the process:
kill 12345Replace 12345 with the actual PID.
Wait several seconds and check:
systemctl status trading-botBecause the service contains:
Restart=on-failuresystemd should start a new process after the configured delay.
You can inspect this event using:
journalctl -u trading-bot -n 50Step 16. Test Startup After a VPS Reboot
Another important test is a complete server restart.
Reboot Ubuntu:
rebootYour SSH connection will close.
Wait until the VPS becomes available again and reconnect:
ssh root@SERVER_IPCheck:
systemctl status trading-botIf everything has been configured correctly, the application should already be running.
Step 17. Configure the Firewall
A trading bot that only makes outgoing HTTPS or WebSocket connections normally does not need to expose its own public application port.
If you use UFW, first allow SSH:
ufw allow OpenSSHThen enable the firewall:
ufw enableCheck the configuration:
ufw status verboseIf your SSH daemon uses a custom port instead of the standard configuration, create the appropriate firewall rule before enabling UFW.
For example:
ufw allow 2222/tcpDo not blindly expose application, database, monitoring, or administration ports to the entire Internet.
If your bot includes a dashboard or API, consider binding it to localhost and accessing it through an SSH tunnel or placing it behind an authenticated reverse proxy.
Step 18. Check Server Time Synchronization
Correct system time is important for applications communicating with trading APIs. Authentication mechanisms frequently depend on timestamps, and a significant clock difference can cause API requests to fail.
Check the server clock:
timedatectlLook for synchronization information.
If network time synchronization needs to be enabled:
timedatectl set-ntp trueCheck again:
timedatectl statusApplication logic should generally store timestamps internally in a consistent timezone, often UTC, and convert them to local time only when displaying information to users.
Step 19. Protect Exchange API Keys
API credentials are one of the most sensitive components of a trading server.
Follow several important rules:
- never store API secrets directly in the source code;
- never commit .env files to Git;
- restrict filesystem permissions;
- create separate API credentials for the bot;
- enable only the permissions that the bot actually requires;
- avoid withdrawal permissions unless they are absolutely necessary;
- use IP restrictions if your exchange provides them;
- rotate compromised credentials immediately;
- do not send API keys through public chats, issue trackers, or screenshots.
For a bot that only collects public market data, API credentials may not be necessary at all.
For live trading, the key usually needs trading permissions, but allowing withdrawals significantly increases the consequences of credential theft.
Step 20. Secure SSH Access
SSH keys provide a stronger server access model than reusable passwords.
Generate a key on your local computer if you do not already have one:
ssh-keygen -t ed25519Copy the public key to the VPS:
ssh-copy-id root@SERVER_IPConfirm that key-based login works before changing SSH authentication settings.
You can then edit:
nano /etc/ssh/sshd_configCommon hardening options include:
PermitRootLogin no
PasswordAuthentication noHowever, disable root and password authentication only after creating another administrative user with working SSH key access. Otherwise, you may lock yourself out of the server.
Validate the SSH configuration before restarting the service:
sshd -tIf no errors are returned, restart SSH:
systemctl restart sshKeep your current SSH session open while testing a second connection.
Step 21. Updating the Trading Bot
Applications and dependencies will eventually need updates.
If the project is stored in Git, switch to the application account:
sudo -iu tradingbotGo to the project:
cd /opt/trading-botDownload the latest changes:
git pullActivate the environment:
source venv/bin/activateUpdate dependencies:
pip install -r requirements.txtExit:
exitRestart the application:
systemctl restart trading-botVerify:
systemctl status trading-botThen inspect logs:
journalctl -u trading-bot -n 100For important production systems, test updates in a separate environment before deploying them to the live server.
Step 22. Pin Python Dependency Versions
Installing the newest versions of every package during each deployment can produce unexpected behavior when upstream libraries introduce changes.
After testing your environment, record installed versions:
sudo -u tradingbot /opt/trading-bot/venv/bin/pip freeze > /opt/trading-bot/requirements.txtA resulting file might contain entries such as:
ccxt==X.Y.Z
python-dotenv==X.Y.ZThe actual versions depend on the environment at the time the command is executed.
Pinned dependencies make deployment more reproducible because another server can install the same package versions.
Do not update production dependencies automatically without testing them first.
Step 23. Monitor CPU and Memory Usage
Check current resource consumption:
topor:
htopIf htop is not installed:
apt install htop -yRun:
htopYou can also inspect memory:
free -hDisk usage:
df -hAnd system load:
uptimeA lightweight trading bot may consume very few resources, while applications performing large pandas calculations, technical indicator analysis, machine-learning inference, backtesting, or processing hundreds of markets can require considerably more CPU and RAM.
Step 24. Monitor Disk Space
Trading applications can unexpectedly consume disk space if they continuously store:
- market data;
- candles;
- order books;
- trade history;
- application logs;
- database files;
- backtesting datasets.
Check disk usage:
df -hFind large project directories:
du -sh /opt/trading-bot/*If your application writes its own log files instead of using the system journal, configure log rotation so they do not grow indefinitely.
Step 25. Using a Database with the Trading Bot
A more advanced bot may need persistent storage for:
- historical prices;
- generated signals;
- orders;
- positions;
- strategy state;
- performance statistics;
- error information.
Small applications can use SQLite.
More complex systems may use PostgreSQL or another database server.
A typical architecture might look like:
Avoid exposing a database directly to the public Internet unless there is a specific reason to do so.
If the database and trading bot run on the same VPS, the database can normally listen only on localhost.
Step 26. Running Multiple Trading Bots
You can operate several independent bots on the same VPS.
For example:
/opt/trading-bot-btc/
/opt/trading-bot-eth/
/opt/trading-bot-arbitrage/Each application can have:
- its own virtual environment;
- its own .env file;
- its own systemd service;
- its own exchange credentials;
- its own logs and configuration.
Corresponding services might be:
trading-bot-btc.service
trading-bot-eth.service
arbitrage-bot.serviceCheck them independently:
systemctl status trading-bot-btcand:
systemctl status trading-bot-ethThis is generally easier to maintain than placing unrelated strategies inside one large process.
Step 27. Add Health Monitoring
systemd can restart a crashed application, but it cannot always determine whether the trading logic itself is functioning correctly.
For example, a Python process could remain alive while:
- API requests continuously fail;
- market data stops updating;
- a WebSocket connection becomes stale;
- the database becomes unavailable;
- the strategy loop becomes blocked;
- credentials expire or are revoked.
For production workloads, consider adding application-level health monitoring.
The bot can periodically report:
- last successful API request;
- last received market update;
- current exchange connection state;
- open positions;
- last completed strategy cycle;
- database status;
- memory consumption;
- error count.
Notifications can be delivered to an external monitoring platform, email, Telegram, Slack, or another communication system.
The important principle is that the monitoring mechanism should be independent enough to notify you when the bot itself is unable to do so.
Recommended Production Directory Structure
As the application grows, keeping the project organized becomes increasingly useful.
For example:
/opt/trading-bot/
├── bot.py
├── requirements.txt
├── .env
├── venv/
├── config/
│ └── strategy.yaml
├── strategies/
│ ├── **init**.py
│ └── moving_average.py
├── services/
│ ├── exchange.py
│ └── notifications.py
├── storage/
│ └── database.py
└── tests/
└── test_strategy.py
The exact structure is project-specific, but separating exchange communication, strategy logic, configuration, storage, and notifications makes the application easier to test and maintain.
Common Trading Bot Deployment Problems
| Problem | Possible Cause | What to Check |
|---|---|---|
| ModuleNotFoundError | Dependency installed outside the virtual environment | Check the Python path and reinstall requirements.txt inside venv |
| API authentication error | Incorrect key, missing permission, IP restriction, or incorrect system time | API credentials, exchange settings, .env, and timedatectl |
| Bot works manually but fails in systemd | Incorrect working directory, Python path, permissions, or environment variables | systemctl status and journalctl -u trading-bot |
| Exchange rejects requests | Request frequency or exchange-specific API restrictions | API documentation and application request frequency |
| Service continuously restarts | Application exits during initialization | journalctl -u trading-bot -n 100 |
| Bot stops after SSH disconnect | Application was started directly from the terminal | Run the application as a systemd service |
Useful Commands for Managing the Bot
Check status:
systemctl status trading-botStart:
systemctl start trading-botStop:
systemctl stop trading-botRestart:
systemctl restart trading-botEnable startup after reboot:
systemctl enable trading-botDisable automatic startup:
systemctl disable trading-botFollow logs:
journalctl -u trading-bot -fShow the latest 100 log entries:
journalctl -u trading-bot -n 100Reload a modified systemd configuration:
systemctl daemon-reload
systemctl restart trading-botProduction Checklist
Before connecting the bot to a live trading account, verify the entire deployment.
- The bot runs under a dedicated Linux user.
- The project uses a Python virtual environment.
- Dependencies are documented and preferably pinned.
- API credentials are not stored in source code.
- The .env file has restricted permissions.
- API keys have only the permissions actually required.
- Withdrawal permissions are disabled unless specifically required.
- The strategy has been tested separately from production.
- API and network errors are handled by the application.
- The bot respects exchange request limits.
- The process is managed by systemd.
- Automatic restart has been tested.
- Automatic startup after server reboot has been tested.
- Logs can be inspected with journalctl.
- System time is synchronized.
- SSH access is secured.
- Unnecessary network ports are closed.
- CPU, RAM, and disk consumption are monitored.
- There is an independent way to detect application failures.
A technically running process should not automatically be considered a healthy trading system. Production monitoring should also verify that new market data is arriving, API calls succeed, strategy cycles complete, and application state remains consistent.
Conclusion
Deploying a Python trading bot on an Ubuntu VPS transforms a local script into a continuously running server application.
The basic production workflow consists of creating an Ubuntu server, installing Python, isolating dependencies inside a virtual environment, transferring the project, protecting API credentials, testing the application manually, and moving the process under systemd.
From there, the infrastructure can evolve with the project. You can add PostgreSQL, Redis, Docker, monitoring systems, notifications, backup processes, multiple strategies, or separate services for market data and order execution.
The VPS solves an important operational problem: the trading application no longer depends on your laptop, home Internet connection, or an open terminal session. However, reliable infrastructure does not make a trading strategy profitable and does not eliminate market, API, software, or operational risks.
Run Your Python Trading Bot on Serverspace
Serverspace provides Ubuntu cloud servers suitable for hosting continuously running Python applications, including trading bots, market monitoring tools, API integrations, and data-processing services.
You can choose the required vCPU, RAM, and storage configuration when deploying the VPS and adjust the infrastructure as the project grows. A lightweight bot can start with a small virtual machine, while more demanding systems can use additional computing resources for multiple strategies, databases, analytics, or large datasets.
The cloud environment also gives you full administrative access, so you are free to configure Python, systemd, Docker, PostgreSQL, Redis, monitoring software, or any other components required by your application.
Instead of keeping a trading script running on a personal computer, deploy an Ubuntu VPS on Serverspace and create a dedicated environment that can operate independently around the clock.
Create your Serverspace cloud server, deploy Ubuntu, connect via SSH, and use this guide to bring your Python trading bot online.
Frequently Asked Questions (FAQ)
Why run a Python trading bot on a VPS?
A VPS allows a Python trading bot to run continuously without depending on your personal computer or home Internet connection. The server remains available around the clock and can automatically restart the application after failures or system reboots.
Using a VPS also gives you full control over Python versions, libraries, databases, monitoring tools, and other components required by the trading application.
What VPS configuration is recommended for a Python trading bot?
A lightweight trading bot can usually start with 1 vCPU and 1–2 GB of RAM. Applications that monitor multiple markets, process large datasets, use pandas extensively, or run several strategies may require 2–4 vCPU and 4 GB of RAM or more.
The actual requirements depend on the number of trading pairs, request frequency, data processing workload, databases, and additional services running on the VPS.
How do I keep a Python trading bot running after closing SSH?
The recommended approach is to run the trading bot as a systemd service instead of starting the Python script directly from an SSH session.
systemd can keep the application running in the background, start it automatically after a VPS reboot, and restart the process if it terminates unexpectedly.
How should API keys be stored on an Ubuntu VPS?
Exchange API keys should not be hardcoded directly in the Python source code. Store them in a separate environment file such as .env, restrict access to the file with Linux permissions, and exclude it from Git repositories.
For additional security, create dedicated API credentials for the trading bot, enable only the required permissions, and avoid enabling withdrawal permissions unless they are absolutely necessary.
How can I check the logs of a Python trading bot?
If the application is managed by systemd, you can view its logs using journalctl.
For example:
journalctl -u trading-bot
To follow new log entries in real time, use:
journalctl -u trading-bot -f
Logs can help identify Python exceptions, exchange API errors, authentication problems, network failures, and unexpected service restarts.
Can I run multiple Python trading bots on one VPS?
Yes. Multiple trading bots can run on the same Ubuntu VPS as long as the server has enough CPU, RAM, and storage resources.
For easier management, each bot can use its own project directory, Python virtual environment, configuration file, API credentials, and systemd service. This allows individual strategies to be started, stopped, updated, and monitored independently.