Saturday, August 8, 2009
Tuesday, September 16, 2008
AIG Commercials
You ever see those commercials with the little kids worrying about their parent's financial future and then parents say dont worry we're with AIG? Well, if it was reality now, the kids should be like noo we f***ed and jump in front of the school bus.
This market is so crazy. What's going to happen next?
AIG Commercial... someone should voice over the little kid to say OMG We're f***!
This market is so crazy. What's going to happen next?
AIG Commercial... someone should voice over the little kid to say OMG We're f***!
Sunday, September 14, 2008
Groovy code to grab stock quotes from Yahoo Finance
I'm working on a new website that will do analysis on stocks and was thinking about developing it using Groovy. I'm still in the early stages and wanted to find a way to grab stock quotes from the web. I found some nice python code written by Corey Goldberg and basically converted it to Groovy. His code basically allows you to grab stock quotes from Yahoo Finance, given that you know it's ticker symbol. It took me an hour or so to convert. Seeing how useful it is, I decided this code would be pretty nice for other people to use ( if they're using Groovy ).
Requirements
Java 1.5
Apache HttpClient jars ( you'll need commons-codec-1.3.jar, commons.httpclient-3.1.jar and commons-logging-1.1.1.jar)
I'm pretty new to Groovy so please feel free to give comments, criticisms, whatever.
Requirements
Java 1.5
Apache HttpClient jars ( you'll need commons-codec-1.3.jar, commons.httpclient-3.1.jar and commons-logging-1.1.1.jar)
I'm pretty new to Groovy so please feel free to give comments, criticisms, whatever.
/**
*
*/
package groovy
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod
/**
* @author actionjax
*
* Credit goes to Corey Goldberg for creating ystockquote.
* This code below is basically a port of the same code to Groovy.
*
* Copyright (c) 2007-2008, Corey Goldberg (corey@goldb.org)
*
* license: GNU LGPL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This is the "YahooStockQuoteInterface" module.
*
* This module provides a Groovy API for retrieving stock data from Yahoo Finance.
*
* sample usage:
* >>> import ystockquote
* >>> print ystockquote.get_price('GOOG')
* 529.46
*
*/
public class YahooStockQuoteInterface {
private static __request(symbol, stat) {
String url = "http://finance.yahoo.com/d/quotes.csv?s=$symbol&f=$stat"
HttpClient client = new HttpClient()
GetMethod get = new GetMethod(url)
client.executeMethod(get)
return get.getResponseBodyAsString().toString().replaceAll("\"","")
}
static get_all(symbol) {
"""
Get all available quote data for the given ticker symbol.
Returns a dictionary.
"""
def values = __request(symbol, 'l1c1va2xj1b4j4dyekjm3m4rr5p5p6s7').split(',')
def data = [:]
data['price'] = values[0]
data['change'] = values[1]
data['volume'] = values[2]
data['avg_daily_volume'] = values[3]
data['stock_exchange'] = values[4]
data['market_cap'] = values[5]
data['book_value'] = values[6]
data['ebitda'] = values[7]
data['dividend_per_share'] = values[8]
data['dividend_yield'] = values[9]
data['earnings_per_share'] = values[10]
data['52_week_high'] = values[11]
data['52_week_low'] = values[12]
data['50day_moving_avg'] = values[13]
data['200day_moving_avg'] = values[14]
data['price_earnings_ratio'] = values[15]
data['price_earnings_growth_ratio'] = values[16]
data['price_sales_ratio'] = values[17]
data['price_book_ratio'] = values[18]
data['short_ratio'] = values[19]
return data
}
static get_price(symbol) {
return __request(symbol, 'l1')
}
static get_change(symbol) {
return __request(symbol, 'c1')
}
static get_volume(symbol) {
return __request(symbol, 'v')
}
static get_avg_daily_volume(symbol) {
return __request(symbol, 'a2')
}
static get_stock_exchange(symbol) {
return __request(symbol, 'x')
}
static get_market_cap(symbol) {
return __request(symbol, 'j1')
}
static get_book_value(symbol) {
return __request(symbol, 'b4')
}
static get_ebitda(symbol) {
return __request(symbol, 'j4')
}
static get_dividend_per_share(symbol) {
return __request(symbol, 'd')
}
static get_dividend_yield(symbol) {
return __request(symbol, 'y')
}
static get_earnings_per_share(symbol) {
return __request(symbol, 'e')
}
static get_52_week_high(symbol) {
return __request(symbol, 'k')
}
static get_52_week_low(symbol) {
return __request(symbol, 'j')
}
static get_50day_moving_avg(symbol) {
return __request(symbol, 'm3')
}
static get_200day_moving_avg(symbol) {
return __request(symbol, 'm4')
}
static get_price_earnings_ratio(symbol) {
return __request(symbol, 'r')
}
static get_price_earnings_growth_ratio(symbol) {
return __request(symbol, 'r5')
}
static get_price_sales_ratio(symbol) {
return __request(symbol, 'p5')
}
static get_price_book_ratio(symbol) {
return __request(symbol, 'p6')
}
static get_short_ratio(symbol) {
return __request(symbol, 's7')
}
static get_historical_prices(symbol, start_date, end_date) {
"""
Get historical prices for the given ticker symbol.
Date format is 'YYYYMMDD'
Returns a nested list.
"""
int end_day = Integer.valueOf(end_date[4..5] - 1)
def end_month = end_date[6..7]
def end_year = end_date[0..3]
int start_day = Integer.valueOf(start_date[4..5] - 1)
def start_month = start_date[6..7]
def start_year = start_date[0..3]
String url = "http://ichart.yahoo.com/table.csv?s=$symbol&" +
"d=$end_day&" +
"e=$end_month&" +
"f=$end_year&" +
"g=d&" +
"a=$start_day&" +
"b=$start_month&" +
"c=$start_year&"+
"ignore=.csv"
HttpClient client = new HttpClient()
GetMethod get = new GetMethod(url)
client.executeMethod(get)
BufferedReader reader = new BufferedReader(new InputStreamReader(get.getResponseBodyAsStream()))
ArrayList<String> data = new ArrayList<String>()
reader.eachLine( { day-> data.add(day.split(","))} )
return data
}
// /**
// * @param args
// */
// public static void main(def args) {
// for(datum in YahooStockQuoteInterface.get_historical_prices("GOOG","20070101","20080101"))
// println datum }
}
Sunday, August 31, 2008
SKF play a bit early
Can you believe this GDP report? The economy is NOT okay.
SKF closed at 116.69 for the weekend. I don't think it can go lower than 100. I'm thinking about getting in SKF soon! I'm holding on for the ride up.
SKF closed at 116.69 for the weekend. I don't think it can go lower than 100. I'm thinking about getting in SKF soon! I'm holding on for the ride up.
Tuesday, August 26, 2008
Its been a while since my last update...
So we stopped updating because we got killed in the market. I guess it happens.
Lessons learned
Instead of options, I've been playing stocks. Maybe when I get better I'll look back into options.
My picks ( I think will do well in the next 6 months )
ATVI - Guitar Hero World Tour, possible announcement of Blizzard games. It's a bit weak right now but I don't see this stock going below 30 again ( if it does forget my recommendation )
SKF - this is an ETF, basically a short on financials. Need I say more?
SIRI - It's a buck + some change. It seems to have stabilized from its crazy fall. I'm a bit skeptical, I might stop liking it if it goes below 1.20.
XOM - It hasn't been this low for a while, can oil really stop going up? 78-80 sounds like a bargain for a stock that been in the 80s - 90s pretty much all year.
Probably the best pick right now is SKF. If it can break 140 resistance, we might see this sucker go up to 200 like it did in July.
Lessons learned
- Do not hold short term options longer than a week, you just lose money
- Do not put all your eggs in one basket ( in this case financial stocks )
- Market can turn on you any minute without reason ( gov't intervention, etc )
Instead of options, I've been playing stocks. Maybe when I get better I'll look back into options.
My picks ( I think will do well in the next 6 months )
ATVI - Guitar Hero World Tour, possible announcement of Blizzard games. It's a bit weak right now but I don't see this stock going below 30 again ( if it does forget my recommendation )
SKF - this is an ETF, basically a short on financials. Need I say more?
SIRI - It's a buck + some change. It seems to have stabilized from its crazy fall. I'm a bit skeptical, I might stop liking it if it goes below 1.20.
XOM - It hasn't been this low for a while, can oil really stop going up? 78-80 sounds like a bargain for a stock that been in the 80s - 90s pretty much all year.
Probably the best pick right now is SKF. If it can break 140 resistance, we might see this sucker go up to 200 like it did in July.
Monday, July 21, 2008
Thursday, July 17, 2008
GOOG play
Well my financials are pretty dead. But I did make a gutsy GOOG Jul 510 put @ 10.50, 15 minutes before close. My rationale was that EBAY (down 13%) and VCLK (down 20%) did bad. Looks like it will pay off tomorrow! Too bad GOOG puts were expensive.
Wednesday, July 16, 2008
VIX stupid play
So gk19 and I made stupid VIX plays without knowing that VIX options expire Wednesday! Big blunder! Guess we learned out lesson the hard way :(. I think today was pretty much a short squeeze day. I got Aug 22.50 put on WFC @ 0.70. Hope the market tumbles again! MER and JPM earnings are tomorrow if they report bad numbers the market could tip. I'm also going to keep watch for GOOG earnings after hours.
Looking for an explanation of the financial bomb?
This comic is pretty fun although its a bit long.
http://www.telegraph.co.uk/money/main.jhtml?view=DETAILS&grid=&xml=/money/2008/03/26/bcncrisis126.xml
I loaded up on a lot of aug puts today: WM @ 0.90, WB @ 2 and LEH @ 2.25. Looking for more down turn. I say VIX has to hit 35 before I call it a bottom.
http://www.telegraph.co.uk/money/main.jhtml?view=DETAILS&grid=&xml=/money/2008/03/26/bcncrisis126.xml
I loaded up on a lot of aug puts today: WM @ 0.90, WB @ 2 and LEH @ 2.25. Looking for more down turn. I say VIX has to hit 35 before I call it a bottom.
Tuesday, July 15, 2008
VIX
Well, the fear index finally topped over 30 today before pulling back to the ridiculous run in the middle of the day. I ended up getting massive Jul 30 calls (66 @ 0.15, 100 more @, 0.10) today on the pullback. Actionjax is luckier getting 200 @ 0.10
Looking historically, Vix SHOULD bounce higher than that and doesn't just top over and then pull back and everything is ok. In recent history, VIX's been topping 35, with it topping 30 in 2 or 3 consecutive days. I'm betting this continues and when the VIX hits 35, I'm getting some 32.5 puts equally cheap for 5-15 cents max.
Let's see if we can turn 2k into a quarter mil.
Looking historically, Vix SHOULD bounce higher than that and doesn't just top over and then pull back and everything is ok. In recent history, VIX's been topping 35, with it topping 30 in 2 or 3 consecutive days. I'm betting this continues and when the VIX hits 35, I'm getting some 32.5 puts equally cheap for 5-15 cents max.
Let's see if we can turn 2k into a quarter mil.
Subscribe to:
Posts (Atom)