POST
https://api.cryptohopper.com/v1/hopper/{id}/position/settakeprofit
Sets the take profit percentage on the given open positions, and optionally their layered take profit levels.
OAuth scope:
read manage About scopes
Send percentage_profit, take_profit_levels or both. take_profit_levels is a list of up to 10 levels: profit is the profit percentage at which the level sells, share the percentage of the original position sold; shares may add up to at most 100. It also accepts a JSON string or the shorthand "2:50,4:50". Send [] for no levels, or "inherit" to go back to the hopper's levels. Levels are not saved for positions that have an open sell order. Layered take profit is not supported for margin/futures bots. Not available for exchange arbitrage, market maker, copy and grid bots.
Example request
curl -X POST "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/settakeprofit" \
-H "access-token: YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"position_ids":[123456,123457],"percentage_profit":3.5,"take_profit_levels":[{"profit":2,"share":50},{"profit":4,"share":50}]}'
const response = await fetch('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/settakeprofit', {
method: 'POST',
headers: {
"access-token": "YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"position_ids": [
123456,
123457
],
"percentage_profit": 3.5,
"take_profit_levels": [
{
"profit": 2,
"share": 50
},
{
"profit": 4,
"share": 50
}
]
})
});
const data = await response.json();
import requests
response = requests.post(
"https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/settakeprofit",
headers={
"access-token": "YOUR_ACCESS_TOKEN"
},
json={
"position_ids": [
123456,
123457
],
"percentage_profit": 3.5,
"take_profit_levels": [
{
"profit": 2,
"share": 50
},
{
"profit": 4,
"share": 50
}
]
},
)
data = response.json()
$ch = curl_init('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/settakeprofit');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'access-token: YOUR_ACCESS_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'position_ids' => [
123456,
123457,
],
'percentage_profit' => 3.5,
'take_profit_levels' => [
[
'profit' => 2,
'share' => 50,
],
[
'profit' => 4,
'share' => 50,
],
],
]),
]);
$data = json_decode(curl_exec($ch), true);
Parameters
Headers
| Name | Type | Required | Description |
|---|---|---|---|
access-token |
string | Required | The OAuth access token of the user. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string | Required | Hopper ID. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
position_ids | array of integer | Required | |
percentage_profit | number | Required | Minimum 0. |
Response
{
"data": "Position percentage profit has been set."
}