![]() |
|||||||||||||||||||||||||||||||||||||||||||||
|
Alera API - Printable Version +- Alera Forum (https://aleratrading.com/forum) +-- Forum: Alera Portfolio Manager (https://aleratrading.com/forum/forumdisplay.php?fid=1) +--- Forum: Documentation (https://aleratrading.com/forum/forumdisplay.php?fid=2) +--- Thread: Alera API (/showthread.php?tid=89) |
|||||||||||||||||||||||||||||||||||||||||||||
Alera API - admin - 04-14-2020 Alera API This guide explains how the Alera API works and how you can use it. Available with APM version 2.1.0+ The Alera API allows you to:
This feature is only available for fully automated licenses. HTTP Endpoints All end-points are prefixed with http://localhost:<port>/api where <port> is the API Port set up in the account setting page. Don't forget to actually enable the API. We've also gone ahead and prevented any traffic to the API from a non-local IP. This means you should only be accessing the API from the same computer that the APM runs on. Port 7425 is the default port and will be used throughout this document. Please make sure that you select a different port for each account when enabling the API for multiple accounts and that you are connected to the proper account.
HTTP POST Requests Account These calls allow us to start/stop the account. Endpoint: http://localhost:7425/api/account?cmd=start Parameters: None Endpoint: http://localhost:7425/api/account?cmd=stop Parameters: None Strategies This call allows the http client to send signals directly to APM for immediate processing. It requires the account to be running. Signals Endpoint: http://localhost:7425/api/strategies/<id> Parameters:
Example URL: http://localhost:7425/api/strategies/1002
Header: Content-Type: application/json
Body:{"signals":"
# This is just a comment
BTO SPY
LONG IVV 20 %position
SHORT DELL 100 shares LMT 45
"}
Response:
BTO SPY
LONG IVV 20 %POSITION
SHORT DELL 100 SHARES LMT 45
Run Strategy Endpoint: http://localhost:7425/api/strategies/<id>?cmd=run Parameters: None HTTP GET Requests Account This call returns the account settings that were setup in the APM user interface. Endpoint: http://localhost:7425/api/account Parameters: NONE Endpoint: http://localhost:7425/api/account/stats Parameters:
Strategies This call returns information regarding the strategies setup in the APM user interface. Any call to a specific strategy requires the account to be running. Endpoint: http://localhost:7425/api/strategies Parameters:
If no parameters are specified, the GET request returns settings information for all strategies. GET Examples Settings The outputs for these are not specified here since there are a lot of settings. If you want to use this information, we suggest you look at the output yourself and determine what information you might want to use. Orders URL: http://localhost:7425/api/strategies/1002/orders
Response:
[
{
"Symbol": "QQQ",
"Currency": "USD",
"Country": "US",
"Action": "SELL",
"Type": "TGT",
"Quantity": 100.0,
"TimeInForce": "GTC",
"LimitPrice": null,
"StopPrice": null,
"TargetPrice": 215.5,
"TrailingPercent": null
},
{
"Symbol": "QQQ",
"Currency": "USD",
"Country": "US",
"Action": "SELL",
"Type": "STP",
"Quantity": 100.0,
"TimeInForce": "GTC",
"LimitPrice": null,
"StopPrice": 195.36,
"TargetPrice": null,
"TrailingPercent": null
},
]
Code: URL: http://localhost:7425/api/strategies/1002/orders/text
Response:
ORDERS Action Quantity Type Limit % TIF ID
-------------------------------------------------------------------
1. QQQ SELL 100 TGT 215.50 GTC
2. QQQ SELL 100 STP 195.36 GTC
3. SVXY SELL 917 MKT DAY
4. TLT SELL 1,000 STP 160.47 GTC
5. TLT SELL 1,000 TGT 177.01 GTC
6. TLT SELL 1,018 LOC 100.00 DAY
7. TSLA BUY 80 TGT 551.95 GTC
8. TSLA BUY 80 STP 611.31 GTC
9. TSLA BUY 49 MKT DAY
10. USD BUY 370 MKT DAY
-------------------------------------------------------------------ReEnter Orders The responses to these requests are the same as regular order requests: Portfolio URL: http://localhost:7425/api/strategies/1002/portfolio
Response:
[
{
"Symbol": "QQQ",
"Currency": "USD",
"Country": "US",
"Quantity": 100.0,
"Exposure": "LONG",
"MarketPrice": 201.3999939,
"MarketValue": 20140.0,
"AverageCost": 216.555,
"UnrealizedPNL": -1515.5,
"RealizedPNL": null,
"Hold": null
},
{
"Symbol": "SVXY",
"Currency": "USD",
"Country": "US",
"Quantity": 917.0,
"Exposure": "LONG",
"MarketPrice": 32.54999925,
"MarketValue": 29848.35,
"AverageCost": 53.88827155,
"UnrealizedPNL": -19567.2,
"RealizedPNL": null,
"Hold": null
},
]Trades URL: http://localhost:7425/api/strategies/1002/symbols
Response:
[
{
"Symbol": "GS",
"Currency": "USD",
"Country": "US",
"Side": "BOT",
"Quantity": 181.0,
"AveragePrice": 183.21,
"Value": 33161.01,
"Time": "20200413 10:30:32"
},
{
"Symbol": "GS",
"Currency": "USD",
"Country": "US",
"Side": "BOT",
"Quantity": 46.0,
"AveragePrice": 183.38,
"Value": 8435.48,
"Time": "20200413 10:33:14"
},
]Symbols URL: http://localhost:7425/api/strategies/1002/symbols
Response:
["QQQ","SVXY","TLT","TSLA"]
Strategy Stats URL: http://localhost:7425/api/strategies/1002/stats
Response:
{
"Allocation": 550000,
"LongExposure": 383826.07999999996,
"ShortExposure": -76561.5,
"NumberOfLongPositions": 3,
"NumberOfShortPositions": 1,
"LongPNL": 20382.74,
"ShortPNL": 23753.41,
"NetExposure": 307264.57999999996,
"TotalExposure": 460387.57999999996,
"TotalNumberOfPositions": 4,
"TotalPNL": 44136.15
} |