579 lines
13 KiB
HTTP
579 lines
13 KiB
HTTP
###
|
|
# Screener Tracker API Testing
|
|
# REST Client file untuk testing tracker endpoints
|
|
#
|
|
# Setup:
|
|
# 1. Install REST Client extension di VS Code
|
|
# 2. Update @baseUrl dengan URL server Anda
|
|
###
|
|
|
|
@baseUrl = https://devcpone.aplikasi.web.id/one-api
|
|
@contentType = application/json
|
|
|
|
###
|
|
# 0. Get All Templates
|
|
# GET /screener/tracker/get_templates
|
|
# Response: List of all active screener templates with configuration
|
|
|
|
GET {{baseUrl}}/screener/tracker/index
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 1. Get All Templates
|
|
# GET /screener/tracker/get_templates
|
|
# Response: List of all active screener templates with configuration
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_templates
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 2. Get Single Template by ID
|
|
# GET /screener/tracker/get_template
|
|
# Params: template_id or template_slug
|
|
|
|
POST {{baseUrl}}/screener/tracker/get_template
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"template_slug": "foreign_flow_momentum"
|
|
}
|
|
###
|
|
# 3. Get Single Template by Slug
|
|
# GET /screener/tracker/get_template
|
|
# Params: template_id or template_slug
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_template?template_slug=momentum-strategy
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 4. Run Screener
|
|
# POST /screener/tracker/run_screener
|
|
# Body: template_id, ihsg_price, market_sentiment, notes
|
|
# Description: Execute screener via Stockbit API and save results
|
|
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 3,
|
|
"ihsg_price": 8366.51,
|
|
"market_sentiment": "BEARISH",
|
|
"notes": "Testing screener run pada market bearish"
|
|
}
|
|
|
|
###
|
|
# 5. Run Screener - Minimal Parameters
|
|
# POST /screener/tracker/run_screener
|
|
# Only template_id is required
|
|
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 2
|
|
}
|
|
|
|
###
|
|
# 6. Score Results
|
|
# POST /screener/tracker/score_results
|
|
# Body: run_id, auto_track_high_scores, min_score_to_track
|
|
# Description: Score stocks based on strategy criteria
|
|
|
|
POST {{baseUrl}}/screener/tracker/score_results
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"run_id": 2,
|
|
"auto_track_high_scores": true,
|
|
"min_score_to_track": 10
|
|
}
|
|
|
|
###
|
|
# 7. Score Results - Auto Track Disabled
|
|
# POST /screener/tracker/score_results
|
|
|
|
POST {{baseUrl}}/screener/tracker/score_results
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"run_id": 2,
|
|
"auto_track_high_scores": false
|
|
}
|
|
|
|
###
|
|
# 8. Update Prices
|
|
# POST /screener/tracker/update_prices
|
|
# Body: date (optional), check_targets
|
|
# Description: Update current prices for all tracked stocks
|
|
|
|
POST {{baseUrl}}/screener/tracker/update_prices
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"date": "2025-11-11",
|
|
"check_targets": true
|
|
}
|
|
|
|
###
|
|
# 9. Update Prices - Default Date (Today)
|
|
# POST /screener/tracker/update_prices
|
|
|
|
POST {{baseUrl}}/screener/tracker/update_prices
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"check_targets": true
|
|
}
|
|
|
|
###
|
|
# 10. Get Active Positions - All
|
|
# GET /screener/tracker/get_active_positions
|
|
# Query params: template_id, min_score, sort_by, order
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_active_positions
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 11. Get Active Positions - Filtered by Template
|
|
# GET /screener/tracker/get_active_positions
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_active_positions?template_id=1&sort_by=return_percentage&order=desc
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 12. Get Active Positions - High Scores Only
|
|
# GET /screener/tracker/get_active_positions
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_active_positions?min_score=12&sort_by=score&order=desc
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 13. Get Active Positions - Sort by Days Held
|
|
# GET /screener/tracker/get_active_positions
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_active_positions?sort_by=days_held&order=desc
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 14. Get Statistics - All Templates
|
|
# GET /screener/tracker/get_statistics
|
|
# Query params: template_id, period, refresh
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=all&period=ALL_TIME
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 15. Get Statistics - Specific Template
|
|
# GET /screener/tracker/get_statistics
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=1&period=LAST_3M
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 16. Get Statistics - With Refresh
|
|
# GET /screener/tracker/get_statistics
|
|
# Set refresh=true to recalculate statistics
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=1&period=ALL_TIME&refresh=true
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 17. Get Statistics - Last 6 Months
|
|
# GET /screener/tracker/get_statistics
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=1&period=LAST_6M
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 18. Get Statistics - Last 1 Year
|
|
# GET /screener/tracker/get_statistics
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=1&period=LAST_1Y
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 19. Track Result Manually
|
|
# POST /screener/tracker/track_result
|
|
# Body: result_id
|
|
# Description: Manually start tracking a specific scored result
|
|
|
|
POST {{baseUrl}}/screener/tracker/track_result
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 1
|
|
}
|
|
|
|
###
|
|
# 20. Track Result - Error Case (Already Tracked)
|
|
# POST /screener/tracker/track_result
|
|
# This will fail if result is already being tracked
|
|
|
|
POST {{baseUrl}}/screener/tracker/track_result
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 2
|
|
}
|
|
|
|
###
|
|
# 21. Close Position - Manual Exit
|
|
# POST /screener/tracker/close_position
|
|
# Body: result_id, exit_price, exit_reason, notes
|
|
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 1,
|
|
"exit_price": 2500,
|
|
"exit_reason": "TARGET_2",
|
|
"notes": "Manual exit after target 2 hit"
|
|
}
|
|
|
|
###
|
|
# 22. Close Position - Auto Exit Price
|
|
# POST /screener/tracker/close_position
|
|
# If exit_price not provided, will fetch current market price
|
|
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 2,
|
|
"exit_reason": "STOP_LOSS",
|
|
"notes": "Stop loss triggered"
|
|
}
|
|
|
|
###
|
|
# 23. Close Position - Manual Exit
|
|
# POST /screener/tracker/close_position
|
|
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 3,
|
|
"exit_reason": "MANUAL",
|
|
"notes": "Manual exit due to market condition"
|
|
}
|
|
|
|
###
|
|
# 24. Get Symbol Performance - Basic
|
|
# GET /screener/tracker/get_symbol_performance
|
|
# Query params: symbol (required), include_price_history
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_symbol_performance?symbol=BBCA
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 25. Get Symbol Performance - With Price History
|
|
# GET /screener/tracker/get_symbol_performance
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_symbol_performance?symbol=BBCA&include_price_history=true
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 26. Get Symbol Performance - Another Symbol
|
|
# GET /screener/tracker/get_symbol_performance
|
|
|
|
GET {{baseUrl}}/screener/tracker/get_symbol_performance?symbol=TLKM&include_price_history=true
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# ============================================
|
|
# WORKFLOW EXAMPLES
|
|
# ============================================
|
|
|
|
###
|
|
# WORKFLOW 1: Complete Screener Run Flow
|
|
# Step 1: Run screener
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"ihsg_price": 7200.00,
|
|
"market_sentiment": "BULLISH",
|
|
"notes": "Daily screener run"
|
|
}
|
|
|
|
# Step 2: Score results (use run_id from step 1)
|
|
# POST {{baseUrl}}/screener/tracker/score_results
|
|
# {
|
|
# "run_id": <RUN_ID_FROM_STEP_1>,
|
|
# "auto_track_high_scores": true,
|
|
# "min_score_to_track": 10
|
|
# }
|
|
|
|
# Step 3: View active positions
|
|
# GET {{baseUrl}}/screener/tracker/get_active_positions
|
|
|
|
###
|
|
# WORKFLOW 2: Manual Tracking (Score without Auto-Track)
|
|
# Step 1: Score results without auto-tracking
|
|
# POST {{baseUrl}}/screener/tracker/score_results
|
|
# {
|
|
# "run_id": <RUN_ID>,
|
|
# "auto_track_high_scores": false
|
|
# }
|
|
|
|
# Step 2: Manually select and track specific result
|
|
POST {{baseUrl}}/screener/tracker/track_result
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 1
|
|
}
|
|
|
|
# Step 3: View tracked position
|
|
# GET {{baseUrl}}/screener/tracker/get_active_positions
|
|
|
|
###
|
|
# WORKFLOW 3: Daily Price Update
|
|
# Step 1: Update all prices
|
|
POST {{baseUrl}}/screener/tracker/update_prices
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"check_targets": true
|
|
}
|
|
|
|
# Step 2: Check active positions for alerts
|
|
# GET {{baseUrl}}/screener/tracker/get_active_positions?sort_by=return_percentage&order=desc
|
|
|
|
###
|
|
# WORKFLOW 4: Performance Analysis
|
|
# Step 1: Get statistics
|
|
GET {{baseUrl}}/screener/tracker/get_statistics?template_id=1&period=LAST_3M&refresh=true
|
|
Content-Type: {{contentType}}
|
|
|
|
# Step 2: Check specific symbol performance
|
|
# GET {{baseUrl}}/screener/tracker/get_symbol_performance?symbol=BBCA&include_price_history=true
|
|
|
|
###
|
|
# ============================================
|
|
# ERROR TESTING
|
|
# ============================================
|
|
|
|
###
|
|
# Error Test 1: Missing Template ID
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"ihsg_price": 7200.00
|
|
}
|
|
|
|
###
|
|
# Error Test 2: Invalid Template ID
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 999999
|
|
}
|
|
|
|
###
|
|
# Error Test 3: Missing Run ID
|
|
POST {{baseUrl}}/screener/tracker/score_results
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"auto_track_high_scores": true
|
|
}
|
|
|
|
###
|
|
# Error Test 4: Missing Symbol
|
|
GET {{baseUrl}}/screener/tracker/get_symbol_performance
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# Error Test 5: Missing Result ID for Close Position
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"exit_reason": "MANUAL"
|
|
}
|
|
|
|
###
|
|
# Error Test 6: Track Unscored Result
|
|
POST {{baseUrl}}/screener/tracker/track_result
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 999
|
|
}
|
|
|
|
###
|
|
# Error Test 7: Missing Result ID for Track
|
|
POST {{baseUrl}}/screener/tracker/track_result
|
|
Content-Type: {{contentType}}
|
|
|
|
{}
|
|
|
|
###
|
|
# ============================================
|
|
# BATCH TESTING - Run Multiple Requests
|
|
# ============================================
|
|
|
|
###
|
|
# Batch Test 1: Complete Flow for New Screener Run
|
|
# Run these in sequence:
|
|
|
|
# 1. Get templates first
|
|
GET {{baseUrl}}/screener/tracker/get_templates
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# 2. Run screener with template_id=1
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"ihsg_price": 7150.00,
|
|
"market_sentiment": "NEUTRAL"
|
|
}
|
|
|
|
###
|
|
# 3. Score the results (replace run_id with actual value from step 2)
|
|
POST {{baseUrl}}/screener/tracker/score_results
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"run_id": 1,
|
|
"auto_track_high_scores": true,
|
|
"min_score_to_track": 10
|
|
}
|
|
|
|
###
|
|
# 4. Update prices for tracked positions
|
|
POST {{baseUrl}}/screener/tracker/update_prices
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"check_targets": true
|
|
}
|
|
|
|
###
|
|
# 5. View results
|
|
GET {{baseUrl}}/screener/tracker/get_active_positions?sort_by=return_percentage&order=desc
|
|
Content-Type: {{contentType}}
|
|
|
|
###
|
|
# ============================================
|
|
# MARKET SENTIMENT VARIATIONS
|
|
# ============================================
|
|
|
|
###
|
|
# Run Screener - BEARISH Market
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"ihsg_price": 6950.00,
|
|
"market_sentiment": "BEARISH",
|
|
"notes": "Market correction phase"
|
|
}
|
|
|
|
###
|
|
# Run Screener - NEUTRAL Market
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"ihsg_price": 7100.00,
|
|
"market_sentiment": "NEUTRAL",
|
|
"notes": "Sideways market"
|
|
}
|
|
|
|
###
|
|
# Run Screener - VERY_BULLISH Market
|
|
POST {{baseUrl}}/screener/tracker/run_screener
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"template_id": 1,
|
|
"ihsg_price": 7350.00,
|
|
"market_sentiment": "VERY_BULLISH",
|
|
"notes": "Strong uptrend"
|
|
}
|
|
|
|
###
|
|
# ============================================
|
|
# EXIT REASON VARIATIONS
|
|
# ============================================
|
|
|
|
###
|
|
# Close Position - Target 1 Hit
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 1,
|
|
"exit_reason": "TARGET_1",
|
|
"notes": "First target achieved +15%"
|
|
}
|
|
|
|
###
|
|
# Close Position - Target 2 Hit
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 2,
|
|
"exit_reason": "TARGET_2",
|
|
"notes": "Second target achieved +30%"
|
|
}
|
|
|
|
###
|
|
# Close Position - Target 3 Hit
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 3,
|
|
"exit_reason": "TARGET_3",
|
|
"notes": "Third target achieved +50%"
|
|
}
|
|
|
|
###
|
|
# Close Position - Stop Loss
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 4,
|
|
"exit_reason": "STOP_LOSS",
|
|
"notes": "Cut loss at -8%"
|
|
}
|
|
|
|
###
|
|
# Close Position - Time Stop
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 5,
|
|
"exit_reason": "TIME_STOP",
|
|
"notes": "Held for 8 weeks with minimal return"
|
|
}
|
|
|
|
###
|
|
# Close Position - Market Condition
|
|
POST {{baseUrl}}/screener/tracker/close_position
|
|
Content-Type: {{contentType}}
|
|
|
|
{
|
|
"result_id": 6,
|
|
"exit_reason": "MARKET_CONDITION",
|
|
"notes": "Exiting due to bearish market sentiment"
|
|
}
|
|
|
|
###
|