mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 08:44:01 +08:00
BUG: for issue #178, adjusted the fallback processing of orders for exchanges lacking a "my trades" api
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user