def getAllSellPoints(pricesData, macd, signalLine, modifiedSignalLine): periods = getTradingPeriods(macd, signalLine) allSellPoints = [] for period in periods: upPoint = getUpCrossingPointInAPeriod(macd, signalLine, period) totalTrade = getTotalTradesInAPeriod(macd, modifiedSignalLine, period, upPoint) if totalTrade is not None: for trade in totalTrade.tradeList: allSellPoints.append(trade.sellPoint) print('total sell' ,len(allSellPoints)) return allSellPoints
def getAllSellPoints(pricesData, macd, signalLine, modifiedSignalLine): periods = getTradingPeriods(macd, signalLine) allSellPoints = [] for period in periods: upPoint = getUpCrossingPointInAPeriod(macd, signalLine, period) totalTrade = getTotalTradesInAPeriod(macd, modifiedSignalLine, period, upPoint) if totalTrade is not None: for trade in totalTrade.tradeList: allSellPoints.append(trade.sellPoint) print('total sell', len(allSellPoints)) return allSellPoints
def modifiedSignalLineTest(pricesData, macd, signalLine, modifiedSignalLine): periods = getTradingPeriods(macd, signalLine) profitRateList = [] successList = [] for period in periods: upPoint = getUpCrossingPointInAPeriod(macd, signalLine, period) totalTrade = getTotalTradesInAPeriod(macd, modifiedSignalLine, period, upPoint) if totalTrade is not None: profitRate = totalTrade.getProfitRate(pricesData) profitRateList.append(profitRate) if profitRate > 0: successList.append(1) else: successList.append(0) if len(profitRateList) > 0: return np.mean(successList), np.mean(profitRateList) else: return None, None