remove unnecessary Decimal construction
This commit is contained in:
parent
5c02f0983d
commit
0454b4c8d5
@ -187,8 +187,8 @@ class Trade(_DECL_BASE):
|
||||
"""
|
||||
open_trade_price = self.calc_open_trade_price()
|
||||
close_trade_price = self.calc_close_trade_price(
|
||||
rate=Decimal(rate or self.close_rate),
|
||||
fee=Decimal(fee or self.fee)
|
||||
rate=(rate or self.close_rate),
|
||||
fee=(fee or self.fee)
|
||||
)
|
||||
return float("{0:.8f}".format(close_trade_price - open_trade_price))
|
||||
|
||||
@ -206,8 +206,8 @@ class Trade(_DECL_BASE):
|
||||
|
||||
open_trade_price = self.calc_open_trade_price()
|
||||
close_trade_price = self.calc_close_trade_price(
|
||||
rate=Decimal(rate or self.close_rate),
|
||||
fee=Decimal(fee or self.fee)
|
||||
rate=(rate or self.close_rate),
|
||||
fee=(fee or self.fee)
|
||||
)
|
||||
|
||||
return float("{0:.8f}".format((close_trade_price / open_trade_price) - 1))
|
||||
|
@ -271,10 +271,6 @@ def test_calc_profit(limit_buy_order, limit_sell_order):
|
||||
# Lower than open rate
|
||||
assert trade.calc_profit(rate=0.00000123, fee=0.003) == -0.00089092
|
||||
|
||||
# Only custom fee without sell order applied
|
||||
with pytest.raises(TypeError):
|
||||
trade.calc_profit(fee=0.003)
|
||||
|
||||
# Test when we apply a Sell order. Sell higher than open rate @ 0.00001173
|
||||
trade.update(limit_sell_order)
|
||||
assert trade.calc_profit() == 0.00006217
|
||||
@ -299,10 +295,6 @@ def test_calc_profit_percent(limit_buy_order, limit_sell_order):
|
||||
# Get percent of profit with a custom rate (Lower than open rate)
|
||||
assert trade.calc_profit_percent(rate=0.00000123) == -0.88863827
|
||||
|
||||
# Only custom fee without sell order applied
|
||||
with pytest.raises(TypeError):
|
||||
trade.calc_profit_percent(fee=0.003)
|
||||
|
||||
# Test when we apply a Sell order. Sell higher than open rate @ 0.00001173
|
||||
trade.update(limit_sell_order)
|
||||
assert trade.calc_profit_percent() == 0.06201057
|
||||
|
Loading…
Reference in New Issue
Block a user