Risk Calculator API (1.0.0)

Download OpenAPI specification: [Risk_Calculator_API.yaml]

This document describes Autochartist's Risk Calculator API which provides users with an indication of the position size to be taken given a base currency, pair to trade, a stop loss, and a cash value to risk.

API Request Authentication

Our APIs require the following url parameters on every call:

brokerid – your customer ID on our systems (provided to you)
user – a unique ID of the end-user consuming the information. For server-2-Server integrations this would typically be your company name
accounttype – 0 = LIVE, 1 = DEMO
expiry – Unix timestamp of when this token will expire________token – a token generated by MD5(user|[accounttype]|[expiry][secretkey])

in which secretkey is the secret key provided to you, not to be shared with the end-user

Note the ‘|’ (Pipe) character before and after the AccountType parameter

$expiryDate = time() + (3 * 24 * 60 * 60);
$userid = “myuserid”;
$accountType =0;
$secretKey = “secretkey”;
$token = md5(${userid}|${accountType}|${expiryDate}${secretKey });
echo $token;
?>
import hashlib
import time
expiry_date = int(time.time()) + (3 * 24 * 60 * 60)
userid = "myuserid"
account_type = "0"
secret_key = "secretkey"
token = hashlib.md5(f"{userid}|{account_type}|{expiry_date}{secret_key}".encode("utf-8")).hexdigest()
print(token)

Risk Calculator

Trading Volume

Determines position size by specifying the amount that you are prepared to risk, opening and stop loss price, account currency, currency pair and contract type(Standard, Mini or Micro).

Input Body (JSON)

{    

"account_currency" : [account currency, eg. "USD"],

"trade_pair" : [trading pair, eg "EURUSD"],    

"contract_type" : [account type, "Standard"/"Micro"/"mini",    

"account_risk" : [risk amount], eg 1000.00,    

"entry_level" : [entry level, eg 1.18347],   

"stop_loss" : [exit level, eg. 1.18705]
}

Return format

  • Status 200 - application/json - latest pattern results.
  • The JSON object includes the following keys:
    • lot_size - Position size
    • risk_in_pips - Stop loss in pips

Requires authentication

A valid request with an authorized MD5 token will be accepted

query Parameters
account_type
string
Example: account_type={{account_type}}

LIVE / DEMO

broker_id
string
Example: broker_id={{broker_id}}

the broekr_id as provided by Autochartist

token
expire
string
Example: expire={{expire}}

Expiry of this link as a unix timestamp

user
string
Example: user={{user}}

username

Request Body schema: application/json
object

Responses

Request samples

Content type
application/json
{
  • "account_currency": "{{account_currency}}",
  • "trade_pair": "{{trade_pair}}",
  • "contract_type": "{{contract_type}}",
  • "account_risk": "{{account_risk}}",
  • "entry_level": "{{entry_level}}",
  • "stop_loss": "{{stop_loss}}"
}

Response samples

Content type
application/json
{
  • "lot_size": 2.79,
  • "risk_in_pips": 35
}