-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/tox_travis_coverall' into develop
- Loading branch information
Showing
14 changed files
with
324 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.tox | ||
.cache/v/cache |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: python | ||
|
||
python: | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
|
||
install: | ||
- pip install -r requirements.txt | ||
- pip install -r test-requirements.txt | ||
- pip install tox-travis | ||
|
||
script: | ||
- tox | ||
|
||
after_success: | ||
- coveralls |
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
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,3 +1,5 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
|
||
SYMBOL_TYPE_SPOT = 'SPOT' | ||
|
||
|
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,104 +1,54 @@ | ||
from .enums import * | ||
from .exceptions import * | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
|
||
# https://binance.zendesk.com/hc/en-us/articles/115000594711 | ||
TRADE_LIMITS = { | ||
'ETHBTC': { | ||
'min_amount': 0.001, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'LTCBTC': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'BNBBTC': { | ||
'min_amount': 1, | ||
'min_price': 0.00000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'NEOBTC': { | ||
'min_amount': 0.001, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'GASBTC': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'BCCBTC': { | ||
'min_amount': 0.001, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'HCCBTC': { | ||
'min_amount': 1, | ||
'min_price': 0.00000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'HSRBTC': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.001 | ||
}, | ||
'BNBETH': { | ||
'min_amount': 1, | ||
'min_price': 0.00000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'QTUMETH': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'SNTETH': { | ||
'min_amount': 1, | ||
'min_price': 0.00000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'BNTETH': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'EOSETH': { | ||
'min_amount': 0.01, | ||
'min_price': 0.000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'BTMETH': { | ||
'min_amount': 1, | ||
'min_price': 0.00000001, | ||
'min_order_value': 0.01 | ||
}, | ||
'BTCUSDT': { | ||
'min_amount': 0.000001, | ||
'min_price': 0.01, | ||
'min_order_value': 1 | ||
}, | ||
'ETHUSDT': { | ||
'min_amount': 0.00001, | ||
'min_price': 0.01, | ||
'min_order_value': 1 | ||
}, | ||
from .exceptions import BinanceOrderUnknownSymbolException, \ | ||
BinanceOrderInactiveSymbolException, \ | ||
BinanceOrderMinPriceException, \ | ||
BinanceOrderMinAmountException, \ | ||
BinanceOrderMinTotalException | ||
|
||
""" | ||
Use details from | ||
https://www.binance.com/exchange/public/product | ||
minTrade means min Amount | ||
ticksize means min price | ||
Notional limits from https://binance.zendesk.com/hc/en-us/articles/115000594711 | ||
BTC - 0.001 | ||
ETH - 0.01 | ||
USDT - 1 | ||
""" | ||
|
||
NOTIONAL_LIMITS = { | ||
'BTC': 0.001, | ||
'ETH': 0.01, | ||
'USDT': 1 | ||
} | ||
|
||
|
||
def validate_order(params): | ||
limits = TRADE_LIMITS[params['symbol']] | ||
def validate_order(params, products): | ||
print(params) | ||
if params['symbol'] not in products: | ||
raise BinanceOrderUnknownSymbolException(params['symbol']) | ||
|
||
limits = products[params['symbol']] | ||
|
||
if not limits['active']: | ||
raise BinanceOrderInactiveSymbolException(params['symbol']) | ||
|
||
price = float(params['price']) | ||
quantity = float(params['quantity']) | ||
# check price | ||
if price < limits['min_price'] != 0: | ||
raise BinanceOrderMinPriceException(limits['min_price']) | ||
if price < float(limits['tickSize']) != 0: | ||
raise BinanceOrderMinPriceException(limits['tickSize']) | ||
|
||
# check order amount | ||
if quantity % limits['min_amount'] != 0.0: | ||
raise BinanceOrderMinAmountException(limits['min_amount']) | ||
min_trade = float(limits['minTrade']) | ||
if quantity / min_trade - int(quantity / min_trade) > 0.0: | ||
raise BinanceOrderMinAmountException(limits['minTrade']) | ||
|
||
# check order total | ||
total = float(params['price']) * float(params['quantity']) | ||
if total < limits['min_order_value']: | ||
raise BinanceOrderMinTotalException(limits['min_order_value']) | ||
notional_total = NOTIONAL_LIMITS[limits['quoteAsset']] | ||
if total < notional_total: | ||
raise BinanceOrderMinTotalException(notional_total) |
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,3 +1,6 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
|
||
import json | ||
import threading | ||
|
||
|
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,2 +1,5 @@ | ||
[bdist_wheel] | ||
universal = 1 | ||
|
||
[pep8] | ||
ignore = E501 |
Oops, something went wrong.