Skip to content

A modern React Native trading journal app with P&L tracking, analytics, and real-time Firebase sync. Built with Expo, TypeScript, and Firestore.

Notifications You must be signed in to change notification settings

AsinOmal/ReactNative-TradeX

Repository files navigation

1  Hero

TradeX Β· P&L Tracker

A modern, feature-rich mobile application for tracking trading performance

React Native Expo TypeScript Firebase


Overview

TradeX is a comprehensive trading journal and P&L tracking application built with React Native and Expo. It helps traders monitor their performance through detailed analytics, monthly tracking, and individual trade logging with real-time cloud synchronization.

Key Features

  • πŸ“Š Monthly P&L Tracking β€” Track capital, deposits, withdrawals, and net profit/loss
  • πŸ“ˆ Individual Trade Logging β€” Log trades with entry/exit prices, quantities, and tags
  • 🎯 Goal Setting β€” Set yearly profit targets with visual progress tracking
  • πŸ“± Cross-Platform β€” Runs on iOS and Android with native performance
  • πŸ” Firebase Authentication β€” Secure Google Sign-In with real-time data sync
  • πŸŒ™ Dark/Light Mode β€” Adaptive theming based on system preferences
  • πŸ“„ PDF Reports β€” Generate and share professional trading reports
  • πŸ”’ Privacy Mode β€” Hide sensitive financial data with one tap

Tech Stack

Core

Technology Version Purpose
React Native 0.81.5 Cross-platform mobile framework
Expo 54.0 Development platform & tooling
TypeScript 5.9 Type-safe JavaScript
Expo Router 6.0 File-based navigation

Backend & Data

Technology Purpose
Firebase Auth User authentication (Google Sign-In)
Cloud Firestore Real-time NoSQL database
React Context API Global state management

UI/UX

Library Purpose
React Native Reanimated Fluid animations
React Native Gesture Handler Touch gestures & swipe actions
Expo Linear Gradient Gradient backgrounds
Expo Haptics Tactile feedback

Testing & Quality

Tool Purpose
Jest Unit testing framework
ESLint Code linting
TypeScript Static type checking

Architecture

src/
β”œβ”€β”€ components/          # Reusable UI components
β”‚   β”œβ”€β”€ MonthCard.tsx   # Monthly performance card
β”‚   β”œβ”€β”€ SwipeableRow.tsx # Swipeable list item
β”‚   └── ...
β”œβ”€β”€ context/            # React Context providers
β”‚   β”œβ”€β”€ AuthContext.tsx # Authentication state
β”‚   β”œβ”€β”€ TradingContext.tsx # Trading data & operations
β”‚   └── ThemeContext.tsx # Dark/Light mode
β”œβ”€β”€ services/           # Business logic & API
β”‚   β”œβ”€β”€ firestoreService.ts # Firebase operations
β”‚   β”œβ”€β”€ calculationService.ts # P&L calculations
β”‚   β”œβ”€β”€ tradeCalculationService.ts # Trade analytics
β”‚   └── pdfService.ts   # Report generation
β”œβ”€β”€ types/              # TypeScript interfaces
β”œβ”€β”€ utils/              # Helper functions
β”‚   β”œβ”€β”€ formatters.ts   # Currency/date formatting
β”‚   └── scaling.ts      # Responsive scaling
└── config/             # Configuration files
    β”œβ”€β”€ firebaseConfig.ts
    └── fonts.ts

app/                    # Expo Router pages
β”œβ”€β”€ (tabs)/             # Tab navigation screens
β”‚   β”œβ”€β”€ index.tsx       # Home (Dashboard)
β”‚   β”œβ”€β”€ trades.tsx      # Trade list
β”‚   β”œβ”€β”€ calendar.tsx    # Calendar view
β”‚   β”œβ”€β”€ analytics.tsx   # Performance analytics
β”‚   └── history.tsx     # Monthly history
β”œβ”€β”€ add-month.tsx       # Add month form
β”œβ”€β”€ add-trade.tsx       # Add trade form
β”œβ”€β”€ onboarding.tsx      # First-time user flow
└── login.tsx           # Authentication

Data Models

MonthRecord

interface MonthRecord {
  id: string;
  month: string;              // 'YYYY-MM' format
  year: number;
  startingCapital: number;
  endingCapital: number;
  deposits: number;
  withdrawals: number;
  grossChange: number;        // Computed
  netProfitLoss: number;      // Computed
  returnPercentage: number;   // Computed
  pnlSource: 'manual' | 'trades';
  status: 'active' | 'closed';
}

Trade

interface Trade {
  id: string;
  symbol: string;
  tradeType: 'long' | 'short';
  entryDate: string;
  exitDate: string;
  entryPrice: number;
  exitPrice: number;
  quantity: number;
  pnl: number;                // Computed
  returnPercentage: number;   // Computed
  tags: string[];
  monthKey: string;           // Links to month
}

Features Deep Dive

Real-Time Data Synchronization

All data is synchronized in real-time using Firestore's onSnapshot listeners:

  • Instant updates across devices
  • Offline-first with automatic sync when online
  • Optimistic UI updates for responsive UX

Analytics Engine

The calculation services compute:

  • Monthly Stats: Net P&L, ROI%, profit factor, win rate
  • Trade Stats: Win streaks, best/worst trades, per-symbol performance
  • Goal Progress: YTD performance vs. annual targets

PDF Report Generation

Uses expo-print with custom HTML templates:

  • Professional branded layout
  • Monthly summary with key metrics
  • Trade table with performance breakdown
  • Automatic date formatting

Responsive Design

Custom scaling utilities ensure consistent UI across screen sizes:

const scale = (size: number) => PixelRatio.roundToNearestPixel(size * SCALE_FACTOR);
const fontScale = (size: number) => scale(size) * FONT_SCALE;

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Expo CLI
  • iOS Simulator (macOS) or Android Emulator

Installation

# Clone the repository
git clone https://github.com/AsinOmal/ReactNative-PnL-Tracker.git
cd ReactNative-PnL-Tracker

# Install dependencies
npm install

# Start the development server
npx expo start

Firebase Setup

  1. Create a Firebase project at console.firebase.google.com
  2. Enable Authentication (Google Sign-In)
  3. Enable Cloud Firestore
  4. Add your GoogleService-Info.plist (iOS) and google-services.json (Android)
  5. Update src/config/firebaseConfig.ts with your config

Testing

# Run all tests
npm test

# Run with coverage
npm test -- --coverage

Current test coverage includes:

  • Calculation service (20 tests)
  • Trade calculation service (24 tests)

Scripts

Command Description
npm start Start Expo development server
npm run ios Run on iOS Simulator
npm run android Run on Android Emulator
npm test Run test suite
npm run lint Run ESLint

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is private and not licensed for public use.


About

A modern React Native trading journal app with P&L tracking, analytics, and real-time Firebase sync. Built with Expo, TypeScript, and Firestore.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages