add contract_size to database
This commit is contained in:
parent
6036018f35
commit
78b161e14c
@ -290,13 +290,14 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
|
|
||||||
def startup_backpopulate_precision(self):
|
def startup_backpopulate_precision(self):
|
||||||
|
|
||||||
trades = Trade.get_trades([Trade.precision_mode.is_(None)])
|
trades = Trade.get_trades([Trade.contract_size.is_(None)])
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if trade.exchange != self.exchange.id:
|
if trade.exchange != self.exchange.id:
|
||||||
continue
|
continue
|
||||||
trade.precision_mode = self.exchange.precisionMode
|
trade.precision_mode = self.exchange.precisionMode
|
||||||
trade.amount_precision = self.exchange.get_precision_amount(trade.pair)
|
trade.amount_precision = self.exchange.get_precision_amount(trade.pair)
|
||||||
trade.price_precision = self.exchange.get_precision_price(trade.pair)
|
trade.price_precision = self.exchange.get_precision_price(trade.pair)
|
||||||
|
trade.contract_size = self.exchange.get_contract_size(trade.pair)
|
||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
|
||||||
def startup_update_open_orders(self):
|
def startup_update_open_orders(self):
|
||||||
|
@ -133,6 +133,7 @@ def migrate_trades_and_orders_table(
|
|||||||
amount_precision = get_column_def(cols, 'amount_precision', 'null')
|
amount_precision = get_column_def(cols, 'amount_precision', 'null')
|
||||||
price_precision = get_column_def(cols, 'price_precision', 'null')
|
price_precision = get_column_def(cols, 'price_precision', 'null')
|
||||||
precision_mode = get_column_def(cols, 'precision_mode', 'null')
|
precision_mode = get_column_def(cols, 'precision_mode', 'null')
|
||||||
|
contract_size = get_column_def(cols, 'contract_size', 'null')
|
||||||
|
|
||||||
# Schema migration necessary
|
# Schema migration necessary
|
||||||
with engine.begin() as connection:
|
with engine.begin() as connection:
|
||||||
@ -161,7 +162,7 @@ def migrate_trades_and_orders_table(
|
|||||||
timeframe, open_trade_value, close_profit_abs,
|
timeframe, open_trade_value, close_profit_abs,
|
||||||
trading_mode, leverage, liquidation_price, is_short,
|
trading_mode, leverage, liquidation_price, is_short,
|
||||||
interest_rate, funding_fees, realized_profit,
|
interest_rate, funding_fees, realized_profit,
|
||||||
amount_precision, price_precision, precision_mode
|
amount_precision, price_precision, precision_mode, contract_size
|
||||||
)
|
)
|
||||||
select id, lower(exchange), pair, {base_currency} base_currency,
|
select id, lower(exchange), pair, {base_currency} base_currency,
|
||||||
{stake_currency} stake_currency,
|
{stake_currency} stake_currency,
|
||||||
@ -189,7 +190,7 @@ def migrate_trades_and_orders_table(
|
|||||||
{is_short} is_short, {interest_rate} interest_rate,
|
{is_short} is_short, {interest_rate} interest_rate,
|
||||||
{funding_fees} funding_fees, {realized_profit} realized_profit,
|
{funding_fees} funding_fees, {realized_profit} realized_profit,
|
||||||
{amount_precision} amount_precision, {price_precision} price_precision,
|
{amount_precision} amount_precision, {price_precision} price_precision,
|
||||||
{precision_mode} precision_mode
|
{precision_mode} precision_mode, {contract_size} contract_size
|
||||||
from {trade_back_name}
|
from {trade_back_name}
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
@ -308,7 +309,7 @@ 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, 'stop_price')):
|
# or not has_column(cols_orders, 'stop_price')):
|
||||||
migrating = False
|
migrating = False
|
||||||
if not has_column(cols_trades, 'precision_mode'):
|
if not has_column(cols_trades, 'contract_size'):
|
||||||
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}")
|
||||||
|
@ -296,6 +296,7 @@ class LocalTrade():
|
|||||||
amount_precision: Optional[float] = None
|
amount_precision: Optional[float] = None
|
||||||
price_precision: Optional[float] = None
|
price_precision: Optional[float] = None
|
||||||
precision_mode: Optional[int] = None
|
precision_mode: Optional[int] = None
|
||||||
|
contract_size: Optional[float] = None
|
||||||
|
|
||||||
# Leverage trading properties
|
# Leverage trading properties
|
||||||
liquidation_price: Optional[float] = None
|
liquidation_price: Optional[float] = None
|
||||||
@ -1142,6 +1143,7 @@ class Trade(_DECL_BASE, LocalTrade):
|
|||||||
amount_precision = Column(Float, nullable=True)
|
amount_precision = Column(Float, nullable=True)
|
||||||
price_precision = Column(Float, nullable=True)
|
price_precision = Column(Float, nullable=True)
|
||||||
precision_mode = Column(Integer, nullable=True)
|
precision_mode = Column(Integer, nullable=True)
|
||||||
|
contract_size = Column(Float, nullable=True)
|
||||||
|
|
||||||
# Leverage trading properties
|
# Leverage trading properties
|
||||||
leverage = Column(Float, nullable=True, default=1.0)
|
leverage = Column(Float, nullable=True, default=1.0)
|
||||||
|
Loading…
Reference in New Issue
Block a user