Jose Sandoval Google
 Resume     Book     Software     Drawings     Home     Subscribe to RSS feed Search Web Search

The stock picker
Monday, October 26, 2009

One of the main factors in stock market performance is determined by interest rates, or so it has been observed.

The dependency of our economy on interest rates is based on the fact that everything we do requires money. To create value out of nothing, we treat the concept of money as something tangible and assign a cost to borrowing capital, a cost that we call interest.

Empirical data (read any economics and finance book) show that as interest rates increase, which makes money more expensive, the equity market suffers. The opposite is true as well: as interest rates decrease, the stock market begins to perform better and to yield better returns.

The theory states that as interest rates increase, investors take money out of the stock market and begin investing in more secure investment vehicles, for example, in bonds, T-bills, or other capital investment that assure the protection of capital.

Again, as the rate of return on any investment increases so does the risk. The stock market has been known to outperform secure-capital investments, though the risk is greater. Leaving all the math of theoretical models aside, as interest rates increase, the rate of return of secure-capital investments increases. And as for any rational investor, less risk for the same return is better. Therefore, the equity market suffers because investing in companies futures is riskier and money starts flowing out of the stock market into bonds, T-bills, and other fixed income commodities.

At the end of the day, however, the market is not a rational entity: investors are driven by emotions, resulting in bubbles, crashes, and inside trading fiascoes. Nevertheless, the manipulation of interest rates has become the main tool for governments to maintain order in world markets. For instance, Obama's policies seem to be working. The idea is to keep us going: as long as we keep buying and consuming goods, we will continue to maintain and to create jobs that support the cycle.

7:41 AM | 0 comment(s) |

A beautiful thing to watch: Barcelona FC
Sunday, October 25, 2009

Barcelona has some of the best soccer players in the world--Messi, Iniesta, Xavi. Having great players doesn't guarantee success, though. Barcelona is a club with an identity and a team with a clear idea of how to play together. It can be argued that Barcelona is a successful team. On the other hand, Real Madrid has the rest of the top players in the world--Kaka, Benzema, Casillas--but it's an organization in trouble: ugly playing, unconvincing wins, and Cristiano Ronaldo-dependency--he's injured and their firepower has decreased.

Whose to blame for Real Madrid's woes? Who knows. In the mean time, enjoy Barcelona's last win (6-1 against Zaragoza):

9:52 PM | 0 comment(s) |

Restlet 2.0 sample application with annotations
Friday, October 23, 2009

The new version of Restlet, 2.0, uses Java annotations to make web service development easier than it was with version 1.1. However, these annotations are not based on the JAX-RS specification. They are similar, but they are not the same.

In Chapter 6, I cover in detail the web component portion of the Restlet framework, versions 1.1 and 2.0. For this entry, however, I will just give an example of a full RESTful web service implementation using Restlet 2.0 that runs as a standalone Java application (I cover this topic in Chapter 9).

The Restlet framework, aside from a Java web container component, offers a library for standalone web application development. With it, you can create desktop applications that don't require a full Java web container such as Tomcat or JBoss (though, technically, the standalone library provides a deployment-free HTTP server).

A full listing of a Restlet web service looks as follows:
import org.restlet.Server;
import org.restlet.resource.Delete;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;

public class StandAloneServer extends ServerResource {
public static void main(String[] args) throws Exception {
new Server(Protocol.HTTP, 8006,

public String handleGet() {
return "HTTP GET.";

public String handlePost() {
return "HTTP POST.";

public String handlePut() {
return "HTTP PUT.";

public String handleDelete() {
return "HTTP DELETE.";
The main() method instantiates an org.restlet.Server object that listens to HTTP requests on port 8006. This takes care of the HTTP request listening.

What about the specific HTTP request methods?

This is where the Restlet annotation functionality comes into play. Servicing specific HTTP requests takes nothing more than coding and annotating a method for each HTTP request, as follows:
  • @Get - for resource retrieval.
  • @Post - for resource creation.
  • @Put - for resource updates.
  • @Delete - for resource deletion.
The name of each annotated method is arbitrary, and this is represented in my example above. For instance, handleGet() handles GET requests, handlePost() handles POST requests, handlePut() handles PUT requests, and handleDelete() handles DELETE requests.

Each of these request handlers returns a String representation as the response. For a real example, however, you should be returning XML or JSON structures that are specific to your problem domain.

Assuming that your Java source file is called, you can compile this application with the following command:
javac -classpath RESTLET_HOME/lib/org.restlet.jar
To run the application, you would use the command:
java -classpath RESTLET_HOME/lib/org.restlet.jar
To access the web service, just point your testing client to the URI http://localhost:8006/. For a GET request, you can use your web browser. For example, using FireFox, a GET request's response looks as follows:

To test the requests POST, PUT, and DELETE, you will need a more sophisticated web client, as web browsers can't generate PUT or DELETE requests. If you don't have a client that can generate these requests, you can use my Java Swing client (full code listing is in Chapter 2). A PUT request using this client looks as follows:

11:40 PM | 0 comment(s) |

RESTful Java Web Services available now
Wednesday, October 14, 2009

The book that I've been writing since the beginning of the year is available for pre-ordering now.

I'm polishing the last 2 chapters, but the first printed version will be available next month.

If you buy it and have any questions, you can reach me via email.

10:01 PM | 0 comment(s) |

This page is powered by Blogger. Isn't yours?

© Jose Sandoval 2004-2009