Example #1
0
def test_risk_to_qty():
    # long
    assert utils.risk_to_qty(10000, 1, 100, 80) == 5
    # short
    assert utils.risk_to_qty(10000, 1, 80, 100) == 5

    # should not return more than maximum capital. Expect 100 instead of 125
    assert utils.risk_to_qty(10000, 5, 100, 96) == 100
Example #2
0
def test_risk_to_qty():
    # long
    assert utils.risk_to_qty(10000, 1, 100, 80) == 5
    # short
    assert utils.risk_to_qty(10000, 1, 80, 100) == 5

    # should not return more than maximum capital. Expect 100 instead of 125
    assert utils.risk_to_qty(10000, 5, 100, 96) == 100

    # when fee is included
    assert utils.risk_to_qty(10000, 1, 100, 80, fee_rate=0.001) == 4.97