Archive for November, 2008

28th November
2008
written by simplelight
  1. Upgrade to latest version of RubyGems (‘sudo gem update –system’)
  2. Add GitHub repository (‘gem sources -a http://gems.github.com’)
  3. Upgrade to latest version of Ziya (‘sudo gem install derailed-ziya’)
  4. Install Ziya in project directory (‘Ziyafy –charts’ in project home, note the double dash)
  5. Add ziya.rb to config/initializers directory
  6. Copy your themes into ../public/themes/

Some other thoughts: If you’re frustrated by the almost non-existent documentation and the fact that the gem is in constant flux, don’t despair. The best way to understand how to customize your graph is to look through the example themes (for some reason they didn’t install with my gem but I downloaded them from GitHub).

Note: You can not instantiate the Ziya object in the controller corresponding to the chart’s view. It needs to be in a separate controller. Otherwise, an XML file (instead of a chart) will be returned when that controller is invoked.

Also, the reference material at XML/SWF charts is very useful and Ziya seems to adhere quite closely to the naming conventions.

I also found that I needed user-defined functions fairly quickly to customize axes etc.

Here is an example of how to use Ziya to create a scatter chart:

== Chart Controller ==

01: def load_ef

02:    # Create graph data object
03:    chart_data   = Array.new

04:    # Pull portfolios out of database
05:   @query = sessions[:period].to_i

06:    @portfolios = Portfolio.find(:all, :conditions => ["period = ?", @query])

07:    # Strip out risk and return
08:    @portfolios.each { |x|
09:       chart_data  << x.std_dev
10:       chart_data  << x.port_ret
11:    }

12:    title = “User-entered portfolios”

13:    chart = Ziya::Charts::Scatter.new(‘LICENSE-KEY’)
14:    chart.add( :axis_category_text, %w[x y]*(chart_data.length/2) )
15:    chart.add( :series, title, chart_data )

16:    chart.add( :theme , “assetcorrelation” )

17:    respond_to do |fmt|
18:      fmt.xml { render : xml => chart.to_xml }
19:    end
20: end

== View ==

1: <div>
2:   <%= ziya_chart load_ef_url, :size => “1200×800″ – %>
3: </div>

== Routes.rb ==

1:  map.load_ef   ‘/chart/load_ef’,   :controller => ‘chart’, :action => ‘load_ef’

As far as I understand, Rails will first look for a method in your controller that matches the view, then, once it starts rendering the view, it hits the callback (line 2 in the view snippet above) and at that point calls the method in the chart_controller to render the chart data, using the routing information in Routes.rb.

Note that in this case, I am pulling the data for the chart out of my database.

23rd November
2008
written by admin

[Welcome to our first-time guest blogger]

 

It is a relief to many that Obama is in. Credit goes to those who feel that way for significant, i.e. policy, reasons, but public comments made it seem we were simply proud we have proven to the world that we’re not racist.

 

Oddly enough, no one is eager to show we are not sexist. To the contrary, like bullies on the playground, we shouted at the female candidates: “She-goat!” “Dominatrix!” and my favorite, “Breeder!” (Thank you for that last one, Bigot Maher.)

 

Reuters photographed Palin from behind and between her legs…ah, harkens back to the good-old-days when She-Ra’s legs framed the shots of He-Man in the 80’s.  I say those were the good-old-days because that was a time when educated women called foul on things like that. But this time I heard crickets.  Even my (former) hero Steinem held the coats for the ensuing mob.

 

Especially mesmerizing was the “role of the vice president” discussion. Palin said the VP is in charge of the Senate.  Article 1 Section 3 of the constitution says:

The Vice President of the United States shall be President of the Senate, but shall have no Vote, unless they be equally divided. The Senate shall choose their other Officers, and also a President pro tempore, in the absence of the Vice President.

This election was indeed about audacity — the audacity to take direction from the Constitution.  If only legislators would treat Article I Section 8  with more reverence we would have a much simpler government. (I’ll give you a hint, establishing a post office and postal roads is 1 of the 18 things with which they are actually tasked.)  But I digress. For this comment Palin was burnt at the ignoramus stake.  I can’t bring myself to discuss the bikini characterizations, the dolls, and the frenzy on fashion. It is a confounding hatred for the very gender that promoted the abolition of slavery (to make no mention of the party.)

 

And now to keep hope alive: history suggests we have only 50 more years before a woman is in the White House:

  • Voting rights:  African American Men – 1870. Women – 1920.
  • US Senate:   AAM – 1870. Women – 1922* 
  • US Congress: AAM – 1868. Women – 1917

If history repeats once more, Obama’s daughters will have to wait until they are nearly 60 years old for our great nation to consider their application on merit.  Chelsea will be in her 70s, and, apparently, too old for the job.

 

We’ve come a long way from slavery. But we’ve hardly come a long way from the Salem witch trials. In fact, some might say we just had one. 

 

*Rebecca Latimer Felton of Georgia, the first woman to serve in the United States Senate, took the oath of office on November 21, 1922. Having been appointed to fill the vacancy for her husband, Felton served for just 24 hours. The first woman elected to the Senate was Hattie Wyatt Caraway of Arkansas in 1932.

23rd November
2008
written by simplelight

What has been wanting on the right at the start of this century is a true “conservative disposition” — the disposition to enjoy what is rather than pining for what might be (to paraphrase Himmelfarb), to enjoy the givens and the goods of life without subjecting them to social or political validation.

Rationalism in Politics, despite being clouded by the “fumes of tradition”, is a breath of fresh air.

His [the Rationalist's] mental attitude is at once sceptical and optimistic: sceptical, because there is no opinion, no habit, no belief, nothing so firmly rooted or so widely held that he hesitates to question it and to judge it by what he calls his ‘reason’; optimistic, because the Rationalist never doubts the power of his ‘reason (when properly applied) to determine the worth of a thing, the truth of an opinion or the propriety of an action. Moreover, he is fortified by a belief in a reason’ common to all mankind, a common power of rational consideration, which is the ground and inspiration of argument: set up on his door is the precept of Parmenides–judge by rational argument. But besides this, which gives the Rationalist a touch of intellectual equalitarianism, he is something also of an individualist, finding it difficult to believe that anyone who can think honestly and clearly will think differently from himself.

19th November
2008
written by simplelight

Volatility is usually expressed as the annualized standard deviation of returns. Volatility is proportional to the square root of time. That means one can approximate a volatility over a smaller time period than one year by dividing the annual vol by the square root of the number of trading periods one is interested in.

So, to convert annual volatility to a daily vol, divide by 16, which is the square root of 256 — about the number of trading days in the year. This paper on converting 1-day to h-day volatility contains some important caveats. (Summary: Modeling volatility only at one short horizon, followed by scaling to convert to longer horizons, is likely to be inappropriate and misleading, because temporal aggregation should reduce volatility fluctuations, whereas scaling amplifies them.

Back in the days when vol was 15-20% annually (way back in 2007), a daily vol was about 1%. These days, the VIX is closer to 80 which implies a daily return of +- 5%.

On Sept 15th, 2008, when Lehman was allowed to go bankrupt (“Lehman is not too big to fail” – Paulson), the VIX went up to 80 and has been in that region ever since. The Lehman bankruptcy has turned out to be a massive event in financial history.

3rd November
2008
written by simplelight

Stilling the eternal, internal murmur of self-reproach

God stopped to show us that what we create becomes meaningful to us only once we stop creating it and start to think about why we did so. The implication is clear. We could let the world wind us up and set us to marching, like mechanical dolls that go and go until they fall over, because they don’t have a mechanism that allows them to pause. But that would make us less than human. We have to remember to stop because we have to stop to remember. 

Tags: