Tickety, Tickety Tick

TickerTo develop and back-test trading algos its essential to have great gobs of historical data on hand, almost always at the tick level.  More often than not this data comes from your broker—OANDAAlpariDukasCopy, and Integral (TrueFX), to name a popular few—whether through commercial platforms like MT4 or proprietary APIs.  Alternately, one can use a generic downloader like Birt’s Tick Data Suite.

Over the years I’ve worked with more than a dozen brokers and other data providers so you think I’d have a handle on this stuff by now, but nothing could be further from the truth.  No, its an ever changing and messy landscape.   Continue reading

Cancel That

Cancellation in a multi-threaded Console App can be surprisingly difficult, even though I’ve done it dozens (hundreds?!?) of times before.  As any programmer can tell you, there are the “Things you know” and “Things you merely think you know.”  In programming, fiddly little details count.

I won’t go into the trade-offs between using Tasks or Parallel.For[Each] or TPL DataFlow, but suffice it to say that the later is both the most useful and easiest to get right.  Enjoy…

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

namespace CancelDemo
{
   class Program
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Press any key to cancel...");
         Console.WriteLine();

         var cts = new CancellationTokenSource();

         var client = new HttpClient();

         try
         {
            var fetcher = new ActionBlock<string>(
               async url =>
               {
                  await client.GetAsync(url, cts.Token);

                  Console.WriteLine($"FETCHED {url}");
               },
               new ExecutionDataflowBlockOptions()
               {
                  CancellationToken = cts.Token,
                  MaxDegreeOfParallelism = Environment.ProcessorCount
               });

            urls.ForEach(url => fetcher.Post(url));

            fetcher.Complete();

            var readKey = new TaskFactory(cts.Token).StartNew(() =>
            {
               while (!Console.KeyAvailable)
                  Thread.Sleep(100);

               cts.Cancel();

               Console.ReadKey(true);
            });

            Task.WaitAny(new Task[] { fetcher.Completion, readKey });
         }
         catch (OperationCanceledException)
         {
         }
         catch (Exception error)
         {
            cts.Cancel();

            Console.WriteLine("Error: " + error.Message);
         }

         Console.WriteLine();
         Console.Write("Press any key to terminate...");

         Console.ReadKey(true);
      }

      private static List<string> urls = new List<string>()
      {
         "https://www.pinterest.com/pin/143270831869696811/",
         "https://www.pinterest.com/pin/155585362100632165/",
         "https://www.pinterest.com/pin/23010648069511614/",
         "https://www.pinterest.com/pin/303711568591359002/",
         "https://www.pinterest.com/pin/314900198915723688/",
         "https://www.pinterest.com/pin/316166836311260373/",
         "https://www.pinterest.com/pin/535576580657166380/",
         "https://www.pinterest.com/pin/56154326576327972/",
         "https://www.pinterest.com/pin/56154326576368600/",
         "https://www.pinterest.com/pin/88523948898601589/",
         "https://www.pinterest.com/pin/108438303498183811/",
         "https://www.pinterest.com/pin/127156389453876236/",
         "https://www.pinterest.com/pin/270708627574674608/",
         "https://www.pinterest.com/pin/368380444492800731/",
         "https://www.pinterest.com/pin/250653535491278041/",
         "https://www.pinterest.com/pin/565483296932119884/",
         "https://www.pinterest.com/pin/173177548141309276/",
         "https://www.pinterest.com/pin/430867889333901210/",
         "https://www.pinterest.com/pin/61361613645883874/",
         "https://www.pinterest.com/pin/16466354858074206/"
      };
   }
}


Guitar #3

Taylor_GS_Mini_e_Koa_FLTD

I am by no means a talented guitarist, although after more than six full months of trying I can report that I have indeed been making progress. Maddeningly-slow-make-you-question-the-whole-thing progress, but progress nonetheless.

I love to twang the strings and hear them resonate.  I love to palpate my fingertips and worry at my hardening calluses.  I love to sub-vocalize the name of a note only to find my fingers on the strings in the (mostly!) correct position. I’ve come to hate my all too weak and bendy ring finger but can’t help but be inordinately pleased those few times it comes perfectly into line without the least bit of wheedling.  I even love the stupid evil what-the-hell-could-they-have-been-thinking F-Major; the barred five-string chord from hell! Continue reading

A Personal Confession

The truth of the matter is that I’ve had relatively little success as an observational astronomer, never no mind the embarrassing fact that I’ve been at it for more than forty years.  Resorting to numeracy, alone, there are at least at least 3×1023 stars in the observable universe (https://en.wikipedia.org/wiki/Star) yet I’ve barely glanced at a measling fraction of that whole.  Take the 4×1012 stars in the thirty-nine Messier Galaxies, for instance, then toss in a few odds and ends from the ARP and NGC yet that wouldn’t even put me within ten orders of magnitude of the theoretical total.  Not that the reality of it all is likely to be a fraction of that optimistic number.  No, I’d be astounded to learn that I’d so much as glanced upon a quadrillionth of it all.  And I’m an unabashed optimist!

So the question one might ask is : “Why bother?”

It’s a great question, not that I find myself quite able to answer it well.  Indeed, when I think back upon my astronomical life I can’t help but focus on the frigid nights and the long and dangerous drives to the middle of nowhere.  Plus the bears; I’ve been accosted by way too many bears for my taste.  Add in the great expense and a host of technical difficulties, plus the all-too-likely likelihood of being skunked—I once spent several thousand dollars and great deal of effort to haul my ass up to the largest observatory in Europe (Pic Di Midi) only to be met by an honest to goodness blizzard; on a June 1st, no less!—and any rational observer (pun intended!) would have to be perplexed as to why I do it.

Now I know I’m supposed to wax glorific, to expound upon the spectacle of it all, to offer something pompous and poetical, but the truth of the matter is that I do view my life in astronomy as somewhat quixotic.  Like most of my fellows I rarely look at things that haven’t been looked at before.  And even then, my instruments have been far from ideal.  For a start, I’m more than a little blind (literally, I mean; my vision barely corrects to 20/30 with glasses) but the metaphor is pretty apt, too.  Those with keener “sight” have come before me.  They’ve perceived the heavens with more sharpness and fervor and love than I; no mean trick if I may be allowed to boast.

Happily, though, I’m long past the point of trying to suss it all out.  Indeed, I can’t quite even remember a time when I didn’t think of myself as an astronomer.  Yes, it’s all too often a pain in the ass and frequently underwhelming.  Not to mention difficult; like “Make you feel fifty IQ points dumber than you’d prefer” difficult.  And inconvenient; “No we can’t {whatever rational nighttime activity you want}, I have to go outside and look up before I miss it.”  And it’s cold; did I mention the cold.  Astronomy comes with a whole lot of bone aching “What the in the world could I have been thinking?” chill.  Hell, it doesn’t even come in color; not really, not like in the magazines.  No, there are countless negatives.

Then again, and here’s the rub of it all, there’s wonder; unabashed mouth-agog can’t-stop-yapping-about-a-bunch-of-overachieving-photons-while-you-freeze-your-toes-off astonishment.  Yeah, I know it doesn’t make a normal kind of sense.  Then again, I’m an astronomer.

BTW, and I probably should have started with this: I’m “your” new president (if you’re a DVAA member, that is).  Hello!

I very much doubt that I will be able to serve you as well as any one of my wonderful predecessors but I do promise to try.  There’s a bunch of the day to day stuff to get done but if I may be so bold I hope to do more.  With your help, that is….

3 Weeks; 2 Guitars (and Counting)

Epiphone Les Paul Standard PlusProBeing a musical noob, an aspiring guitar player / mangler with a whopping three weeks of superb yet less-than-sufficient tutelage under my belt, it’s only natural for me to “need” a second guitar.  After all, my first guitar is merely superlative, a gorgeous Epiphone Les Paul Standard PlusTop Pro Electric Guitar with the Honey Burst styling.  Surely, I need—dare I deserve!—something more.

Actually, though, I kinda do.  This year’s New Year resolution, like so many before, was to finally (finally!) learn how to play guitar.  I’d been intending to do so for more decades than I care to enumerate but for no explicable reason I just got on with doing the do this year.  I won’t bore you with a full list of my learnings to date but the big takeaway is that if I am to avoid becoming road splat on that big highway to non-suckalege I’ll need to pick up and play a guitar each and every day; every day, without fail. Continue reading

Bleak House

When the incomparable Charles Dickens wrote his masterpiece, Bleak House, he did so to satirize the unbelievably flawed English judicial system, but after the horror of last night’s election he could have as easily written his opus about our failed election.  Fuck Trump, I could care less that “he” won; the Orange Talking STD is a symptom of last night’s travesty but in no way it’s cause.  Even so, his presidency will surely bring great harm upon the republic.

What makes me heartsick, however, are my so-called “fellow” Americans; the bitter and disenfranchised half of our so-called plurality who sided with hate and hopelessness, with pettiness and bile and spite.

Sad to say, the joke’s on them.  The “Make America Great” nostrum was always a farce, and will only prove to be more so as time marches on.  And no, I’m not talking about Trump reneging on his promises.  I have every belief that he’ll build his stupid useless wall.  Even so, he will not make “his” people one whit safer, or richer or happier or any of the other good and desirable words, let alone “great.”  Indeed, his so-called “Non-College Educated Whites” will continue their historic slide away from greatness as technology and globalization makes them increasingly irrelevant (except, perhaps, as canon fodder) in the coming years.

The thing they don’t get is that Trump’s central argument is hopelessly flawed.  When the unschooled braggart tweets “I will bring our jobs back to the U.S., and keep our companies from leaving. Nobody else can do it. Our economy will ‘sing’ again.” he has no ideas what he’s talking about.  There are (literally!) no good jobs to be brought back.  Indeed, the future is quite visibly rushing in the exact opposite direction.  In GM’s heyday, it employed 618,365 people in the US, alone.  Today, it employs 216,000 or so, worldwide, a great many of which will be ripe for the chopping block in the coming years.

The heart of a tragedy is missing the obvious as it stares you in the face.  Something you’d learn in college…

How many cops does it take to evict a hawk from a porch?

Upside Down HawkTrick question.  It actually took my bird-savvy neighbor, Jocelyn Bayes, to finally send the poor beastie on it’s way, but I’m very grateful for the cops help, too!

My wife Marie and I woke up before 7:00am last Saturday morning to get ready for a contractor (the talented and helpful Larry Andreozzi) who was coming over to replace a broken window on our third floor.  Imagine Marie’s surprise when she went downstairs and discovered that some sort of big bird had made it’s way onto our screened in porch and was flapping around violently.  The flapping, however, was the least of it.  It turns out the bird was a largish hawk who had smashed straight through the screening only to get tangled up in some Christmas lights and shade pulls  on the front side of the porch.

When I arrived on the scene, the bird had been hanging upside down but as I approached the nearby French door, the bird went into a flapping frenzy.  It must have been exhausted, but being a hawk, the chief thing it looked was steaming mad!

We had no idea, of course, how long the bird had been there but it clearly needed help to get gone.  Unfortunately, with Saturday morning not being the best time for any sort of emergency, a couple of calls to animal control didn’t yield anything!  Our contractor had showed up by that time, however,  and had a great idea: call the cops.

I was a little trepidatious to do so, at first—they certainly had better things to do—but within a few short minutes, first one, then two and ultimately four separate cop cars showed up in front of our house.  Apparently, Drexel Hill’s finest do indeed do birds, and they do so in force.

None of us knew exactly what to do, but Larry had the idea to wrap the bird up in a big moving blanket he had in his truck so it wouldn’t be able to claw anyone while being cut free of the cords.  The cops went with it.  It’s a bit hard to describe what followed next but this video should give you some idea.  I was holding the screen door open for the cops so my camera work is pretty shaky.  Sorry!  Also, the video stopped a bit shy of the bird being eventually shooed off the porch by Jocelyn (who was yielding nothing more than a towel!), but the important takeaways are (a) the cops cut the bird free then after a bit of alarm and hilarity (b) the bird was shooed off the porch and winged it’s way away; hopefully unharmed.

Quite a story!  I’m sure the bird had a lot to tell its friends…