######## CREATE THE OBJECT AND LOAD THE DATA ##########
# Tell which company and which period we want
timeData = CTD.CTimeData(symbols[0], periods[0])
timeData.set_csv(storage_folder)  # Load the data into the model
timeData.set_interval(sdate, edate)  # Set the interval period to be analysed

trading_indicators_complex = 1
if (trading_indicators_complex == 1):
    ## Example on how to construct complex graphs showing better graphs
    dates = timeData.get_dates()
    Ndiv = 6
    HPV = 2

    ### Plot the initial Price Volume
    gl.plot_indicator(timeData, Ndiv=Ndiv, HPV=HPV)
    axes = gl.get_axes()
    axP = axes[0]  # Price axes
    axV = axes[1]  # Volumne exes

    # Plot something on the price
    priceA = timeData.get_timeSeries(["Average"])
    MA1 = 16
    MA2 = 9
    Av1 = timeData.SMA(n=MA1)
    Av2 = timeData.SMA(n=MA2)

    gl.plot(dates,
            Av1,
            nf=0,
            ax=axP,
            color='#e1edf9',
示例#2
0
            AxesStyle="Normal2")
    gl.stem([],
            EMAw2,
            nf=1,
            sharex=ax1,
            sharey=ax1,
            labels=["", "Lag", ""],
            legend=["EMA(%i)" % nMA2],
            color="k",
            xlimPad=[0.1, 0.3],
            ylimPad=[0.1, 0.4],
            marker=marker,
            AxesStyle="Normal2 - No yaxis")

    gl.set_zoom(xlim=[-2, nMA2 * (1.10)], ylim=[-0.01, 0.25])
    axes_list = gl.get_axes()
    for ax in axes_list:
        gl.format_yaxis(ax=ax, Nticks=10)

    gl.subplots_adjust(left=.09,
                       bottom=.10,
                       right=.90,
                       top=.95,
                       wspace=.05,
                       hspace=0.05)

    gl.savefig(folder_images + 'windows.png',
               dpi=100,
               sizeInches=[2 * 8, 2 * 3])

if (MAMAs):
    ### PLOT THE ORIGINAL PRICE AND MOVING AVERAGES
    timeData = Cartera.get_timeDataObj(period = -1, symbol_names = [symbols[indx]])[0]
    
    gl.init_figure()
    ##########################  AX0 ########################
    ### Plot the initial Price Volume
    gl.subplot2grid((Ndiv,4), (0,0), rowspan=HPV, colspan=4)
#    gl.plot_indicator(timeData, Ndiv = Ndiv, HPV = HPV)
    gl.plot(dates, prices[:,indx], legend = ["Price"], nf = 0,
            labels = ["Xing Average Strategy","Price","Time"])
    
    Volume = timeData.get_timeSeries(seriesNames = ["Volume"])
    gl.plot(dates, Volume, nf = 0, na = 1, lw = 0, alpha = 0)
    gl.fill_between(dates, Volume)
    
    axes = gl.get_axes()
    axP = axes[0]  # Price axes
    axV = axes[1]  # Volumne exes
    
    axV.set_ylim(0,3 * max(Volume))
    gl.plot(dates, EMAfast[:,indx],ax = axP, legend = ["EMA = %i" %(n_fast)], nf = 0)
    gl.plot(dates, EMAslow[:,indx],ax = axP, legend = ["EMA = %i" %(n_slow)], nf = 0)
    
    ##########################  AX1 ########################
    pos = 0
    gl.subplot2grid((Ndiv,4), (HPV + pos,0), rowspan=1, colspan=4, sharex = axP)
    gl.plot(dates, Y_data, nf = 0, legend = ["Y data filtered"])
    
   ##########################  AX2 ########################
    pos = pos +1
    gl.subplot2grid((Ndiv,4), (HPV + pos,0), rowspan=1, colspan=4, sharex = axP)
示例#4
0
#######################################################
############# DANSKE BANK Stuff ###################
######################################################

timeDataObjs = Cartera.get_timeDataObj(period1)
Nsym = len(timeDataObjs)
gl.init_figure()

#ax1.xaxis_date()

i = 0
for tdo in timeDataObjs:
    gl.subplot2grid((Nsym, 4), (i, 0), rowspan=1, colspan=4)
    gl.tradingPV(tdo, color_mode=1, fontsize=15)
    i = i + 1
    ax = gl.get_axes()[-1]

all_axes = gl.get_axes()
for i in range(len(all_axes) - 2):
    ax = all_axes[i]
    plt.setp(ax.get_xticklabels(), visible=False)

#plt.setp(ax.get_xticklabels(), visible=True)
plt.suptitle("Danske Bank", color='k', fontsize=20)
plt.subplots_adjust(left=.09,
                    bottom=.10,
                    right=.90,
                    top=.95,
                    wspace=.20,
                    hspace=0)
#gl.savefig("./pene.png", dpi = 200)
示例#5
0
            legend = ["WMA(%i)"%nMA2], color = "k",
            xlimPad = [0.1,0.3], ylimPad = [0.1,0.4],
            marker = marker, AxesStyle = "Normal2 - No yaxis - No xaxis")
    gl.stem([], EMAw, nf = 1, sharex = ax1, sharey = ax1,
            labels = ["","Lag","EMA"],
            legend = ["EMA(%i)"%nMA1],
            xlimPad = [0.1,0.3], ylimPad = [0.1,0.4],
            marker = marker, AxesStyle = "Normal2")
    gl.stem([], EMAw2, nf = 1, sharex = ax1, sharey = ax1,
            labels = ["","Lag",""],
            legend = ["EMA(%i)"%nMA2], color = "k",
            xlimPad = [0.1,0.3], ylimPad = [0.1,0.4],
            marker = marker, AxesStyle = "Normal2 - No yaxis")
            
    gl.set_zoom(xlim = [-2,nMA2 * (1.10)], ylim = [-0.01, 0.25])
    axes_list = gl.get_axes()
    for ax in axes_list:
        gl.format_yaxis(ax = ax, Nticks = 10)
        
    gl.subplots_adjust(left=.09, bottom=.10, right=.90, top=.95, wspace=.05, hspace=0.05)

    gl.savefig(folder_images +'windows.png', 
               dpi = 100, sizeInches = [2*8, 2*3])

if (MAMAs):
    # Some basic indicators.
    price = timeData.get_timeSeries(["Close"]);
    dates = timeData.get_dates()

    # For comparing SMA, EMA, WMA
    nHMA = 10