-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtc_analysis.py
More file actions
138 lines (124 loc) · 3.8 KB
/
btc_analysis.py
File metadata and controls
138 lines (124 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import json
import random
btc_data = {
"Symbol": "btc",
"Project": "Bitcoin",
"Category": "Layer 1",
"Market Sector": "Blockchains (L1)",
"EQS": 0,
"UGS": 73.61458333,
"FVS": 53.1483871,
"SS": 96.87,
"how3 Score": 74.54432348,
"Growth Category": "Strong Growth",
"Valuation Category": "Fairly Valued",
"SS (Rating)": "AAA"
}
def generate_jsons(data):
# Safety Score JSON
main_score = data["SS"]
random.seed(data["Project"])
variation = 8
if main_score > 90:
variation = 5
elif main_score > 80:
variation = 6
cs_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
m_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
o_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
c_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
g_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
f_score = min(100, max(50, main_score + random.uniform(-variation, variation)))
avg = (cs_score + m_score + o_score + c_score + g_score + f_score) / 6
adjustment = main_score - avg
cs_score += adjustment
m_score += adjustment
o_score += adjustment
c_score += adjustment
g_score += adjustment
f_score += adjustment
cs_score = round(cs_score, 2)
m_score = round(m_score, 2)
o_score = round(o_score, 2)
c_score = round(c_score, 2)
g_score = round(g_score, 2)
f_score = round(f_score, 2)
safety_score = {
"name": data["Project"],
"mainScore": round(data["SS"], 2),
"rating": data["SS (Rating)"],
"subScores": {
"CS": cs_score,
"M": m_score,
"O": o_score,
"C": c_score,
"G": g_score,
"F": f_score
}
}
# Earnings Quality Score JSON
eqs_data = {
"protocols": {
data["Project"]: {
"name": data["Project"],
"sector": data["Market Sector"],
"scores": {
"earnings_quality": data["EQS"]
},
"peers": [],
"sector_averages": {
"earnings_quality": None,
"count": 0
}
}
},
"sectors": {
data["Market Sector"]: {
"name": data["Market Sector"],
"averages": {
"earnings_quality": None
},
"protocol_count": 1
}
}
}
# User Growth Score JSON
ugs_data = {
"protocols": {
data["Project"]: {
"name": data["Project"],
"sector": data["Market Sector"],
"scores": {
"user_growth": data["UGS"],
"growth_category": data["Growth Category"]
},
"peers": [],
"sector_averages": {
"user_growth": None,
"count": 0
}
}
},
"sectors": {
data["Market Sector"]: {
"name": data["Market Sector"],
"averages": {
"user_growth": None
},
"protocol_count": 1
}
}
}
# Combine all jsons into one
combined_json = {
"safety_score": safety_score,
"eqs_data": eqs_data,
"ugs_data": ugs_data
}
return combined_json
if __name__ == "__main__":
btc_jsons = generate_jsons(btc_data)
# Write combined JSON to a file
with open("btc_analysis.json", "w") as outfile:
json.dump(btc_jsons, outfile, indent=4)
print("btc_analysis.json file created successfully.")