Strategies
POST{{baseUrl}}/v1/strategies
{{baseUrl}}/v1/strategies
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | false | |
buy_percentage | number | true | 0 - 1 |
buy_percentage_type_of | string | true | equity or buying_power (of Alpaca account). |
sell_percentage | number | true | 0 - 1 |
sell_percentage_type_of | string | true | quantity or cost_basis (of position). |
is_active | boolean | false | Defaults to true . StockPros will initialize with active strategies, only. |
Bodyraw (json)
json
{
"name": "Strategy 1",
"buy_percentage": 0.70,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity"
}
Example Request
{{baseUrl}}/v1/strategies
curl
curl --location -g '{{baseUrl}}/v1/strategies' \
--data '{
"name": "Strategy 1",
"buy_percentage": 0.70,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity"
}'
Example Response
json
{
"success": true,
"message": "Strategy successfully created",
"data": {
"id": 1,
"name": "Strategy 1",
"buy_percentage": 0.7,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity",
"is_active": true,
"created_at": "2021-01-12T04:08:11.331Z",
"updated_at": "2021-01-12T04:08:11.331Z",
"is_deleted": false
}
}
No response headers
This request doesn't return any response headers
GET{{baseUrl}}/v1/strategies
{{baseUrl}}/v1/strategies
Example Request
{{baseUrl}}/v1/strategies
curl
curl --location -g '{{baseUrl}}/v1/strategies'
Example Response
json
{
"success": true,
"message": "Strategies successfully found",
"data": [
{
"id": 1,
"name": "Strategy 1",
"buy_percentage": 0.7,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity",
"signals": [
{
"id": 1,
"type": "buy",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.2,
"operand_2": "sma_50_day",
"next_signal_inclusive": false,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 2,
"type": "buy",
"operand_1": "sma_50_day",
"operator": ">=",
"percentage_difference": 0,
"operand_2": "price",
"next_signal_inclusive": true,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 3,
"type": "buy",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.2,
"operand_2": "high_52_week",
"next_signal_inclusive": null,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 4,
"type": "sell",
"operand_1": "avg_entry_price",
"operator": ">=",
"percentage_difference": 0.4,
"operand_2": "price",
"next_signal_inclusive": false,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 5,
"type": "sell",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.01,
"operand_2": "avg_entry_price",
"next_signal_inclusive": null,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
}
],
"is_active": true
}
]
}
No response headers
This request doesn't return any response headers
GET{{baseUrl}}/v1/strategies/:id
{{baseUrl}}/v1/strategies/1
Example Request
{{baseUrl}}/v1/strategies/:id
curl
curl --location -g '{{baseUrl}}/v1/strategies/1'
Example Response
json
{
"success": true,
"message": "Strategy successfully found",
"data": {
"id": 1,
"name": "Strategy 1",
"buy_percentage": 0.7,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity",
"signals": [
{
"id": 1,
"type": "buy",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.2,
"operand_2": "sma_50_day",
"next_signal_inclusive": false,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 2,
"type": "buy",
"operand_1": "sma_50_day",
"operator": ">=",
"percentage_difference": 0,
"operand_2": "price",
"next_signal_inclusive": true,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 3,
"type": "buy",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.2,
"operand_2": "high_52_week",
"next_signal_inclusive": null,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 4,
"type": "sell",
"operand_1": "avg_entry_price",
"operator": ">=",
"percentage_difference": 0.4,
"operand_2": "price",
"next_signal_inclusive": false,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
},
{
"id": 5,
"type": "sell",
"operand_1": "price",
"operator": ">=",
"percentage_difference": 0.01,
"operand_2": "avg_entry_price",
"next_signal_inclusive": null,
"created_at": "2021-01-26T22:43:24.131351-05:00",
"updated_at": "2021-01-26T22:43:24.131351-05:00",
"is_deleted": false
}
],
"is_active": true
}
}
No response headers
This request doesn't return any response headers
PATCH{{baseUrl}}/v1/strategies/:id
{{baseUrl}}/v1/strategies/1
Bodyraw (json)
json
{
"name": "Strategy 1",
"buy_percentage": 70,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 100,
"sell_percentage_type_of": "quantity"
}
Example Request
{{baseUrl}}/v1/strategies/:id
curl
curl --location -g --request PATCH '{{baseUrl}}/v1/strategies/1' \
--data '{
"name": "Strategy 1",
"buy_percentage": 0.70,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity"
}'
Example Response
json
{
"success": true,
"message": "Strategy successfully updated",
"data": {
"id": 1,
"name": "Strategy 1",
"buy_percentage": 0.7,
"buy_percentage_type_of": "buying_power",
"sell_percentage": 1,
"sell_percentage_type_of": "quantity",
"is_active": true,
"created_at": "2021-01-12T04:08:11.331Z",
"updated_at": "2021-01-12T04:08:11.331Z",
"is_deleted": false
}
}
No response headers
This request doesn't return any response headers