James MacQuillan commited on
Commit
2e3e384
·
1 Parent(s): 6f5ae72
Files changed (2) hide show
  1. app.py +1 -1
  2. healthcheck.txt +114 -0
app.py CHANGED
@@ -116,7 +116,7 @@ def process_query(user_input, history):
116
  # Create the response request with HuggingFace using search results
117
  response = client.chat_completion(
118
  model="Qwen/Qwen2.5-72B-Instruct",
119
- messages=[{"role": "user", "content": f"YOU ARE AN INVESTMENT CHATBOT . Answer the user's request '{user_input}' using the following information: {search_results} and the chat history {history}. Provide a concise, direct answer in no more than 2-3 sentences, with appropriate emojis. If the user asks for a smart sheet, generate up to 3000 tokens analyzing all trends and patterns as though you are a stock analyst, look for every pattern and form conclusions. IF YOU ARE ASKED TO BUILD MODELS OR LIST STOCKS, USE THE SEARCH DATA TO HELP YOU BUILD THEM AND MAKE SURE YOU ACTUALLY GIVE THE VALUES AND WHAT THE ARTICLE SAYS RATHER THAN JUST SAYING THAT IT IS AVAILABLE FROM THE WEBSITE. unless the user asks for a smart sheet. keep responses short, quick and logical, using the data provided"}],
120
  max_tokens=3000,
121
  stream=True
122
  )
 
116
  # Create the response request with HuggingFace using search results
117
  response = client.chat_completion(
118
  model="Qwen/Qwen2.5-72B-Instruct",
119
+ messages=[{"role": "user", "content": f"YOU ARE AN INVESTMENT CHATBOT . Answer the user's request '{user_input}' using the following information: {search_results} and the chat history {history}. Provide a concise, direct answer in no more than 2-3 sentences, with appropriate emojis. If the user asks for a smart sheet, generate up to 3000 tokens analyzing all trends and patterns as though you are a stock analyst, look for every pattern and form conclusions. IF YOU ARE ASKED TO BUILD MODELS OR LIST STOCKS, USE THE SEARCH DATA TO HELP YOU BUILD THEM AND MAKE SURE YOU ACTUALLY GIVE THE VALUES AND WHAT THE ARTICLE SAYS RATHER THAN JUST SAYING THAT IT IS AVAILABLE FROM THE WEBSITE. unless the user asks for a smart sheet. keep responses short, quick and logical, using the data provided. AT THE END OF EACH RESPONSE ESPECIALLY SAY HOW THIS IS NOT FINANCIAL ADVICE AND QUANTINEURON.COM IS NOT RESPONSIBLE FOR ANYTHING THAT GOES WRONG BECAUSE OF WHAT YOU SAY, AND THAT BY USING YOU, YOU AGREE TO OUR DISCLAIMER STATEMENT, TERMS OF SERVICE, TERMS AND CONSITIONS AND DATA COLLECTION AND PRIVACY POLICY"}],
120
  max_tokens=3000,
121
  stream=True
122
  )
healthcheck.txt ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Objective
2
+ This file outlines a structured approach to evaluate the financial health of a company using a set of key financial ratios and metrics. The model will analyze these ratios, apply context-specific logic, and derive a health score on a scale from 1 to 10. This score—known as the QuantiNeuron Health Check Score—serves as a snapshot indicator of the company's current financial viability.
3
+
4
+ Metrics and Ratios
5
+ 1. Liquidity Ratios
6
+ Current Ratio = Current Assets / Current Liabilities
7
+ Interpretation: A ratio between 1.5 and 3.0 is generally considered healthy. Below 1 indicates potential liquidity issues, while above 3 could signal inefficient capital allocation.
8
+ Quick Ratio = (Current Assets - Inventory) / Current Liabilities
9
+ Interpretation: A ratio above 1 indicates that the company can cover short-term obligations without selling inventory, which implies robust liquidity.
10
+ Logic:
11
+
12
+ If Current Ratio < 1 or Quick Ratio < 0.8, mark as “Weak Liquidity.”
13
+ If Current Ratio is between 1.5 and 3, and Quick Ratio > 1, mark as “Healthy Liquidity.”
14
+ 2. Profitability Ratios
15
+ Gross Profit Margin = (Revenue - Cost of Goods Sold) / Revenue
16
+ Interpretation: Indicates core profitability before operational expenses. Higher values signal cost efficiency.
17
+ Net Profit Margin = Net Income / Revenue
18
+ Interpretation: Represents final profitability after all expenses. Higher percentages generally indicate a profitable business.
19
+ Return on Assets (ROA) = Net Income / Total Assets
20
+ Interpretation: Shows how effectively assets generate profit, with values over 5% considered healthy.
21
+ Logic:
22
+
23
+ High margins and ROA (>5%) indicate strong profitability, labeled as “Strong Profitability.”
24
+ If either margin is consistently low (<5%) over recent periods, flag as “Profitability Concern.”
25
+ 3. Leverage Ratios
26
+ Debt-to-Equity Ratio = Total Debt / Total Equity
27
+ Interpretation: A ratio below 2 is typically favorable, as it indicates less reliance on debt.
28
+ Interest Coverage Ratio = Earnings Before Interest & Taxes (EBIT) / Interest Expense
29
+ Interpretation: Values above 3 suggest that the company can comfortably pay its interest expenses.
30
+ Logic:
31
+
32
+ If Debt-to-Equity < 2 and Interest Coverage > 3, label as “Low Financial Risk.”
33
+ If Debt-to-Equity > 3 or Interest Coverage < 1.5, flag as “High Financial Risk.”
34
+ 4. Efficiency Ratios
35
+ Asset Turnover Ratio = Revenue / Total Assets
36
+ Interpretation: High values indicate efficient asset utilization.
37
+ Inventory Turnover Ratio = Cost of Goods Sold / Average Inventory
38
+ Interpretation: High turnover rates indicate efficient inventory management.
39
+ Logic:
40
+
41
+ If Asset Turnover is above industry average and Inventory Turnover shows strong movement, mark as “Efficient Operations.”
42
+ Low turnover rates suggest operational inefficiencies, flagged as “Operational Concern.”
43
+ 5. Growth Ratios
44
+ Revenue Growth Rate (year-over-year or quarter-over-quarter)
45
+ Interpretation: Positive, sustainable growth indicates business expansion.
46
+ Earnings Per Share (EPS) Growth = (EPS in current period - EPS in prior period) / EPS in prior period
47
+ Interpretation: Consistent positive EPS growth implies profitability and investor confidence.
48
+ Logic:
49
+
50
+ Strong growth in Revenue and EPS indicates “Positive Growth,” while negative trends raise “Growth Concerns.”
51
+ Scoring Logic: QuantiNeuron Health Check Score
52
+ To derive a QuantiNeuron Health Check Score (1-10), assign weighted values to each category based on their contribution to financial health. This score is a weighted aggregate that emphasizes profitability and liquidity, followed by leverage, efficiency, and growth.
53
+
54
+ Step 1: Assign Ratings (1-5) for Each Metric
55
+
56
+ Based on each metric’s analysis, assign scores:
57
+ 5 = Very Strong
58
+ 4 = Strong
59
+ 3 = Average
60
+ 2 = Weak
61
+ 1 = Very Weak
62
+ Step 2: Weighted Category Score Calculation
63
+
64
+ Weight each category:
65
+
66
+ Profitability: 25%
67
+ Liquidity: 20%
68
+ Leverage: 20%
69
+ Efficiency: 15%
70
+ Growth: 20%
71
+ Calculate weighted scores for each category:
72
+
73
+ Category Score
74
+ =
75
+ (Category Rating)
76
+ ×
77
+ Weight
78
+ Category Score=(Category Rating)×Weight
79
+ Step 3: Aggregate for Final Score
80
+
81
+ Sum up the weighted scores to derive a total score out of 10.
82
+ Step 4: Determine Health Check Tier
83
+
84
+ Score 9-10: “Excellent Health” (Low risk, high profitability)
85
+ Score 7-8: “Good Health” (Generally strong but minor areas to improve)
86
+ Score 5-6: “Moderate Health” (Mixed performance; moderate risk)
87
+ Score 3-4: “Poor Health” (Significant concerns in multiple areas)
88
+ Score 1-2: “Critical Health” (Severe financial distress)
89
+ Example Walkthrough
90
+ If the model processes a company and finds:
91
+
92
+ Liquidity metrics in the healthy range,
93
+ Profitability metrics above average,
94
+ High leverage ratios,
95
+ Efficient operations,
96
+ Moderate growth,
97
+ The model might assign:
98
+
99
+ Liquidity = 4.5, Profitability = 4.8, Leverage = 2.0, Efficiency = 4.2, Growth = 3.5
100
+ Calculating:
101
+
102
+ Liquidity Score = 4.5 * 0.2 = 0.9
103
+ Profitability Score = 4.8 * 0.25 = 1.2
104
+ Leverage Score = 2.0 * 0.2 = 0.4
105
+ Efficiency Score = 4.2 * 0.15 = 0.63
106
+ Growth Score = 3.5 * 0.2 = 0.7
107
+ Total Health Check Score = 0.9 + 1.2 + 0.4 + 0.63 + 0.7 = 3.83
108
+
109
+ Output
110
+ The model will return:
111
+
112
+ A QuantiNeuron Health Check Score on a 1-10 scale.
113
+ A Health Summary, outlining strengths and weaknesses based on metrics.
114
+ A Recommendation statement, if necessary, for areas needing attention.