A Bitcoin historical data viewer and virtual trading simulator built with Streamlit. View historical BTC-USD price data and practice trading strategies with a virtual $10,000 portfolio.
- Interactive Charts: Candlestick charts with 5-hour sliding windows
- Multiple Timeframes: 5m, 10m, 15m, 30m, and 1h intervals
- Timezone Support: Auto-detection with manual override options
- Random Date Picker: Explore random historical periods from the past 45 days
- $10,000 Starting Portfolio: Begin with virtual cash to practice trading
- Turn-Based Trading: Execute buy, sell, hold, or limit order actions each turn
- Limit Orders: Place conditional orders that execute automatically when price targets are reached
- Real Price Data: Trade using actual historical Bitcoin prices
- Realistic Trading Fees: 0.5% taker fee (market orders) + 0.25% maker fee (limit orders) + $15-50 gas fees
- Order Management: View, cancel, and track active limit orders with automatic execution
- Smart Memory: Remembers your preferred trade amounts
- Complete History: Track all trades with detailed transaction records and comprehensive fee breakdowns
- Dual Modes: Switch between chart viewing and trading simulation
- Auto-Refresh: Charts update automatically when changing parameters
- Compact Design: Optimized layout for efficient screen usage
- Persistent State: Your trading session and preferences are maintained
- Clone this repository:
git clone <repository-url>
cd tradr
- Install dependencies:
pip install -r requirements.txt
- Run the application:
streamlit run bitcoin_trader_streamlit.py
- Select your preferred date, time, interval, and timezone
- The chart automatically updates with historical Bitcoin data
- Use the "🎲 Random" button to explore random historical periods
- View 5 hours of price data ending at your selected time
- Click "Enable Trading" to enter simulation mode
- View your portfolio: Cash, BTC holdings, and total value
- Select an action: Buy, Sell, Hold, Limit Buy, or Limit Sell
- Enter your trade amount (see real-time fee estimates)
- For limit orders: Set your target price and click "📋 Place Limit Order"
- For market orders: Review total costs (buy) or net proceeds (sell) including fees
- Click "
▶️ Next" to execute market trades and advance time - Monitor active limit orders and cancel if needed
- Track your trading history and portfolio performance with comprehensive fee details
- Buy Orders: Purchase BTC immediately using your cash balance (plus trading and gas fees)
- Sell Orders: Convert BTC back to cash immediately (minus trading and gas fees)
- Hold Actions: Skip trading but advance to the next time interval
- Limit Buy Orders: Set a target price below current market - executes automatically when price drops to/below target
- Limit Sell Orders: Set a target price above current market - executes automatically when price rises to/above target
- Order Management: View all active orders, cancel orders, automatic execution notifications
- Price Validation: Interface warns when limit prices don't make sense (buy limit above market, sell limit below market)
- Market Orders: 0.5% trading fee (taker fee) + $15-50 gas fee
- Limit Orders: 0.25% trading fee (maker fee) + $15-50 gas fee
- Gas Fees: $15-50 dynamically calculated based on trade size and simulated network conditions
- Trade Validation: Prevents trades exceeding available balances (including fees)
- Price Execution: First turn uses close prices, subsequent turns use open prices
- Automatic Execution: Limit orders execute automatically when price conditions are met
- Fee Transparency: Real-time fee estimates and detailed fee breakdowns in trade history
- Comprehensive Logging: All trades, holds, failures, order placements, executions, and fee details are recorded
- Data Source: Yahoo Finance API via
yfinance
- Charts: Interactive Plotly candlestick charts
- UI Framework: Streamlit with session state management
- Time Handling: Automatic timezone detection and conversion
- Data Range: Past 45 days of historical Bitcoin data
- streamlit
- yfinance
- plotly
- pandas
- numpy
- pytz
- datetime
- random
- logging
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
This is a virtual trading simulator for educational purposes only. It uses historical data and does not involve real money or actual cryptocurrency trading. Past performance does not guarantee future results. This tool should not be used as the sole basis for investment decisions.