docstring for maxreturn
(nbarprice, islong)
| 114 | |
| 115 | |
| 116 | def 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 | |
| 143 | def simple_deal_tradeinfo(tradeinfo, pricefname, n=10, intraday=False): |