I. Attached is the raw un-annotated transcript of today's ipython session.
II. Also, here's a "Further Reading" list:
o http://python.org/doc/
o Python Essential Reference by David M Beazley -- Third Edition, 2006; Forth edition due out this May.
o Core Python Programming by Wesley Chun -- Second Edition, 2006.
o Dive Into Python by Mark Pilgrim -- 2004. Free Download available at http://diveintopython.org/index.html
o Numerical Methods in Engineering with Python by Jaan Kiusalaas, 2005. Excerpts available on books.google.com.
o "Why Python?", by Eric Raymond (http://www.linuxjournal.com/article/3882)
o Python Module of The Week Web-Site -- http://blog.doughellmann.com/search/label/PyMOTW
III. Finally, below are some ideas for exercises that should help reinforce what we covered in the workshop, Saturday:
1. Warm-ups (Mostly taken from Chun):
1.1. Use a list-comprehension to write your own implementation of str.strip() -- should be a one-liner.
1.2. Write a one-liner that converts a date-string in the format YYYY-MM-DD into a tuple of three integers (year, month, day).
2. Daily-close prices from the Yahoo Finance data:
2.1.1. Retrieve some daily-close prices from yahoo-finance for some heavily traded instruments. These will come down as CSV-files.
2.1.2. Write a function that loads the csv into Python -- I leave it up to you how you want to represent this data in Python (e.g. a list of dictionaries, a list of tuples, etc.)
2.1.3. Write a function that converts the sequence of closing-prices into a sequence of daily returns assuming return(t+1) = (price(t+1) - price(t)) / price(t).
3. Histogram Calculator:
3.1. Write a function that takes the sequence of numbers and returns histogram-buckets like so:
hist_buckets([9,22,39,14,25,11], n_buckets=3)
[[(9,19), 3], [(19,29), 2], [(29,39), 1]]
3.2. Hit Google and see if there are libraries that do this already. If you find any, try them out.
3.2.1. What did you find?
3.2.2. Were you able to use it?
3.2.3. If so, was it easier to use than the one you had written?
3.2.4. How would you judge the quality of the code?
3.2.4.1. Did it work?
3.2.4.2. Did the results it gave make sense? Were they correct?
3.2.4.3. Was it buggy? Buggier than your code?
3.2.4.4. Was the interface more useable than yours?
3.2.4.5. How did the code look? More readable than yours? Less?
3.2.4.6. Did the project appear to be active? Did you get the sense there was an active community behind it? Or did it look like some code somebody posted and no one ever touched it again?
3.3."Extra Credit:" Look up the unittest package in the Python Library online documentation.
3.3.1. Create some unit-tests for your function using the above example.
3.3.2. Try to run your unittests using nose or trial (part of twisted).
4. Put it all together:
4.1. Choose some histogram calculator (be it your own, or one of the ones you found out there)
4.2. Feed your daily-returns into the histogram calculator. Try various n_buckets settings.
4.3. Based on your advanced studies in the topic of price-processes, any comments on the results?
II. Also, here's a "Further Reading" list:
o http://python.org/doc/
o Python Essential Reference by David M Beazley -- Third Edition, 2006; Forth edition due out this May.
o Core Python Programming by Wesley Chun -- Second Edition, 2006.
o Dive Into Python by Mark Pilgrim -- 2004. Free Download available at http://diveintopython.org/index.html
o Numerical Methods in Engineering with Python by Jaan Kiusalaas, 2005. Excerpts available on books.google.com.
o "Why Python?", by Eric Raymond (http://www.linuxjournal.com/article/3882)
o Python Module of The Week Web-Site -- http://blog.doughellmann.com/search/label/PyMOTW
III. Finally, below are some ideas for exercises that should help reinforce what we covered in the workshop, Saturday:
1. Warm-ups (Mostly taken from Chun):
1.1. Use a list-comprehension to write your own implementation of str.strip() -- should be a one-liner.
1.2. Write a one-liner that converts a date-string in the format YYYY-MM-DD into a tuple of three integers (year, month, day).
2. Daily-close prices from the Yahoo Finance data:
2.1.1. Retrieve some daily-close prices from yahoo-finance for some heavily traded instruments. These will come down as CSV-files.
2.1.2. Write a function that loads the csv into Python -- I leave it up to you how you want to represent this data in Python (e.g. a list of dictionaries, a list of tuples, etc.)
2.1.3. Write a function that converts the sequence of closing-prices into a sequence of daily returns assuming return(t+1) = (price(t+1) - price(t)) / price(t).
3. Histogram Calculator:
3.1. Write a function that takes the sequence of numbers and returns histogram-buckets like so:
hist_buckets([9,22,39,14,25,11], n_buckets=3)
[[(9,19), 3], [(19,29), 2], [(29,39), 1]]
3.2. Hit Google and see if there are libraries that do this already. If you find any, try them out.
3.2.1. What did you find?
3.2.2. Were you able to use it?
3.2.3. If so, was it easier to use than the one you had written?
3.2.4. How would you judge the quality of the code?
3.2.4.1. Did it work?
3.2.4.2. Did the results it gave make sense? Were they correct?
3.2.4.3. Was it buggy? Buggier than your code?
3.2.4.4. Was the interface more useable than yours?
3.2.4.5. How did the code look? More readable than yours? Less?
3.2.4.6. Did the project appear to be active? Did you get the sense there was an active community behind it? Or did it look like some code somebody posted and no one ever touched it again?
3.3."Extra Credit:" Look up the unittest package in the Python Library online documentation.
3.3.1. Create some unit-tests for your function using the above example.
3.3.2. Try to run your unittests using nose or trial (part of twisted).
4. Put it all together:
4.1. Choose some histogram calculator (be it your own, or one of the ones you found out there)
4.2. Feed your daily-returns into the histogram calculator. Try various n_buckets settings.
4.3. Based on your advanced studies in the topic of price-processes, any comments on the results?