Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"featureShortDescription": {
"01" : "",
"02" : "",
"03" : ""
"03" : "",
"04" : "",
"05" : "",
"06" : ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Code generated by API-Reference-Code-Generator.py -->

<p>
Read out the logs of a backtest.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Code generated by API-Reference-Code-Generator.py -->

<p>
Per our <a href='/terms'>Terms and Conditions</a>, you may not use this endpoint to export market data or any other dataset information. For more information about the logs you can produce, see <a href='/docs/v2/cloud-platform/organizations/resources#09-Log-Quotas'>Log Quotas</a>.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- Code generated by API-Reference-Code-Generator.py -->
<p>
Fetch the logs of a backtest for the project Id, backtest Id and lines provided. The <code>/backtests/read/log</code> API accepts requests in the following format:
</p>
<table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>ReadBacktestLogsRequest</code> Model - Request to read logs from a backtest.</th>
</tr>
</thead>
<tr>
<td width="20%">projectId</td> <td> <code>integer<br/><i><sub>required</sub></i><br/><i><sub>example: 23456789</sub></i></code> <br/> Id of the project from which to read the backtest.</td>
</tr>
<tr>
<td width="20%">backtestId</td> <td> <code>string<br/><i><sub>required</sub></i><br/><i><sub>example: 26c7bb06b8487cff1c7b3c44652b30f1</sub></i></code> <br/> Id of the backtest from which to read the logs.</td>
</tr>
<tr>
<td width="20%">start</td> <td> <code>integer<br/><i><sub>required</sub></i><br/><i><sub>example: 0</sub></i></code> <br/> Start line (inclusive) of logs to read. The lines numbers start at 0.</td>
</tr>
<tr>
<td width="20%">end</td> <td> <code>integer<br/><i><sub>required</sub></i><br/><i><sub>example: 200</sub></i></code> <br/> End line (exclusive) of logs to read, where end - start <= 200.</td>
</tr>
<tr>
<td width="20%">query</td> <td> <code>string<br/><i><sub>required</sub></i><br/><i><sub>example: error</sub></i></code> <br/> Case-insensitive keyword to filter the log lines. The start and end lines index the lines that contain the keyword. To read all the lines, set it to null or an empty string.</td>
</tr>
<tr>
<td width="20%">Example</td>
<td>
<div class="cli section-example-container"><pre>
{
"projectId": 23456789,
"backtestId": "26c7bb06b8487cff1c7b3c44652b30f1",
"start": 0,
"end": 200,
"query": "error"
}</pre>
</div>
</td>
</tr>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!-- Code generated by API-Reference-Code-Generator.py -->

<p>
The <code>/backtests/read/log</code> API provides a response in the following format:
</p>
<h4>200 Success</h4>
<table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>ReadBacktestLogsResponse</code> Model - Logs from a backtest.</th>
</tr>
</thead>
<tr>
<td width="20%">logs</td> <td> <code>string Array</code> <br/> List of logs from the backtest.</td>
</tr>
<tr>
<td width="20%">length</td> <td> <code>integer</code> <br/> Total number of log lines in the backtest that match the query.</td>
</tr>
<tr>
<td width="20%">success</td> <td> <code>boolean</code> <br/> Indicate if the API request was successful.</td>
</tr>
<tr>
<td width="20%">errors</td> <td> <code>string Array</code> <br/> List of errors with the API call.</td>
</tr>
<tr>
<td width="20%">Example</td>
<td>
<div class="cli section-example-container"><pre>
{
"logs": [
"string"
],
"length": 0,
"success": true,
"errors": [
"string"
]
}</pre>
</div>
</td>
</tr>
</table><h4>401 Authentication Error</h4>
<table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>UnauthorizedError</code> Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash.</th>
</tr>
</thead>
<tr>
<td width="20%">www_authenticate</td> <td> <code>string</code> <br/> Header</td>
</tr>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<? include(DOCS_RESOURCES."/qc-api/examples/backtest-management.php");?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "metadata",
"values": {
"description": "Read out the logs of a backtest.",
"keywords": "api, backtest management, backtest logs",
"og:description": "Read out the logs of a backtest.",
"og:title": "Logs - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Logs - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/cloud-platform/api-reference/backtest-management/read-backtest/logs.png"
}
}
82 changes: 82 additions & 0 deletions QuantConnect-Platform-2.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,33 @@ paths:
"401":
$ref: '#/components/responses/UnauthorizedErrorResponse'
operationId: readBacktestInsights
/backtests/read/log:
post:
tags:
- 01 Cloud Platform
- 99 API Reference
- 05 Backtest Management
- 02 Read Backtest
- 06 Logs
summary: Read out the logs of a backtest.
description: "Per our <a href='/terms'>Terms and Conditions</a>, you may not use this endpoint to export market data or any other dataset information. For more information about the logs you can produce, see <a href='/docs/v2/cloud-platform/organizations/resources#09-Log-Quotas'>Log Quotas</a>."
requestBody:
description: Fetch the logs of a backtest for the project Id, backtest Id and lines provided.
content:
application/json:
schema:
$ref: '#/components/schemas/ReadBacktestLogsRequest'
required: true
responses:
"200":
description: Logs of the backtest within range.
content:
application/json:
schema:
$ref: '#/components/schemas/ReadBacktestLogsResponse'
"401":
$ref: '#/components/responses/UnauthorizedErrorResponse'
operationId: readBacktestLogs
/backtests/update:
post:
tags:
Expand Down Expand Up @@ -7081,6 +7108,61 @@ components:
- 26c7bb06b8487cff1c7b3c44652b30f1
description: Id of the backtest from which to read the insights.
description: Request to read insights from a backtest.
ReadBacktestLogsRequest:
required:
- projectId
- backtestId
- start
- end
- query
type: object
properties:
projectId:
type: integer
examples:
- 23456789
description: Id of the project from which to read the backtest.
backtestId:
type: string
examples:
- 26c7bb06b8487cff1c7b3c44652b30f1
description: Id of the backtest from which to read the logs.
start:
type: integer
examples:
- 0
description: Start line (inclusive) of logs to read. The lines numbers start at 0.
end:
type: integer
examples:
- 200
description: End line (exclusive) of logs to read, where end - start <= 200.
query:
type: string
examples:
- error
description: Case-insensitive keyword to filter the log lines. The start and end lines index the lines that contain the keyword. To read all the lines, set it to null or an empty string.
description: Request to read logs from a backtest.
ReadBacktestLogsResponse:
type: object
properties:
logs:
type: array
description: List of logs from the backtest.
items:
type: string
length:
type: integer
description: Total number of log lines in the backtest that match the query.
success:
type: boolean
description: Indicate if the API request was successful.
errors:
type: array
description: List of errors with the API call.
items:
type: string
description: Logs from a backtest.
ReadLiveChartRequest:
type: object
required:
Expand Down
18 changes: 18 additions & 0 deletions Resources/qc-api/examples/backtest-management.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
print("Backtest Statistics:")
print(result)

### Read Backtest Logs
# Prepare data payload to read the first 200 log lines
payload = {
"projectId": project_id, # ID of the project
"backtestId": backtest_id, # ID of the backtest to read
"start": 0, # Start line (inclusive)
"end": 200, # End line (exclusive), at most 200 lines per request
"query": None # Keyword to filter the lines, or None to read all of them
}
# Send a POST request to the /backtests/read/log endpoint to get the logs
response = post(f'{BASE_URL}/backtests/read/log', headers=get_headers(), json=payload)
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the logs
if result['success']:
print("Backtest Logs:")
print(result)

### Update Backtest
# Send a POST request to the /backtests/update endpoint to update backtest details
response = post(f'{BASE_URL}/backtests/update', headers=get_headers(), json={
Expand Down