mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
chore: don't rerun binance futures migration
once it's migrated, new migrations shouldn't be necessary.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import ClassVar
|
from typing import ClassVar, Literal
|
||||||
|
|
||||||
from sqlalchemy import String
|
from sqlalchemy import String
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
@@ -18,9 +18,11 @@ class ValueTypesEnum(str, Enum):
|
|||||||
INT = "int"
|
INT = "int"
|
||||||
|
|
||||||
|
|
||||||
class KeyStoreKeys(str, Enum):
|
KeyStoreKeys = Literal[
|
||||||
BOT_START_TIME = "bot_start_time"
|
"bot_start_time",
|
||||||
STARTUP_TIME = "startup_time"
|
"startup_time",
|
||||||
|
"binance_migration",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class _KeyValueStoreModel(ModelBase):
|
class _KeyValueStoreModel(ModelBase):
|
||||||
@@ -192,7 +194,7 @@ class KeyValueStore:
|
|||||||
return kv.int_value
|
return kv.int_value
|
||||||
|
|
||||||
|
|
||||||
def set_startup_time():
|
def set_startup_time() -> None:
|
||||||
"""
|
"""
|
||||||
sets bot_start_time to the first trade open date - or "now" on new databases.
|
sets bot_start_time to the first trade open date - or "now" on new databases.
|
||||||
sets startup_time to "now"
|
sets startup_time to "now"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from freqtrade.exceptions import ExchangeError, PricingError
|
|||||||
from freqtrade.exchange import Exchange, timeframe_to_minutes, timeframe_to_msecs
|
from freqtrade.exchange import Exchange, timeframe_to_minutes, timeframe_to_msecs
|
||||||
from freqtrade.exchange.exchange_utils import price_to_precision
|
from freqtrade.exchange.exchange_utils import price_to_precision
|
||||||
from freqtrade.loggers import bufferHandler
|
from freqtrade.loggers import bufferHandler
|
||||||
from freqtrade.persistence import CustomDataWrapper, KeyStoreKeys, KeyValueStore, PairLocks, Trade
|
from freqtrade.persistence import CustomDataWrapper, KeyValueStore, PairLocks, Trade
|
||||||
from freqtrade.persistence.models import PairLock
|
from freqtrade.persistence.models import PairLock
|
||||||
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
||||||
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
|
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
|
||||||
@@ -635,7 +635,7 @@ class RPC:
|
|||||||
first_date = trades[0].open_date_utc if trades else None
|
first_date = trades[0].open_date_utc if trades else None
|
||||||
last_date = trades[-1].open_date_utc if trades else None
|
last_date = trades[-1].open_date_utc if trades else None
|
||||||
num = float(len(durations) or 1)
|
num = float(len(durations) or 1)
|
||||||
bot_start = KeyValueStore.get_datetime_value(KeyStoreKeys.BOT_START_TIME)
|
bot_start = KeyValueStore.get_datetime_value("bot_start_time")
|
||||||
return {
|
return {
|
||||||
"profit_closed_coin": profit_closed_coin_sum,
|
"profit_closed_coin": profit_closed_coin_sum,
|
||||||
"profit_closed_percent_mean": round(profit_closed_ratio_mean * 100, 2),
|
"profit_closed_percent_mean": round(profit_closed_ratio_mean * 100, 2),
|
||||||
@@ -1601,7 +1601,7 @@ class RPC:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if bot_start := KeyValueStore.get_datetime_value(KeyStoreKeys.BOT_START_TIME):
|
if bot_start := KeyValueStore.get_datetime_value("bot_start_time"):
|
||||||
res.update(
|
res.update(
|
||||||
{
|
{
|
||||||
"bot_start": str(bot_start),
|
"bot_start": str(bot_start),
|
||||||
@@ -1609,7 +1609,7 @@ class RPC:
|
|||||||
"bot_start_ts": int(bot_start.timestamp()),
|
"bot_start_ts": int(bot_start.timestamp()),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if bot_startup := KeyValueStore.get_datetime_value(KeyStoreKeys.STARTUP_TIME):
|
if bot_startup := KeyValueStore.get_datetime_value("startup_time"):
|
||||||
res.update(
|
res.update(
|
||||||
{
|
{
|
||||||
"bot_startup": str(bot_startup),
|
"bot_startup": str(bot_startup),
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ from sqlalchemy import select
|
|||||||
from freqtrade.constants import DOCS_LINK, Config
|
from freqtrade.constants import DOCS_LINK, Config
|
||||||
from freqtrade.enums import TradingMode
|
from freqtrade.enums import TradingMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
|
from freqtrade.persistence import KeyValueStore, Trade
|
||||||
from freqtrade.persistence.pairlock import PairLock
|
from freqtrade.persistence.pairlock import PairLock
|
||||||
from freqtrade.persistence.trade_model import Trade
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -20,6 +20,9 @@ def migrate_binance_futures_names(config: Config):
|
|||||||
):
|
):
|
||||||
# only act on new futures
|
# only act on new futures
|
||||||
return
|
return
|
||||||
|
if KeyValueStore.get_int_value("binance_migration"):
|
||||||
|
# already migrated
|
||||||
|
return
|
||||||
import ccxt
|
import ccxt
|
||||||
|
|
||||||
if version.parse("2.6.26") > version.parse(ccxt.__version__):
|
if version.parse("2.6.26") > version.parse(ccxt.__version__):
|
||||||
@@ -29,6 +32,7 @@ def migrate_binance_futures_names(config: Config):
|
|||||||
)
|
)
|
||||||
_migrate_binance_futures_db(config)
|
_migrate_binance_futures_db(config)
|
||||||
migrate_binance_futures_data(config)
|
migrate_binance_futures_data(config)
|
||||||
|
KeyValueStore.store_value("binance_migration", 1)
|
||||||
|
|
||||||
|
|
||||||
def _migrate_binance_futures_db(config: Config):
|
def _migrate_binance_futures_db(config: Config):
|
||||||
|
|||||||
Reference in New Issue
Block a user