This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentralFunction.py
154 lines (120 loc) · 3.97 KB
/
centralFunction.py
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from collections import Counter
import math
class arbObject:
def __init__(self, priceData):
marketPrice = self.determineMarketPrice(priceData)
mean()
riskFactor()
findStandardDeviation()
totalDemand()
potentialProfit()
bullCoefficient()
def determinePurchase(self):
print("hello") #placeholder to suppress errors
def determineMarketPrice (priceData):
marketSummary = Counter(priceData) #returns a dictionary with counted values
priceOccurance = []
possibleMaxima = []
for key, value in marketSummary.items():
for j in range(len(marketSummary)- 1):
beforePoint = marketSummary[j-1]
afterPoint = marketSummary[j+1]
occurances = key * value
slope = ((beforePoint[0] + afterPoint[0]) / 2)
priceOccurance.append((j, occurances, slope))
if (0 < slope < 0.5):
possibleMaxima.append((slope, occurances))
occurancesOnly = [int(i[1]) for i in possibleMaxima]
"''"
localMaxima = []
if len(possibleMaxima) == 1:
globalMaxima = possibleMaxima[0]
print ("Global Maxima found at %d and no local Maxima" % (globalMaxima))
else:
reverseOrderOccurances = sorted(occurancesOnly, reversed == True)
globalMaxima = (possibleMaxima[reverseOrderOccurances[0]], reverseOrderOccurances[0])
j = 1
while j < len(reverseOrderOccurances):
localMaxima.append((possibleMaxima[reverseOrderOccurances[j]], reverseOrderOccurances[j]))
j += 1
print("Global Maxima found at %s and local maxima at %s" % (globalMaxima, localMaxima))
i = 1
return marketSummary
#maketSummary
def mean(marketSummary):
return sum(marketSummary)*1.0/len(marketSummary)
#mean
def findStandardDeviation(marketSummary):
length = len(marketSummary )
m = mean(marketSummary)
total_sum = 0
for i in range(length):
total_sum += (marketSummary[i]-m)**2
stanDev = total_sum*1.0/length
return math.sqrt(stanDev)
#stanDev
def findGlobalMax(marketSummary):
localMaxList = [(float, int, float)]
for i in marketSummary:
coordinate = tuple(i)
x = coordinate[0]
y = coordinate[1]
derivative = float
if derivative < 0.2 and derivative > -0.2:
localMaxList.append((derivative, x, y))
else:
pass
if len(localMaxList) > 1:
yList = float(i[2] for i in localMaxList)
sortedDeriv = sorted(yList, reversed)
globalMaxY = sortedDeriv[0]
return globalMaxY
#globalMax Y is the frequncy
#globalmax X is the price
def findS(GlobalMax, LocalMax,standDev):
S = (GlobalMax - LocalMax)/standDev
return S
#S is how many standard deviation to the left is the local max ( 0 derivative) from the global max
def finds():
s = 1;
return s
# s is the coefficient for S, will be adjusted accordingly
def findLowRating(pricedata):
Fivestar = float
Fourstar = float
Threestar = float
Twostar = float
Onestar = float
C = (Threestar + Twostar + Onestar)/(Fivestar + Fourstar + Threestar + Twostar + Onestar)
return C
#C is percentage of 3-star rating and below
def findc():
c = 1;
return c
# c is the coefficient for C, will be adjusted accordingly
def findriskFactor ( sellerRating, stanDev):
riskfactor = (1- s * S)*(c * C)
return R
#R is the risk Factor
def findr():
r = 1;
return r
# r is the coefficient for R, will be adjusted accordingly
def findtotalDemand (purchaseData):
D = float
return D
# D is the total number of transactions in the last 30 days
def findd():
d = 1;
return d
# d is the coefficient for D, will be adjusted accordingly
def potentialProfit (GlobalMax, LocalMax):
P =(GlobalMax - LocalMax)/GlobalMax
return P
def findp():
p = 1;
return p
# p is the coefficient for P, will be adjusted accordingly
def findbullCoefficient (d,D,r,R,p,P):
BC = r*R*d*D/(p*P)
return BC