def main(cp, conn, cursor):
    sql3 = (
        """SELECT neues_kursziel, zieldatum, analyst, avg FROM analyst_avg_2 WHERE unternehmen = %d AND neues_kursziel >0 AND avg_datum<(SELECT CURDATE()) ORDER BY avg_datum, zieldatum """
        % (cp)
    )

    sql = "SELECT close , `datum` FROM kursdaten WHERE unternehmen =%d ORDER BY `datum" % (cp)

    sql4 = """SELECT neues_kursziel, zieldatum, analyst FROM prognose
     WHERE unternehmen = %d
     AND `zieldatum`>(SELECT CURDATE()) AND neues_kursziel >0
     ORDER BY zieldatum""" % (
        cp
    )

    avg_kurse = calculate_data.get_select(sql, cursor, conn)
    ziel_kurse = calculate_data.get_select(sql3, cursor, conn)
    prognose = calculate_data.get_select(sql4, cursor, conn)

    avg = [q[0] for q in avg_kurse]

    datum_avg = [q[1] for q in avg_kurse]
    datum_avg = dates.date2num(datum_avg)

    datum_ziel = [q[1] for q in ziel_kurse]
    datum_ziel = dates.date2num(datum_ziel)

    datum_prognose = [q[1] for q in prognose]
    datum_prognose = dates.date2num(datum_prognose)

    analysten_dict = calculate_data.get_analysten_dict(ziel_kurse)

    analysten_prognosen_dict = calculate_data.get_analysten_prognosen_dict(prognose)

    predictions_dict = calculate_data.get_prediction_dictionary(analysten_dict, analysten_prognosen_dict)
    predictions_and_dates_list = calculate_data.get_predictions_and_dates(predictions_dict)
    mittelwert = calculate_data.get_mittelwert(predictions_and_dates_list)
    Varianz = calculate_data.get_varianz(mittelwert, [q[1] for q in predictions_and_dates_list])
    sigma = np.sqrt(Varianz)

    data_plot_future = calculate_data.get_data_for_plot_future(analysten_dict, analysten_prognosen_dict)
    data_plot_own_forecast_ponts = calculate_data.get_data_for_plot_own_forecast_points()
    #    fig = figure()
    #    ax = fig.add_subplot(111)
    #    plot.plot_avg(datum_avg,avg,ax,fig)
    #    plot.plot_future([q[0] for q in data_plot_future], [q[1] for q in data_plot_future],'yellow',ax,fig)
    #    plot.plot_own_forecast_line([q[1] for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list],sigma,ax,fig)
    #    plot.plot_own_forecast_points([q[0] for q in data_plot_own_forecast_ponts],[q[1] for q in data_plot_own_forecast_ponts],ax,fig)
    #    plot.show_plot(ax,fig)

    konfidenz_intervall_95_sigma_oben = [
        [(q[1] + 1.9600 * sigma) for q in predictions_and_dates_list],
        [q[0] for q in predictions_and_dates_list],
    ]
    konfidenz_intervall_95_sigma_unten = [
        [(q[1] - 1.9600 * sigma) for q in predictions_and_dates_list],
        [q[0] for q in predictions_and_dates_list],
    ]
    tats_kurse_datum = [datum_avg, avg]
    prognosekurse_analysten_datum = [q[0] for q in data_plot_future], [q[1] for q in data_plot_future]
    unsere_vorhersage_linie = [q[1] for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]
    unsere_vorhersage_punkte = [
        [q[0] for q in data_plot_own_forecast_ponts],
        [q[1] for q in data_plot_own_forecast_ponts],
    ]

    result_set = []
    result_set.append(konfidenz_intervall_95_sigma_oben)
    result_set.append(konfidenz_intervall_95_sigma_unten)
    result_set.append(tats_kurse_datum)
    result_set.append(prognosekurse_analysten_datum)
    result_set.append(unsere_vorhersage_linie)
    result_set.append(unsere_vorhersage_punkte)
    result_set.append(sigma)

    calculate_data.reset_global_variables()
    calculate_data.initialize_global_variables()
    return result_set
def main(cp):
    sql3 = """SELECT `new_price`, `target_date`, `analyst_id`, `avg` 
            FROM analyst_avg_2  
            WHERE `company_id`= %d 
            AND `new_price`>0 
            AND `avg_date`<(SELECT CURDATE()) 
            ORDER BY `avg_date`, `target_date`"""%(cp)    
    
    sql = """SELECT `closing_price`, `date` 
            FROM secop_quote 
            WHERE `company_id`=%d 
            ORDER BY `date`"""%(cp)
    
    sql4 = """SELECT `new_price`, `target_date`, `analyst_id`
            FROM secop_prediction
            WHERE `company_id`= %d
            AND `target_date`>(SELECT CURDATE()) 
            AND `new_price`>0
            ORDER BY `target_date`"""%(cp)
    
    
    avg_kurse = connector.get_select(sql)
    ziel_kurse = connector.get_select(sql3)
    prognose = connector.get_select(sql4)
    
    avg = [q[0] for q in avg_kurse]
    
    datum_avg = [q[1] for q in avg_kurse]
    
    
    analysten_dict = calculate_data.get_analysten_dict(ziel_kurse)
    
    analysten_prognosen_dict = calculate_data.get_analysten_prognosen_dict(prognose)
    
    predictions_dict = calculate_data.get_prediction_dictionary(analysten_dict,analysten_prognosen_dict)
    predictions_and_dates_list = calculate_data.get_predictions_and_dates(predictions_dict)
    mittelwert = calculate_data.get_mittelwert(predictions_and_dates_list)
    Varianz = calculate_data.get_varianz(mittelwert,[q[1] for q in predictions_and_dates_list])
    sigma = np.sqrt(Varianz)
    
    
    data_plot_future = calculate_data.get_data_for_plot_future(analysten_dict,analysten_prognosen_dict)
    data_plot_own_forecast_ponts = calculate_data.get_data_for_plot_own_forecast_points()
    

    konfidenz_intervall_95_sigma_oben = [[(q[1]+ 1.9600 * sigma) for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]]
    konfidenz_intervall_95_sigma_unten = [[(q[1]- 1.9600 * sigma) for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]]
    tats_kurse_datum = [datum_avg,avg]
    prognosekurse_analysten_datum = [q[0] for q in data_plot_future], [q[1] for q in data_plot_future]
    unsere_vorhersage_linie = [q[1] for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]
    unsere_vorhersage_punkte = [[q[0] for q in data_plot_own_forecast_ponts],[q[1] for q in data_plot_own_forecast_ponts]]
    
    result_set = []
    result_set.append(konfidenz_intervall_95_sigma_oben)
    result_set.append(konfidenz_intervall_95_sigma_unten)
    result_set.append(tats_kurse_datum)
    result_set.append(prognosekurse_analysten_datum)
    result_set.append(unsere_vorhersage_linie)
    result_set.append(unsere_vorhersage_punkte)
    result_set.append(sigma)

    calculate_data.reset_global_variables()
    calculate_data.initialize_global_variables()
    return result_set
    
def main(cp):
    sql_training = """SELECT `new_price`, `target_date`,`avg` 
            FROM `analyst_avg_2` 
            WHERE `company_id` = %d  
            AND `avg_date` > '2010-01-01' 
            AND `avg_date` < '2012-03-01'"""%(cp)
            
    sql_testing = """SELECT `new_price`, `target_date`, `analyst_id`, `avg` 
            FROM `analyst_avg_2`  
            WHERE `company_id` = %d  
            AND `avg_date` > '2012-03-01'
            AND `avg_date` < (SELECT CURDATE())"""%(cp)
            
    sql = """SELECT `closing_price`, `date` 
            FROM secop_quote 
            WHERE `company_id`=%d 
            ORDER BY `date`"""%(cp)
    
    sql_prognose = """SELECT `new_price`, `target_date`
            FROM `secop_prediction`
            WHERE `company_id` = %d
            AND `target_date` > (SELECT CURDATE())
            AND `new_price` > 0"""%(cp)
    
    
    #fig = figure()
    #ax = fig.add_subplot(111)    
    
    avg_kurse = connector.get_select(sql)
    kurse_training = connector.get_select(sql_training)
    kurse_testing = connector.get_select(sql_testing)
    prognose = connector.get_select(sql_prognose)
    
    avg = [q[0] for q in avg_kurse]
    datum_avg = [q[1] for q in avg_kurse]
    #datum_avg =dates.date2num(datum_avg)
    
    trainya = calculate_data.train_machine(kurse_training)
    
    testinya = calculate_data.get_testing_data(kurse_testing)
    
        
    ###################################################
    #predict training and testing data --> consistency, validity
    ##################################################
    consistency = calculate_data.predict_own(trainya)
    testing_check = calculate_data.predict_own(testinya)
    
    
    sigma_training = calculate_data.get_sigma(consistency,[q[1] for q in calculate_data.training_predictions_and_dates_list])
    #print sigma_training
    #konsitenz = [consistency, [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    konsistenz_sigma = sigma_training
    
    sigma_testing = calculate_data.get_sigma(testing_check,[q[1] for q in calculate_data.testing_predictions_and_dates_list])
    #print sigma_testing
    #plot.plot_own_forecast_line_2(testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list],sigma_testing,'yellow',ax,fig)
    validity = [testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    validity_sigma = sigma_testing
    
    ################################# predict future
    prognose_kurs = calculate_data.get_future_data(prognose)
    predictions = calculate_data.predict_own(prognose_kurs)
    mittelwert = calculate_data.get_mittelwert_2(predictions)
    Varianz_prog = calculate_data.get_varianz(mittelwert,[q[1] for q in calculate_data.forecast_predictions_and_dates_list])
    sigma_prog = np.sqrt(Varianz_prog)
    
    #print sigma_prog
    #plot.plot_own_forecast_line_2(predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list],sigma_prog,'red',ax,fig)
    prognosis = [predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    prognosis_sigma = sigma_prog
    #plot analysten prognosen zum vergleich
    #plot.plot_future([q[1] for q in calculate_data.forecast_predictions_and_dates_list],[q[0] for q in calculate_data.forecast_predictions_and_dates_list],'yellow',ax,fig)
    #plot.plot_avg(datum_avg,avg,ax,fig)    
    #plot.show_plot(ax,fig)
    
    #training_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * konsistenz_sigma) for q in consistency], [dates.num2date(q[0]) for q in calculate_data.training_predictions_and_dates_list]]
    training_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * konsistenz_sigma) for q in consistency], [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    
    #training_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * konsistenz_sigma) for q in consistency], [dates.num2date(q[0]) for q in calculate_data.training_predictions_and_dates_list]]
    training_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * konsistenz_sigma) for q in consistency], [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    
    #testing_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * validity_sigma) for q in validity], [dates.num2date(q[0]) for q in calculate_data.testing_predictions_and_dates_list]]
    testing_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * validity_sigma) for q in validity], [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    
    #testing_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * validity_sigma) for q in validity], [dates.num2date(q[0]) for q in calculate_data.testing_predictions_and_dates_list]] 
    testing_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * validity_sigma) for q in validity], [q[0] for q in calculate_data.testing_predictions_and_dates_list]] 
    
    #prognose_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * prognosis_sigma) for q in prognosis], [dates.num2date(q[0]) for q in calculate_data.forecast_predictions_and_dates_list]]
    prognose_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * prognosis_sigma) for q in prognosis], [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    
    #prognose_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * prognosis_sigma) for q in prognosis], [dates.num2date(q[0]) for q in calculate_data.forecast_predictions_and_dates_list]] 
    prognose_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * prognosis_sigma) for q in prognosis], [q[0] for q in calculate_data.forecast_predictions_and_dates_list]] 
    
    #tats_kurse_datum = [dates.num2date(datum_avg),avg]
    tats_kurse_datum = [datum_avg,avg]
    
    #prognosekurse_analysten_datum = [[q[1] for q in calculate_data.forecast_predictions_and_dates_list],[dates.num2date(q[0]) for q in calculate_data.forecast_predictions_and_dates_list]]
    prognosekurse_analysten_datum = [[q[1] for q in calculate_data.forecast_predictions_and_dates_list],[q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    
    #training_unsere_vorhersage_linie = [consistency, [dates.num2date(q[0]) for q in calculate_data.training_predictions_and_dates_list]]
    training_unsere_vorhersage_linie = [consistency, [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    
    #testing_unsere_vorhersage_linie = [testing_check, [dates.num2date(q[0]) for q in calculate_data.testing_predictions_and_dates_list]]
    testing_unsere_vorhersage_linie = [testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    
    #prognose_unsere_vorhersage_linie = [predictions, [dates.num2date(q[0]) for q in calculate_data.forecast_predictions_and_dates_list]]
    prognose_unsere_vorhersage_linie = [predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]    
    
    
    result_set = []
    result_set.append(training_konfidenz_intervall_95_sigma_oben)
    result_set.append(training_konfidenz_intervall_95_sigma_unten)
    result_set.append(testing_konfidenz_intervall_95_sigma_oben)
    result_set.append(testing_konfidenz_intervall_95_sigma_unten)
    result_set.append(prognose_konfidenz_intervall_95_sigma_oben)
    result_set.append(prognose_konfidenz_intervall_95_sigma_unten)
    result_set.append(tats_kurse_datum) 
    result_set.append(prognosekurse_analysten_datum)
    result_set.append(training_unsere_vorhersage_linie)
    result_set.append(testing_unsere_vorhersage_linie)
    result_set.append(prognose_unsere_vorhersage_linie)
    result_set.append(konsistenz_sigma)
    result_set.append(validity_sigma)
    result_set.append(prognosis_sigma)
    
    
    calculate_data.reset_global_variables()
    calculate_data.initialize_global_variables()
    
    return result_set
    
def main(cp,conn,cursor):
    sql_training = """SELECT neues_kursziel, zieldatum,avg FROM analyst_avg_2 WHERE unternehmen = %d  AND avg_datum>'2010-01-01'AND avg_datum<'2012-03-01'"""%(cp)
    sql_testing = """SELECT neues_kursziel, zieldatum, analyst, avg FROM analyst_avg_2 WHERE unternehmen = %d  AND avg_datum>'2012-03-01' AND avg_datum<(SELECT CURDATE())"""%(cp)
    sql = "SELECT close , `datum` FROM kursdaten WHERE unternehmen =%d ORDER BY `datum"%(cp)
    
    sql_prognose = """SELECT neues_kursziel, zieldatum FROM prognose
     WHERE unternehmen = %d
     AND `zieldatum`>(SELECT CURDATE()) AND neues_kursziel >0
     """%(cp)
    
    
    #fig = figure()
    #ax = fig.add_subplot(111)    
    
    avg_kurse = calculate_data.get_select(sql,cursor,conn)
    kurse_training = calculate_data.get_select(sql_training,cursor,conn)
    kurse_testing = calculate_data.get_select(sql_testing,cursor,conn)
    prognose = calculate_data.get_select(sql_prognose,cursor,conn)
    
    avg = [q[0] for q in avg_kurse]
    datum_avg = [q[1] for q in avg_kurse]
    datum_avg =dates.date2num(datum_avg)
    trainya = calculate_data.train_machine(kurse_training)
    
    testinya = calculate_data.get_testing_data(kurse_testing)
    
        
    ###################################################
    #predict training and testing data --> consistency, validity
    ##################################################
    consistency = calculate_data.predict_own(trainya)
    testing_check = calculate_data.predict_own(testinya)
    
    
    sigma_training = calculate_data.get_sigma(consistency,[q[1] for q in calculate_data.training_predictions_and_dates_list])
    #print sigma_training
    #plot.plot_own_forecast_line_2(consistency, [q[0] for q in calculate_data.training_predictions_and_dates_list],sigma_training,'green',ax,fig) 
    konsitenz = [consistency, [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    konsistenz_sigma = sigma_training
    
    sigma_testing = calculate_data.get_sigma(testing_check,[q[1] for q in calculate_data.testing_predictions_and_dates_list])
    #print sigma_testing
    #plot.plot_own_forecast_line_2(testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list],sigma_testing,'yellow',ax,fig)
    validity = [testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    validity_sigma = sigma_testing
    
    ################################# predict future
    prognose_kurs = calculate_data.get_future_data(prognose)
    predictions = calculate_data.predict_own(prognose_kurs)
    mittelwert = calculate_data.get_mittelwert_2(predictions)
    Varianz_prog = calculate_data.get_varianz(mittelwert,[q[1] for q in calculate_data.forecast_predictions_and_dates_list])
    sigma_prog = np.sqrt(Varianz_prog)
    #print sigma_prog
    #plot.plot_own_forecast_line_2(predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list],sigma_prog,'red',ax,fig)
    prognosis = [predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    prognosis_sigma = sigma_prog
    #plot analysten prognosen zum vergleich
    #plot.plot_future([q[1] for q in calculate_data.forecast_predictions_and_dates_list],[q[0] for q in calculate_data.forecast_predictions_and_dates_list],'yellow',ax,fig)
    #plot.plot_avg(datum_avg,avg,ax,fig)    
    #plot.show_plot(ax,fig)
    
    training_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * konsistenz_sigma) for q in consistency], [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    training_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * konsistenz_sigma) for q in consistency], [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    testing_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * validity_sigma) for q in validity], [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    testing_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * validity_sigma) for q in validity], [q[0] for q in calculate_data.testing_predictions_and_dates_list]] 
    prognose_konfidenz_intervall_95_sigma_oben = [[(q+ 1.9600 * prognosis_sigma) for q in prognosis], [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    prognose_konfidenz_intervall_95_sigma_unten = [[(q- 1.9600 * prognosis_sigma) for q in prognosis], [q[0] for q in calculate_data.forecast_predictions_and_dates_list]] 
    tats_kurse_datum = [datum_avg,avg]
    prognosekurse_analysten_datum = [[q[1] for q in calculate_data.forecast_predictions_and_dates_list],[q[0] for q in calculate_data.forecast_predictions_and_dates_list]]
    training_unsere_vorhersage_linie = [consistency, [q[0] for q in calculate_data.training_predictions_and_dates_list]]
    testing_unsere_vorhersage_linie = [testing_check, [q[0] for q in calculate_data.testing_predictions_and_dates_list]]
    prognose_unsere_vorhersage_linie = [predictions, [q[0] for q in calculate_data.forecast_predictions_and_dates_list]]    
    
    
    result_set = []
    result_set.append(training_konfidenz_intervall_95_sigma_oben)
    result_set.append(training_konfidenz_intervall_95_sigma_unten)
    result_set.append(testing_konfidenz_intervall_95_sigma_oben)
    result_set.append(testing_konfidenz_intervall_95_sigma_unten)
    result_set.append(prognose_konfidenz_intervall_95_sigma_oben)
    result_set.append(prognose_konfidenz_intervall_95_sigma_unten)
    result_set.append(tats_kurse_datum) 
    result_set.append(prognosekurse_analysten_datum)
    result_set.append(training_unsere_vorhersage_linie)
    result_set.append(testing_unsere_vorhersage_linie)
    result_set.append(prognose_unsere_vorhersage_linie)
    result_set.append(konsistenz_sigma)
    result_set.append(validity_sigma)
    result_set.append(prognosis_sigma)
    
    
    calculate_data.reset_global_variables()
    calculate_data.initialize_global_variables()
    
    return result_set
    
def main(cp):    
    sql3 = """SELECT `new_price`, `target_date`, `analyst_id`, `avg` 
            FROM `analyst_avg_2`
            WHERE `company_id` = %d 
            AND `new_price` >0 
            AND `avg_date`<'2012-01-01' 
            ORDER BY `avg_date`, `target_date` """%(cp)
    
    sql = """SELECT `closing_price`, `date` 
            FROM secop_quote 
            WHERE `company_id`=%d 
            ORDER BY `date`"""%(cp)
    
    sql4 = """SELECT `new_price`, `target_date`, `analyst_id`
            FROM secop_prediction
            WHERE `company_id`= %d
            AND `target_date`>'2012-01-01' 
            AND `target_date`<(SELECT CURDATE()) 
            AND `new_price`>0
            ORDER BY `target_date`"""%(cp)

    avg_kurse = connector.get_select(sql)
    ziel_kurse = connector.get_select(sql3)
    prognose = connector.get_select(sql4)
    
    avg = [q[0] for q in avg_kurse]
    
    datum_avg = [q[1] for q in avg_kurse]
    #datum_avg =dates.date2num(datum_avg)
    
    #datum_ziel = [q[1] for q in ziel_kurse]
    #datum_ziel =dates.date2num(datum_ziel)
    
    #datum_prognose = [q[1] for q in prognose]
    #datum_prognose = dates.date2num(datum_prognose)
    
    #analysten_list = [q[2] for q in ziel_kurse]
    
    
    
    analysten_dict = calculate_data.get_analysten_dict(ziel_kurse)
    
    analysten_prognosen_dict = calculate_data.get_analysten_prognosen_dict(prognose)
    
    predictions_dict = calculate_data.get_prediction_dictionary(analysten_dict,analysten_prognosen_dict)
    predictions_and_dates_list = calculate_data.get_predictions_and_dates(predictions_dict)
    mittelwert = calculate_data.get_mittelwert(predictions_and_dates_list)
    Varianz = calculate_data.get_varianz(mittelwert,[q[1] for q in predictions_and_dates_list])
    standardabweichung = np.sqrt(Varianz)
    
    data_plot_future = calculate_data.get_data_for_plot_future(analysten_dict,analysten_prognosen_dict)
    data_plot_own_forecast_ponts = calculate_data.get_data_for_plot_own_forecast_points()
#    fig = figure()
#    ax = fig.add_subplot(111)
#    plot.plot_avg(datum_avg,avg,ax,fig)
#    plot.plot_future([q[0] for q in data_plot_future], [q[1] for q in data_plot_future],'yellow',ax,fig)
#    plot.plot_own_forecast_line([q[1] for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list],standardabweichung,ax,fig) 
#    plot.plot_own_forecast_points([q[0] for q in data_plot_own_forecast_ponts],[q[1] for q in data_plot_own_forecast_ponts],ax,fig)   
#    plot.show_plot(ax,fig)
    
    #konfidenz_intervall_95_sigma_oben = [[(q[1]+ 1.9600 * standardabweichung) for q in predictions_and_dates_list], [dates.num2date(q[0]) for q in predictions_and_dates_list]]
    konfidenz_intervall_95_sigma_oben = [[(q[1]+ 1.9600 * standardabweichung) for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]]
    
    #konfidenz_intervall_95_sigma_unten = [[(q[1]- 1.9600 * standardabweichung) for q in predictions_and_dates_list], [dates.num2date(q[0]) for q in predictions_and_dates_list]]
    konfidenz_intervall_95_sigma_unten = [[(q[1]- 1.9600 * standardabweichung) for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]]
    
    #tats_kurse_datum = [dates.num2date(datum_avg),avg]
    tats_kurse_datum = [datum_avg,avg]
    
    #prognosekurse_analysten_datum = [q[0] for q in data_plot_future], [dates.num2date(q[1]) for q in data_plot_future]
    prognosekurse_analysten_datum = [q[0] for q in data_plot_future], [q[1] for q in data_plot_future]
    
    #unsere_vorhersage_linie = [q[1] for q in predictions_and_dates_list], [dates.num2date(q[0]) for q in predictions_and_dates_list]
    unsere_vorhersage_linie = [q[1] for q in predictions_and_dates_list], [q[0] for q in predictions_and_dates_list]
    
    #unsere_vorhersage_punkte = [[q[0] for q in data_plot_own_forecast_ponts],[dates.num2date(q[1]) for q in data_plot_own_forecast_ponts]]
    unsere_vorhersage_punkte = [[q[0] for q in data_plot_own_forecast_ponts],[q[1] for q in data_plot_own_forecast_ponts]]
    
    
    standardfehler = calculate_data.get_data_test_MSE(data_plot_own_forecast_ponts,avg_kurse)    
    standardfehler = calculate_data.get_sigma([q[0] for q in standardfehler],[q[1] for q in standardfehler])
    print standardfehler
    
    result_set = []
    result_set.append(konfidenz_intervall_95_sigma_oben)
    result_set.append(konfidenz_intervall_95_sigma_unten)
    result_set.append(tats_kurse_datum)
    result_set.append(prognosekurse_analysten_datum)
    result_set.append(unsere_vorhersage_linie)
    result_set.append(unsere_vorhersage_punkte)
    result_set.append(standardabweichung)
    result_set.append(standardfehler)
    
    
    calculate_data.reset_global_variables()
    
    return result_set