-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from dan-seol/master
Update tick size price adjustment policy and quotation api test case
- Loading branch information
Showing
3 changed files
with
59 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,46 @@ | ||
from pyupbit.quotation_api import get_tickers | ||
import pytest | ||
from pyupbit.exchange_api import * | ||
|
||
|
||
def test_get_tick_size_defaults(): | ||
# hoga >= 2000000 | ||
assert 2000000 == get_tick_size(2000100) | ||
assert 2000000 == get_tick_size(2000900) | ||
# hoga >= 1000000 | ||
assert 1000000 == get_tick_size(1000100) | ||
assert 1000000 == get_tick_size(1000400) | ||
# hoga >= 500000 | ||
assert 500000 == get_tick_size(500010) | ||
assert 500000 == get_tick_size(500090) | ||
# hoga >= 100000 | ||
assert 100000 == get_tick_size(100010) | ||
assert 100000 == get_tick_size(100040) | ||
# hoga >= 10000 | ||
assert 10000 == get_tick_size(10001) | ||
assert 10000 == get_tick_size(10004) | ||
# hoga >= 1000 | ||
assert 1000 == get_tick_size(1001) | ||
assert 1000 == get_tick_size(1004) | ||
# hoga >= 100 | ||
assert 101 == get_tick_size(101.1) | ||
assert 104 == get_tick_size(104.9) | ||
# hoga >= 10 | ||
assert 10.1 == get_tick_size(10.11) | ||
assert 10.1 == get_tick_size(10.19) | ||
# hoga >= 0 | ||
assert 0.01 == get_tick_size(0.011) | ||
assert 0.01 == get_tick_size(0.019) | ||
from pyupbit.exchange_api import * | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"expected_output,actual_inputs", | ||
[ | ||
# quote (hoga) >= 2000000 | ||
(2000000, (2000100, 2000900)), | ||
# quote (hoga) >= 1000000 | ||
(1000000, (1000100, 1000400)), | ||
# quote (hoga) >= 500000 | ||
(500000, (500010, 500090)), | ||
# quote (hoga) >= 100000 | ||
(100000, (100010, 100040)), | ||
# quote (hoga) >= 10000 | ||
(10000, (10001, 10004)), | ||
# quote (hoga) >= 1000 | ||
(1001, (1001.1, 1001.4)), | ||
# quote (hoga) >= 100 | ||
(101.2, (101.21, 101.29)), | ||
# quote (hoga) >= 10 | ||
(10.31, (10.314, 10.318)), | ||
# quote (hoga) >= 1 | ||
(2.577, (2.5775, 2.57709)), | ||
# quote (hoga) >= 0.1 | ||
(0.1728, (0.17286, 0.17287)), | ||
# quote (hoga) >= 0.01 | ||
(0.01, (0.010001, 0.010006)), | ||
# quote (hoga) >= 0.001 | ||
(0.001, (0.0010009, 0.0010007)), | ||
# quote (hoga) >= 0.0001 | ||
(0.0002, (0.00020001, 0.000200012)), | ||
# quote (hoga) >= 0.00001 ("else") | ||
(0.00008002, (0.000080023, 0.000080024)), | ||
]) | ||
def test_get_tick_size_defaults(expected_output, actual_inputs): | ||
""" | ||
Given: expected output and actual inputs | ||
When: every actual input is passed to get_tick_size(..) | ||
Then: indeed expected_output == get_tick_size(actual_input) | ||
, consistent with https://docs.upbit.com/docs/market-info-trade-price-detail (v 1.4.4) | ||
""" | ||
for actual_input in actual_inputs: | ||
assert expected_output == get_tick_size(actual_input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters