openapi: 3.0.0
info:
  title: Risk Calculator API
  description: "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.\n\n# API Request\
    \ Authentication\n\nOur APIs require the following url parameters on every call:\n\n_**broker**_**id** – your customer\
    \ ID on our systems (provided to you)  \n_**user**_ – a unique ID of the end-user consuming the information. For server-2-Server\
    \ integrations this would typically be your company name  \n_**accounttype**_ – 0 = LIVE, 1 = DEMO  \n**expiry** _– Unix\
    \ timestamp of when this token will expire__________**token**_ – a token generated by MD5(user|\\[accounttype\\]|\\[expiry\\\
    ]\\[secretkey\\])\n\nin which _secretkey_ is the secret key provided to you, not to be shared with the end-user\n\nNote\
    \ the ‘|’ (Pipe) character before and after the AccountType parameter\n\n``` php\n$expiryDate = time() + (3 * 24 * 60\
    \ * 60);\n$userid = “myuserid”;\n$accountType = “0”;\n$secretKey = “secretkey”;\n$token = md5(“${userid}|${accountType}|${expiryDate}${secretKey\
    \ }”);\necho $token;\n?>\n\n ```\n\n``` python\nimport hashlib\nimport time\nexpiry_date = int(time.time()) + (3 * 24\
    \ * 60 * 60)\nuserid = \"myuserid\"\naccount_type = \"0\"\nsecret_key = \"secretkey\"\ntoken = hashlib.md5(f\"{userid}|{account_type}|{expiry_date}{secret_key}\"\
    .encode(\"utf-8\")).hexdigest()\nprint(token)\n\n ```"
  version: 1.0.0
servers:
- url: https://api.autochartist.com
paths:
  /rc/resources/risk/lots:
    post:
      tags:
      - Risk Calculator
      summary: Trading Volume
      description: "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).\n\n#### Input Body (JSON)\n\n\
        {    \n\n\"account_currency\" : \\[account currency, eg. \"USD\"\\],\n\n\"trade_pair\" : \\[trading pair, eg \"EURUSD\"\
        \\],    \n\n\"contract_type\" : \\[account type, \"Standard\"/\"Micro\"/\"mini\",    \n\n\"account_risk\" : \\[risk\
        \ amount\\], eg 1000.00,    \n\n\"entry_level\" : \\[entry level, eg 1.18347\\],   \n\n\"stop_loss\" : \\[exit level,\
        \ eg. 1.18705\\]  \n}\n\n#### Return format\n\n*   **Status 200** - application/json - latest pattern results.\n*\
        \   The JSON object includes the following keys:\n    *   lot_size - Position size\n    *   risk_in_pips - Stop loss\
        \ in pips\n\n#### Requires authentication\n\nA valid request with an authorized MD5 token will be accepted"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              example:
                account_currency: '{{account_currency}}'
                trade_pair: '{{trade_pair}}'
                contract_type: '{{contract_type}}'
                account_risk: '{{account_risk}}'
                entry_level: '{{entry_level}}'
                stop_loss: '{{stop_loss}}'
      parameters:
      - name: account_type
        in: query
        schema:
          type: string
        description: LIVE / DEMO
        example: '{{account_type}}'
      - name: broker_id
        in: query
        schema:
          type: string
        description: the broekr_id as provided by Autochartist
        example: '{{broker_id}}'
      - name: token
        in: query
        schema:
          type: string
        description: Security token. See https://support.autochartist.com/en/knowledgebase/article/security-token-generation
        example: '{{token}}'
      - name: expire
        in: query
        schema:
          type: string
        description: Expiry of this link as a unix timestamp
        example: '{{expire}}'
      - name: user
        in: query
        schema:
          type: string
        description: username
        example: '{{user}}'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              example:
                lot_size: 2.79
                risk_in_pips: 35
tags:
- name: Risk Calculator
