def download_data_from_yahoo(symbol, adjust=True, backfill=False, start_date=config.start_date, end_date=config.end_date): """Generates a .csv file containing the high, low, open, close, volume, and adjusted close by date from Yahoo for the given symbol For currency conversion rates, the format is like "USDCAD=X" For the S&P500 index, Yahoo uses the ticker GSPX. This function is hardcoded to query Yahoo using GSPX instead of SP500, but save the data to SP500. Parameters: symbol : str adjust : bool Whether to incluse the AdjClose column or not. Uses my implementation, not Yahoo's backfill : bool, optional start_date : date, optional end_date : date, optional Returns: dataframe A dataframe containing high, low, open, close, volume, and adjusted close by date for the given symbol """ # Get some extra data to minimize refreshing if start_date > config.start_date: start_date = config.start_date if end_date < config.end_date: end_date = config.end_date with utils.HiddenPrints(): df = yf.Ticker(symbol).history(auto_adjust=False, start=start_date, end=end_date) # This causes an error with pandas, so we're using yfinance instead # if dividends causes errors, go to the error and remove the 'eval' # df = dr.get_data_yahoo(symbol, start_date, end_date) # df = df.merge(dr.DataReader(symbol, 'yahoo-dividends', start_date, end_date), how='outer', left_index=True, right_index=True) if symbol.upper() in yf.shared._ERRORS: raise RemoteDataError("No data fetched for symbol " + symbol + " using yfinance") df.drop("Adj Close", axis=1, inplace=True) df.drop("Stock Splits", axis=1, inplace=True) if adjust: df["AdjClose"] = df["Close"].add(df["Dividends"].cumsum()) if backfill: utils.backfill(df) # df.sort_index(inplace=True) # Yahoo data is sorted anyways utils.debug(df) df.to_csv( utils.get_file_path(config.prices_data_path, price_table_filename, symbol=symbol)) return df
import os sys.path.insert(0, '..') import numpy as np from gym.spaces import Discrete, Box from featureExtractor.drone_feature_extractor import total_angle_between from featureExtractor.drone_feature_extractor import DroneFeatureSAM1, DroneFeatureMinimal, DroneFeatureOccup, DroneFeatureRisk, DroneFeatureRisk_v2 from featureExtractor.drone_feature_extractor import DroneFeatureRisk_speed from envs.drone_env_utils import InformationCollector from alternateController.potential_field_controller import PotentialFieldController as PFController from alternateController.social_forces_controller import SocialForcesController from itertools import count import utils # NOQA: E402 from envs.gridworld import GridWorld from envs.drone_env_utils import angle_between import copy with utils.HiddenPrints(): import pygame import pygame.freetype def deg_to_rad(deg): return deg*np.pi/180 def rad_to_deg(rad): return rad*180/np.pi def get_rot_matrix(theta): ''' returns the rotation matrix given a theta value(radians) '''
import os import argparse import utils as ut desc_msg = 'MNIST segmentation using tensorflow and some sort of LeNet-5' parser = argparse.ArgumentParser(desc_msg) ### START: Select the device where the operations will be executed # All posible choices for device selection # Hidde debug infro from tf... https://stackoverflow.com/a/38645250/5969548 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' from tensorflow.python.client import device_lib with ut.HiddenPrints(): all_devices = device_lib.list_local_devices() choices = [] for i in range(len(all_devices)): choices.append(i) device_default = choices[-1] msg = 'Select which device tf should use for the ops.'\ +' 0: CPU, 1>=GPU (if available).' parser.add_argument('-d','--device',help=msg,type=int, choices=choices,default=device_default)