PATCH https://api.cryptohopper.com/v1/strategy/{strategy_id}

Updates one of the user's own strategies. Fields you leave out or send empty keep their current value.

OAuth scope: read manage About scopes

Unlike Create strategy, image here is image data encoded as base64; it is uploaded and cropped to 600 by 430 pixels. min_buys or min_sells of 0 keep the current value. Each config item needs id, name, chartperiod, params, type, candle_pattern and keep_signal, and may also have description, necessary, min_buys, min_sells, signal_when, signal_when_value, candle_value and exclusive; any other key makes the config invalid. The values are checked as well: id must be a known indicator, type buy, sell or the indicator's own indicator_type, chartperiod one of 60, 300, 900, 1800, 3600, 7200, 14400 or 86400 (seconds), keep_signal a whole number from 0 to 999 (id, chartperiod and keep_signal as plain integers or digit strings, no spaces or signs), candle_pattern and necessary 0 or 1, and params an object. Keys may only contain letters, digits, _ and -, unless the indicator has the same key at the same place. Text may not contain < > " ' & or \ unless the indicator has the same text at the same place (a copied label or option) or it is a signal_when operator. In params.signal_when, the operators and thresholds of every entry in defaults are checked too, and a buy or sell indicator needs an operator and a threshold it will use: its own signal_when and signal_when_value, each falling back to defaults[type] (in the legacy string form, params.signal_when_value). config must be a JSON list, not an object. A number param must be a number within the indicator's min and max, a select param one of the indicator's options, and a signal_when operator one of <, <=, =, >= or >. The 400 message names the first indicator with a problem, for example "Invalid strategy config: Indicator 2 (MACD): chartperiod must be one of 60, 300, 900, 1800, 3600, 7200, 14400, 86400 (seconds)." config may also be sent as a JSON string.

Example request

curl -X PATCH "https://api.cryptohopper.com/v1/strategy/STRATEGY_ID" \
  -H "access-token: YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"RSI and SAR v2","description":"Tighter RSI thresholds","config":[{"id":"121","name":"RSI with region crossovers (RSI)","type":"buy","params":{"candle_value":{"type":"select","name":"OHLCV Value","options":["open","close","high","low","volume"],"default":"close"},"period":{"type":"number","step":1,"min":1,"max":500,"name":"RSI Period","default":14},"oversold":{"type":"number","step":0.01,"min":0,"max":100,"name":"Oversold threshold","default":30},"overbought":{"type":"number","step":0.01,"min":0,"max":100,"name":"Overbought threshold","default":70},"region_type":{"type":"select","name":"Signal on region","options":["in","out"],"default":"in"}},"chartperiod":"900","candle_pattern":0,"necessary":1,"keep_signal":0}],"min_buys":1}'

Parameters

Headers

NameTypeRequiredDescription
access-token string Required The OAuth access token of the user.

Path parameters

NameTypeRequiredDescription
strategy_id string Required ID of the strategy.

Request body

JSON, model StrategyPOST

FieldTypeRequiredDescription
namestringOptional
descriptionstringOptional
imagestringOptional
configobjectOptional
idnumberOptionalMinimum 0.
namestringOptional
chartperiodstringOptional
paramsstringOptional
typestringOptional
descriptionstringOptional
signal_whenstringOptional
signal_when_valuestringOptional
candle_valuestringOptional
candle_patternstringOptional
keep_signalstringOptional
min_buysnumberOptionalMinimum 0.
min_sellsnumberOptionalMinimum 0.

Response

Example response (illustrative values)

{
    "data": {
        "strategy_id": "369000",
        "message": "Strategy has been saved."
    }
}

Status codes: 200. Errors return JSON with status, error and message. See How the API works for response codes and rate limits.