dont apply fees on trade creation

This commit is contained in:
gcarq 2017-11-22 21:01:44 +01:00
parent 9136e64d89
commit 9a87dcf0a1
2 changed files with 4 additions and 5 deletions

View File

@ -204,10 +204,9 @@ def create_trade(stake_amount: float) -> bool:
else: else:
return False return False
# Calculate amount and subtract fee # Calculate amount
fee = exchange.get_fee()
buy_limit = get_target_bid(exchange.get_ticker(pair)) buy_limit = get_target_bid(exchange.get_ticker(pair))
amount = (1 - fee) * stake_amount / buy_limit amount = stake_amount / buy_limit
order_id = exchange.buy(pair, buy_limit, amount) order_id = exchange.buy(pair, buy_limit, amount)
# Create trade entity and return # Create trade entity and return
@ -222,7 +221,7 @@ def create_trade(stake_amount: float) -> bool:
pair=pair, pair=pair,
stake_amount=stake_amount, stake_amount=stake_amount,
amount=amount, amount=amount,
fee=fee * 2, fee=exchange.get_fee() * 2,
open_rate=buy_limit, open_rate=buy_limit,
open_date=datetime.utcnow(), open_date=datetime.utcnow(),
exchange=exchange.get_name().upper(), exchange=exchange.get_name().upper(),

View File

@ -41,7 +41,7 @@ def test_process_trade_creation(default_conf, ticker, health, mocker):
assert trade.open_date is not None assert trade.open_date is not None
assert trade.exchange == Exchanges.BITTREX.name assert trade.exchange == Exchanges.BITTREX.name
assert trade.open_rate == 0.072661 assert trade.open_rate == 0.072661
assert trade.amount == 0.6864067381401302 assert trade.amount == 0.6881270557795791
def test_process_exchange_failures(default_conf, ticker, health, mocker): def test_process_exchange_failures(default_conf, ticker, health, mocker):