add strategy to the freqai object

This commit is contained in:
robcaulk 2022-08-22 19:15:56 +02:00
parent a2a4bc05db
commit f9a49744e6
3 changed files with 4 additions and 2 deletions

View File

@ -142,7 +142,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
current_profit = 0 current_profit = 0
for trade in open_trades: for trade in open_trades:
if trade.pair == pair: if trade.pair == pair:
current_value = self.strategy.dp._exchange.get_rate(pair, refresh=False) current_value = self.strategy.dp._exchange.get_rate(pair, refresh=False) #, side="buy", is_short=True)
openrate = trade.open_rate openrate = trade.open_rate
if 'long' in trade.enter_tag: if 'long' in trade.enter_tag:
market_side = 1 market_side = 1

View File

@ -7,7 +7,7 @@ import time
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from pathlib import Path from pathlib import Path
from threading import Lock from threading import Lock
from typing import Any, Dict, Tuple from typing import Any, Dict, Tuple, Optional
import numpy as np import numpy as np
import pandas as pd import pandas as pd
@ -90,6 +90,7 @@ class IFreqaiModel(ABC):
self.begin_time: float = 0 self.begin_time: float = 0
self.begin_time_train: float = 0 self.begin_time_train: float = 0
self.base_tf_seconds = timeframe_to_seconds(self.config['timeframe']) self.base_tf_seconds = timeframe_to_seconds(self.config['timeframe'])
self.strategy: Optional[IStrategy] = None
def assert_config(self, config: Dict[str, Any]) -> None: def assert_config(self, config: Dict[str, Any]) -> None:

View File

@ -152,6 +152,7 @@ class IStrategy(ABC, HyperStrategyMixin):
self.freqai = FreqaiModelResolver.load_freqaimodel(self.config) self.freqai = FreqaiModelResolver.load_freqaimodel(self.config)
self.freqai_info = self.config["freqai"] self.freqai_info = self.config["freqai"]
self.freqai.strategy = self
else: else:
# Gracious failures if freqAI is disabled but "start" is called. # Gracious failures if freqAI is disabled but "start" is called.
class DummyClass(): class DummyClass():