Invest in ETFs

Invest in ETFs · GPT 작업

Stock Analysis API

API for calculating final market value and annualised rate of return for a set of stock tickers based on cashflows and dates.

  • POST /api/financials/calculations/performanceCalculate the final market value and annualised rate of return for given stock tickers. The tickers are in the format used by Yahoo Finance, e.g. "AAPL", "IWDA.L".
원본 API 스키마
{
  "openapi": "3.1.0",
  "info": {
    "title": "Stock Analysis API",
    "description": "API for calculating final market value and annualised rate of return for a set of stock tickers based on cashflows and dates.",
    "version": "1.0.0"
  },
  "paths": {
    "/api/financials/calculations/performance": {
      "post": {
        "operationId": "calculateStockPerformance",
        "summary": "Calculate the final market value and annualised rate of return for given stock tickers. The tickers are in the format used by Yahoo Finance, e.g. \"AAPL\", \"IWDA.L\".",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "symbols": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "description": "Stock tickers in the format used by Yahoo Finance, e.g. \"AAPL\", \"IWDA.L\". Maximum number of tickers is 50."
                        }
                      },
                      "cashflows": {
                        "type": "array",
                        "items": {
                          "type": "number",
                          "description": "Cashflows to buy the stocks, the first cashflow must be positive. The cashflows are in the same order as the dates. All stocks share the same set of cashflows and dates. Maximum number of cashflows is 100."
                        }
                      },
                      "dates": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "format": "date",
                          "description": "Dates of the cashflows. The dates are in the same order as the cashflows. Maximum number of dates is 100."
                        }
                      },
                      "endDate": {
                        "type": "string",
                        "format": "date",
                        "description": "The end date to calculate the final market value and annualised rate of return."
                      }
                    }
                  }
                },
                "required": [
                  "symbols",
                  "cashflows",
                  "dates",
                  "endDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "output": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/StockAnalysisData"
                          }
                        },
                        "chart": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "description": "URL to the chart image.",
                              "format": "uri",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - input is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StockAnalysisData": {
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string",
            "description": "Stock ticker in the format used by Yahoo Finance, e.g. \"AAPL\", \"IWDA.L\"."
          },
          "investment": {
            "type": "number",
            "description": "Total cashflows to buy the stock."
          },
          "marketValue": {
            "type": "number",
            "description": "Final market value of the stock including dividends earned during the investment period."
          },
          "annualisedReturn": {
            "type": "number",
            "description": "Annualised rate of return for the stock using IRR method."
          },
          "maxDrawdown": {
            "type": "number",
            "description": "Largest drop from a peak."
          },
          "totalShares": {
            "type": "number",
            "description": "Total number of shares bought."
          },
          "actualEndDate": {
            "type": "string",
            "format": "date",
            "description": "The actual end date of the investment period."
          },
          "priceAsOfEndDate": {
            "type": "number",
            "description": "Price of the stock as of the end date."
          },
          "fundamentalData": {
            "type": "object",
            "description": "Fundamental data of the ETF, if available, including, but not limited to inception date, expense ratio, top holdings."
          }
        }
      },
      "SearchInput": {
        "description": "Serializable base class.",
        "properties": {
          "query": {
            "type": "string",
            "title": "Query from user to search for relevant documents.",
            "description": "Query from user to search for relevant documents."
          }
        },
        "title": "SearchInput",
        "type": "object"
      },
      "documents_output": {
        "items": {
          "$ref": "#/components/schemas/Document"
        },
        "title": "documents_output",
        "type": "array"
      },
      "Document": {
        "description": "Class for storing a piece of text and associated metadata.",
        "properties": {
          "metadata": {
            "title": "Metadata",
            "type": "object",
            "properties": {
              "title": {
                "title": "Title of the document",
                "type": "string"
              },
              "source": {
                "title": "Link to the source document",
                "type": "string"
              }
            }
          },
          "page_content": {
            "title": "Page Content",
            "type": "string"
          },
          "type": {
            "default": "Document",
            "enum": [
              "Document"
            ],
            "title": "Type",
            "type": "string"
          }
        },
        "required": [
          "page_content"
        ],
        "title": "Document",
        "type": "object"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.aisoph.co",
      "description": "Main API server"
    }
  ]
}