mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 18:04:12 +08:00
BUG: trying to fix issue #178 with Binance lot sizes
This commit is contained in:
@@ -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')
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user