# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + colab={"base_uri": "https://localhost:8080/"} id="VvMG8jtJfo8a" outputId="63924f21-6665-4381-903b-5deb2d389489"
list1 = ['Symbol', 'AAPL', 'F', 'AMD', 'DIDI', 'VICI']
list1[1:]

# + colab={"base_uri": "https://localhost:8080/"} id="iEKcJyFdfua0" outputId="b476e8f7-b1dc-4eac-e016-ac224d19fc95"
# #!pip install yfinance

# + colab={"base_uri": "https://localhost:8080/", "height": 426} id="rnB0b_XefsvU" outputId="b0cb9e05-baf5-4a4a-809f-5c921f081205"
import yfinance as yf
import csv
import pandas as pd
import numpy as np

urls=list1[1:]
shortName = []
symbol = []
volume = []
currentPrice = []
averageVolume = []
previousClose = []
for url in urls:
    tickerTag = yf.Ticker(url)
    shortName.append(tickerTag.info['shortName'])
    symbol.append(tickerTag.info['symbol'])
    volume.append(tickerTag.info['volume'])
    currentPrice.append(tickerTag.info['currentPrice'])
    averageVolume.append(tickerTag.info['averageVolume'])
    previousClose.append(tickerTag.info['previousClose'])
print(shortName)
print(symbol)
print(volume)
print(currentPrice)
print(averageVolume)
print(previousClose)

data = [
    shortName,
    symbol,
    volume,
    currentPrice,
    averageVolume,
    previousClose,
]

df = pd.DataFrame(columns=[list1[1:]], data=data)
df

# + id="0uYkevDPf_mj"
list = ['Symbol', 'AAPL', 'F', 'AMD', 'DIDI', 'VICI', 'NIO', 'INTC', 'T', 'VALE', 'BAC', 'NVDA', 'FB', 'BABA', 'NOK', 'ITUB', 'BBD', 'NLY', 'TWTR', 'SWN', 'MSFT', 'SNAP', 'CMCSA', 'TDOC', 'VZ', 'PBR', 'HOOD', 'SOFI', 'SIRI', 'ABEV', 'PLTR', 'TSLA', 'BMY', 'PDD', 'PCG', 'XOM', 'KMI', 'BEKE', 'UBER', 'IQ', 'GGB', 'CLF', 'X', 'DKNG', 'C', 'AAL', 'PYPL', 'ABBV', 'CCL', 'AMC', 'KO', 'HBAN', 'OXY', 'PFE', 'WFC', 'TLRY', 'LYG', 'RBLX', 'TELL', 'GOLD', 'JD', 'WBD', 'LCID', 'AMCR', 'CS', 'DNA', 'ROKU', 'FCX', 'MU', 'DIS', 'GM', 'RIG', 'AUY', 'ET', 'PLUG', 'ZNGA', 'MRK', 'AGNC', 'KGC', 'LUMN', 'PBR-A', 'BP', 'NFLX', 'BSX', 'PINS', 'CL', 'JPM', 'CVE', 'CVX', 'TME', 'AVTR', 'GRAB', 'FTI', 'CSCO', 'QCOM', 'DAL', 'BKR', 'IBN', 'MRO', 'WU', 'APA']

# + colab={"base_uri": "https://localhost:8080/"} id="_0N5-kjXgApK" outputId="784eab8e-ac2e-491a-d8e0-90e619779c44"
list[1:]
print(list[1:10])

# + colab={"base_uri": "https://localhost:8080/", "height": 461} id="dzQL_YnHgFQq" outputId="c725f407-5820-4c5d-ec9b-59a621f9f460"
import yfinance as yf
import csv
import pandas as pd
import numpy as np

urls=list[1:10]
shortName = []
symbol = []
volume = []
currentPrice = []
averageVolume = []
previousClose = []
for url in urls:
    tickerTag = yf.Ticker(url)
    shortName.append(tickerTag.info['shortName'])
    symbol.append(tickerTag.info['symbol'])
    volume.append(tickerTag.info['volume'])
    currentPrice.append(tickerTag.info['currentPrice'])
    averageVolume.append(tickerTag.info['averageVolume'])
    previousClose.append(tickerTag.info['previousClose'])
print(shortName)
print(symbol)
print(volume)
print(currentPrice)
print(averageVolume)
print(previousClose)

data = [
    shortName,
    symbol,
    volume,
    currentPrice,
    averageVolume,
    previousClose,
]

df = pd.DataFrame(columns=[list[1:10]], data=data)
df

# + id="7ucCLCpxiQ9_"
df.to_csv('data.csv')

# + colab={"base_uri": "https://localhost:8080/"} id="P8LBsJ89liv_" outputId="a4183cde-9e12-4147-a2e2-9736b5888864"
# reading a second row in csv
import csv
noise_amp=[]         #an empty list to store the second column
with open('data.csv', 'r') as rf:
    reader = csv.reader(rf, delimiter=',')
    for row in reader:
        noise_amp.append(row[1]) # which row we need to read , 1 is frist row , 2 is second row
    print(noise_amp)


StarcoderdataJupyterScriptsDedupFiltered