### Python Code Example Source: https://docs.fincept.in/quickstart Example of how to price an option using the Fincept API in Python. ```APIDOC ## Python Code Example ### Description This example demonstrates how to use the Fincept API in Python to price an option using the Black-Scholes model. ### Code ```python import requests API_KEY = "fk_user_your_key_here" BASE_URL = "https://finceptbackend.share.zrok.io" headers = { "X-API-Key": API_KEY, "Content-Type": "application/json" } # Price an option response = requests.post( f"{BASE_URL}/quantlib/pricing/black-scholes", headers=headers, json={ "spot": 100, "strike": 105, "rate": 0.05, "volatility": 0.2, "time_to_maturity": 0.25, "option_type": "call" } ) data = response.json() print(f"Option Price: {data['data']['price']}") print(f"Delta: {data['data']['delta']}") ``` ``` -------------------------------- ### JavaScript Code Example Source: https://docs.fincept.in/quickstart Example of how to price an option using the Fincept API in JavaScript. ```APIDOC ## JavaScript Code Example ### Description This example demonstrates how to use the Fincept API in JavaScript to price an option using the Black-Scholes model. ### Code ```javascript const API_KEY = "fk_user_your_key_here"; const BASE_URL = "https://finceptbackend.share.zrok.io"; async function priceOption() { const response = await fetch(`${BASE_URL}/quantlib/pricing/black-scholes`, { method: "POST", headers: { "X-API-Key": API_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ spot: 100, strike: 105, rate: 0.05, volatility: 0.2, time_to_maturity: 0.25, option_type: "call" }) }); const data = await response.json(); console.log("Option Price:", data.data.price); console.log("Delta:", data.data.delta); } priceOption(); ``` ``` -------------------------------- ### Getting Started with Fincept API Source: https://docs.fincept.in/introduction Guides to help users quickly begin using the Fincept API, including setup, authentication, and understanding pricing. ```APIDOC ## Getting Started 1. **[Quickstart Guide](/quickstart)** - Get up and running in 5 minutes 2. **[Authentication](/authentication)** - Learn about API keys and security 3. **[Pricing](/pricing)** - Understand credit costs and subscription plans 4. **[QuantLib Overview](/quantlib-overview)** - Explore modules and capabilities 5. **[API Reference](/api-reference)** - Browse complete endpoint documentation ``` -------------------------------- ### Price an Option using Python Source: https://docs.fincept.in/quickstart This Python code example demonstrates how to price an option using the Fincept API's Black-Scholes endpoint. It includes setting up the API key, base URL, and headers, then making a POST request and printing the results. Dependencies include the 'requests' library. ```python import requests API_KEY = "fk_user_your_key_here" BASE_URL = "https://finceptbackend.share.zrok.io" headers = { "X-API-Key": API_KEY, "Content-Type": "application/json" } # Price an option response = requests.post( f"{BASE_URL}/quantlib/pricing/black-scholes", headers=headers, json={ "spot": 100, "strike": 105, "rate": 0.05, "volatility": 0.2, "time_to_maturity": 0.25, "option_type": "call" } ) data = response.json() print(f"Option Price: {data['data']['price']}") print(f"Delta: {data['data']['delta']}") ``` -------------------------------- ### API Authentication Header Example Source: https://docs.fincept.in/quickstart This bash command snippet shows the required header for authenticating API requests. It includes the 'X-API-Key' header with a placeholder for the user's actual API key. ```bash -H "X-API-Key: fk_user_your_key_here" ``` -------------------------------- ### Price an Option using JavaScript Source: https://docs.fincept.in/quickstart This JavaScript code example shows how to price an option using the Fincept API's Black-Scholes endpoint. It utilizes the `fetch` API to make a POST request with the necessary authentication and content type headers, then logs the option price and delta. This example is suitable for web applications. ```javascript const API_KEY = "fk_user_your_key_here"; const BASE_URL = "https://finceptbackend.share.zrok.io"; async function priceOption() { const response = await fetch(`${BASE_URL}/quantlib/pricing/black-scholes`, { method: "POST", headers: { "X-API-Key": API_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ spot: 100, strike: 105, rate: 0.05, volatility: 0.2, time_to_maturity: 0.25, option_type: "call" }) }); const data = await response.json(); console.log("Option Price:", data.data.price); console.log("Delta:", data.data.delta); } priceOption(); ``` -------------------------------- ### Error Handling Source: https://docs.fincept.in/quickstart Details on how the API handles errors, including common status codes and example error responses. ```APIDOC ## Error Handling The API returns detailed error messages: ```json { "success": false, "message": "Insufficient credits", "detail": "Required: 2 credits, Available: 0.5 credits. Please purchase a new plan to continue." } ``` Common HTTP status codes: * `200` - Success * `400` - Bad request (invalid parameters) * `401` - Unauthorized (invalid/missing API key) * `402` - Insufficient credits * `403` - Forbidden (tier access required) * `500` - Server error ``` -------------------------------- ### Guest User API Source: https://docs.fincept.in/quickstart Obtain a temporary API key for testing purposes. Guest keys are valid for 24 hours and have limited credits. ```APIDOC ## POST /guest/create ### Description Creates a temporary guest API key for testing. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/guest/create ### Parameters #### Request Body - **device_id** (string) - Required - An identifier for the testing device. ### Request Example ```json { "device_id": "my-test-device" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the guest key was created successfully. - **data** (object) - Contains guest key details. - **api_key** (string) - The temporary API key. - **credit_balance** (integer) - The initial credit balance for the guest user. - **expires_at** (string) - The expiration timestamp of the guest key (ISO 8601 format). #### Response Example ```json { "success": true, "data": { "api_key": "fk_guest_temp123...", "credit_balance": 50, "expires_at": "2024-01-16T10:30:00Z" } } ``` ``` -------------------------------- ### Base URL Source: https://docs.fincept.in/quickstart The base URL for all Fincept API requests. ```APIDOC ## Base URL ``` https://finceptbackend.share.zrok.io ``` ``` -------------------------------- ### Credit Costs Source: https://docs.fincept.in/quickstart Information on credit costs per request for different subscription tiers. ```APIDOC ## Credit Costs All QuantLib endpoints cost credits based on tier: | Tier | Cost per Request | | -------- | ---------------- | | Free | 0 credits | | Basic | 1 credit | | Standard | 2 credits | | Pro | 5 credits | See the [Pricing page](/pricing) for detailed credit information. ``` -------------------------------- ### API Content Type Header Example Source: https://docs.fincept.in/quickstart This bash command snippet demonstrates the 'Content-Type' header required for POST requests. It specifies that the request body will be in JSON format. ```bash -H "Content-Type: application/json" ``` -------------------------------- ### Date Format Example (JSON) Source: https://docs.fincept.in/quickstart Illustrates the standard ISO 8601 format (YYYY-MM-DD) used for all date-related inputs and outputs within the Fincept API, such as settlement and maturity dates. ```json { "settlement_date": "2024-01-15", "maturity_date": "2025-01-15" } ``` -------------------------------- ### User Profile and Credit Balance API Source: https://docs.fincept.in/quickstart Retrieve user profile information, including credit balance and account status. Requires authentication with an API key. ```APIDOC ## GET /user/profile ### Description Fetches the profile information for the authenticated user, including their credit balance. ### Method GET ### Endpoint https://finceptbackend.share.zrok.io/user/profile ### Parameters #### Query Parameters - **X-API-Key** (string) - Required - The API key for authentication. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (object) - User profile details. - **id** (integer) - The user's unique identifier. - **username** (string) - The user's username. - **email** (string) - The user's email address. - **account_type** (string) - The type of account (e.g., 'free'). - **credit_balance** (integer) - The current credit balance. - **is_verified** (boolean) - Indicates if the user account is verified. #### Response Example ```json { "success": true, "data": { "id": 42, "username": "johndoe", "email": "john@example.com", "account_type": "free", "credit_balance": 350, "is_verified": true } } ``` ``` -------------------------------- ### Authentication Header Source: https://docs.fincept.in/quickstart All requests, except for registration and login, require the API key to be included in the request header. ```APIDOC ## Authentication Header All requests (except registration/login) require the API key header: ```bash -H "X-API-Key: fk_user_your_key_here" ``` ``` -------------------------------- ### Create Temporary Guest API Key (Bash) Source: https://docs.fincept.in/quickstart Generates a temporary API key for guest users, valid for 24 hours. This is suitable for testing purposes and requires a device ID. The response includes the temporary API key, credit balance, and expiration time. ```bash curl -X POST https://finceptbackend.share.zrok.io/guest/create \ -H "Content-Type: application/json" \ -d '{ "device_id": "my-test-device" }' ``` -------------------------------- ### Register for a Fincept API Key (Bash) Source: https://docs.fincept.in/quickstart Registers a new user account with Fincept to obtain a permanent API key. Requires username, email, and password. The response includes a success message and prompts for email verification. ```bash curl -X POST https://finceptbackend.share.zrok.io/user/register \ -H "Content-Type: application/json" \ -d '{ "username": "johndoe", "email": "john@example.com", "password": "SecurePassword123!" }' ``` -------------------------------- ### POST /quantlib/pricing/black-scholes Source: https://docs.fincept.in/quickstart Prices an option using the Black-Scholes model. Requires parameters like spot price, strike price, interest rate, volatility, time to maturity, and option type. ```APIDOC ## POST /quantlib/pricing/black-scholes ### Description Prices an option using the Black-Scholes model. ### Method POST ### Endpoint `/quantlib/pricing/black-scholes` ### Parameters #### Request Body - **spot** (number) - Required - The current price of the underlying asset. - **strike** (number) - Required - The strike price of the option. - **rate** (number) - Required - The risk-free interest rate. - **volatility** (number) - Required - The volatility of the underlying asset. - **time_to_maturity** (number) - Required - The time until the option expires, in years. - **option_type** (string) - Required - The type of option ('call' or 'put'). ### Request Example ```json { "spot": 100, "strike": 105, "rate": 0.05, "volatility": 0.2, "time_to_maturity": 0.25, "option_type": "call" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the pricing results. - **price** (number) - The calculated price of the option. - **delta** (number) - The delta of the option. #### Response Example ```json { "success": true, "data": { "price": 5.75, "delta": 0.45 } } ``` ``` -------------------------------- ### Content Type Source: https://docs.fincept.in/quickstart For all POST requests, the 'Content-Type' header must be set to 'application/json'. ```APIDOC ## Content Type All POST requests require JSON content type: ```bash -H "Content-Type: application/json" ``` ``` -------------------------------- ### User Registration API Source: https://docs.fincept.in/quickstart Register for a new user account to access the Fincept API. This process involves providing user details and verifying with an OTP. ```APIDOC ## POST /user/register ### Description Registers a new user account with Fincept. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/user/register ### Parameters #### Request Body - **username** (string) - Required - The desired username. - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```json { "username": "johndoe", "email": "john@example.com", "password": "SecurePassword123!" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the registration was successful. - **message** (string) - A message confirming the registration status. #### Response Example ```json { "success": true, "message": "Registration successful. Please verify your email with the OTP sent." } ``` ``` ```APIDOC ## POST /user/verify-otp ### Description Verifies a user's account using an One-Time Password (OTP) sent to their email. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/user/verify-otp ### Parameters #### Request Body - **email** (string) - Required - The user's email address. - **otp** (string) - Required - The One-Time Password received via email. ### Request Example ```json { "email": "john@example.com", "otp": "123456" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the verification was successful. - **data** (object) - Contains verification details. - **api_key** (string) - The generated API key for the verified user. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "data": { "api_key": "fk_user_abc123xyz789...", "message": "Account verified successfully" } } ``` ``` -------------------------------- ### Bond Pricing API Source: https://docs.fincept.in/quickstart Calculate the price of a bond given its face value, coupon rate, yield, and maturity. Requires authentication. ```APIDOC ## POST /quantlib/pricing/bond-price ### Description Calculates the price of a bond based on its financial characteristics and market yield. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/quantlib/pricing/bond-price ### Parameters #### Request Body - **face_value** (number) - Required - The nominal value of the bond. - **coupon_rate** (number) - Required - The annual coupon rate. - **yield** (number) - Required - The market yield to maturity. - **years_to_maturity** (number) - Required - The number of years until the bond matures. - **frequency** (integer) - Required - The number of coupon payments per year (e.g., 1 for annual, 2 for semi-annual). ### Request Example ```json { "face_value": 1000, "coupon_rate": 0.05, "yield": 0.04, "years_to_maturity": 5, "frequency": 2 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the calculation was successful. - **data** (object) - The calculated bond price. - **price** (number) - The calculated price of the bond. #### Response Example ```json { "success": true, "data": { "price": 1045.50 } } ``` ``` -------------------------------- ### Portfolio Value at Risk (VaR) API Source: https://docs.fincept.in/quickstart Compute the Value at Risk (VaR) for a given portfolio based on historical returns and a confidence level. Requires authentication. ```APIDOC ## POST /quantlib/risk/var ### Description Calculates the Value at Risk (VaR) for a portfolio using specified returns and confidence level. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/quantlib/risk/var ### Parameters #### Request Body - **returns** (array of numbers) - Required - A list of historical portfolio returns. - **confidence_level** (number) - Required - The desired confidence level (e.g., 0.95 for 95%). - **method** (string) - Required - The method for VaR calculation (e.g., 'historical'). ### Request Example ```json { "returns": [-0.02, 0.01, -0.015, 0.03, -0.01, 0.02], "confidence_level": 0.95, "method": "historical" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the VaR calculation was successful. - **data** (object) - The calculated VaR details. - **var** (number) - The calculated Value at Risk. #### Response Example ```json { "success": true, "data": { "var": -0.018 } } ``` ``` -------------------------------- ### Security Best Practices - Ignore API Keys Source: https://docs.fincept.in/authentication Example of how to configure a `.gitignore` file to prevent sensitive information like API keys and configuration files from being committed to version control. This is a crucial step in protecting credentials. ```bash # .gitignore .env config.json secrets.* ``` -------------------------------- ### Calculate Portfolio VaR (Bash) Source: https://docs.fincept.in/quickstart Computes the Value at Risk (VaR) for a given portfolio using historical data and a specified confidence level. Supports different calculation methods like 'historical'. ```bash curl -X POST https://finceptbackend.share.zrok.io/quantlib/risk/var \ -H "X-API-Key: fk_user_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "returns": [-0.02, 0.01, -0.015, 0.03, -0.01, 0.02], "confidence_level": 0.95, "method": "historical" }' ``` -------------------------------- ### Build Yield Curve (Bash) Source: https://docs.fincept.in/quickstart Constructs a yield curve from a set of market dates and corresponding interest rates using a specified interpolation method. This is useful for various financial modeling tasks. ```bash curl -X POST https://finceptbackend.share.zrok.io/quantlib/curves/yield-curve \ -H "X-API-Key: fk_user_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "dates": ["2024-01-15", "2024-07-15", "2025-01-15", "2026-01-15"], "rates": [0.02, 0.025, 0.03, 0.035], "method": "linear" }' ``` -------------------------------- ### API Request Registration Example (Bash) Source: https://docs.fincept.in/credit-system Demonstrates how to register a new user via the Fincept API to receive initial credits. This involves a POST request with user credentials. ```bash # Register curl -X POST https://finceptbackend.share.zrok.io/user/register \ -H "Content-Type: application/json" \ -d '{"username": "john", "email": "john@example.com", "password": "Pass123!"}' # After verification: credit_balance = 350 ``` -------------------------------- ### API Error Response Example Source: https://docs.fincept.in/quickstart This JSON structure illustrates a typical error response from the Fincept API, indicating a failure and providing a descriptive message and detailed explanation. It is useful for understanding how to parse and react to API errors. ```json { "success": false, "message": "Insufficient credits", "detail": "Required: 2 credits, Available: 0.5 credits. Please purchase a new plan to continue." } ``` -------------------------------- ### API Key Usage Examples Source: https://docs.fincept.in/api-keys Examples demonstrating how to include your API key in requests using the `X-API-Key` header, environment variables, and within code snippets for different languages. ```APIDOC ## Using Your API Key ### Authentication Header Include the `X-API-Key` header in every request. ```bash curl https://finceptbackend.share.zrok.io/user/profile \ -H "X-API-Key: fk_user_your_key_here" ``` ### Environment Variables **Linux/macOS:** ```bash export FINCEPT_API_KEY="fk_user_your_key" curl https://finceptbackend.share.zrok.io/user/profile \ -H "X-API-Key: $FINCEPT_API_KEY" ``` **Windows CMD:** ```cmd set FINCEPT_API_KEY=fk_user_your_key curl https://finceptbackend.share.zrok.io/user/profile ^ -H "X-API-Key: %FINCEPT_API_KEY%" ``` **Windows PowerShell:** ```powershell $env:FINCEPT_API_KEY="fk_user_your_key" curl https://finceptbackend.share.zrok.io/user/profile ` -H "X-API-Key: $env:FINCEPT_API_KEY" ``` ### In Code **Python:** ```python import os import requests API_KEY = os.getenv("FINCEPT_API_KEY") headers = {"X-API-Key": API_KEY} response = requests.get( "https://finceptbackend.share.zrok.io/user/profile", headers=headers ) ``` **JavaScript/Node.js:** ```javascript const API_KEY = process.env.FINCEPT_API_KEY; const response = await fetch( "https://finceptbackend.share.zrok.io/user/profile", { headers: { "X-API-Key": API_KEY } } ); ``` ``` -------------------------------- ### Black-Scholes Option Pricing API Source: https://docs.fincept.in/quickstart Calculate the price and Greeks of a European option using the Black-Scholes model. Requires authentication. ```APIDOC ## POST /quantlib/pricing/black-scholes ### Description Prices a European option (call or put) using the Black-Scholes model and calculates its Greeks. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/quantlib/pricing/black-scholes ### Parameters #### Request Body - **spot** (number) - Required - The current price of the underlying asset. - **strike** (number) - Required - The strike price of the option. - **rate** (number) - Required - The risk-free interest rate. - **volatility** (number) - Required - The volatility of the underlying asset. - **time_to_maturity** (number) - Required - The time until the option expires, in years. - **option_type** (string) - Required - The type of option ('call' or 'put'). ### Request Example ```json { "spot": 100, "strike": 105, "rate": 0.05, "volatility": 0.2, "time_to_maturity": 0.25, "option_type": "call" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the calculation was successful. - **data** (object) - The calculated option details. - **price** (number) - The theoretical price of the option. - **delta** (number) - The option's delta. - **gamma** (number) - The option's gamma. - **vega** (number) - The option's vega. - **theta** (number) - The option's theta. - **rho** (number) - The option's rho. #### Response Example ```json { "success": true, "data": { "price": 2.4561, "delta": 0.5432, "gamma": 0.0284, "vega": 0.1561, "theta": -0.0121, "rho": 0.0892 } } ``` ``` -------------------------------- ### Yield Curve Construction API Source: https://docs.fincept.in/quickstart Build a yield curve by providing a set of market rates at specific dates. Requires authentication. ```APIDOC ## POST /quantlib/curves/yield-curve ### Description Constructs a yield curve using provided market rates and dates. ### Method POST ### Endpoint https://finceptbackend.share.zrok.io/quantlib/curves/yield-curve ### Parameters #### Request Body - **dates** (array of strings) - Required - An array of dates in ISO 8601 format (YYYY-MM-DD). - **rates** (array of numbers) - Required - An array of corresponding interest rates. - **method** (string) - Required - The interpolation method to use (e.g., 'linear'). ### Request Example ```json { "dates": ["2024-01-15", "2024-07-15", "2025-01-15", "2026-01-15"], "rates": [0.02, 0.025, 0.03, 0.035], "method": "linear" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the yield curve was constructed successfully. - **data** (object) - The constructed yield curve data. - **yield_curve** (object) - Representation of the yield curve (details may vary). #### Response Example ```json { "success": true, "data": { "yield_curve": { "dates": ["2024-01-15", "2024-07-15", "2025-01-15", "2026-01-15"], "rates": [0.02, 0.025, 0.03, 0.035] } } } ``` ``` -------------------------------- ### Guest Account Creation (Bash) Source: https://docs.fincept.in/credit-system Shows how to create a guest account for temporary testing using the Fincept API. This endpoint requires a device ID and provides a limited number of credits for 24 hours. ```bash curl -X POST https://finceptbackend.share.zrok.io/guest/create \ -H "Content-Type: application/json" \ -d '{"device_id": "test-device"}' ``` -------------------------------- ### Example Free Account User Credit Calculation Source: https://docs.fincept.in/tier-system Illustrates how a free account user with initial signup credits can utilize different tiers based on their credit balance and the cost per request for each tier. ```text Account: Free (350 signup credits) Can access: Free tier: Unlimited (0 credits) Basic tier: 350 requests (1 credit each) Standard tier: 175 requests (2 credits each) Pro tier: 70 requests (5 credits each) ``` -------------------------------- ### View Available Fincept Plans with cURL Source: https://docs.fincept.in/pricing This example shows how to retrieve a list of available Fincept API plans and their details using a cURL command. It requires your API key for authentication. The response includes plan ID, name, credit amount, price, and validity. ```bash curl https://finceptbackend.share.zrok.io/payment/plans \ -H "X-API-Key: fk_user_your_key" ``` -------------------------------- ### Calculate Bond Price (Bash) Source: https://docs.fincept.in/quickstart Calculates the price of a bond based on its face value, coupon rate, yield, years to maturity, and payment frequency. This endpoint is part of the QuantLib pricing functionalities. ```bash curl -X POST https://finceptbackend.share.zrok.io/quantlib/pricing/bond-price \ -H "X-API-Key: fk_user_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "face_value": 1000, "coupon_rate": 0.05, "yield": 0.04, "years_to_maturity": 5, "frequency": 2 }' ``` -------------------------------- ### Guest Account Creation Source: https://docs.fincept.in/credit-system Create a temporary guest account to receive 50 credits for a 24-hour testing period. ```APIDOC ## POST /guest/create ### Description Creates a temporary guest account for testing purposes. This account is granted 50 credits that are valid for 24 hours only and cannot be replenished. ### Method POST ### Endpoint `/guest/create` ### Parameters #### Request Body - **device_id** (string) - Required - A unique identifier for the device requesting guest access. ### Request Example ```json { "device_id": "test-device" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains guest account details. - **guest_token** (string) - A token for accessing guest account features. - **expires_in** (integer) - The remaining validity period in seconds. #### Response Example ```json { "success": true, "data": { "guest_token": "some_guest_token", "expires_in": 86400 } } ``` ``` -------------------------------- ### Error Response - Invalid API Key Source: https://docs.fincept.in/authentication Example of an error response when an invalid or expired API key is provided. This response indicates a 401 Unauthorized status and includes a message detailing the issue, prompting the user to use a valid API key. ```json { "success": false, "message": "Invalid or expired API key", "detail": "Valid API key required" } ```