diff --git a/upbit/__init__.py b/upbit/__init__.py index d3fcc92..00beedd 100644 --- a/upbit/__init__.py +++ b/upbit/__init__.py @@ -7,7 +7,7 @@ __all__ = ['client'] __module_name__ = 'upbit-client' -__version__ = '1.1.6.15' +__version__ = '1.1.6.16' __released_version__ = pkg_version.get_versions(__module_name__) __latest_version__ = __released_version__[0] diff --git a/upbit/pkg_version.py b/upbit/pkg_version.py index 918bdab..9fcb83b 100644 --- a/upbit/pkg_version.py +++ b/upbit/pkg_version.py @@ -9,4 +9,4 @@ def get_versions(package_name): resp = requests.get(url) data = resp.json() versions = data["releases"].keys() - return sorted(versions, key=LooseVersion, reverse=True) \ No newline at end of file + return sorted(versions, key=LooseVersion, reverse=True) diff --git a/upbit/utils.py b/upbit/utils.py new file mode 100644 index 0000000..4980857 --- /dev/null +++ b/upbit/utils.py @@ -0,0 +1,43 @@ + +from typing import Union + + +def validate_price(price: Union[int, float, str]) -> float: + """ + Documents: https://docs.upbit.com/docs/market-info-trade-price-detail + + [Order price units] + ~10 : 0.01 + ~100 : 0.1 + ~1,000 : 1 + ~10,000 : 5 + ~100,000 : 10 + ~500,000 : 50 + ~1,000,000 : 100 + ~2,000,000 : 500 + +2,000,000 : 1,000 + """ + + price = float(price) + unit = 0.01 + if price <= 10: + unit = 0.01 + elif price <= 100: + unit = 0.1 + elif price <= 1_000: + unit = 1 + elif price <= 10_000: + unit = 5 + elif price <= 100_000: + unit = 10 + elif price <= 500_000: + unit = 50 + elif price <= 1_000_000: + unit = 100 + elif price <= 2_000_000: + unit = 500 + elif price > 2_000_000: + unit = 1000 + else: + raise ValueError('Invaild Price') + return price - (price % unit)