Muschamp Rd

3 More CFA Questions

March 4th, 2013

First of all it should go without saying, you have to pass the CFA exams yourself, it isn’t like “Who wants to be a millionaire?”, you don’t get to phone a friend when you get stuck. Secondly if you’re going to go to the trouble of finding my blog, then my phone number, which only appears on my resume, I’d appreciate it if you called me about a potential job offer, not some CFA questions you read in a book and are unsure how to solve.

I most definitely don’t have all the answers, I’m just a guy. Nonetheless here are the questions and my attempt to recollect the answers having not studied this material in well over a year. In future it would be better to post questions like these to an online forum such AnalystForums where multiple people could attempt them. I should probably crosspost…

Question 1

You buy a share of Microsoft in 1987 for $0.20 per share. You sell the stock for $32/share in 2012. What was your total return over your holding period? What was your annual return over this time period?

The return over a holding period is calculated as follows:

  • HPY = (P1 – P0 + D1) / P0 which in our case is: (32 – .2) / .2 = 159

The next part of the question is a bit less clear, the question is probably asking for the effective annual yield. Yield and return can be used almost interchangeably. Reading comprehension is a big part of the CFA exam in addition to memorization and ability to calculate solutions. The Investopedia provides the following formula:

  • HPY^(1/years held) all minus 1 which in our case is 159^(1/25) – 1 = .2248

Question 2

Stock A is selling for $100 per share today. You believe each share of Stock A will sell for $110 in one year. Your next best investment generates a 5% return per year. a. Is Stock A worth buying at $100 per share today? Why or why not? b. What is the highest price you would be willing to pay for Stock A? c. You find Bond B which promises 18% return per year. Does this change the price you are willing to pay for Stock A? If not, why not? If so, what is the new price you are willing to pay for Stock A?

Yes getting ten dollars profit in one year is better than getting five dollars profit in one year. A stock worth $110 in the future with interest rates at 5% is worth 104.76 now.

The final part of the question makes it abundantly clear that 18% is better than the return on the stock if you pay $104.76 per share, in order for the stock to become a better investment than the bond its current price must be 93.22 or lower.

Question 3

You buy a stock in Company B on January 1, 2000 for $100. The stock pays you a 1% dividend every quarter on the last day of the quarter. On January 1, 2002, the stock is selling for $100. Please assume that all dividends are reinvested in the stock, and that the stock price has remained at $100 throughout the 2 year period. What was your return over the 2 year holding period? What was your annual return?

This question is more difficult and would be better illustrated with a spreadsheet perhaps, but in the CFA exam you have your calculator and your wits, sometimes you lose one or the other… Where it says “Please assume that all dividends are reinvested in the stock” makes this question more complicated, but given that on the CFA Level 1 exam the answer has to be one of A, B, or C, the solution is most likely to use one of the many return or yield formulas or the Time Value of Money function on your calculator.

One thing that you have to learn is most yields are stated annually, 1% annually is actually .25 per quarter.

  • PV = -100
  • FV = 100
  • PMT = .25
  • N = 2 * 4
  • I =  CPT

I or I/Y or yield is .25 using my BA II Plus which I dug out to answer these questions, because in the exam you don’t get a laptop or Excel, knowing how to calculate the answer with Excel won’t help you come exam time. This is the quarterly return. Annualizing a quarterly return isn’t hard, but with the current numbers the answer comes back  a suspicious 1%. Which if I’m incorrect means I made a false assumption or this question is trying to be overly cute. Replacing PMT with 1 above yields an I/Y value of 1, but if you assume that is a quarterly rate and convert it to an annual rate using the formula linked to above, the answer is then .0406.

In a real exam you are very much pressed for time, you can’t look up formulas on the Internet, but sometimes you have to perform a calculation more than once just to be sure. Sometimes the answer will state .0406 another time it might be stated 4.06%, some questions might give you two answers that differ by a factor or 10 or 100. In the real CFA Level 1 exam every question is multiple choice and you have 1.5 minutes to answer each question, some questions will have two or more parts, that doesn’t mean they’ll give you more time. Sometimes you can get away with calculating only one part of a question and then using logic to deduce the other portion.

The other part of the question is easier to get an answer close to correct:

  • P1 = 100
  • P0 = 100
  • D = .25 * 8 (approximately)

The answer for holding period yield is about 2%. Many, many times on the CFA Level 1 exam it will say choose the answer closest to the correct value. Hopefully on an exam you can use these numbers to circle the correct answer, the formulas I’ve used I think are correct.

Even though I am unemployed, I do have stuff to do at 10:00 AM on Monday morning. I don’t mind trying to help people, well I do mind trying to help some people… I’ve made a lot of study materials available free of charge, some people think I should charge for them. It is definitely better to contact me via email or blog comment than by phone for questions regarding my blog. It is also probably in your best interest if you are stuck on a CFA question to find a study group or post questions to an online forum.

I passed the Level 1 CFA exam all by myself using primarily the official CFA curriculum books. That isn’t necessarily the easiest way, but there were reasons…

Finding audio previews for album tracks in iTunes with PHP

March 3rd, 2013

When I started building my mashups with PHP one idea I had was to fetch audio previews for songs and albums, this was actually supposedly possible with the Amazon Product Advertising API, but I could never get it to work with the limited data I had in my csv file. Last.fm does not provide audio previews through their API either. iTunes Music Store isn’t perhaps known for their API, nor can you earn any referral income if you’re Canadian but I actually was able to fetch direct links to audio previews from the iTunes Music Store using their Search API.

I’m not sure Apple would applaud this, I’ve been doing it for well over a year, but it is only used as part of one or two of my web mashups. I don’t think I violate the TOS, I do cache the returned JSON results but only to prevent repeated redundant calls to Apple’s API. I don’t cache images and certainly not audio previews. I’m not sure I meet their display requirements, frickin’ display requirements…

Considering how much time and effort I spent debugging and re-reading API documentation there may be other methods I’ve written which people would find useful, but no one uses because they don’t want to jump through all the hoops necessary to use my mashup codebase. Apple doesn’t require public and private keys or OAuth or hashing, you can just format a URL and get back data. It is up to you to format the URL correctly and parse the data, this is non-trivial.

My solution is part of my musicCollection.php class but it is actually three methods, one which makes requests to the other two. It is necessary to make multiple calls to Apple’s Search API in order to get the resulting preview tracks for the entire album. You can rip out the caching if you like. My caching technique isn’t terribly sophisticated, it is contained in caching.php and the code below may need one function from muskLib.php which is just a wrapper for cURL.  All this code is in GitHub.

I think I’ll finally switch my mashups to a CSV file that is a subset of my actual collection of albums as things will run faster and smoother. This code has been tested on 100s of different albums, if an album isn’t in iTunes or there are various different editions of an album, or there two albums by the same artist with the same album title…

There is no warranty or guarantee for this code and you are responsible for not breaking Apple’s Terms of Service and/or getting throttled for making excessive number of requests, I recommend you cache what you can.

Album track previews from iTunes working on my random CD mashup

Been Building Stuff with PHP

February 28th, 2013

Although it hasn’t helped me find a job, I’ve continued to build stuff with PHP. I’ve also been brushing up on my Objective-C. After upgrading to use Version 2 of the GData (YouTube) API I had to upgrade to Version 1.1 of the Twitter API. This took a lot more work especially trying to meet the display requirements. I’m not sure it is perfect, it is close and I’m still not a PHP guy. Once again I’ll decided to include the key code snippets in a blog post as no one uses them if I just check them into GitHub. Plus the code is probably more useful without all the overhead of every other API.

I’ve also been trying to use Masonry on top of my CD Cover Gallery but I have some bugs to work out. I have an open question on StackOverflow but it is plain I need to brush up on my JavaScript a lot more. I’m also not a JavaScript guy. The best code I’ve probably written of late is for searching Twitter and then displaying the tweets. My solution uses CodeBird and follows the same basic techniques as others.

Searching Twitter and Displaying the Tweets with PHP & CSS

  1. Register an app with Twitter, you will need a pair of keys and two more keys that represent your access token.
  2. Download and create an instance of CodeBird in your code. Instructions are linked to above.
  3. Borrow two functions from the web: relativeTime() and linkify_tweet().
  4. You need to include widgets.js in your client code, Twitter provides this.
  5. I created two methods, one for searching and one for displaying the returned tweets correctly. I put them in Pastebin in addition to GitHub.

You also need a whole bunch of CSS rules to make it look pretty:

Of course Pastebin always seems a bit wonky or at least their default embed code is… I think it doesn’t like being previewed by WordPress. I’ve also been trying to build another news aggregator/Internet dashboard. I’ve include a screenshot of it. I leverage SimplePie, Topsy, as well as iFrames and JavaScript widgets. I may end up using some of the PHP code above too.

My code almost meets the Twitter display requirements

My latest CD cover gallery is not quite functioning as intended

My WIP Internet Dashboard

Blocker iPhone Game Screenshot

Upcycled Furniture

February 26th, 2013

I read recently about a woman in Alaska who makes her living blogging about woodworking. Apparently that is another niche I missed out on when I set up Muskblog and Muschamp.ca, I’ve always liked working with wood. Ana White’s website supposedly gets 100,000 of readers a month, enabling her to sell advertisements and pay for her family expenses. Good for her.

Finished Upcycled TV Stand

This project isn’t going to win any awards it is not my best work. Middle school shop class was a long time ago and I didn’t even have the best tools or workspace. The project came about as my mom wanted a really low TV stand on castors to fit into her family room. She wanted to put her largest TV in the room she spends the most time in and she wanted it on wheels so it could be tucked back into the recess when my sister’s dogs came over. The TV can also be rotated for when she is sitting at her computer or has guests.

Tables to be Upcycled

She had been looking for one or something that could be adapted when we decided to brave the dangers of her basement and see what we could use from down there. The two end tables were someone’s school woodworking projects that were abandoned and saved by my Aunt. They were going to become just scrap wood, the best of them had already been upcycled by my grandfather and I years ago. I decided with some cutting of legs and merging two end tables together I could make a sturdy but small TV stand.

Both end tables were not well built, they were not finished, they were not planed well, they wobbled, etc. The first thing I did was put glue in all the gaps and cracks and really clamp it down. This made it sturdier but it became obvious that the tables weren’t perfectly square or level. I never had the best tools to work with, an old rusty handsaw, a rusty and bent t-square, I did have a sander which means about the only thing well done is the sanding on the table top. But you can’t sand out flaws in the wood.

More clamping and gluing

I did some measurements and calculations and once we found some really small casters I cut the four legs down and attached the second tabletop to the base of the better end table’s shortened legs. I then disassembled it for ease of painting and I tried to use a rasp to level the table, but removing a little the uneven legs. Eventually it had to be deemed good enough and it currently holds my grandmother’s old TV just fine. I wish it was a tad wider, but the whole thing cost less than ten dollars.

At some point my mom got her kitchen countertops replaced and a tile backsplash put in and some other updates to her house in Deep Bay. She got the bright idea to change out the old sockets and switches to the new style, but in black with aluminium trim. Unfortunately the holes in the tile were very tight and replacing one switch in particular took a lot of grinding with my poor Dremel rotary tool. We bought a special bit but this tile was really strong and thick.

Working Socket

I was going to blog about these projects sooner but they dragged on. The kitchen project in particular required a lot of frustrating work, replacing sockets and switches is easier when the wall is drywall, tile is the worst, but wooden walls can also be problematic. I recommend buying one of those little socket testers and of course turning off the power at the breaker. The other tip is you may need to break of a brass tab when replacing the sockets in particular.  Look at the old plugins before you unhook them and see if they have the tap broken off.

In addition to sockets and switches I also had to rewire a phonejack. Maybe I should go on Canada’s Handyman Challenge or Canada’s Biggest Know-it-all or even King of the Nerds though I fear I’m too old for the latter. I could definitely do better than some of the contestants that do make it on to TV. I took some pictures during the process for friends, family, and blogosphere. I’ve actually been working on a bunch of other projects that use PHP, JavaScript, and Objective-C, stuff that will hopefully help me get a job.

Necessary Tools

Searching YouTube with PHP

February 17th, 2013

During my most recent period of unemployment, I’ve tried to brush up on some of my skills, perversely one thing I’ve spent a lot of time doing is writing PHP. I’m not a big fan of PHP, but I seem to have written and most importantly maintained some code I used to make web mashups, but other people could use for other evil purposes.

One method I wrote searches YouTube for a passed in string and returns the HTML code for the top video matching that string or NULL. I was originally going to search other APIs for video clips but never got around to implementing that feature yet. I keep trying to get a paying job.

I don’t think anyone is using all of my code to do anything interesting but referral logs indicate people are looking at the code. I think my code for accessing the Amazon Product API and some code I wrote that uses SimplePie may be the most popular but this simple function for searching YouTube seems like it would be useful. The official Google Data API is quite daunting and there are multiple more official ways to do things, but behold mine:

Damn Pastebin embed code doesn’t always work. Here is a link to the code snippet.

My web mashup code uses a lot of APIs and to use some of them you have to jump through a lot of hoops. Amazon alone has made several changes and demands in the last few years. Rotten Tomatoes changed their API suddenly, Topsy wants to charge for using their API now, I’ve encountered plenty of bugs when using PHP to access Last.fm, so I was reluctant to integrate either Zend or Google’s beta PHP code. Zend requires “PHP 5.2.11 or later” and Google requires you to register your app/domain (which I did) but worse seems to want you to set up a session connected to a database or a memcache just to search for YouTube videos.

I mainly search YouTube for movie trailers and song performances to go with my quotations. Installing and setting up an entire library of code seems a bit much when I just want to perform a quick search. Google is now working on Version 3.0 of their API. The original version, which my code used to use seems to have been completely retired, but my code now uses version 2.0 which is what the Zend framework uses. I can’t be the only one who wants a lighter weight PHP function to search YouTube.

Posts on Muskblog © Muskie McKay comments not necessarily so...
Social Media Icons created by komodomomedia, used with permission.