Make plot_profit.py flake8 compliant

This commit is contained in:
Gerald Lonlas 2018-01-22 21:20:17 -08:00
parent 6d8252e2b6
commit 5c499d16a5

View File

@ -1,27 +1,24 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
import argparse
import json import json
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
import freqtrade.optimize as optimize import freqtrade.optimize as optimize
import freqtrade.misc as misc import freqtrade.misc as misc
import freqtrade.exchange as exchange
import freqtrade.analyze as analyze
from freqtrade.strategy.strategy import Strategy from freqtrade.strategy.strategy import Strategy
def plot_parse_args(args ): def plot_parse_args(args):
parser = misc.common_args_parser('Graph utility') parser = misc.common_args_parser('Graph utility')
# FIX: perhaps delete those backtesting options that are not feasible (shows up in -h) # FIX: perhaps delete those backtesting options that are not feasible (shows up in -h)
misc.backtesting_options(parser) misc.backtesting_options(parser)
parser.add_argument( parser.add_argument(
'-p', '--pair', '-p', '--pair',
help = 'Show profits for only this pairs. Pairs are comma-separated.', help='Show profits for only this pairs. Pairs are comma-separated.',
dest = 'pair', dest='pair',
default = None default=None
) )
return parser.parse_args(args) return parser.parse_args(args)
@ -48,7 +45,7 @@ def make_profit_array(data, px, filter_pairs=[]):
# total profits at each timeframe # total profits at each timeframe
# to accumulated profits # to accumulated profits
pa = 0 pa = 0
for x in range(0,len(pg)): for x in range(0, len(pg)):
p = pg[x] # Get current total percent p = pg[x] # Get current total percent
pa += p # Add to the accumulated percent pa += p # Add to the accumulated percent
pg[x] = pa # write back to save memory pg[x] = pa # write back to save memory
@ -104,7 +101,7 @@ def plot_profit(args) -> None:
# if max_x != n: # if max_x != n:
# raise Exception('Please rerun script. Input data has different lengths %s' # raise Exception('Please rerun script. Input data has different lengths %s'
# %('Different pair length: %s <=> %s' %(max_x, n))) # %('Different pair length: %s <=> %s' %(max_x, n)))
print('max_x: %s' %(max_x)) print('max_x: %s' % (max_x))
# We are essentially saying: # We are essentially saying:
# array <- sum dataframes[*]['close'] / num_items dataframes # array <- sum dataframes[*]['close'] / num_items dataframes
@ -114,7 +111,7 @@ def plot_profit(args) -> None:
for pair, pair_data in dataframes.items(): for pair, pair_data in dataframes.items():
close = pair_data['close'] close = pair_data['close']
maxprice = max(close) # Normalize price to [0,1] maxprice = max(close) # Normalize price to [0,1]
print('Pair %s has length %s' %(pair, len(close))) print('Pair %s has length %s' % (pair, len(close)))
for x in range(0, len(close)): for x in range(0, len(close)):
avgclose[x] += close[x] / maxprice avgclose[x] += close[x] / maxprice
# avgclose += close # avgclose += close