Bloomberg 1970s

by Kofi Sarfo 15. October 2009 19:51

Bloomberg connectivity is a riot. We submit (by FTP) a text file with an expected format using carriage return and line feed to separate data entity requests.

From C# this means shelling out to a batch file (remember DOS) which executes some Java code responsible for handling request/response. If the request is valid then one minute later a zip file is returned that contains a text file. We parse and we have a database ready data file. If the request is badly formed, however, then an error file is created on the remote FTP directory but that is never returned!

Five years ago someone asked on WILMOTT (serving the Quantitative Finance Community) how to connect a Java application with Bloomberg to send and receive data. Dominic Connor was kind enough to reply.

At another time, at another place we used the DLLs on the Bloomberg terminal to return the data we needed. It was fast, efficient, predictable and illegal. Good times.

You may be here looking for something on bbdlftp or BBDL FTP. Good luck.

Tags:

Nostalgia

Project Euler

by Kofi Sarfo 25. August 2009 00:43

"Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems." - Project Euler .Net

Maths problems aren't something we've been going out of our way to find. In fact we were looking for Code Katas when we found Project Euler. The first Code Kata, Supermarket Pricing, isn't immediately a programming problem. In fact it doesn't take a tremendous leap to flesh out concrete example code even though the real idea is to practise some modelling. So in pursuit of an immediate problem requiring an immediate solution via code:

#1 Add all the natural numbers below one thousand that are multiples of 3 or 5

No, it's not in the least bit difficult but that's not the idea. The obvious solution:

public static long AddNumbersThatAreMultiplesOf(int Min, int Max, int[] Primes) { long sum = 0; for (int i = Min; i < Max; i++) { foreach (int p in Primes) { if (i % p == 0) { sum += i; break; } } } return sum; }

It's an example of doing just enough to get the right answer. A better solution (cleverly translated from PHP) is below:

public static double GetAnswerUsingMoreOptimalSolution() { long max = 1000; double SumOfMultiplesOfThreeBelowMax = 1.5 * (int)((max-1)/3) * (int)((max+2)/3); double SumOfMultiplesOfFiveBelowMax = 2.5 * (int)((max-1)/5) * (int)((max+4)/5); double SumOfMultiplesOfFifteenBelowMax = 7.5 * (int)((max-1)/15)*(int)((max+14)/15); return SumOfMultiplesOfThreeBelowMax + SumOfMultiplesOfFiveBelowMax - SumOfMultiplesOfFifteenBelowMax; }

This more optimal solution (not mine) looks to be derived from GCSE mathematics, the formula for arithmetic progressions: A sum of terms equals (n/2)(a+l), where n is the number of terms, a is the first term, and l is the last term.

Note: The obvious refactoring in GetAnswerUsingMoreOptimalSolution() has been left intentionally :)

Online Hang Outs Part I

by Kofi Sarfo 5. June 2009 16:56

 

I can't remember where I read something about having to read a decent amount of well written code in order to be able to understand how to code well. I think a parallel with writers and books was drawn somewhere nearby... Anyhow, this is why we've been hanging round the The Code Project since 2001 sometime and there appear excellent articles / code samples every so often; for example, the "Best C# article of April 2009" competition winner was Geoplaces. "A hybrid smart client, involving RESTful WCF/WPF and more." It's pretty.

 

It's a while since we wrote anything from scratch and those bits of code we've picked up in the last year don't look much like this. They don't look this good.

The Data Layer is all Entity Framework so happy to give that a miss but the Restful Service Layer is a nice intro into the System.ServiceModel namespace.

The Service Interface provides examples of ServiceContract and OperationContract. Backing up... MSDN: Introduction to Building Windows Communication Foundation Services. Note that this intro was written four years ago! Cut to mid 2009 and we still have indication of pain. Ayende: WCF Works in Mysterious Ways. IColloquialize: WCF Service References Generating Empty Root Proxy Classes. First takes suggest WCF might not be so straightforward.

Kofi Sarfo modified theme by Mads Kristensen



Content by WIMIRO Technology is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Creative Commons License

Powered by BlogEngine.NET 1.5.0.7

About Me

Director, Wimiro Technology
London, United Kingdom

Writes in third person and first person plural; currently commutes to Moorgate.

Kiva Loans

  • Issa Sarr

    Issa Sarr

    Personal Purchases

    Requested loan: $200

    Amount raised: $75

    Dakar, Senegal

    social needs

    Loan Now »

  • Edwin

    Edwin

    Movie Tapes & DVDs

    Requested loan: $800

    Amount raised: $125

    La Paz, Bolivia

    Buy a DVD burner tower

    Loan Now »

  • Soo

    Soo

    Laundry

    Requested loan: $5375

    Amount raised: $2175

    Queens, New York, United States

    To purchase a new dry cleaning machine

    Loan Now »

 To see more entrepreneurs »

Kiva Loans