Exemplo n.º 1
0
async def support_resistance(market, candles):
    close_prices = [float(i['mid']['c']) for i in candles]
    data = np.array(close_prices)
    close_series = pd.Series(data)
    (minimaIdxs, pmin, mintrend,
     minwindows), (maximaIdxs, pmax, maxtrend,
                   maxwindows) = trendln.calc_support_resistance(close_series)
    fig = trendln.plot_support_resistance(close_series)
    # plt.savefig('suppres_{}_{}.svg'.format(market, str(datetime.now())), format='svg')
    # plt.show()
    plt.clf()
    return minimaIdxs, pmin, mintrend, minwindows, maximaIdxs, pmax, maxtrend, maxwindows
Exemplo n.º 2
0
def drawChart(hist, update):
    mins, maxs = trendln.calc_support_resistance(hist[-1000:].close)
    minimaIdxs, pmin, mintrend, minwindows = trendln.calc_support_resistance(
        (hist[-1000:].low, None))  #support only
    mins, maxs = trendln.calc_support_resistance(
        (hist[-1000:].low, hist[-1000:].high))
    (minimaIdxs, pmin, mintrend, minwindows), (maximaIdxs, pmax, maxtrend,
                                               maxwindows) = mins, maxs
    minimaIdxs, maximaIdxs = trendln.get_extrema(hist[-1000:].close)
    maximaIdxs = trendln.get_extrema((None, hist[-1000:].high))  #maxima only
    minimaIdxs, maximaIdxs = trendln.get_extrema(
        (hist[-1000:].low, hist[-1000:].high))
    fig = trendln.plot_support_resistance(
        hist[-1000:].close)  # requires matplotlib - pip install matplotlib
    #if not update:
    #    plt.savefig('suppres.svg', format='svg')
    #    plt.show()
    #    plt.clf() #clear figure
    fig = trendln.plot_sup_res_date((hist[-1000:].low, hist[-1000:].high),
                                    hist[-1000:].index)  #requires pandas
    if not update:
        plt.show()
    curdir = '.'
Exemplo n.º 3
0
def drawChart(hist, update):
    global support
    global resistance
    global symbol
    try:
        mins, maxs = trendln.calc_support_resistance(
            (hist[-1000:].low, hist[-1000:].high))
        support = mins[1][1]
        resistance = maxs[1][1]
        print("Current Support : ", support,
              " Will buy once " + symbol.upper() + " reaches this number.")
        print("Current Resistance : ", resistance)
        minimaIdxs, maximaIdxs = trendln.get_extrema(
            (hist[-1000:].low, hist[-1000:].high))
        fig = trendln.plot_sup_res_date((hist[-1000:].low, hist[-1000:].high),
                                        hist[-1000:].index)
        fig.canvas.set_window_title(symbol.upper() + " Bot")
        fig.suptitle(symbol.upper() + " Support/Resistance Lines")
        plt.draw()
    except Exception as e:
        print('')
Exemplo n.º 4
0
    'WHIRLPOOL.NS', 'SYMPHONY.NS', 'HINDCOPPER.NS', 'FLFL.NS', 'ABFRL.NS',
    'DMART.NS', 'SHOPERSTOP.NS', 'SPIC.NS', '524013.BO', 'IFCI.NS',
    'TFCILTD.NS', 'BATAINDIA.NS', 'KANSAINER.NS', 'EUROCERA.NS',
    'BERGEPAINT.NS', 'BHEL.NS', 'THERMAX.NS', 'ITDC.NS', 'PHOENIXTN.BO',
    'LEMONTREE.NS', 'TAJGVK.NS', 'INDHOTEL.NS', 'JINDHOT.BO', 'ADVANIHOTR.NS',
    'GREAVESCOT.NS', 'RELIANCE.NS', 'MAHSCOOTER.NS', 'JSWSTEEL.NS', 'SAIL.NS',
    'GULFOILLUB.NS', 'INOXLEISUR.NS', 'IOC.NS', 'TATAMOTORS.NS'
]

for t in tickers:
    try:
        start = '2020-03-01'
        end = '2020-05-4'  #timeframe = '3mo'   #30d #1mo, 3mo, max, 1y
        hist = yf.download(
            t, start, end)  # tick.history(period=timeframe, rounding=True)
        mins, maxs = trendln.calc_support_resistance(hist[-1000:].Close)
        minimaIdxs, pmin, mintrend, minwindows = trendln.calc_support_resistance(
            (hist[-1000:].Low, None))  #support only
        mins, maxs = trendln.calc_support_resistance(
            (hist[-1000:].Low, hist[-1000:].High))
        (minimaIdxs, pmin, mintrend, minwindows), (maximaIdxs, pmax, maxtrend,
                                                   maxwindows) = mins, maxs
        minimaIdxs, maximaIdxs = trendln.get_extrema(hist[-1000:].Close)
        maximaIdxs = trendln.get_extrema(
            (None, hist[-1000:].High))  #maxima only
        minimaIdxs, maximaIdxs = trendln.get_extrema(
            (hist[-1000:].Low, hist[-1000:].High))
        fig = trendln.plot_support_resistance(
            hist[-1000:].Close)  # requires matplotlib - pip install matplotlib
        t1 = t
        t = t + "_" + start + "_" + end + ".png"