working on backtesting
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import logging
|
||||
|
||||
from freqtrade.arguments import Arguments
|
||||
from freqtrade.configuration import Configuration
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
|
||||
|
||||
def backtest(event, context):
|
||||
"""
|
||||
this method is running on the AWS server
|
||||
@@ -11,8 +16,12 @@ def backtest(event, context):
|
||||
:param event:
|
||||
{
|
||||
'strategy' : 'url handle where we can find the strategy'
|
||||
'pair' : ' pair to backtest, BTC_ETH as example'
|
||||
'timeframe' : 'how long should we backtest for, 0-100 as example for the last 100 ticks'
|
||||
'stake_currency' : 'our desired stake currency'
|
||||
'asset' : '[] asset we are interested in. If empy, we fill use a default list
|
||||
'username' : user who's strategy should be evaluated
|
||||
'name' : name of the strategy we want to evaluate
|
||||
'exchange' : name of the exchange we should be using
|
||||
|
||||
}
|
||||
:param context:
|
||||
standard AWS context, so pleaes ignore for now!
|
||||
@@ -20,14 +29,77 @@ def backtest(event, context):
|
||||
no return
|
||||
"""
|
||||
|
||||
backtesting = Backtesting()
|
||||
backtesting.start()
|
||||
name = "TestStrategy"
|
||||
user = "12345678"
|
||||
stake_currency = "USDT"
|
||||
asset = ["ETH", "BTC"]
|
||||
exchange = "binance"
|
||||
|
||||
assets = list(map(lambda x: "{}/{}".format(x, stake_currency).upper(), asset))
|
||||
|
||||
configuration = {
|
||||
"max_open_trades": 1,
|
||||
"stake_currency": stake_currency,
|
||||
"stake_amount": 0.001,
|
||||
"fiat_display_currency": "USD",
|
||||
"unfilledtimeout": 600,
|
||||
"bid_strategy": {
|
||||
"ask_last_balance": 0.0
|
||||
},
|
||||
"exchange": {
|
||||
"name": "bittrex",
|
||||
"enabled": True,
|
||||
"key": "key",
|
||||
"secret": "secret",
|
||||
"pair_whitelist": assets
|
||||
},
|
||||
"telegram": {
|
||||
"enabled": False,
|
||||
"token": "token",
|
||||
"chat_id": "0"
|
||||
},
|
||||
"initial_state": "running",
|
||||
"datadir": ".",
|
||||
"experimental": {
|
||||
"use_sell_signal": True,
|
||||
"sell_profit_only": True
|
||||
},
|
||||
"internals": {
|
||||
"process_throttle_secs": 5
|
||||
},
|
||||
'realistic_simulation': True,
|
||||
"loglevel": logging.DEBUG
|
||||
|
||||
}
|
||||
|
||||
print("generated configuration")
|
||||
print(configuration)
|
||||
|
||||
print("initialized backtesting")
|
||||
backtesting = Backtesting(configuration)
|
||||
result = backtesting.start()
|
||||
print("finished test")
|
||||
|
||||
print(result)
|
||||
print("persist data in dynamo")
|
||||
|
||||
for index, row in result.iterrows():
|
||||
item = {
|
||||
"id": "{}.{}:{}".format(user, name, row['pair']),
|
||||
"pair": row['pair'],
|
||||
"profit": row['profit'],
|
||||
"loss": row['loss'],
|
||||
"duration": row['avg duration'],
|
||||
"avg profit": row['avg profit %'],
|
||||
"total profit": row['total profit {}'.format(stake_currency)]
|
||||
|
||||
}
|
||||
|
||||
print(item)
|
||||
pass
|
||||
|
||||
|
||||
def submit(event, context):
|
||||
|
||||
"""
|
||||
|
||||
this functions submits a new strategy to the backtesting queue
|
||||
@@ -37,3 +109,7 @@ def submit(event, context):
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
backtest({}, {})
|
||||
|
||||
Reference in New Issue
Block a user