📄 The Paper Trading API is a Node.js-based application designed for simulating cryptocurrency trades using real-time market data from Binance. This API currently works exclusively for BTCUSDT, allowing users to create accounts, execute trades, monitor active trades, and retrieve trade histories, making it a useful tool for testing trading strategies without the risk of actual financial loss.
- Real-Time Market Data: Leverages WebSocket connections to receive live trade data.
- Account Management: Create, update, and delete paper trading accounts.
- Trade Execution: Simulate long and short trades with leverage, including stop-loss and take-profit orders.
- Trade Monitoring: Automatically exits trades based on market conditions.
- Trade History: Retrieve detailed histories of all executed trades.
- Balance Management: Update account balances to reflect profits, losses, and deposits.
- Node.js
- npm (Node Package Manager)
- Access to Binance WebSocket API
.env
file with a definedPORT
variable
-
Clone the repository:
git clone https://github.com/SanelRyan/paper-trading-api.git cd paper-trading-api
-
Install the required dependencies:
npm install
-
Create a
.env
file in the root directory and set your preferred port:PORT=3000
-
Create an
accounts
directory inside the project root to store account data:mkdir accounts
Start the server:
node API/app.js
The server will start running at http://localhost:3000
.
- GET /createAccount: Create a new paper trading account.
- POST /takeTrade: Execute a new trade for an account.
- POST /exitTrade: Exit an active trade for an account.
- GET /getTradeHistory: Retrieve the trade history of an account.
- GET /getAccountInfo: Get details about a specific account.
- PUT /updateBalance: Update the balance of an account.
- DELETE /deleteAccount: Delete an account.
- PUT /updateAccountInfo: Update the name of an account.
- GET /getAllAccountList: Retrieve a list of all accounts.
- GET /getFinancialInfo: Get financial information about an account.
- GET /getCurrentTrade: Retrieve information about the current active trade of an account.
- GET /getCumulativeBalance: Get the cumulative balance history of an account.
The application includes a watchdog process that monitors the Bitcoin Pricing live and executes TP/SL accordingly. It is initiated alongside the API server:
node API/watchdog.js
Sanel Ryan
Email: sanelryantclitus@gmail.com