mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Compare commits
24 Commits
12ef588bd6
...
e89c3f4a59
Author | SHA1 | Date | |
---|---|---|---|
|
e89c3f4a59 | ||
|
3bbc6cbab1 | ||
|
15de53a22d | ||
|
59a44d6973 | ||
|
7561692352 | ||
|
f50a633f87 | ||
|
ad295946c0 | ||
|
d7b86ee436 | ||
|
7a04f876c3 | ||
|
0ef7e9db13 | ||
|
ac5c22d0bc | ||
|
98ef62cb46 | ||
|
45c8161448 | ||
|
62c64e2467 | ||
|
fce4536ef2 | ||
|
0008a87232 | ||
|
116bcc2bce | ||
|
778add6d92 | ||
|
5782124df9 | ||
|
c5e68afb2c | ||
|
49487afc86 | ||
|
4b9f0c2fc2 | ||
|
a72587576e | ||
|
c537c43dd0 |
|
@ -130,20 +130,20 @@ Most properties here can be None as they are dependent on the exchange response.
|
||||||
|
|
||||||
| Attribute | DataType | Description |
|
| Attribute | DataType | Description |
|
||||||
|------------|-------------|-------------|
|
|------------|-------------|-------------|
|
||||||
`trade` | Trade | Trade object this order is attached to
|
| `trade` | Trade | Trade object this order is attached to |
|
||||||
`ft_pair` | string | Pair this order is for
|
| `ft_pair` | string | Pair this order is for |
|
||||||
`ft_is_open` | boolean | is the order filled?
|
| `ft_is_open` | boolean | is the order filled? |
|
||||||
`order_type` | string | Order type as defined on the exchange - usually market, limit or stoploss
|
| `order_type` | string | Order type as defined on the exchange - usually market, limit or stoploss |
|
||||||
`status` | string | Status as defined by ccxt. Usually open, closed, expired or canceled
|
| `status` | string | Status as defined by ccxt. Usually open, closed, expired or canceled |
|
||||||
`side` | string | Buy or Sell
|
| `side` | string | Buy or Sell |
|
||||||
`price` | float | Price the order was placed at
|
| `price` | float | Price the order was placed at |
|
||||||
`average` | float | Average price the order filled at
|
| `average` | float | Average price the order filled at |
|
||||||
`amount` | float | Amount in base currency
|
| `amount` | float | Amount in base currency |
|
||||||
`filled` | float | Filled amount (in base currency)
|
| `filled` | float | Filled amount (in base currency) |
|
||||||
`remaining` | float | Remaining amount
|
| `remaining` | float | Remaining amount |
|
||||||
`cost` | float | Cost of the order - usually average * filled (*Exchange dependent on futures, may contain the cost with or without leverage and may be in contracts.*)
|
| `cost` | float | Cost of the order - usually average * filled (*Exchange dependent on futures, may contain the cost with or without leverage and may be in contracts.*) |
|
||||||
`stake_amount` | float | Stake amount used for this order. *Added in 2023.7.*
|
| `stake_amount` | float | Stake amount used for this order. *Added in 2023.7.* |
|
||||||
`order_date` | datetime | Order creation date **use `order_date_utc` instead**
|
| `order_date` | datetime | Order creation date **use `order_date_utc` instead** |
|
||||||
`order_date_utc` | datetime | Order creation date (in UTC)
|
| `order_date_utc` | datetime | Order creation date (in UTC) |
|
||||||
`order_fill_date` | datetime | Order fill date **use `order_fill_utc` instead**
|
| `order_fill_date` | datetime | Order fill date **use `order_fill_utc` instead** |
|
||||||
`order_fill_date_utc` | datetime | Order fill date
|
| `order_fill_date_utc` | datetime | Order fill date |
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -70,7 +70,7 @@ class IFreqaiModel(ABC):
|
||||||
self.retrain = False
|
self.retrain = False
|
||||||
self.first = True
|
self.first = True
|
||||||
self.set_full_path()
|
self.set_full_path()
|
||||||
self.save_backtest_models: bool = self.freqai_info.get("save_backtest_models", True)
|
self.save_backtest_models: bool = self.freqai_info.get("save_backtest_models", False)
|
||||||
if self.save_backtest_models:
|
if self.save_backtest_models:
|
||||||
logger.info("Backtesting module configured to save all models.")
|
logger.info("Backtesting module configured to save all models.")
|
||||||
|
|
||||||
|
@ -258,6 +258,23 @@ class IFreqaiModel(ABC):
|
||||||
if self.freqai_info.get("write_metrics_to_disk", False):
|
if self.freqai_info.get("write_metrics_to_disk", False):
|
||||||
self.dd.save_metric_tracker_to_disk()
|
self.dd.save_metric_tracker_to_disk()
|
||||||
|
|
||||||
|
def _train_model(self, dataframe_train, pair, dk, tr_backtest):
|
||||||
|
try:
|
||||||
|
self.tb_logger = get_tb_logger(
|
||||||
|
self.dd.model_type, dk.data_path, self.activate_tensorboard
|
||||||
|
)
|
||||||
|
model = self.train(dataframe_train, pair, dk)
|
||||||
|
self.tb_logger.close()
|
||||||
|
return model
|
||||||
|
except Exception as msg:
|
||||||
|
logger.warning(
|
||||||
|
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
||||||
|
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}."
|
||||||
|
f"Message: {msg}, skipping.",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
def start_backtesting(
|
def start_backtesting(
|
||||||
self, dataframe: DataFrame, metadata: dict, dk: FreqaiDataKitchen, strategy: IStrategy
|
self, dataframe: DataFrame, metadata: dict, dk: FreqaiDataKitchen, strategy: IStrategy
|
||||||
) -> FreqaiDataKitchen:
|
) -> FreqaiDataKitchen:
|
||||||
|
@ -352,37 +369,26 @@ class IFreqaiModel(ABC):
|
||||||
if not self.model_exists(dk):
|
if not self.model_exists(dk):
|
||||||
dk.find_features(dataframe_train)
|
dk.find_features(dataframe_train)
|
||||||
dk.find_labels(dataframe_train)
|
dk.find_labels(dataframe_train)
|
||||||
|
self.model = self._train_model(dataframe_train, pair, dk, tr_backtest)
|
||||||
|
|
||||||
try:
|
if self.model:
|
||||||
self.tb_logger = get_tb_logger(
|
self.dd.pair_dict[pair]["trained_timestamp"] = int(tr_train.stopts)
|
||||||
self.dd.model_type, dk.data_path, self.activate_tensorboard
|
if self.plot_features and self.model is not None:
|
||||||
)
|
plot_feature_importance(self.model, pair, dk, self.plot_features)
|
||||||
self.model = self.train(dataframe_train, pair, dk)
|
if self.save_backtest_models and self.model is not None:
|
||||||
self.tb_logger.close()
|
logger.info("Saving backtest model to disk.")
|
||||||
except Exception as msg:
|
self.dd.save_data(self.model, pair, dk)
|
||||||
logger.warning(
|
else:
|
||||||
f"Training {pair} raised exception {msg.__class__.__name__}. "
|
logger.info("Saving metadata to disk.")
|
||||||
f"Message: {msg}, skipping.",
|
self.dd.save_metadata(dk)
|
||||||
exc_info=True,
|
|
||||||
)
|
|
||||||
self.model = None
|
|
||||||
|
|
||||||
self.dd.pair_dict[pair]["trained_timestamp"] = int(tr_train.stopts)
|
|
||||||
if self.plot_features and self.model is not None:
|
|
||||||
plot_feature_importance(self.model, pair, dk, self.plot_features)
|
|
||||||
if self.save_backtest_models and self.model is not None:
|
|
||||||
logger.info("Saving backtest model to disk.")
|
|
||||||
self.dd.save_data(self.model, pair, dk)
|
|
||||||
else:
|
|
||||||
logger.info("Saving metadata to disk.")
|
|
||||||
self.dd.save_metadata(dk)
|
|
||||||
else:
|
else:
|
||||||
self.model = self.dd.load_data(pair, dk)
|
self.model = self.dd.load_data(pair, dk)
|
||||||
|
|
||||||
pred_df, do_preds = self.predict(dataframe_backtest, dk)
|
if self.model and len(dataframe_backtest):
|
||||||
append_df = dk.get_predictions_to_append(pred_df, do_preds, dataframe_backtest)
|
pred_df, do_preds = self.predict(dataframe_backtest, dk)
|
||||||
dk.append_predictions(append_df)
|
append_df = dk.get_predictions_to_append(pred_df, do_preds, dataframe_backtest)
|
||||||
dk.save_backtesting_prediction(append_df)
|
dk.append_predictions(append_df)
|
||||||
|
dk.save_backtesting_prediction(append_df)
|
||||||
|
|
||||||
self.backtesting_fit_live_predictions(dk)
|
self.backtesting_fit_live_predictions(dk)
|
||||||
dk.fill_predictions(dataframe)
|
dk.fill_predictions(dataframe)
|
||||||
|
@ -829,7 +835,7 @@ class IFreqaiModel(ABC):
|
||||||
:param pair: current pair
|
:param pair: current pair
|
||||||
:return: if the data exists or not
|
:return: if the data exists or not
|
||||||
"""
|
"""
|
||||||
if self.config.get("freqai_backtest_live_models", False) and len_dataframe_backtest == 0:
|
if len_dataframe_backtest == 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"No data found for pair {pair} from "
|
f"No data found for pair {pair} from "
|
||||||
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}. "
|
f"from {tr_backtest.start_fmt} to {tr_backtest.stop_fmt}. "
|
||||||
|
|
|
@ -62,7 +62,7 @@ from freqtrade.rpc.rpc_types import (
|
||||||
)
|
)
|
||||||
from freqtrade.strategy.interface import IStrategy
|
from freqtrade.strategy.interface import IStrategy
|
||||||
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
|
||||||
from freqtrade.util import MeasureTime
|
from freqtrade.util import FtPrecise, MeasureTime
|
||||||
from freqtrade.util.migrations.binance_mig import migrate_binance_futures_names
|
from freqtrade.util.migrations.binance_mig import migrate_binance_futures_names
|
||||||
from freqtrade.wallets import Wallets
|
from freqtrade.wallets import Wallets
|
||||||
|
|
||||||
|
@ -784,7 +784,14 @@ class FreqtradeBot(LoggingMixin):
|
||||||
if stake_amount is not None and stake_amount < 0.0:
|
if stake_amount is not None and stake_amount < 0.0:
|
||||||
# We should decrease our position
|
# We should decrease our position
|
||||||
amount = self.exchange.amount_to_contract_precision(
|
amount = self.exchange.amount_to_contract_precision(
|
||||||
trade.pair, abs(float(stake_amount * trade.amount / trade.stake_amount))
|
trade.pair,
|
||||||
|
abs(
|
||||||
|
float(
|
||||||
|
FtPrecise(stake_amount)
|
||||||
|
* FtPrecise(trade.amount)
|
||||||
|
/ FtPrecise(trade.stake_amount)
|
||||||
|
)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if amount == 0.0:
|
if amount == 0.0:
|
||||||
|
|
|
@ -4,7 +4,7 @@ bottleneck==1.4.0
|
||||||
numexpr==2.10.1
|
numexpr==2.10.1
|
||||||
pandas-ta==0.3.14b
|
pandas-ta==0.3.14b
|
||||||
|
|
||||||
ccxt==4.4.3
|
ccxt==4.4.5
|
||||||
cryptography==42.0.8; platform_machine == 'armv7l'
|
cryptography==42.0.8; platform_machine == 'armv7l'
|
||||||
cryptography==43.0.1; platform_machine != 'armv7l'
|
cryptography==43.0.1; platform_machine != 'armv7l'
|
||||||
aiohttp==3.10.5
|
aiohttp==3.10.5
|
||||||
|
|
Loading…
Reference in New Issue
Block a user