one last step before tests

This commit is contained in:
misagh 2018-11-25 22:02:59 +01:00
parent 29c23e3136
commit 962b02b079
5 changed files with 33 additions and 3 deletions

View File

@ -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']

View File

@ -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

View File

@ -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(),

View File

@ -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

View File

@ -7,7 +7,7 @@ from pandas import DataFrame
# Add your lib to import here
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy # noqa
import numpy # noqa
# This class is a sample. Feel free to customize it.
@ -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