Reference no: EM13842066
I am new to Phython. Using Spyder IDE Simple code. It is not recognizing by Data file see line 33.
I/O error TSX_Listing.cvs not found
# -*- coding: utf-8 -*-
"""
Assignment 1 Sample code: Python code for grabbing data from Yahoo!Finance
Note: This code guides you to grab Canadian stock returns data from Yahoo!Finance.
The purpose of this assignment is to get you familiar with the Python. Enjoy!
Reference: https://pandas.pydata.org/pandas-docs/stable/remote_data.html
Source file https://github.com/pydata/pandas/blob/master/pandas/io/data.py
"""
# Load packages
import pandas.io.data as web
import datetime
import pandas as pd
import os
import numpy as np
import statsmodels.formula.api as sm
#create your current working directory of the located .py file
directory = 'C:\\Users\\maryannp\\Documents\\Phython Scripts\\Assignment#1'
#Choose your starting and ending time
start = datetime.datetime(2014, 1, 1) #(YYYY, m, d)
end = datetime.datetime(2014, 12, 31)
#Load the csv file with the TSX Tickers, this code assume that the ticker files
#located in the same folder as the directory
tickers = pd.read_csv(directory + '\\' + 'TSX_Listing.csv')
tickers = list(tickers['YAHOO_TICKER'])
#Intiate the dictionnary that will store all the downloaded tick data
d = pd.DataFrame()
# Options for web.DataReader function:
"""
input 1: ticker in string form - Ex: OSPTX is for the S&P/TSX
input 2: the source (ex: 'yahoo' or 'google') to download the data from
input 3: start time in datatime.datetime format
input 4: end time in datatime.datetime format
"""
#Loop over each tickers to load the data to be stored in the dictionnary d
for tick in tickers:
f = web.DataReader(tick, 'yahoo', start, end)
d[tick] = f['Adj Close'] # select the adjusted close price
# how to calculate simple returns
ret=d.pct_change()
#Example on how to compute the log returns for all the stocks in d
d_lret = np.log(d) - np.log(d.shift())
#export the return data to csv file
d_lret.to_csv ('C:\\Users\\maryannp\\Documents\\Phyton Scripts\\Assignment#1\\TSX_data2014.csv')
Attachment:- TSX_Listing.csv
Perform preliminary SWOT analysis
: Based on the information provided on the website, describe Sony's SBUs. Does Sony have SBUs that are divisions, product lines, or some other profit center structure within the parent company? Assess the quality and effectiveness of Sony's website. Sp..
|
What is corporate entrepreneurship
: In your own words, what is corporate entrepreneurship? What are some of the corporate obstacles that must be overcome to establish a corporate entrepreneurial environment? What are some of the innovative principles identified by James Brian Quinn tha..
|
External resource approach and internal systems approach
: As a leader in business, what one would be your preferred approach (External Resource Approach / Internal Systems Approach / Technical Approach) and why? Have you had the opportunity to experience any of them first hand?
|
Most projects overrun their budget
: Did you overrun the project budget again? Discuss from your experience some of the most important components of good project management practices. What is your view on the statement "Most projects overrun their budget?" Give specific examples from yo..
|
Python code for grabbing data from yahoo finance
: I am new to Phython. Using Spyder IDE Simple code. It is not recognizing by Data file see line 33 - The purpose of assignment is to get you familiar with the Python.
|
Ethically responsible for what occurred
: Identify a company you believe is/was ethically responsible for what occurred. How would you have approached this differently as the CEO/Marketer to ensure this hadn't happened? Be sure to share the URL with your fellow students of the organization y..
|
The glass ceiling is an invisible barrier
: The textbook states the "glass ceiling" is an invisible barrier that exists for women and minorities that limits their upward mobility. Do you feel this ceiling still exists? Why?
|
Helpful in measuring nonfinancial performance
: Research Six Sigma, Balanced Scorecard, and Triple Bottom Line. (A Google search with ethics AND the chosen model works well.) Which do you think would be most helpful in measuring nonfinancial performance? Why?
|
Planning and goals are important part of any undertaking
: Planning and goals are an important part of any undertaking. Who do you feel they should be including in business planning and why
|