def _gen_real_prices(self): ''' Attempt to generate real prices. Returns None if prices cannot be found ''' prices = Ticker(f'{self.code}.AX').history(start=self.dates[0], end=TOMORROW) if isinstance(prices, dict): return None prices = prices.reset_index()[['date', 'close']].set_index('date') prices.columns = ['price'] return prices
def load_data(codes, start=str(LAST_WEEK), end=TOMORROW, verbose=True): ''' Takes list of shares and returns data from the start date ''' daily = pd.DataFrame({'date': []}) codes = tqdm(codes) if verbose else codes # Load data for code in codes: df = Ticker(f'{code}.AX').history(start=start, end=end).reset_index()[['date', 'close']] df.columns = ['date', code] daily = pd.merge(daily, df, on='date', how='outer') daily['date'] = pd.to_datetime(daily.date) daily = daily.sort_values('date').ffill().set_index('date') return daily
# https://gist.github.com/rodrigobercini/8bbee7fc735ad7d696f7a2ec31df9610 from yahooquery import Ticker # Período máximo petr = Ticker("PETR4.SA") petr.history(period='max') # Datas específicas petr.history(start='2005-05-01', end='2013-12-31') # Intraday - 30 minutos abev = Ticker('ABEV3.SA') abev.history(period='60d', interval="30m") # Intraday - 1 minuto abev = abev.history(period='7d', interval="1m") abev # Informações financeiras petr = Ticker("PETR4.SA") # Coleta dados petr = petr.income_statement() # Chama função de Demonstração de resultados petr = petr.transpose() # Transpõe a matriz petr.columns = petr.iloc[0, :] # Renomeia colunas petr = petr.iloc[2:, :-1] # Seleciona dados petr = petr.iloc[:, ::-1] # Inverte colunas petr
from yahooquery import Ticker # financial report petr = Ticker("PETR4.SA") # Pick up data petr = petr.income_statement() # Call income statement function petr = petr.transpose() # Transpor matrix petr.columns = petr.iloc[0, :] # Rename columns petr = petr.iloc[2:, :-1] # Select data petr = petr.iloc[:, ::-1] # Invert columns print(petr)
support_lines = None for ta in tas: data = Data() data.support_lines = ta.resistance_lines("s") data.resistance_lines = ta.resistance_lines("r") ta.run(run, data) plot_ta(ta) current_price = ta.data['close'].iloc[-1] support = last_resistance_line(ta.resistance_lines('s')) support_distance = -(current_price - support) / current_price * 100 resistance = last_resistance_line(ta.resistance_lines('r')) resistance_distance = (resistance - current_price) / current_price * 100 print("{:4.2f} {:4.2f} {:4.2f} {:4.2f} {:4.2f}".format( current_price, support, support_distance, resistance, resistance_distance)) # plot_ta(ta) print(symbol_list) print(tickers[0].asset_profile) exit(0) # Informações financeiras petr = Ticker("PETR4.SA") petr = petr.income_statement() petr = petr.transpose() petr.columns = petr.iloc[0, :] petr = petr.iloc[2:, :-1] petr = petr.iloc[:, ::-1] print(petr)