BUG: for issue #178, adjusted the fallback processing of orders for exchanges lacking a "my trades" api

This commit is contained in:
Frederic Fortier
2018-01-31 17:12:05 -05:00
parent 69507d1b00
commit c0ba8b2ebb
2 changed files with 20 additions and 16 deletions
+3 -3
View File
@@ -248,7 +248,7 @@ if __name__ == '__main__':
if live:
run_algorithm(
capital_base=100,
capital_base=0.035,
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=True,
simulate_orders=False,
stats_output=None,
# auth_aliases=dict(poloniex='auth2')
)
@@ -274,7 +274,7 @@ if __name__ == '__main__':
# -x bitfinex -s 2017-10-1 -e 2017-11-10 -c usdt -n mean-reversion \
# --data-frequency minute --capital-base 10000
run_algorithm(
capital_base=0.1,
capital_base=0.035,
data_frequency='minute',
initialize=initialize,
handle_data=handle_data,
+17 -13
View File
@@ -765,7 +765,7 @@ class CCXT(Exchange):
self.api.load_markets()
# https://github.com/ccxt/ccxt/issues/1483
adj_amount = abs(amount)
adj_amount = round(abs(amount), asset.decimals)
market = self.api.markets[symbol]
if 'lots' in market and market['lots'] > amount:
raise CreateOrderError(
@@ -776,7 +776,7 @@ class CCXT(Exchange):
)
else:
adj_amount = abs(amount)
adj_amount = round(abs(amount), asset.decimals)
try:
result = self.api.create_order(
@@ -858,25 +858,29 @@ class CCXT(Exchange):
order.id, order.asset, return_price=True
)
order.status = exc_order.status
order.commission = exc_order.commission
if order.amount != exc_order.amount:
log.warn(
'executed order amount {} differs '
'from original'.format(
exc_order.amount, order.amount
)
)
order.amount = exc_order.amount
order.filled = exc_order.amount
if order.status == ORDER_STATUS.FILLED:
if exc_order.status == ORDER_STATUS.FILLED:
if order.amount > exc_order.amount:
log.warn(
'executed order amount {} differs '
'from original'.format(
exc_order.amount, order.amount
)
)
order.check_triggers(
price=price,
dt=exc_order.dt,
)
transaction = Transaction(
asset=order.asset,
amount=order.amount,
dt=pd.Timestamp.utcnow(),
price=price,
order_id=order.id,
commission=order.commission
commission=order.commission,
)
return [transaction]