Walt Mankowski

All glory to the hypnotoad

Changing Finance::Quote to Use AlphAdvantage

| Comments

I have a Perl script that uses Finance::Quote to fetch quotes for a few stocks and mutual funds I’m interested in and store them in a SQLite database. I run this in a cron job, and it had been working fine for nearly 5 years. On November 1 it suddenly stopped working. It turned out that the module defaulted to using Yahoo for its quotes, and they’d decided to no longer allow the module to access its data.

This led to a flurry of discussions online and quite a few updates to the module. After a week or two it settled down and I read that they’d switched to using a service called AlphAdvantage. Unfortunately my script still wasn’t working, nor were the example scripts in the module documentation.

Finally tonight I decided to see if I could get it working. I downloaded and built the latest version of Finance::Quote (1.47) from source. It has a test called alphavantage.t, and its tests passed! I compared its code to mine and finally got it working again. Here’s what I did:

  1. Went to the Alphavantage web site and got a free API key.

  2. I stored the key in an environment variabled named ALPHAVANTAGE_API_KEY:

    export ALPHAVANTAGE_API_KEY=##########

    If you’re doing this yourself, you’ll need to replace “##########” with your actual API key, and add that export to wherever you set your other environment variables (possibly ~/.bashrc).

  3. My previous code looked like this:

Fetch quotes with Yahoo
1
2
3
4
5
6
7
8
use Finance:Quote;
@syms = qw(APPL MSFT GOOG);
my $q = Finance::Quote->new;
my %quotes = $q->fetch("nasdaq",@syms);
for my $sym (@syms) {
    my $price = $quotes{$sym,'price'};
    ...
}

I had to change lines 4 and 6:

Fetch quotes with AlphAdvantage
1
2
3
4
5
6
7
8
use Finance:Quote;
@syms = qw(APPL MSFT GOOG);
my $q = Finance::Quote->new;
my %quotes = $q->alphavantage(@syms);
for my $sym (@syms) {
    my $price = $quotes{$sym,'close'};
    ...
}

That’s it! It took a bit of digging to find it, but the actual change was pretty simple. Hopefully the module developers will eventually get around to updating their documentation.

Don't Hate COBOL Until You've Tried It

| Comments

The folks at opensource.com asked some of the speakers at next weekend’s FOSSCON to submit articles based on their talks. Here’s the article I wrote for my talk, A punch card ate my program! (Sadly they wanted to go with a different title.) While I’ve had a number of academic papers published, this is the first general audience article I’ve ever had published!

This is just a tiny preview of my talk, so you’ll want to come out to FOSSCON next Saturday to hear the full version. This talk began in May as a 10 minute talk at !!Con 2017, but I’ve expanded it to 50 minutes with lots more COBOL and punch card history!

There's Only One Race

| Comments

Paul Offit, in his chapter on eugenics in Pandora’s Lab:

People then and now seem perfectly willing to ignore the fact that we all come from a common ancestor and are far more alike than different. There is no Nordic or Aryan or Mexican or Muslim or Syrian race. There’s only one race: the human race

The Allimon Cricket Club

| Comments

Yesterday morning I was watching some cricket on TV while eating breakfast. It was the 4th test match between England and South Africa, but that doesn’t really matter. What does matter is that it was very slow, and so after every ball the cameras would find some interesting spectators in the stands for the announcers to talk about. Another important fact for this story is that one of the announcers was a very famous English cricket announcer named David Lloyd, who everyone affectionately calls “Bumble” and who speaks with what I’m told is a distinctive Lancashire accent.

Now, it’s common at English cricket matches to see people in the stands wearing distinctive red earpiece radios that let you listen to the live TV broadcast. (I think you can rent them at the grounds.) Sometimes, during particularly slow stretches of the game, the announcers will even try to talk to the fans after they see themselves on the Jumbotron. (The fans aren’t miked so they can’t talk back.)

At one point the cameras found an adorable little kid. Bumble saw the kid’s shirt and said, “Look, he’s wearing an Allimon Cricket Club shirt!” The kid was wearing an earpiece radios and saw himself on TV, and so Bumble started talking to him.

“Are you from Allimon?”

I’d never heard of Allimon, but the kid nodded excitedly.

“Good man! Are you from…” and he said some town I’d never heard of. The kid shook his head. He tried a few more towns and eventually the kid nodded yes.

While this was going on the camera zoomed in a bit and I got a better look at the kid’s shirt. I recognized the logo and realized that Bumble wasn’t actually saying “Allimon”. Want to try to guess what it really was? Your clues are:

  • It sounds like Allimon when spoken with a funny (to my American ears) English accent.
  • It’s somewhere in the British Isles.
  • The symbol for this place is distinctive, but I think it’s not well known outside of the British Isles. The actual place itself is not particularly obscure.

If you can’t get it from that, click here to see the logo. If you’re still stumped after that, click here for the solution.

A Quiet Night in Bryn Mawr

| Comments

It seemed like a quiet night in Bryn Mawr, so after dinner I walked down to the comic book store, and discovered they were doing a live broadcast of a podcast called “This Week In Film”. The hosts were interviewing the creator of a comic called Boy Zero, who was also there for a book signing. There was an entourage of producers and camera people and folks like me who’d wandered in, and it was crazy, but fun crazy. I’d never heard of either the podcast or the comic, but the show sounded pretty good. Well, it was good, up until they finished interviewing the comic guy and moved on to the main part of their show with the tagline “So, Nick, what did you watch…THIS WEEK IN FILM?”

As I was walking back to my car I heard music and saw they were having a concert at the gazebo behind the library. I didn’t recognize the band, but I thought they sounded a bit like Genesis. When I got there I asked the woman at the gate who they were, and she said it was Trespass. “They’re a Genesis tribute band,” she said. I had no idea there were Genesis tribute bands, but the Genesis home page lists over 50 of them!

Trespass was just finishing up their first set so I didn’t stick around. As I walked past the library’s parking lot I came across a group of people wondering if they should walk or drive Tango, a restaurant by the Bryn Mawr train station.. “You can walk there,” I suggested. “It’s right across the street.” One of the men in the party insisted on driving. “We’re not British!” he explained.

I'm Speaking at Fosscon!

| Comments

If you missed my talk about COBOL and punch cards at !!Con a few weekends ago, good news — the video is now online. And if that’s not enough for you, if you want even more COBOL and punch cards goodness, I’ve got good news for you! I’ll be doing an expanded directors cut 50 minute version of the talk this August in Philadelphia at Fosscon!

All the talks (except for one which wasn’t recorded at the speaker’s request) from this year’s !!Con are up on youtube, and they’re pretty much all excellent. I encourage you to try out some of the other talks which you’ll probably see on the same page as mine. You won’t be disappointed.

Paul Offit on Trans Fats

| Comments

Yesterday I bought Paul Offit’s new book Pandora’s Lab at an Independent Bookstore Day sale at my local independent bookstore. I had the following two reactions(*) after reading his chapter on trans fats:

  1. I checked the labels on everything in my kitchen for trans fats. (I couldn’t find anything.)
  2. I checked online to see how far I’d have to drive to sample some of those Berger Cookies he mentions in the chapter. (It’s about a 45 minute drive to a supermarket in Delaware.)

Offit does a really great job explaining the chemistry behind what makes trans fats bad for our health, as well as describing the series of scientific and political mistakes behind how they came to be such a big part of the America diet in the 20th Century. I have to confess that while I vaguely remember thinking “Wait, so margarine’s bad for us now? I guess I’ll go back to butter!”, I’d never really paid much attention to it beyond that. This was the first time I’d ever seen the science explained as to why it’s so bad.

(*) Not necessarily in this order.