diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/00.json b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/00.json index 958cefefce..3dd85dd814 100644 --- a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/00.json +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/00.json @@ -8,6 +8,9 @@ "featureShortDescription": { "01" : "", "02" : "", - "03" : "" + "03" : "", + "04" : "", + "05" : "", + "06" : "" } } diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/01 Introduction.html b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/01 Introduction.html new file mode 100644 index 0000000000..a61df907dc --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/01 Introduction.html @@ -0,0 +1,5 @@ + + +

+Read out the logs of a backtest. +

diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/02 Description.html b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/02 Description.html new file mode 100644 index 0000000000..e797709107 --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/02 Description.html @@ -0,0 +1,5 @@ + + +

+Per our Terms and Conditions, 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 Log Quotas. +

diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/03 Request.html b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/03 Request.html new file mode 100644 index 0000000000..8dc6bfa95f --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/03 Request.html @@ -0,0 +1,40 @@ + +

+Fetch the logs of a backtest for the project Id, backtest Id and lines provided. The /backtests/read/log API accepts requests in the following format: +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
ReadBacktestLogsRequest Model - Request to read logs from a backtest.
projectId integer
required
example: 23456789

Id of the project from which to read the backtest.
backtestId string
required
example: 26c7bb06b8487cff1c7b3c44652b30f1

Id of the backtest from which to read the logs.
start integer
required
example: 0

Start line (inclusive) of logs to read. The lines numbers start at 0.
end integer
required
example: 200

End line (exclusive) of logs to read, where end - start <= 200.
query string
required
example: error

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.
Example +
+{
+  "projectId": 23456789,
+  "backtestId": "26c7bb06b8487cff1c7b3c44652b30f1",
+  "start": 0,
+  "end": 200,
+  "query": "error"
+}
+
+
\ No newline at end of file diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/04 Responses.html b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/04 Responses.html new file mode 100644 index 0000000000..9c5d810c3e --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/04 Responses.html @@ -0,0 +1,52 @@ + + +

+The /backtests/read/log API provides a response in the following format: +

+

200 Success

+ + + + + + + + + + + + + + + + + + + + + + +
ReadBacktestLogsResponse Model - Logs from a backtest.
logs string Array
List of logs from the backtest.
length integer
Total number of log lines in the backtest that match the query.
success boolean
Indicate if the API request was successful.
errors string Array
List of errors with the API call.
Example +
+{
+  "logs": [
+    "string"
+  ],
+  "length": 0,
+  "success": true,
+  "errors": [
+    "string"
+  ]
+}
+
+

401 Authentication Error

+ + + + + + + + + +
UnauthorizedError Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash.
www_authenticate string
Header
diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/99 Examples.php b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/99 Examples.php new file mode 100644 index 0000000000..c766cb2967 --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/99 Examples.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/metadata.json b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/metadata.json new file mode 100644 index 0000000000..6b31ebea7c --- /dev/null +++ b/01 Cloud Platform/99 API Reference/05 Backtest Management/02 Read Backtest/06 Logs/metadata.json @@ -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" + } +} diff --git a/QuantConnect-Platform-2.0.0.yaml b/QuantConnect-Platform-2.0.0.yaml index cb8b1e3f71..fe172e76d5 100644 --- a/QuantConnect-Platform-2.0.0.yaml +++ b/QuantConnect-Platform-2.0.0.yaml @@ -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 Terms and Conditions, 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 Log Quotas." + 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: @@ -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: diff --git a/Resources/qc-api/examples/backtest-management.php b/Resources/qc-api/examples/backtest-management.php index 1c57681d56..7a29fa0f1e 100644 --- a/Resources/qc-api/examples/backtest-management.php +++ b/Resources/qc-api/examples/backtest-management.php @@ -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={