Trading
Access trade ideas, market insights, and portfolio management
Manage trade ideas, track performance, and access market insights.
Trading Features
Comprehensive trading tools including idea management, P&L tracking, performance analytics, and position monitoring.
Overview
The Trading API provides:
- Trade idea management (CRUD)
- Position tracking
- P&L calculations
- Performance analytics
- Trade history
Base Path: /v1/trade-ideas
Endpoints
Get All Trade Ideas
Retrieve all trade ideas with pagination and filtering.
GET /v1/trade-ideasX-API-Key: your-api-key
Authorization: Bearer your-jwt-token| Parameter | Type | Description | Default |
|---|---|---|---|
| page | number | Page number | 1 |
| limit | number | Results per page | 10 |
| status | string | Filter by status (active, closed) | all |
| symbol | string | Filter by symbol | all |
# Development
curl "https://api-gateway.dev.1houseglobalservices.com/v1/trade-ideas?page=1&limit=10&status=active" \
-H "X-API-Key: your-development-api-key" \
-H "Authorization: Bearer your-jwt-token"
# Production
curl "https://api-gateway.prod.1houseglobalservices.com/v1/trade-ideas?page=1&limit=10&status=active" \
-H "X-API-Key: your-production-api-key" \
-H "Authorization: Bearer your-jwt-token"// Development
const DEV_API_URL = 'https://api-gateway.dev.1houseglobalservices.com';
const DEV_API_KEY = 'your-development-api-key';
// Production
const PROD_API_URL = 'https://api-gateway.prod.1houseglobalservices.com';
const PROD_API_KEY = 'your-production-api-key';
// Use appropriate environment
const apiUrl = process.env.NODE_ENV === 'production' ? PROD_API_URL : DEV_API_URL;
const apiKey = process.env.NODE_ENV === 'production' ? PROD_API_KEY : DEV_API_KEY;
const response = await fetch(`${apiUrl}/v1/trade-ideas?page=1&limit=10&status=active`, {
headers: {
'X-API-Key': apiKey,
'Authorization': `Bearer ${token}`
}
});
const data = await response.json();import requests
import os
# Development
DEV_API_URL = 'https://api-gateway.dev.1houseglobalservices.com'
DEV_API_KEY = 'your-development-api-key'
# Production
PROD_API_URL = 'https://api-gateway.prod.1houseglobalservices.com'
PROD_API_KEY = 'your-production-api-key'
# Use appropriate environment
api_url = PROD_API_URL if os.getenv('ENVIRONMENT') == 'production' else DEV_API_URL
api_key = PROD_API_KEY if os.getenv('ENVIRONMENT') == 'production' else DEV_API_KEY
response = requests.get(
f'{api_url}/v1/trade-ideas',
params={'page': 1, 'limit': 10, 'status': 'active'},
headers={
'X-API-Key': api_key,
'Authorization': f'Bearer {token}'
}
)
data = response.json(){
"success": true,
"status": 200,
"message": "Trade ideas retrieved successfully",
"data": [
{
"id": "trade_123",
"userId": "user_456",
"symbol": "EUR/USD",
"direction": "buy",
"entryPrice": 1.0850,
"targetPrice": 1.0950,
"stopLoss": 1.0800,
"status": "active",
"profitLoss": 0,
"profitLossPercentage": 0,
"createdAt": "2025-10-21T10:00:00.000Z",
"closedAt": null
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 45,
"pages": 5
},
"meta": {
"timestamp": "2025-10-21T12:00:00.000Z",
"version": "v1"
}
}Get User's Trade Ideas
Get trade ideas for a specific user.
GET /v1/trade-ideas/user/:userIdResponse: Same format as Get All Trade Ideas
Get Trade Idea by ID
Retrieve a specific trade idea.
GET /v1/trade-ideas/:tradeId{
"success": true,
"status": 200,
"message": "Trade idea retrieved successfully",
"data": {
"id": "trade_123",
"userId": "user_456",
"symbol": "EUR/USD",
"direction": "buy",
"entryPrice": 1.0850,
"targetPrice": 1.0950,
"stopLoss": 1.0800,
"currentPrice": 1.0875,
"status": "active",
"profitLoss": 25.00,
"profitLossPercentage": 2.31,
"riskRewardRatio": 3.0,
"notes": "Strong support at 1.0800, targeting previous high",
"createdAt": "2025-10-21T10:00:00.000Z",
"updatedAt": "2025-10-21T12:00:00.000Z"
},
"meta": {
"timestamp": "2025-10-21T12:00:00.000Z",
"version": "v1"
}
}Create Trade Idea
Create a new trade idea.
POST /v1/trade-ideasX-API-Key: your-api-key
Authorization: Bearer your-jwt-token
Content-Type: application/json{
"symbol": "EUR/USD",
"direction": "buy",
"entryPrice": 1.0850,
"targetPrice": 1.0950,
"stopLoss": 1.0800,
"lotSize": 1.0,
"notes": "Strong support at 1.0800"
}{
"success": true,
"status": 201,
"message": "Trade idea created successfully",
"data": {
"id": "trade_789",
"symbol": "EUR/USD",
"direction": "buy",
"entryPrice": 1.0850,
"targetPrice": 1.0950,
"stopLoss": 1.0800,
"status": "active",
"createdAt": "2025-10-21T12:00:00.000Z"
},
"meta": {
"timestamp": "2025-10-21T12:00:00.000Z",
"version": "v1"
}
}Update Trade Idea
Update an existing trade idea.
PUT /v1/trade-ideas/:tradeId{
"targetPrice": 1.1000,
"notes": "Extending target due to strong momentum"
}Close Trade Idea
Close a trade (marks as completed).
DELETE /v1/trade-ideas/:tradeIdOr update with status:
PUT /v1/trade-ideas/:tradeId{
"status": "closed",
"exitPrice": 1.0920,
"result": "win"
}{
"success": true,
"status": 200,
"message": "Trade closed successfully",
"data": {
"id": "trade_123",
"status": "closed",
"result": "win",
"profitLoss": 70.00,
"profitLossPercentage": 6.45,
"closedAt": "2025-10-21T15:30:00.000Z"
},
"meta": {
"timestamp": "2025-10-21T15:30:00.000Z",
"version": "v1"
}
}Get Trade Updates
Get all updates for a specific trade.
GET /v1/trade-ideas/:tradeId/updates{
"success": true,
"status": 200,
"message": "Trade updates retrieved",
"data": [
{
"timestamp": "2025-10-21T14:00:00.000Z",
"type": "price_update",
"currentPrice": 1.0900,
"profitLoss": 50.00
},
{
"timestamp": "2025-10-21T13:00:00.000Z",
"type": "note_added",
"note": "Price approaching target"
}
],
"meta": {
"timestamp": "2025-10-21T12:00:00.000Z",
"version": "v1"
}
}Analytics
Win/Loss Statistics
GET /v1/trade-ideas/user/:userId?analytics=true{
"success": true,
"status": 200,
"data": {
"trades": [...],
"analytics": {
"totalTrades": 100,
"wins": 65,
"losses": 35,
"winRate": 65.0,
"totalProfitLoss": 1250.00,
"averageWin": 50.00,
"averageLoss": -25.00,
"profitFactor": 2.0
}
}
}Trade Idea Object
Fields
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier |
| userId | string | User who created the trade |
| symbol | string | Trading pair (e.g., EUR/USD) |
| direction | string | buy or sell |
| entryPrice | number | Entry price |
| targetPrice | number | Take profit price |
| stopLoss | number | Stop loss price |
| currentPrice | number | Current market price |
| lotSize | number | Position size |
| status | string | active, closed, pending |
| result | string | win, loss, breakeven (when closed) |
| profitLoss | number | Current P&L in dollars |
| profitLossPercentage | number | Current P&L percentage |
| riskRewardRatio | number | Calculated risk/reward |
| notes | string | Trade notes |
| createdAt | datetime | When trade was created |
| updatedAt | datetime | Last update |
| closedAt | datetime | When trade was closed |
Webhooks (Coming Soon)
Subscribe to trade events:
trade.created- New trade idea createdtrade.target.reached- Target price hittrade.stoploss.hit- Stop loss triggeredtrade.closed- Trade manually closed
Code Examples
JavaScript SDK
import { TradingAPI } from '@1house/sdk';
const trading = new TradingAPI(apiKey, authToken);
// Get all trades
const trades = await trading.getAll({ status: 'active' });
// Create trade
const newTrade = await trading.create({
symbol: 'EUR/USD',
direction: 'buy',
entryPrice: 1.0850,
targetPrice: 1.0950,
stopLoss: 1.0800
});
// Close trade
const closed = await trading.close(tradeId, {
exitPrice: 1.0920,
result: 'win'
});Python SDK
from onehouse import TradingAPI
trading = TradingAPI(api_key, auth_token)
# Get all trades
trades = trading.get_all(status='active')
# Create trade
new_trade = trading.create(
symbol='EUR/USD',
direction='buy',
entry_price=1.0850,
target_price=1.0950,
stop_loss=1.0800
)
# Close trade
closed = trading.close(
trade_id,
exit_price=1.0920,
result='win'
)Best Practices
1. Always Set Stop Loss
{
"stopLoss": 1.0800 // Required field
}2. Calculate Position Size
const riskAmount = accountBalance * (riskPercentage / 100);
const stopLossDistance = Math.abs(entryPrice - stopLoss);
const lotSize = riskAmount / stopLossDistance;3. Track Performance
- Review win rate monthly
- Adjust strategy based on data
- Use analytics endpoint for insights
4. Use Notes
{
"notes": "EUR strengthening due to ECB policy. Support at 1.0800, resistance at 1.0950."
}Related Documentation
- Authentication - Get your tokens
- Analytics API - Deep performance insights
- WebSocket API - Real-time price updates
- AI Assistant - Get trading advice