one last step before tests
This commit is contained in:
parent
29c23e3136
commit
962b02b079
@ -14,6 +14,7 @@ DEFAULT_DB_PROD_URL = 'sqlite:///tradesv3.sqlite'
|
||||
DEFAULT_DB_DRYRUN_URL = 'sqlite://'
|
||||
UNLIMITED_STAKE_AMOUNT = 'unlimited'
|
||||
REQUIRED_ORDERTYPES = ['buy', 'sell', 'stoploss']
|
||||
REQUIRED_ORDERTIF = ['buy', 'sell']
|
||||
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
||||
ORDERTIF_POSSIBILITIES = ['gtc', 'aon', 'fok', 'ioc']
|
||||
|
||||
|
@ -475,7 +475,8 @@ class FreqtradeBot(object):
|
||||
amount = stake_amount / buy_limit
|
||||
|
||||
order_id = self.exchange.buy(pair=pair, ordertype=self.strategy.order_types['buy'],
|
||||
amount=amount, rate=buy_limit)['id']
|
||||
amount=amount, rate=buy_limit,
|
||||
time_in_force=self.strategy.order_time_in_force['buy'])['id']
|
||||
|
||||
self.rpc.send_msg({
|
||||
'type': RPCMessageType.BUY_NOTIFICATION,
|
||||
@ -782,7 +783,10 @@ class FreqtradeBot(object):
|
||||
# Execute sell and update trade record
|
||||
order_id = self.exchange.sell(pair=str(trade.pair),
|
||||
ordertype=self.strategy.order_types[sell_type],
|
||||
amount=trade.amount, rate=limit)['id']
|
||||
amount=trade.amount, rate=limit,
|
||||
time_in_force=self.strategy.order_time_in_force['sell']
|
||||
)['id']
|
||||
|
||||
trade.open_order_id = order_id
|
||||
trade.close_rate_requested = limit
|
||||
trade.sell_reason = sell_reason.value
|
||||
|
@ -83,10 +83,23 @@ class StrategyResolver(IResolver):
|
||||
else:
|
||||
config['order_types'] = self.strategy.order_types
|
||||
|
||||
if 'order_time_in_force' in config:
|
||||
self.strategy.order_time_in_force = config['order_time_in_force']
|
||||
logger.info(
|
||||
"Override strategy 'order_time_in_force' with value in config file: %s.",
|
||||
config['order_time_in_force']
|
||||
)
|
||||
else:
|
||||
config['order_time_in_force'] = self.strategy.order_time_in_force
|
||||
|
||||
if not all(k in self.strategy.order_types for k in constants.REQUIRED_ORDERTYPES):
|
||||
raise ImportError(f"Impossible to load Strategy '{self.strategy.__class__.__name__}'. "
|
||||
f"Order-types mapping is incomplete.")
|
||||
|
||||
if not all(k in self.strategy.order_time_in_force for k in constants.REQUIRED_ORDERTIF):
|
||||
raise ImportError(f"Impossible to load Strategy '{self.strategy.__class__.__name__}'. "
|
||||
f"Order-time-in-force mapping is incomplete.")
|
||||
|
||||
# Sort and apply type conversions
|
||||
self.strategy.minimal_roi = OrderedDict(sorted(
|
||||
{int(key): value for (key, value) in self.strategy.minimal_roi.items()}.items(),
|
||||
|
@ -77,6 +77,12 @@ class IStrategy(ABC):
|
||||
'stoploss': 'limit'
|
||||
}
|
||||
|
||||
# Optional time in force
|
||||
order_time_in_force: Dict = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc',
|
||||
}
|
||||
|
||||
# run "populate_indicators" only for new candle
|
||||
process_only_new_candles: bool = False
|
||||
|
||||
|
@ -55,6 +55,12 @@ class TestStrategy(IStrategy):
|
||||
'stoploss': 'market'
|
||||
}
|
||||
|
||||
# Optional order time in force
|
||||
order_types = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
Loading…
Reference in New Issue
Block a user