Exemplo n.º 1
0
def inputs(company, begin="2000-01-03", end=datetime.date.today()):
    df = dataframe.get_data([company])
    boll = indicators.bollinger_differential(company)
    rsi = indicators.RSI(company)
    oscillator = indicators.stochastic_oscillator(company)
    input_set = df.join(boll.join(rsi))
    return input_set[20:]
 so_d = 15
 # Normal Setup
 steps = np.array(sorted(list(set([25] + list(np.unique(sequence))))))
 seq_len = len(sequence)
 candles = get_candles(currency, granularity, _from, _to, ) 
 up, down, udo, udnext, udmin = get_ud_bars(candles, steps)
 rwo, rwmin = get_position_bars(candles, position)
 # Get Placements and calculate simple statistics
 take = get_positions(candles, steps, sequence, outcomes, udo, udnext)
 results = rwo[direction][take]
 win_perc = results.mean()
 binom = binom_test(results.sum(), results.shape[0], rwo[direction].mean())
 volume = candles.loc[take, 'volume']
 spreads = candles.loc[take, 'spread']
 # Compute indicators
 so = stochastic_oscillator(candles, so_k, so_d)  # 10 5 seems descent so far
 # Print Results
 plt.plot(so[take], results, 'o')
 if direction == 0:
     so10 = rwo[direction][take][so[take] >= 90]
     so20 = rwo[direction][take][so[take] >= 80]
     so30 = rwo[direction][take][so[take] >= 70]
 else:
     so10 = rwo[direction][take][so[take] <= 10]
     so20 = rwo[direction][take][so[take] <= 20]
     so30 = rwo[direction][take][so[take] <= 30]    
 print('timestamp, outcome, bars, stoch osc, spread, volume')
 for each in list(zip(candles.loc[take,'timestamp'], 
                      results, 
                      rwmin[direction][take], 
                      so[take],
Exemplo n.º 3
0

from sklearn.metrics import precision_score as ps
from sklearn.metrics import classification_report as cr
from indicators import stochastic_oscillator

'''
so_k = 5
so_d = 3
print('candles')
candles = get_candles(currency, granularity, _from, _to, ) 
print('rwo')
rwo, rwmin = get_position_bars(candles, position)
print('so')
'''
so = stochastic_oscillator(candles, 15, 5)  # 10 5 seems descent so far
#print(cr(rwo[1], so > 98))
#print(ps(rwo[1], so > 98))

max_get = 0
tracker = ()
for i in range(1, 250):
    for j in range(1, 250):
        so = stochastic_oscillator(candles, i, j)
        if ps(rwo[1], so > 80) > max_get:
            max_get = ps(rwo[1], so > 80)
            tracker = (i, j)
print(tracker)