Ejemplo n.º 1
0
 def __init__(self, fast, slow, MACDLength, RSILength):
     MACDValue = MACD(fast, slow, 'close')
     AvgMACD = EMA(MACDLength, MACDValue)
     self.MACDDiff = MACDValue - AvgMACD
     self.RSI = RSI(RSILength, 'close')
     self.total_length = max(slow + MACDLength, RSILength)
     self.count = 0
Ejemplo n.º 2
0
class MovingAverageCrossStrategy(Strategy):
    def __init__(self, fast, slow, MACDLength, RSILength):
        MACDValue = MACD(fast, slow, 'close')
        AvgMACD = EMA(MACDLength, MACDValue)
        self.MACDDiff = MACDValue - AvgMACD
        self.RSI = RSI(RSILength, 'close')
        self.total_length = max(slow + MACDLength, RSILength)
        self.count = 0

    def handle_data(self):

        for secID in self.tradableAssets:
            if not self.MACDDiff.isFullByName(
                    secID) or not self.RSI.isFullByName(secID):
                continue
            if self.MACDDiff[secID] > 0.01 \
                    and self.RSI[secID] > 51.:
                self.order_to(secID, 1, 1)
            elif self.MACDDiff[secID] < -0.01 \
                    and self.RSI[secID] < 49.:
                self.order_to(secID, 1, -1)
Ejemplo n.º 3
0
 def __init__(self, fast, slow, MACDLength, RSILength):
     MACDValue = MACD(fast, slow, 'close')
     AvgMACD = EMA(MACDLength, MACDValue)
     self.MACDDiff = MACDValue - AvgMACD
     self.RSI = RSI(RSILength, 'close')