Skip to content

Commit 16622fb

Browse files
committed
Updates Broadcast Live Command
1 parent 9eb4c05 commit 16622fb

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

01 Cloud Platform/99 API Reference/07 Live Management/05 Live Commands/02 Broadcast Live Command/02 Request.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
</tr>
1010
</thead>
1111
<tr>
12-
<td width="20%">sourceProjectId</td> <td> <code>integer<br/><i><sub>example: 19626262</sub></i></code> <br/> Project for the live instance we want to source the command from.</td>
12+
<td width="20%">organizationId</td> <td> <code>string<br/><i><sub>example: 5cad178b20a1d52567b534553413b691</sub></i></code> <br/> Organization Id of the projects we would like to broadcast the command to.</td>
13+
</tr>
14+
<tr>
15+
<td width="20%">excludeProjectId</td> <td> <code>integer<br/><i><sub>example: 19626262</sub></i></code> <br/> Project for the live instance we want to exclude from the broadcast list. If null, all projects will be included.</td>
1316
</tr>
1417
<tr>
1518
<td width="20%">command</td> <td> <code>object<br/><i><sub>example: {'$type': 'OrderCommand', 'symbol': {'id': 'BTCUSD 2XR', 'value': 'BTCUSD'}, 'order_type': 'market', 'quantity': '0.1', 'limit_price': 0, 'stop_price': 0, 'tag': ''}</sub></i></code> <br/> The command to run.</td>
@@ -19,7 +22,8 @@
1922
<td>
2023
<div class="cli section-example-container"><pre>
2124
{
22-
"sourceProjectId": 19626262,
25+
"organizationId": "5cad178b20a1d52567b534553413b691",
26+
"excludeProjectId": 19626262,
2327
"command": {
2428
"$type": "OrderCommand",
2529
"symbol": {

03 Writing Algorithms/40 Live Trading/41 Commands/07 Broadcast Commands by API.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<p>
22
To broadcast a command to your live algorithms, send a payload through the <a href='/docs/v2/cloud-platform/api-reference/live-management/live-commands'>QuantConnect REST API</a> or <a href='/docs/v2/lean-cli/live-trading/algorithm-control'>LEAN CLI</a>.
33
<span class='csharp'>LEAN converts the first character in each key of the payload to uppercase before injecting the data into your algorithm.</span>
4-
The following script demonstrates how to broadcast a command with the REST API.
5-
The source project ID is any project in your organization. It will not receive the command.
4+
The following script demonstrates how to broadcast a command to all projects in your organization with the REST API.
65
</p>
76

87
<div class="section-example-container">
@@ -14,6 +13,7 @@
1413
# Edit these values:
1514
USER_ID = 0
1615
API_TOKEN = '_____'
16+
ORGANIZATION_ID = '_____'
1717

1818
BASE_URL = 'https://www.quantconnect.com/api/v2/'
1919

@@ -33,17 +33,17 @@
3333
'Timestamp': timestamp
3434
}
3535

36-
def broadcast_command(source_project_id, command):
36+
def broadcast_command(command):
3737
return post(
3838
f'{BASE_URL}/live/commands/broadcast',
3939
headers=get_headers(),
40-
json={"sourceProjectId": source_project_id, "command": command}
40+
json={"organizationId": ORGANIZATION_ID, "command": command}
4141
).json()
4242

43-
# Provide your project Id and command to call the on_command event handler:
44-
print(broadcast_command(&lt;source_project_id&gt;, {'ticker': 'AAPL', 'quantity': 1}))
45-
# Provide your project Id and command with the $type to call encapsulated event handlers:
46-
print(broadcast_command(&lt;source_project_id&gt;, {'$type': 'MyCommand', 'ticker': 'AAPL', 'quantity': 1}))</pre>
43+
# Provide the command to call the on_command event handler:
44+
print(broadcast_command({'ticker': 'AAPL', 'quantity': 1}))
45+
# Provide the command with the $type to call encapsulated event handlers:
46+
print(broadcast_command({'$type': 'MyCommand', 'ticker': 'AAPL', 'quantity': 1}))</pre>
4747
</div>
4848

49-
<p>To get your user Id and API token, see <a href='/docs/v2/cloud-platform/community/profile#09-Request-API-Token'>Request API Token</a>.</p>
49+
<p>To get your user Id, API token, and organization Id, see <a href='/docs/v2/cloud-platform/community/profile#09-Request-API-Token'>Request API Token</a> and <a href='/docs/v2/cloud-platform/organizations/getting-started#05-Get-Organization-Id'>Get Organization Id</a>.</p>

QuantConnect-Platform-2.0.0.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2438,9 +2438,13 @@ components:
24382438
BroadcastLiveCommandRequest:
24392439
type: object
24402440
properties:
2441-
sourceProjectId:
2441+
organizationId:
2442+
type: string
2443+
description: Organization Id of the projects we would like to broadcast the command to
2444+
example: 5cad178b20a1d52567b534553413b691
2445+
excludeProjectId:
24422446
type: integer
2443-
description: Project for the live instance we want to source the command from.
2447+
description: Project for the live instance we want to exclude from the broadcast list. If null, all projects will be included.
24442448
example: 19626262
24452449
command:
24462450
type: object

0 commit comments

Comments
 (0)