BUG: trying to fix issue #178 with Binance lot sizes

This commit is contained in:
Frederic Fortier
2018-01-24 21:54:05 -05:00
parent e8f98825e0
commit f34a66e9c6
4 changed files with 21 additions and 22 deletions
+2 -2
View File
@@ -248,7 +248,7 @@ if __name__ == '__main__':
if live:
run_algorithm(
capital_base=0.01,
capital_base=100,
initialize=initialize,
handle_data=handle_data,
analyze=analyze,
@@ -257,7 +257,7 @@ if __name__ == '__main__':
algo_namespace=NAMESPACE,
base_currency='btc',
live_graph=False,
simulate_orders=False,
simulate_orders=True,
stats_output=None,
# auth_aliases=dict(poloniex='auth2')
)
+13 -14
View File
@@ -760,25 +760,24 @@ class CCXT(Exchange):
side = 'buy' if amount > 0 else 'sell'
if hasattr(self.api, 'amount_to_lots'):
adj_amount = self.api.amount_to_lots(
symbol=symbol,
amount=abs(amount),
)
if adj_amount != abs(amount):
log.info(
'adjusted order amount {} to {} based on lot size'.format(
abs(amount), adj_amount,
# TODO: is this right?
if self.api.markets is None:
self.api.load_markets()
# https://github.com/ccxt/ccxt/issues/1483
adj_amount = abs(amount)
market = self.api.markets[symbol]
if 'lots' in market and market['lots'] > amount:
raise CreateOrderError(
exchange=self.name,
e='order amount lower than the smallest lot: {}'.format(
amount
)
)
else:
adj_amount = abs(amount)
if adj_amount == 0:
raise CreateOrderError(
exchange=self.name,
e='order amount lower than the smallest lot: {}'.format(amount)
)
try:
result = self.api.create_order(
symbol=symbol,
+1 -1
View File
@@ -81,6 +81,6 @@ empyrical==0.2.1
tables==3.3.0
#Catalyst dependencies
ccxt==1.10.774
ccxt==1.10.837
boto3==1.4.8
redo==1.6
+5 -5
View File
@@ -15,23 +15,23 @@ log = Logger('test_ccxt')
class TestCCXT(BaseExchangeTestCase):
@classmethod
def setup(self):
exchange_name = 'bitfinex'
exchange_name = 'binance'
auth = get_exchange_auth(exchange_name)
self.exchange = CCXT(
exchange_name=exchange_name,
key=auth['key'],
secret=auth['secret'],
base_currency='bnb',
base_currency='usdt',
)
self.exchange.init()
def test_order(self):
log.info('creating order')
asset = self.exchange.get_asset('neo_bnb')
asset = self.exchange.get_asset('eth_usdt')
order_id = self.exchange.order(
asset=asset,
style=ExchangeLimitOrder(limit_price=10),
amount=1,
style=ExchangeLimitOrder(limit_price=1000),
amount=1.01,
)
log.info('order created {}'.format(order_id))
assert order_id is not None