parent
98f2e79f27
commit
de46744aa9
@ -1167,7 +1167,6 @@ class Exchange:
|
|||||||
return (order['fee']['cost'],
|
return (order['fee']['cost'],
|
||||||
order['fee']['currency'],
|
order['fee']['currency'],
|
||||||
self.calculate_fee_rate(order))
|
self.calculate_fee_rate(order))
|
||||||
# calculate rate ? (order['fee']['cost'] / (order['amount'] * order['price']))
|
|
||||||
|
|
||||||
|
|
||||||
def is_exchange_bad(exchange_name: str) -> bool:
|
def is_exchange_bad(exchange_name: str) -> bool:
|
||||||
|
@ -20,7 +20,7 @@ from freqtrade.edge import Edge
|
|||||||
from freqtrade.exceptions import (DependencyException, ExchangeError,
|
from freqtrade.exceptions import (DependencyException, ExchangeError,
|
||||||
InvalidOrderException, PricingError)
|
InvalidOrderException, PricingError)
|
||||||
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date
|
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date
|
||||||
from freqtrade.misc import safe_value_fallback2
|
from freqtrade.misc import safe_value_fallback, safe_value_fallback2
|
||||||
from freqtrade.pairlist.pairlistmanager import PairListManager
|
from freqtrade.pairlist.pairlistmanager import PairListManager
|
||||||
from freqtrade.persistence import Trade
|
from freqtrade.persistence import Trade
|
||||||
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
from freqtrade.resolvers import ExchangeResolver, StrategyResolver
|
||||||
@ -553,14 +553,14 @@ class FreqtradeBot:
|
|||||||
order['filled'], order['amount'], order['remaining']
|
order['filled'], order['amount'], order['remaining']
|
||||||
)
|
)
|
||||||
stake_amount = order['cost']
|
stake_amount = order['cost']
|
||||||
amount = order['amount']
|
amount = order['filled']
|
||||||
buy_limit_filled_price = order['price']
|
buy_limit_filled_price = order['price']
|
||||||
order_id = None
|
order_id = None
|
||||||
|
|
||||||
# in case of FOK the order may be filled immediately and fully
|
# in case of FOK the order may be filled immediately and fully
|
||||||
elif order_status == 'closed':
|
elif order_status == 'closed':
|
||||||
stake_amount = order['cost']
|
stake_amount = order['cost']
|
||||||
amount = order['amount']
|
amount = safe_value_fallback(order, 'filled', 'amount')
|
||||||
buy_limit_filled_price = order['price']
|
buy_limit_filled_price = order['price']
|
||||||
|
|
||||||
# Fee is applied twice because we make a LIMIT_BUY and LIMIT_SELL
|
# Fee is applied twice because we make a LIMIT_BUY and LIMIT_SELL
|
||||||
@ -1249,7 +1249,8 @@ class FreqtradeBot:
|
|||||||
# Try update amount (binance-fix)
|
# Try update amount (binance-fix)
|
||||||
try:
|
try:
|
||||||
new_amount = self.get_real_amount(trade, order, order_amount)
|
new_amount = self.get_real_amount(trade, order, order_amount)
|
||||||
if not isclose(order['amount'], new_amount, abs_tol=constants.MATH_CLOSE_PREC):
|
if not isclose(safe_value_fallback(order, 'filled', 'amount'), new_amount,
|
||||||
|
abs_tol=constants.MATH_CLOSE_PREC):
|
||||||
order['amount'] = new_amount
|
order['amount'] = new_amount
|
||||||
order.pop('filled', None)
|
order.pop('filled', None)
|
||||||
trade.recalc_open_trade_price()
|
trade.recalc_open_trade_price()
|
||||||
@ -1295,7 +1296,7 @@ class FreqtradeBot:
|
|||||||
"""
|
"""
|
||||||
# Init variables
|
# Init variables
|
||||||
if order_amount is None:
|
if order_amount is None:
|
||||||
order_amount = order['amount']
|
order_amount = safe_value_fallback(order, 'filled', 'amount')
|
||||||
# Only run for closed orders
|
# Only run for closed orders
|
||||||
if trade.fee_updated(order.get('side', '')) or order['status'] == 'open':
|
if trade.fee_updated(order.get('side', '')) or order['status'] == 'open':
|
||||||
return order_amount
|
return order_amount
|
||||||
|
@ -17,6 +17,7 @@ from sqlalchemy.orm.session import sessionmaker
|
|||||||
from sqlalchemy.pool import StaticPool
|
from sqlalchemy.pool import StaticPool
|
||||||
|
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
|
from freqtrade.misc import safe_value_fallback
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -376,7 +377,7 @@ class Trade(_DECL_BASE):
|
|||||||
if order_type in ('market', 'limit') and order['side'] == 'buy':
|
if order_type in ('market', 'limit') and order['side'] == 'buy':
|
||||||
# Update open rate and actual amount
|
# Update open rate and actual amount
|
||||||
self.open_rate = Decimal(order['price'])
|
self.open_rate = Decimal(order['price'])
|
||||||
self.amount = Decimal(order.get('filled', order['amount']))
|
self.amount = Decimal(safe_value_fallback(order, 'filled', 'amount'))
|
||||||
self.recalc_open_trade_price()
|
self.recalc_open_trade_price()
|
||||||
logger.info('%s_BUY has been fulfilled for %s.', order_type.upper(), self)
|
logger.info('%s_BUY has been fulfilled for %s.', order_type.upper(), self)
|
||||||
self.open_order_id = None
|
self.open_order_id = None
|
||||||
|
Loading…
Reference in New Issue
Block a user