Add ft_cancel_reason column to order object
This commit is contained in:
@@ -220,6 +220,7 @@ def migrate_orders_table(engine, table_back_name: str, cols_order: List):
|
|||||||
funding_fee = get_column_def(cols_order, 'funding_fee', '0.0')
|
funding_fee = get_column_def(cols_order, 'funding_fee', '0.0')
|
||||||
ft_amount = get_column_def(cols_order, 'ft_amount', 'coalesce(amount, 0.0)')
|
ft_amount = get_column_def(cols_order, 'ft_amount', 'coalesce(amount, 0.0)')
|
||||||
ft_price = get_column_def(cols_order, 'ft_price', 'coalesce(price, 0.0)')
|
ft_price = get_column_def(cols_order, 'ft_price', 'coalesce(price, 0.0)')
|
||||||
|
ft_cancel_reason = get_column_def(cols_order, 'ft_cancel_reason', 'null')
|
||||||
|
|
||||||
# sqlite does not support literals for booleans
|
# sqlite does not support literals for booleans
|
||||||
with engine.begin() as connection:
|
with engine.begin() as connection:
|
||||||
@@ -227,13 +228,13 @@ def migrate_orders_table(engine, table_back_name: str, cols_order: List):
|
|||||||
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,
|
||||||
status, symbol, order_type, side, price, amount, filled, average, remaining, cost,
|
status, symbol, order_type, side, price, amount, filled, average, remaining, cost,
|
||||||
stop_price, order_date, order_filled_date, order_update_date, ft_fee_base, funding_fee,
|
stop_price, order_date, order_filled_date, order_update_date, ft_fee_base, funding_fee,
|
||||||
ft_amount, ft_price
|
ft_amount, ft_price, ft_cancel_reason
|
||||||
)
|
)
|
||||||
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, {average} average, remaining,
|
status, symbol, order_type, side, price, amount, filled, {average} average, remaining,
|
||||||
cost, {stop_price} stop_price, order_date, order_filled_date,
|
cost, {stop_price} stop_price, order_date, order_filled_date,
|
||||||
order_update_date, {ft_fee_base} ft_fee_base, {funding_fee} funding_fee,
|
order_update_date, {ft_fee_base} ft_fee_base, {funding_fee} funding_fee,
|
||||||
{ft_amount} ft_amount, {ft_price} ft_price
|
{ft_amount} ft_amount, {ft_price} ft_price, {ft_cancel_reason} ft_cancel_reason
|
||||||
from {table_back_name}
|
from {table_back_name}
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
@@ -328,8 +329,8 @@ def check_migrate(engine, decl_base, previous_tables) -> None:
|
|||||||
# if ('orders' not in previous_tables
|
# if ('orders' not in previous_tables
|
||||||
# or not has_column(cols_orders, 'funding_fee')):
|
# or not has_column(cols_orders, 'funding_fee')):
|
||||||
migrating = False
|
migrating = False
|
||||||
# if not has_column(cols_orders, 'ft_price'):
|
# if not has_column(cols_trades, 'is_stop_loss_trailing'):
|
||||||
if not has_column(cols_trades, 'is_stop_loss_trailing'):
|
if not has_column(cols_orders, 'ft_cancel_reason'):
|
||||||
migrating = True
|
migrating = True
|
||||||
logger.info(f"Running database migration for trades - "
|
logger.info(f"Running database migration for trades - "
|
||||||
f"backup: {table_back_name}, {order_table_bak_name}")
|
f"backup: {table_back_name}, {order_table_bak_name}")
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class Order(ModelBase):
|
|||||||
ft_is_open: Mapped[bool] = mapped_column(nullable=False, default=True, index=True)
|
ft_is_open: Mapped[bool] = mapped_column(nullable=False, default=True, index=True)
|
||||||
ft_amount: Mapped[float] = mapped_column(Float(), nullable=False)
|
ft_amount: Mapped[float] = mapped_column(Float(), nullable=False)
|
||||||
ft_price: Mapped[float] = mapped_column(Float(), nullable=False)
|
ft_price: Mapped[float] = mapped_column(Float(), nullable=False)
|
||||||
|
ft_cancel_reason: Mapped[str] = mapped_column(String(CUSTOM_TAG_MAX_LENGTH), nullable=True)
|
||||||
|
|
||||||
order_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
order_id: Mapped[str] = mapped_column(String(255), nullable=False, index=True)
|
||||||
status: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
status: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user