Exemplo n.º 1
0
def test_calculate_correct_statistics_of_multiple_entries(rates):
    rates.add_record(entry("BTC_ETH", "10"), entry("LIC_GAME", "2")) \
        .add_record(entry("BTC_ETH", "6"), entry("LIC_GAME", "1")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTC_ETH  |       8.0|       2.0|      10.0|      6.0|     10.0|     -4.0\n" \
                                  " LIC_GAME |       1.5|       0.5|       2.0|      1.0|      2.0|     -1.0\n"
Exemplo n.º 2
0
def test_multiple_exchange_rates(rates):
    rates.add_record(entry("BTC_ETH", "1.267"), entry("LIC_GAME",
                                                      "10.9")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTC_ETH  |     1.267|       0.0|     1.267|    1.267|    1.267|      0.0\n" \
                                  " LIC_GAME |      10.9|       0.0|      10.9|     10.9|     10.9|      0.0\n"
Exemplo n.º 3
0
def test_calculate_correct_statistics(rates):
    rates.add_record(entry("BTC_ETH", "10")) \
        .add_record(entry("BTC_ETH", "5")) \
        .add_record(entry("BTC_ETH", "12")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTC_ETH  |       9.0|2.94392028|      10.0|      5.0|     12.0|      2.0\n"
Exemplo n.º 4
0
def test_truncating_to_max_length(rates):
    rates.add_record(entry("BTCD_NTCD", "12.3456789101112")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTCD_NTCD|12.3456789|       0.0|12.3456789|12.345678|12.345678|      0.0\n"
Exemplo n.º 5
0
def test_different_value_length(rates):
    rates.add_record(entry("BTCD_NTCD", "1.2")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTCD_NTCD|       1.2|       0.0|       1.2|      1.2|      1.2|      0.0\n"
Exemplo n.º 6
0
def test_one_record_single_coin_exchange(rates):
    rates.add_record(entry("BTC_ETH", "1.267")).finish()
    assert str(analyze(rates)) == " EXCHANGE |   MEAN   |    SD    |  MEDIAN  |   MIN   |   MAX   |   DIF   \n" \
                                  "-------------------------------------------------------------------------\n" \
                                  " BTC_ETH  |     1.267|       0.0|     1.267|    1.267|    1.267|      0.0\n"
Exemplo n.º 7
0
def test_no_exchange_data(rates):
    assert str(analyze(rates)) == ""
Exemplo n.º 8
0
import sys

from pythia.core.streams.rates_analytics import analyze
from pythia.core.streams.share_rates import Symbol, ShareRates

if __name__ == '__main__':
    path = "../data/recordings/shares/SPY.csv" if len(
        sys.argv) == 1 else sys.argv[0]
    with open(path) as stream:
        rates = ShareRates(Symbol("SPY", stream))
        print(analyze(rates))