def add_csv(self, file_dir="./storage/", symbolID=None, period=None): print("Setting csv: ", file_dir, ",symbol: ", symbolID, ", period: ", period) # Loads a CSV and adds its values to the main structure symbolID, period = self.get_final_SymbolID_period(symbolID, period) newTD = DBl.load_TD_from_csv(file_dir, symbolID, period) self.add_TD(newTD)
def set_csv(self, file_dir = "./storage/", symbolID = None, period = None): # Loads a CSV from the folder with the naming convention for the period. # The file must have the path: ./TimeScale/symbolName_TimeScale.csv # If we did not specify the symbolID or period and we set them in the # initialization it will get them from there # specific and adds its values to the main structure symbolID, period = self.get_final_SymbolID_period(symbolID, period) TD = DBl.load_TD_from_csv(file_dir,symbolID,period) self.set_TD(TD)
def set_csv(self, file_dir = "./storage/", file_name = None, symbolID = None, period = None): # This function loads the data from the file file_dir + file_name if file_name is provided # Otherwise it uses the naming convention to find it from the root folder: # The file must have the path: ./TimeScale/symbolName_TimeScale.csv # If we did not specify the symbolID or period and we set them in the # initialization it will get them from there # specific and adds its values to the main structure symbolID, period = self.get_final_SymbolID_period(symbolID, period) TD = DBl.load_TD_from_csv(file_dir,file_name,symbolID,period) self.set_TD(TD)
def set_csv(self, file_dir="./storage/", file_name=None, symbolID=None, period=None): # This function loads the data from the file file_dir + file_name if file_name is provided # Otherwise it uses the naming convention to find it from the root folder: # The file must have the path: ./TimeScale/symbolName_TimeScale.csv # If we did not specify the symbolID or period and we set them in the # initialization it will get them from there # specific and adds its values to the main structure symbolID, period = self.get_final_SymbolID_period(symbolID, period) TD = DBl.load_TD_from_csv(file_dir, file_name, symbolID, period) self.set_TD(TD)
updates_folder] = ul.get_foldersData(source=dataSource) folder_images = "../pics/gl/" ######## SELECT SYMBOLS AND PERIODS ######## symbols = ["XAUUSD", "Mad.ITX", "EURUSD"] symbols = ["Alcoa_Inc"] symbols = ["Amazon", "Alcoa_Inc"] periods = [15] ######## SELECT DATE LIMITS ########### sdate = dt.datetime.strptime("21-11-2016", "%d-%m-%Y") #edate = dt.datetime.strptime("25-11-2016", "%d-%m-%Y") edate = dt.datetime.now() ######## CREATE THE OBJECT AND LOAD THE DATA ########## # Tell which company and which period we want timeData = CTD.CTimeData(symbols[0], periods[0]) TD = DBl.load_TD_from_csv(storage_folder, symbols[1], periods[0]) timeData.set_csv(storage_folder) # Load the data into the model timeData.set_TD(TD) cmplist = DBl.read_NASDAQ_companies( whole_path="../storage/Google/companylist.csv") cmplist.sort_values(by=['MarketCap'], ascending=[0], inplace=True) symbolIDs = cmplist.iloc[0:30]["Symbol"].tolist() timeData.set_TD_from_google("AAPL", 5, "3d") #####################################################################3 timeData.set_interval(sdate, edate) opentime, closetime = timeData.guess_openMarketTime() period = timeData.guess_period() print "Period: %f" % period print "Market Hours " + str(opentime) + " - " + str(closetime)
[storage_folder, info_folder, updates_folder] = ul.get_foldersData(source = dataSource) folder_images = "../pics/gl/" ######## SELECT SYMBOLS AND PERIODS ######## symbols = ["XAUUSD","Mad.ITX", "EURUSD"] symbols = ["Alcoa_Inc"] symbols = ["Amazon", "Alcoa_Inc"] periods = [15] ######## SELECT DATE LIMITS ########### sdate = dt.datetime.strptime("21-11-2016", "%d-%m-%Y") edate = dt.datetime.strptime("25-11-2016", "%d-%m-%Y") ######## CREATE THE OBJECT AND LOAD THE DATA ########## # Tell which company and which period we want timeData = CTD.CTimeData(symbols[0],periods[0]) TD = DBl.load_TD_from_csv(storage_folder, symbols[1],periods[0]) timeData.set_csv(storage_folder) # Load the data into the model timeData.set_TD(TD) ############## Obtain time series ########################### price = timeData.get_timeSeries(["Close", "Average"]); ############# Plot time Series and save it to disk ######### gl.plot([],price) datafolder = "../maildata/" picdir = datafolder + "pene.png" gl.savefig(picdir) ########################################################################### ############## BASIC PLOTING FUNC ######################################### ###########################################################################
def add_csv(self, file_dir = "./storage/", symbolID = None, period = None): # Loads a CSV and adds its values to the main structure symbolID, period = self.get_final_SymbolID_period(symbolID, period) newTD = DBl.load_TD_from_csv(file_dir,symbolID,period) self.add_TD(newTD)