MCPcopy Index your code
hub / github.com/QuantFans/quantdigger / max_return

Function max_return

quantdigger/kernel/datasource/data.py:116–140  ·  view source on GitHub ↗

docstring for maxreturn

(nbarprice, islong)

Source from the content-addressed store, hash-verified

114
115
116def max_return(nbarprice, islong):
117 '''docstring for maxreturn'''
118 high = -1000000
119 low = 1000000
120 maxdiffs = []
121 if islong:
122 for ith_price in nbarprice:
123 if ith_price > high:
124 high = ith_price
125 low = 1000000
126 elif ith_price < low:
127 low = ith_price
128 maxdiffs.append(high-low)
129 #print low
130 return max(maxdiffs) if maxdiffs else 0
131 else:
132 for ith_price in nbarprice:
133 if ith_price < low:
134 low = ith_price
135 high = -1000000
136 #print low
137 elif ith_price > high:
138 high = ith_price
139 maxdiffs.append(high-low)
140 return max(maxdiffs) if maxdiffs else 0
141
142
143def simple_deal_tradeinfo(tradeinfo, pricefname, n=10, intraday=False):

Callers 1

deal_tradeinfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected