Beispiel #1
0
 def test_get_gains_losses(self):
     res = {
         'gains': [g for g in EXPECTED_CHANGES if g >= 0],
         'losses': [l for l in EXPECTED_CHANGES if l < 0]
     }
     self.assertEqual(
         poloniex.get_gains_losses(poloniex.parse_changes(HTTP_RESPONSE)),
         res)
Beispiel #2
0
def from_poloniex(json):
    """ Gets RSI from a JSON of market data
    
    Args:
        json: List of dates where each entry is a dict of raw market data.
    
    Returns:
        Float between 0 and 100, momentum indicator
        of a market measuring the speed and change of price movements.
    """
    changes = poloniex.get_gains_losses(poloniex.parse_changes(json))
    return eval_algorithm(changes['gains'], changes['losses'])
Beispiel #3
0
    def eval_from_json(json):
        """ Evaluates RSI from JSON (typically Poloniex API response)

        Args:
            json: List of dates where each entry is a dict of raw market data.

        Returns:
            Float between 0 and 100, momentum indicator
            of a market measuring the speed and change of price movements.
        """
        changes = poloniex.get_gains_losses(poloniex.parse_changes(json))
        return RSI.eval_algorithm(changes['gains'], changes['losses'])
Beispiel #4
0
 def test_parse_changes(self):
     self.assertEqual(poloniex.parse_changes(HTTP_RESPONSE),
                      EXPECTED_CHANGES)