Post Backtest
curl --request POST \
--url https://api.polyquantlab.com/v1/backtest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"strategy": {
"direction": "below",
"side": "buy_yes",
"size_usd": 100,
"threshold": 0.3,
"type": "threshold_entry"
},
"event_type": "<string>",
"ticker": "<string>",
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z",
"market_limit": 50
}
'import requests
url = "https://api.polyquantlab.com/v1/backtest"
payload = {
"strategy": {
"direction": "below",
"side": "buy_yes",
"size_usd": 100,
"threshold": 0.3,
"type": "threshold_entry"
},
"event_type": "<string>",
"ticker": "<string>",
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z",
"market_limit": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
strategy: {
direction: 'below',
side: 'buy_yes',
size_usd: 100,
threshold: 0.3,
type: 'threshold_entry'
},
event_type: '<string>',
ticker: '<string>',
since: '2023-11-07T05:31:56Z',
until: '2023-11-07T05:31:56Z',
market_limit: 50
})
};
fetch('https://api.polyquantlab.com/v1/backtest', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.polyquantlab.com/v1/backtest",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'strategy' => [
'direction' => 'below',
'side' => 'buy_yes',
'size_usd' => 100,
'threshold' => 0.3,
'type' => 'threshold_entry'
],
'event_type' => '<string>',
'ticker' => '<string>',
'since' => '2023-11-07T05:31:56Z',
'until' => '2023-11-07T05:31:56Z',
'market_limit' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polyquantlab.com/v1/backtest"
payload := strings.NewReader("{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.polyquantlab.com/v1/backtest")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polyquantlab.com/v1/backtest")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}"
response = http.request(request)
puts response.read_body{
"job_id": "bt_8421ae0c",
"status": "queued",
"submitted_at": "2026-06-06T03:54:11+00:00",
"strategy": {
"type": "threshold_entry",
"threshold": 0.3,
"direction": "below",
"side": "buy_yes"
},
"params": {
"position_size": 7.5,
"fill_mode": "walk_book",
"max_fill_price": 0.985,
"taker_fee_rate": 0.072
},
"universe": {
"ticker": "BTC",
"event_type": "5m",
"market_limit": 50
},
"result": null,
"error": null
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Backtest
Post Backtest
Submit a backtest job.
Two modes:
- Async (default,
wait_for_result=false): returns HTTP 202 +job_idimmediately. Client pollsGET /v1/backtest/{job_id}. Best for UI and long jobs; survives client disconnects. - Sync-style (
wait_for_result=true): the API holds the connection while a worker processes the job, then returns HTTP 200 with the completed result inline. Matches the curl-friendly pattern PolyBackTest data customers expect. Caps at 30 s of wait; longer than that and you get a 504 + the job_id so you can keep polling.
Tier gates (rate limit already checked in authed_key):
market_limitcap from the tier prevents Free users from queueing a 500-market scan.- Per-key concurrent in-flight cap (
tier.concurrent_backtests): users can’t flood the queue with their own work and starve others.
POST
/
v1
/
backtest
Post Backtest
curl --request POST \
--url https://api.polyquantlab.com/v1/backtest \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"strategy": {
"direction": "below",
"side": "buy_yes",
"size_usd": 100,
"threshold": 0.3,
"type": "threshold_entry"
},
"event_type": "<string>",
"ticker": "<string>",
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z",
"market_limit": 50
}
'import requests
url = "https://api.polyquantlab.com/v1/backtest"
payload = {
"strategy": {
"direction": "below",
"side": "buy_yes",
"size_usd": 100,
"threshold": 0.3,
"type": "threshold_entry"
},
"event_type": "<string>",
"ticker": "<string>",
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z",
"market_limit": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
strategy: {
direction: 'below',
side: 'buy_yes',
size_usd: 100,
threshold: 0.3,
type: 'threshold_entry'
},
event_type: '<string>',
ticker: '<string>',
since: '2023-11-07T05:31:56Z',
until: '2023-11-07T05:31:56Z',
market_limit: 50
})
};
fetch('https://api.polyquantlab.com/v1/backtest', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.polyquantlab.com/v1/backtest",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'strategy' => [
'direction' => 'below',
'side' => 'buy_yes',
'size_usd' => 100,
'threshold' => 0.3,
'type' => 'threshold_entry'
],
'event_type' => '<string>',
'ticker' => '<string>',
'since' => '2023-11-07T05:31:56Z',
'until' => '2023-11-07T05:31:56Z',
'market_limit' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polyquantlab.com/v1/backtest"
payload := strings.NewReader("{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.polyquantlab.com/v1/backtest")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.polyquantlab.com/v1/backtest")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"strategy\": {\n \"direction\": \"below\",\n \"side\": \"buy_yes\",\n \"size_usd\": 100,\n \"threshold\": 0.3,\n \"type\": \"threshold_entry\"\n },\n \"event_type\": \"<string>\",\n \"ticker\": \"<string>\",\n \"since\": \"2023-11-07T05:31:56Z\",\n \"until\": \"2023-11-07T05:31:56Z\",\n \"market_limit\": 50\n}"
response = http.request(request)
puts response.read_body{
"job_id": "bt_8421ae0c",
"status": "queued",
"submitted_at": "2026-06-06T03:54:11+00:00",
"strategy": {
"type": "threshold_entry",
"threshold": 0.3,
"direction": "below",
"side": "buy_yes"
},
"params": {
"position_size": 7.5,
"fill_mode": "walk_book",
"max_fill_price": 0.985,
"taker_fee_rate": 0.072
},
"universe": {
"ticker": "BTC",
"event_type": "5m",
"market_limit": 50
},
"result": null,
"error": null
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
If true, hold the HTTP connection until the backtest finishes (up to 30 s) and return the completed result inline — like a synchronous endpoint. If 30 s isn't enough, you'll get a 504 with the job_id so you can poll GET /v1/backtest/{job_id} instead. Use false (default) for UI / long jobs.
Body
application/json
Examples:
{
"direction": "below",
"side": "buy_yes",
"size_usd": 100,
"threshold": 0.3,
"type": "threshold_entry"
}
{
"lookback": 30,
"size_usd": 100,
"type": "mean_reversion",
"z_threshold": 2
}
Required range:
x <= 500Response
Successful Response
Available options:
queued, running, complete, failed Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes