rename btc_amount to stake_amount
This commit is contained in:
parent
dc1cfe7a7a
commit
48beb279c0
4
main.py
4
main.py
@ -148,7 +148,7 @@ def create_trade(stake_amount: float, _exchange: exchange.Exchange) -> Optional[
|
|||||||
"""
|
"""
|
||||||
logger.info('Creating new trade with stake_amount: %f ...', stake_amount)
|
logger.info('Creating new trade with stake_amount: %f ...', stake_amount)
|
||||||
whitelist = _CONF[_exchange.name.lower()]['pair_whitelist']
|
whitelist = _CONF[_exchange.name.lower()]['pair_whitelist']
|
||||||
# Check if btc_amount is fulfilled
|
# Check if stake_amount is fulfilled
|
||||||
if exchange.get_balance(_CONF['stake_currency']) < stake_amount:
|
if exchange.get_balance(_CONF['stake_currency']) < stake_amount:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'stake amount is not fulfilled (currency={}'.format(_CONF['stake_currency'])
|
'stake amount is not fulfilled (currency={}'.format(_CONF['stake_currency'])
|
||||||
@ -188,7 +188,7 @@ def create_trade(stake_amount: float, _exchange: exchange.Exchange) -> Optional[
|
|||||||
logger.info(message)
|
logger.info(message)
|
||||||
telegram.send_msg(message)
|
telegram.send_msg(message)
|
||||||
return Trade(pair=pair,
|
return Trade(pair=pair,
|
||||||
btc_amount=stake_amount,
|
stake_amount=stake_amount,
|
||||||
open_rate=open_rate,
|
open_rate=open_rate,
|
||||||
open_date=datetime.utcnow(),
|
open_date=datetime.utcnow(),
|
||||||
amount=amount,
|
amount=amount,
|
||||||
|
@ -49,7 +49,7 @@ class Trade(Base):
|
|||||||
open_rate = Column(Float, nullable=False)
|
open_rate = Column(Float, nullable=False)
|
||||||
close_rate = Column(Float)
|
close_rate = Column(Float)
|
||||||
close_profit = Column(Float)
|
close_profit = Column(Float)
|
||||||
btc_amount = Column(Float, nullable=False)
|
stake_amount = Column(Float, name='btc_amount', nullable=False)
|
||||||
amount = Column(Float, nullable=False)
|
amount = Column(Float, nullable=False)
|
||||||
open_date = Column(DateTime, nullable=False, default=datetime.utcnow)
|
open_date = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||||
close_date = Column(DateTime)
|
close_date = Column(DateTime)
|
||||||
|
@ -157,7 +157,7 @@ def _profit(bot: Bot, update: Update) -> None:
|
|||||||
current_rate = exchange.get_ticker(trade.pair)['bid']
|
current_rate = exchange.get_ticker(trade.pair)['bid']
|
||||||
profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate)
|
profit = 100 * ((current_rate - trade.open_rate) / trade.open_rate)
|
||||||
|
|
||||||
profit_amounts.append((profit / 100) * trade.btc_amount)
|
profit_amounts.append((profit / 100) * trade.stake_amount)
|
||||||
profits.append(profit)
|
profits.append(profit)
|
||||||
|
|
||||||
best_pair = Trade.session.query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
|
best_pair = Trade.session.query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
|
||||||
|
@ -61,7 +61,7 @@ class TestMain(unittest.TestCase):
|
|||||||
self.assertEqual(trade.pair, 'BTC_ETH')
|
self.assertEqual(trade.pair, 'BTC_ETH')
|
||||||
self.assertEqual(trade.exchange, exchange.Exchange.BITTREX)
|
self.assertEqual(trade.exchange, exchange.Exchange.BITTREX)
|
||||||
self.assertEqual(trade.amount, 206.43811673387373)
|
self.assertEqual(trade.amount, 206.43811673387373)
|
||||||
self.assertEqual(trade.btc_amount, 15.0)
|
self.assertEqual(trade.stake_amount, 15.0)
|
||||||
self.assertEqual(trade.is_open, True)
|
self.assertEqual(trade.is_open, True)
|
||||||
self.assertIsNotNone(trade.open_date)
|
self.assertIsNotNone(trade.open_date)
|
||||||
buy_signal.assert_called_once_with('BTC_ETH')
|
buy_signal.assert_called_once_with('BTC_ETH')
|
||||||
|
@ -10,7 +10,7 @@ class TestTrade(unittest.TestCase):
|
|||||||
with patch('main.exchange.sell', side_effect='mocked_order_id') as api_mock:
|
with patch('main.exchange.sell', side_effect='mocked_order_id') as api_mock:
|
||||||
trade = Trade(
|
trade = Trade(
|
||||||
pair='BTC_ETH',
|
pair='BTC_ETH',
|
||||||
btc_amount=1.00,
|
stake_amount=1.00,
|
||||||
open_rate=0.50,
|
open_rate=0.50,
|
||||||
amount=10.00,
|
amount=10.00,
|
||||||
exchange=Exchange.BITTREX,
|
exchange=Exchange.BITTREX,
|
||||||
|
Loading…
Reference in New Issue
Block a user