You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I run hyperopt on time parameters? this is the code ive come up with thus far, but it doesnt seem to be working.
``
# Strategy parameters
buy_open_hour = IntParameter(0, 23, default=23, space="buy")
buy_open_minute = IntParameter(0, 59, default=58, space="buy")
sell_open_hour = IntParameter(0, 23, default=23, space="sell")
sell_open_minute = IntParameter(0, 59, default=58, space="sell")
# Run "populate_indicators()" only for new candle.
process_only_new_candles = False
# Number of candles the strategy requires before producing valid signals
startup_candle_count: int = 0
# Optional order type mapping.
order_types = {
'entry': 'market',
'exit': 'limit',
'stoploss': 'limit',
'stoploss_on_exchange': False
}
# Optional order time in force.
order_time_in_force = {
'entry': 'gtc',
'exit': 'gtc'
}
def leverage (self, pair: str, current_time: datetime, current_rate: float, proposed_leverage: float, max_leverage: float, entry_tag: Optional[str], side: str, **kwargs) -> float:
"""
Customize leverage for each new trade. This method is only called in futures mode.
:param pair: Pair that's currently analyzed
:param current_time: datetime object, containing the current datetime
:param current_rate: Rate, calculated based on pricing settings in exit_pricing.
:param proposed_leverage: A leverage proposed by the bot.
:param max_leverage: Max leverage allowed on this pair
:param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal.
:param side: 'long' or 'short' - indicating the direction of the proposed trade
:return: A leverage amount, which is between 1.0 and max_leverage.
"""
return 20.0
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Adds several different TA indicators to the given DataFrame
Performance Note: For the best performance be frugal on the number of indicators
you are using. Let uncomment only the indicator you are using in your strategies
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
:param dataframe: Dataframe with data from the exchange
:param metadata: Additional information, like the currently traded pair
:return: a Dataframe with all mandatory indicators for the strategies
"""
"""Generate all indicators used by the strategy"""
current_hour = dataframe['date'].dt.hour
current_minute = dataframe['date'].dt.minute
# Calculate all hour values
for val in self.buy_open_hour.range:
dataframe[f'hour_{val}'] = dataframe['date'].dt.hour
# Calculate all minute values
for val in self.buy_open_minute.range:
dataframe[f'minute_{val}'] = dataframe['date'].dt.minute
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
conditions = []
conditions.append(dataframe[f'hour_{self.buy_open_hour.value}'])
conditions.append(dataframe[f'minute_{self.buy_open_minute.value}'])
conditions.append(dataframe['volume'] > 0)
if conditions:
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'enter_long'] = 1
return dataframe
The text was updated successfully, but these errors were encountered:
Describe your environment
Your question
How do I run hyperopt on time parameters? this is the code ive come up with thus far, but it doesnt seem to be working.
``
The text was updated successfully, but these errors were encountered: