Example #1
0
    def __init__(self, PathData=None):

        Log.__init__(self, PathData=PathData)

        if PathData is None:
            self.PathData = os.path.dirname(os.getcwd()) + '/data/'
        else:
            self.PathData = PathData

        self.ListOfCompanies = pd.read_csv(self.PathData +
                                           'company_lists/full_list.csv',
                                           index_col='Unnamed: 0')
Example #2
0
    def __init__(self, FileNameListOfCompanies=None, PathData=None):

        Log.__init__(self, PathData=PathData)

        if PathData is None:
            self.PathData = os.path.dirname(os.getcwd()) + '/data/'

        else:
            self.PathData = PathData

        if FileNameListOfCompanies is None:
            self.FileNameListOfCompanies = 'full_list.csv'

        else:
            if os.path.isfile(self.PathData + 'company_lists/' +
                              FileNameListOfCompanies) is True:
                self.FileNameListOfCompanies = FileNameListOfCompanies
            else:
                self.logging("ValueError: List :" + FileNameListOfCompanies +
                             "does not exists in " + self.PathData +
                             "company_lists/")
                raise ValueError('List: ' + FileNameListOfCompanies +
                                 ' does not exists in' + self.PathData +
                                 'company_lists/')

        self.ListOfCompanies = pd.read_csv(self.PathData + 'company_lists/' +
                                           self.FileNameListOfCompanies,
                                           index_col='Unnamed: 0')

        URL_list = self.ListOfCompanies['URL'].tolist()

        URL_list = [
            url.replace('aktien', 'analysen').replace('Aktie', 'Analysen')
            for url in URL_list
        ]

        self.ListOfCompanies.loc[:, 'URL'] = URL_list

        if os.path.exists(self.PathData +
                          'analysts_comments/stocks/') is False:
            os.makedirs(self.PathData + 'analysts_comments/stocks/')
Example #3
0
    def __init__(self, duration, PathData=None):

        Log.__init__(self, PathData=PathData)

        if PathData is None:
            self.PathData = os.path.dirname(os.getcwd()) + '/data/'
        else:
            self.PathData = PathData

        self.PathPrediction = self.PathData + '/predictions/stocks/'

        self.duration = duration

        #check if database exists other wise create empty db
        if os.path.isfile(self.PathPrediction + 'predictions.db') == False:
            db = sql.connect(self.PathPrediction + 'predictions.db')
            db.close()

        #check if appropriate tables exists otherwise create them
        else:
            db = sql.connect(self.PathPrediction + 'predictions.db')

            cursor = db.cursor()
            cursor.execute(
                "SELECT name FROM sqlite_master WHERE type='table';")

            tableNames = cursor.fetchall()

            if np.all(
                    np.array([
                        x[0] == "prediction" + str(self.duration) + "BT"
                        for x in tableNames
                    ]) == False):

                cursor.execute('''CREATE TABLE prediction''' +
                               str(self.duration) +
                               '''BT(id INTEGER PRIMARY KEY,
				Label TEXT,
				LastTrainingsDate DOB,
				PredictionDay DOB,
				ValidationDay DOB,
				PrizeAtPrediction FLOAT,
				PrizeAtValidation FLOAT,
				RelativePrizeChange FLOAT,
				TrueCategory INT,
				PredictedCategory INT,
				PredictedUpperPrize FLOAT,
				PredictedLowerPrize FLOAT,
				ProbCat0 FLOAT,
				ProbCat1 FLOAT,
				ProbCat2 FLOAT,
				ProbCat3 FLOAT,
				ProbCat4 FLOAT,
				ProbCat5 FLOAT,
				ProbCat6 FlOAT,
				ProbCat7 FLOAT,
				ProbCat8 FLOAT,
				ProbCat9 FLOAT,
				ProbCat10 FLOAT,
				ProbCat11 FLOAT,
				Timestamp DOB)''')
                db.commit()

            db.close()
Example #4
0
    def __init__(self,
                 duration,
                 FileNameListOfCompanies=None,
                 PathData=None,
                 PrizeThresholds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]):
        '''
		Parameters
		----------------
		PathData : string (default None) give manually working directory 

		FileNameListOfCompanies : string (default None) if not full list of companies is considered to update give filename.csv of indented list
						  the list has to be stored in "../data/company_lists/"


		ListOfChartFeatures: "GDXX" = moving average and number of days
							 "BB_20_2" = bolling bands (tau = 20 and k=2)
							 "RSI_14" = relative strength index (last 14 days)
							 "ADX" = average directional index
							 "MACD" = moving average convergence/divergence ###check number of days
							 "MAXxx" = moving maximum of xx days
							 "MINxx" = moving minimum of xx days
		'''

        Log.__init__(self, PathData=PathData)

        self.ListOfChartFeatures = [
            'GD200', 'GD100', 'GD50', 'GD38', 'BB_20_2', 'RSI7', 'RSI14',
            'RSI25', 'WR14', 'CCI20', 'ADX', 'MACD', 'MAX20', 'MAX65',
            'MAX130', 'MAX260', 'MIN20', 'MIN65', 'MIN130', 'MIN260', 'PVO',
            'TRIX', 'RSV14'
        ]
        '''
		PrizeThresholds : threshold to categorize relative (in percent) stock evolution within N days

		'''
        self.PrizeThresholds = PrizeThresholds
        self.duration = duration  #duration for which to compute classification

        if PathData is None:
            self.PathData = os.path.dirname(os.getcwd()) + '/data/'
        else:
            self.PathData = PathData

        #check for input ListOfCompanies
        if FileNameListOfCompanies is None:
            self.FileNameListOfCompanies = 'full_list.csv'

        else:
            if os.path.isfile(self.PathData + 'company_lists/' +
                              FileNameListOfCompanies) is True:
                self.FileNameListOfCompanies = FileNameListOfCompanies
            else:
                raise ValueError('List: ' + FileNameListOfCompanies +
                                 ' does not exists in' + self.PathData +
                                 'company_lists/')

        self.ListOfCompanies = pd.read_csv(self.PathData + 'company_lists/' +
                                           self.FileNameListOfCompanies,
                                           index_col='Unnamed: 0')

        #check if directories exists otherwise create them
        if os.path.exists(self.PathData + 'raw/stocks/') is False:
            os.makedirs(self.PathData + 'raw/stocks/')

        if os.path.exists(self.PathData + 'raw/stocks/backup/') is False:
            os.makedirs(self.PathData + 'raw/stocks/backup/')

        if os.path.exists(self.PathData + 'chart/stocks/') is False:
            os.makedirs(self.PathData + 'chart/stocks/')

        if os.path.exists(self.PathData + 'classification/stocks/duration_' +
                          str(self.duration)) is False:
            os.makedirs(self.PathData + 'classification/stocks/duration_' +
                        str(self.duration))