BTX Exchange

BTX: Configuration & Development

This page covers the configuration constants, local development setup, common admin tasks, and tips for working with BTX.


Configuration Reference

All tunables are in constants.js:

ConstantValueDescription
INITIAL_CASH_BALANCE2500Starting virtual cash
MIN_PRICE0.10Absolute minimum price
DEFAULT_BASE_PRICE1.00Base price without seed
PRICE_SENSITIVITY_PER_SHARE0.02Price move per net share
TRANSACTION_FEE_BPS2002% transaction fee
SEED_TO_PRICE_FACTOR0.1Seed to base price conversion
INVESTMENT_TO_SEED_FACTOR0.0001Investment to seed conversion
DRIFT_MAX_PCT_PER_TICK0.015Max random price change per tick
DRIFT_MEAN_REVERSION0.12How quickly prices revert to equilibrium

Local Development

To run BTX locally:

cd serverless-biztechapp-1/services/btx
npx serverless offline --stage dev

This starts:

  • HTTP API on port 4017
  • WebSocket on port 3005
  • DynamoDB Local on port 8000

Dev mode

When IS_OFFLINE=true, the service skips Cognito authentication and uses local-user@btx as the user ID. It also uses individual DynamoDB operations instead of transactions (for compatibility).


Common Tasks

Adding a New Project

Send a POST to the admin endpoint:

POST /btx/admin/project
{
  "projectId": "team-alpha",
  "eventId": "kickstart",
  "ticker": "ALPHA",
  "name": "Team Alpha",
  "description": "A revolutionary fintech startup",
  "seedAmount": 5
}

Applying a Phase Bump

POST /btx/admin/phase-bump
{
  "projectId": "team-alpha",
  "bumpType": "MVP_SHIPPED"
}

Checking a User's Portfolio

GET /btx/portfolio?eventId=kickstart
Authorization: (Cognito token)

Tips for New Developers

  • Start with constants.js and understand the tunables before diving into the logic
  • The executeTrade function in helpers.js is the heart of the system, so read it carefully.
  • Price history gets recorded for every price change, so charts always have data points even from drift
  • The frontend is a single large page (btx.tsx), so use search (Ctrl+F) to find sections
  • WebSocket broadcasts happen asynchronously after trades and use .catch() to avoid blocking the trade response
Previous
Trade Execution & Frontend