Details
π Overview
This proof of concept is a paper trading simulator designed specifically for meme coins on the Solana blockchain. Built fully using python, it has basic features and functionality, allowing users to practice trading strategies without risking real assets, making it an ideal tool for both newcomers and experienced traders looking to test new approaches.
ποΈ Architecture
Frontend: Streamlit
Database: DuckDB (Local)
API: CoinGecko, BitQuery
Backend: Python
Database Structure
The POC v1 uses DuckDB as its local database system, implementing two primary tables to manage trading data efficiently.
Transactions Table
CREATE TABLE IF NOT EXISTS transactions (
date DATE,
time TIME,
symbol TEXT,
token TEXT,
contract_address TEXT,
action TEXT,
market_cap REAL,
token_price REAL,
token_amt REAL,
total REAL
);
date
- Date of the tradetime
- Time of the tradesymbol
- Token symbol/ticker (e.g., PPAWS)token
- Token namecontract_address
- Token's contract addressaction
- Type of trade (buy/sell)market_cap
- Market cap at time of tradetoken_price
- Token price at time of tradetoken_amt
- Amount of tokens tradedtotal
- Total SOL value of trade
Positions Table
CREATE TABLE IF NOT EXISTS positions (
date DATE,
time TIME,
symbol TEXT,
token TEXT,
contract_address TEXT,
market_cap REAL,
average_market_cap REAL,
initial_investment REAL,
remaining REAL,
sold REAL,
unrealized_profit REAL,
realized_profit REAL,
roi REAL,
total_token_amt REAL,
remaining_token_amt REAL
);
date
- Position opening datetime
- Position opening timesymbol
- Token symbol/ticker (e.g., PPAWS)token
- Token namecontract_address
- Token's contract addressmarket_cap
- Current market capaverage_market_cap
- Average market cap for positioninitial_investment
- Total SOL investedremaining
- Current position valuesold
- Amount sold in SOLunrealized_profit
- Current unrealized P/Lrealized_profit
- Total realized P/Lroi
- Return on Investment (%)total_token_amt
- Total tokens purchasedremaining_token_amt
- Remaining tokens held
API Implementation
CoinGecko API Overview
Used for fetching SOL/USD price
Free tier API access
No authentication required
Public endpoint usage
BitQuery API Overview
Used for fetching real-time token data
Provides market cap and price information
Requires API key for authentication
Rate limited based on subscription tier
ποΈ Data Management
POC v2 manages data through two local files: settings.yaml
and trades.ddb
. When the application is first launched, it automatically creates a settings.yaml
file with default values for balance, trading fees, and API key storage. The trades.ddb
database file, however, must be manually created through the settings page in the user interface. This database is essential for storing trade history and tracking positions, and the application will display a warning message until it's created.
settings.yaml
This YAML file serves as the central configuration hub, maintaining user preferences between sessions and ensuring trading parameters remain consistent. The file is easily accessible and can be modified through the settings interface in the application.
api_key:
balance: 3
priority_buy_fee: 0.01
priority_sell_fee: 0.01
api_key
- BitQuery API keybalance
- Available balance (default: 3 SOL)priority_buy_fee
- Priority buy fee (default: 0.01)priority_sell_fee
- Priority sell fee (default: 0.01)
trades.ddb
The trades database is the core storage system for all trading activity within POC v1. This DuckDB database maintains comprehensive records of all transactions and positions. It tracks every buy and sell order and stores detailed token information. The database enables real-time portfolio monitoring and provides the foundation for all trading functionality within the application. Through this database, users can access their complete trading history and monitor their current positions and performance metrics. The database contains 2 tables:
transactions
table - Records every buy and sell trade executed by the user, storing essential details like date, time, token information, trade type, and transaction values.positions
table - Tracks all portfolio positions and their performance metrics, including investment amounts, current values, profits/losses, and token quantities.
Benefits of local storage for data privacy
Implementing a fully local data storage system ensures that all trading data, user settings, and API credentials remain solely on the user's machine, with no transmission to external servers or cloud storage.
This local data management approach ensures that sensitive information, such as trading strategies and portfolio values, stays private and secure. Users maintain complete ownership of their data, with the ability to manage, backup, or delete their information as needed. The application's design eliminates concerns about data breaches or unauthorized access to trading information, as there are no external connections beyond the necessary API calls for real-time market data.
The only external communication occurs through the BitQuery API for token data and CoinGecko API for SOL prices, but these interactions are limited to retrieving market information and do not involve sending any user data outward. This architecture provides users with the confidence that their trading activities and performance metrics remain completely private while still enabling full functionality for paper trading.
ποΈ Project File Structure
paper-paws-poc/
βββ src/ # Source code directory
β βββ app.py # Main application entry point
β βββ trade.py # Trade interface implementation
β βββ portfolio.py # Portfolio management interface
β βββ trade_history.py # Trade history interface
β βββ settings.py # Settings management interface
β β
β βββ helpers/ # Helper modules directory
β βββ __init__.py
β βββ api_helper.py # BitQuery API integration
β βββ database_helper.py # Database operations
β βββ helpers.py # General utility functions
β βββ settings_helper.py # Settings management utilities
β βββ trades_helper.py # Trade processing logic
β
βββ requirements.txt # Python dependencies
βββ settings.yaml # Application configuration
βββ trades.ddb # DuckDB database file
βββ build.py # Executable build script
βββ Dockerfile # Docker configuration
βββ README.md # Project documentation
π¦ Dependencies
Python (3.13+)
Streamlit (1.41.1)
Pandas (2.2.3)
DuckDB (1.1.3)
PyYAML (6.0.2)
Streamlit Extras (0.5.0)
PyInstaller (6.11.0)
Last updated