MyPet Analytics icon

MyPet Analytics

Advanced analytics for MyPet Stocks trading data

Overview

This node, "MyPet Analytics," performs advanced analytics on trading data typically related to stock or financial trades. It processes input trade records and generates various types of analyses such as basic statistics, profit analysis, risk metrics, and overall performance summaries. The node is useful for traders, analysts, or automated systems that want to gain insights into trading performance, profitability, risk exposure, and efficiency.

Common scenarios include:

  • Evaluating the success rate and profitability of a trading strategy.
  • Understanding risk factors like volatility and drawdowns.
  • Generating detailed reports with charts for presentations or email sharing.
  • Comparing calculated metrics against API-provided summary data.

Practical examples:

  • A trader inputs raw trade logs and receives a summarized report showing total trades, net profit, win rate, and risk assessment.
  • An analyst uses the profit analysis mode to identify winning vs losing trades distribution and average gains/losses.
  • A risk manager evaluates maximum drawdown and Sharpe ratio to assess portfolio risk.
  • Automated workflows generate HTML reports with embedded charts for stakeholder review.

Properties

Name Meaning
Analysis Type Type of analysis to perform. Options: Basic Statistics, Profit Analysis, Risk Metrics, Performance Summary.
Include Charts Boolean flag to include chart data (e.g., pie/bar charts) in the output.
Generate HTML Report Boolean flag to generate a complete styled HTML report with embedded charts, suitable for email.

Output

The node outputs a JSON object containing:

  • analysisType: The selected type of analysis performed.

  • includeCharts: Whether chart data was included.

  • generateHtmlReport: Whether an HTML report was generated.

  • timestamp: ISO string timestamp of execution.

  • dataPoints: Number of trade records analyzed.

  • version: Node version string.

  • inputDataStructure: List of keys present in the input data.

  • note: Additional notes about execution.

  • analysis: The main analysis result object, structure varies by analysis type:

    • Basic Statistics: Summary counts, total/closed/open trades, volume, profit, commission, symbol distribution, and insights.
    • Profit Analysis: Profit summary including total profit, win rate, profit factor, average win/loss, largest wins/losses, and profit distribution.
    • Risk Metrics: Risk-related metrics such as volatility, max drawdown, VaR, Sharpe ratio, risk level, skewness, kurtosis, and insights.
    • Performance Summary: Combined performance score, grade, key metrics, breakdown by profitability, consistency, risk management, efficiency, and recommendations.
  • charts (optional): Array of chart objects (pie or bar charts) with titles, base64-encoded SVG images, and legends representing distributions or metrics relevant to the analysis.

  • htmlReport (optional): A full HTML document string containing a styled report with summary statistics, charts, insights, and order information if available.

If errors occur during processing, error details are included in the output when continuing on failure.

Dependencies

  • No external services or APIs are directly called by this node; it operates purely on provided input data.
  • Requires input data structured as arrays or objects containing trade/order information.
  • No special environment variables or credentials needed.
  • Uses standard JavaScript Date and Buffer APIs for date parsing and SVG image encoding.

Troubleshooting

  • No input data received: The node throws an error if no input items are connected or if input data is empty. Ensure upstream nodes provide valid trade data.
  • Invalid or missing trade fields: If trade records lack expected fields (like profit, openTime), some analyses may return errors or incomplete results.
  • No closed trades found: Profit and risk analyses require closed trades with profit values; otherwise, they return errors indicating insufficient data.
  • Chart generation errors: If input data distributions are empty or zero totals, chart creation will skip those charts and log warnings.
  • HTML report rendering issues: Large or malformed input data might cause slow rendering or incomplete reports.
  • To resolve, verify input data format matches expected trade/order structures and contains necessary fields.

Links and References


This summary is based solely on static code analysis of the provided source code and property definitions.

Discussion