How to use numerapi - 10 common examples

To help you get started, we’ve selected a few numerapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uuazed / numerapi / tests / test_utils.py View on Github external
def test_replace():
    d = None
    assert utils.replace(d, "a", float) is None
    # empty dict
    d = {}
    assert not utils.replace(d, "a", float)
    # normal case
    d = {"a": "1"}
    utils.replace(d, "a", float)
    assert d["a"] == 1.0
github uuazed / numerapi / tests / test_numerapi.py View on Github external
def api_fixture():
    api = numerapi.NumerAPI(verbosity='DEBUG')
    return api
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_datetime_string():
    s = "2017-12-24T20:48:25.90349Z"
    t = datetime.datetime(2017, 12, 24, 20, 48, 25, 903490, tzinfo=tzutc())
    assert utils.parse_datetime_string(s) == t
    assert utils.parse_datetime_string(None) is None
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_parse_float_string():
    assert utils.parse_float_string(None) is None
    assert utils.parse_float_string("") is None
    assert utils.parse_float_string("1.23") == decimal.Decimal("1.23")
    assert utils.parse_float_string("12") == decimal.Decimal("12.0")
    assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0")
    assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_post_with_err_handling(caplog):
    # unreachable
    responses.add(responses.POST, "https://someurl1", status=404)
    utils.post_with_err_handling("https://someurl1", None, None)
    assert 'Http Error' in caplog.text
    caplog.clear()

    # invalid resonse type
    responses.add(responses.POST, "https://someurl2")
    utils.post_with_err_handling("https://someurl2", None, None)
    assert 'Did not receive a valid JSON' in caplog.text
    caplog.clear()

    # timeout
    responses.add(responses.POST, "https://someurl3",
                  body=requests.exceptions.Timeout())
    utils.post_with_err_handling("https://someurl3", None, None)
    assert 'Timeout Error' in caplog.text
    caplog.clear()