Took liquidation price out of order completely

This commit is contained in:
Sam Germain 2021-07-07 01:30:42 -06:00
parent a19466c085
commit 86888dbbf0
5 changed files with 2 additions and 19 deletions

View File

@ -148,7 +148,6 @@ def migrate_orders_table(decl_base, inspector, engine, table_back_name: str, col
decl_base.metadata.create_all(engine) decl_base.metadata.create_all(engine)
leverage = get_column_def(cols, 'leverage', '1.0') leverage = get_column_def(cols, 'leverage', '1.0')
is_short = get_column_def(cols, 'is_short', 'False') is_short = get_column_def(cols, 'is_short', 'False')
liquidation_price = get_column_def(cols, 'liquidation_price', 'False')
with engine.begin() as connection: with engine.begin() as connection:
connection.execute(text(f""" connection.execute(text(f"""
insert into orders ( id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id, insert into orders ( id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id,
@ -157,7 +156,7 @@ def migrate_orders_table(decl_base, inspector, engine, table_back_name: str, col
select id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id, select id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id,
status, symbol, order_type, side, price, amount, filled, null average, remaining, cost, status, symbol, order_type, side, price, amount, filled, null average, remaining, cost,
order_date, order_filled_date, order_update_date, order_date, order_filled_date, order_update_date,
{leverage} leverage, {is_short} is_short, {liquidation_price} liquidation_price {leverage} leverage, {is_short} is_short
from {table_back_name} from {table_back_name}
""")) """))

View File

@ -134,7 +134,6 @@ class Order(_DECL_BASE):
leverage = Column(Float, nullable=True, default=1.0) leverage = Column(Float, nullable=True, default=1.0)
is_short = Column(Boolean, nullable=True, default=False) is_short = Column(Boolean, nullable=True, default=False)
# liquidation_price = Column(Float, nullable=True)
def __repr__(self): def __repr__(self):
@ -511,9 +510,6 @@ class LocalTrade():
self.amount = float(safe_value_fallback(order, 'filled', 'amount')) self.amount = float(safe_value_fallback(order, 'filled', 'amount'))
if 'leverage' in order: if 'leverage' in order:
self.leverage = order['leverage'] self.leverage = order['leverage']
if 'liquidation_price' in order:
self.liquidation_price = order['liquidation_price']
self.set_stop_loss(self.stop_loss)
self.recalc_open_trade_value() self.recalc_open_trade_value()
if self.is_open: if self.is_open:
payment = "SELL" if self.is_short else "BUY" payment = "SELL" if self.is_short else "BUY"

View File

@ -2132,8 +2132,7 @@ def limit_short_order_open():
'cost': 0.00106733393, 'cost': 0.00106733393,
'remaining': 90.99181073, 'remaining': 90.99181073,
'status': 'open', 'status': 'open',
'is_short': True, 'is_short': True
'liquidation_price': 0.00001300
} }
@ -2188,7 +2187,6 @@ def market_short_order():
'status': 'closed', 'status': 'closed',
'is_short': True, 'is_short': True,
'leverage': 3.0, 'leverage': 3.0,
'liquidation_price': 0.00004300
} }
@ -2227,7 +2225,6 @@ def limit_leveraged_buy_order_open():
'leverage': 3.0, 'leverage': 3.0,
'status': 'open', 'status': 'open',
'exchange': 'binance', 'exchange': 'binance',
'liquidation_price': 0.00001000
} }
@ -2282,7 +2279,6 @@ def market_leveraged_buy_order():
'remaining': 0.0, 'remaining': 0.0,
'status': 'closed', 'status': 'closed',
'exchange': 'kraken', 'exchange': 'kraken',
'liquidation_price': 0.00004000,
'leverage': 3.0 'leverage': 3.0
} }

View File

@ -426,8 +426,6 @@ def test_update_limit_order_lev(limit_leveraged_buy_order, limit_leveraged_sell_
assert trade.close_profit is None assert trade.close_profit is None
assert trade.close_date is None assert trade.close_date is None
assert trade.borrowed == 0.0019999999998453998 assert trade.borrowed == 0.0019999999998453998
assert trade.stop_loss == 0.00001000
assert trade.liquidation_price == 0.00001000
assert log_has_re(r"LIMIT_BUY has been fulfilled for Trade\(id=2, " assert log_has_re(r"LIMIT_BUY has been fulfilled for Trade\(id=2, "
r"pair=ETH/BTC, amount=272.97543219, open_rate=0.00001099, open_since=.*\).", r"pair=ETH/BTC, amount=272.97543219, open_rate=0.00001099, open_since=.*\).",
caplog) caplog)
@ -493,8 +491,6 @@ def test_update_market_order_lev(market_leveraged_buy_order, market_leveraged_se
assert trade.close_profit is None assert trade.close_profit is None
assert trade.close_date is None assert trade.close_date is None
assert trade.interest_rate == 0.0005 assert trade.interest_rate == 0.0005
assert trade.stop_loss == 0.00004000
assert trade.liquidation_price == 0.00004000
# TODO: Uncomment the next assert and make it work. # TODO: Uncomment the next assert and make it work.
# The logger also has the exact same but there's some spacing in there # The logger also has the exact same but there's some spacing in there
assert log_has_re(r"MARKET_BUY has been fulfilled for Trade\(id=1, " assert log_has_re(r"MARKET_BUY has been fulfilled for Trade\(id=1, "

View File

@ -433,8 +433,6 @@ def test_update_with_binance_short(limit_short_order, limit_exit_short_order, fe
assert trade.close_date is None assert trade.close_date is None
assert trade.borrowed == 90.99181073 assert trade.borrowed == 90.99181073
assert trade.is_short is True assert trade.is_short is True
assert trade.stop_loss == 0.00001300
assert trade.liquidation_price == 0.00001300
assert log_has_re(r"LIMIT_SELL has been fulfilled for Trade\(id=2, " assert log_has_re(r"LIMIT_SELL has been fulfilled for Trade\(id=2, "
r"pair=ETH/BTC, amount=90.99181073, open_rate=0.00001173, open_since=.*\).", r"pair=ETH/BTC, amount=90.99181073, open_rate=0.00001173, open_since=.*\).",
caplog) caplog)
@ -507,8 +505,6 @@ def test_update_market_order_short(
assert trade.close_profit is None assert trade.close_profit is None
assert trade.close_date is None assert trade.close_date is None
assert trade.interest_rate == 0.0005 assert trade.interest_rate == 0.0005
assert trade.stop_loss == 0.00004300
assert trade.liquidation_price == 0.00004300
# The logger also has the exact same but there's some spacing in there # The logger also has the exact same but there's some spacing in there
assert log_has_re(r"MARKET_SELL has been fulfilled for Trade\(id=1, " assert log_has_re(r"MARKET_SELL has been fulfilled for Trade\(id=1, "
r"pair=ETH/BTC, amount=275.97543219, open_rate=0.00004173, open_since=.*\).", r"pair=ETH/BTC, amount=275.97543219, open_rate=0.00004173, open_since=.*\).",