Docker Compose

While I was working for Trading Technologies, we always planned on using Linux Containers to provide secure hosting of user-written TT SDK algos. Docker was supposed to be the way of ensuring proper isolation, resource management, as well as means of convenient deployment of client strategies. The infrastructure was in place, but I left before we had a chance to materialize our plans.

Recently I decided to give Docker another go, this time as a way of managing my various cloud projects. I was happy with DigitalOcean’s offering, so I began migrating my websites and jobs to their cloud. Everything, of course, is containerized and managed together. I am using Ubuntu 14.04 with Docker Compose.

I must say I am pleased with the results. The migration has been rather painless, and I like how simple the config ended up. I am running a container with a shared MariaDB (MySQL) database, a reverse-proxy Nginx to manage routing, several WordPress blog containers, few C# ASP.NET sites (Mono, not CoreCLR), some Python sites (Flask), and bunch of Python/C++ apps. A sample docker-compose.yml file is shown below.

As you can see, I am using dmp1ce/nginx-proxy-letsencrypt image as a web proxy. Just like with jwilder/nginx-proxy, it’s dead simple to configure routes. All a container needs to do is to specify VIRTUAL_HOST=something.com variable, and the web traffic will be forwarded to its exposed port. Image dmp1ce/nginx-proxy-letsencrypt has LetsEncrypt.org support built right in. Specify LETSENCRYPT_HOST and LETSENCRYPT_EMAIL and voilà- free SSL for your site 🙂

Hacktoberfest

I finally got my Hacktoberfest gear from DigitalOcean. It was a fun opportunity to contribute to open-source projects while scoring a sweet t-shirt.
I fixed some annoying bugs in the weld build system that I’ve been using for my personal C++ projects. Hope you guys enjoy.

Hacktoberfest T-Shirt from DigitalOcean

Naturally this “hacktoberfest” made me take a closer look at DigitalOcean and what they have to offer. I’ve gotta say: I’m impressed! Seldom one finds such fast and cost-effective cloud providers. I’ve been using AWS and CloudAtCost, but now I am seriously thinking of migrating at least some of my projects to DigitalOcean. Well done, sirs, well done!

Six months at Thomson Reuters

It’s unbelievable how fast the time goes by. It was only in January that I started my new role of Lead Software Engineer at Thomson Reuters, and here we are six months later. Lots of things have happened during those two quarters, and I feel I really grew a lot professionally. I am part of a new team charged with revitalization of TR’s data feed architecture. I live and breathe C++14 and low-latency is my middle name 😉Thomson ReutersThomson Reuters is a much different place than any of my previous gigs. It’s a large, mature company with thousands of well-known clients. Oftentimes I need to interface with our developers in St Louis, Beijing and Hong Kong, sometimes at ungodly times of the day. Good organization is key. Our code is also well designed. I must admit this is the first time that I was forced to write extensive unit tests. It took some time to get used to, but now I really appreciate them. It’s much quicker to find obvious behavior bugs accidentally introduced by code changes. I cannot believe I’ve gone so many years without proper unit test coverage.

Despite Reuters’ size, I feel like I have a lot of power to innovate on my and cross teams. This was something I feared I’d lose in a large firm, but thankfully I was proven wrong. There is plenty of autonomy.

And finally – the people. I am lucky to be surrounded by lots of smart, kind people who are a pleasure to work and hang out with. I’m learning tons of new stuff, which is a definite plus. Let’s keep this thing going! 🙂

TT Mobile showcase

My friends at TT are really busy trying to get the mobile clients out the door and into production. TT’s twitter account is buzzing with all kinds of photos and videos. I am really happy and proud of how far my apps have come. The end result is looking beautiful and I am sure the end-users will be delighted by both the design and functionality.

I really enjoyed working on TT Mobile, as it presented a very unique set of challenges. How to effectively push price updates over potentially slow cellular connections? How to ensure users don’t accidentally place trades (butt trading anyone)? And how to effectively integrate with the rest of TT’s eco-system? I think the team did a splendid job and the apps are rock solid. One disappointing fact is that both Android and iOS apps could have been released over a year ago, had we chosen to re-use logic. There are ways to write the code once, and use it verbatim on multiple mobile platforms (naturally the look-and-feel needs to be done separately, so that the app feels “native”). I have long argued with the executives and advocated for shared business logic, since it seemed like a no-brainer.

  • Shorter time-to-market. In today’s fast-moving world it’s imperative to be there first.
  • Lower cost of development.
  • Less bugs.
  • Parallel releases on multiple platforms.
  • Lower long-term maintenance costs.
  • Less testing effort.

Other companies are not as short-sighted and have long recognized the benefits of writing the common logic once, instead of re-implementing it for every platform. Xamarin has their cross-platform C#. Google is pushing Java with its ability to share code between Android, iOS and the web. Dropbox uses C++ for shared logic. RemObjects has their cross-platform Swift. Not to mention frameworks like Flash and Cordova. I still cannot believe that the decision makers would rather have us maintain two separate codebases, but I guess you need to be good at engineering to comprehend the benefits.   

On a positive note, I am extremely pleased with the aesthetics of TT Mobile apps; graphical design and usability are essential. Nobody wants to use an app that looks “f-ugly” or that feels cumbersome. Folks at TT spent countless hours doing usability studies and polishing the design. Trust me – a lot of love went into making of these apps. They look awesome, they are snappy and I really hope you’ll enjoy them 🙂

TT Mobile in Google Play

Today marks an important milestone. TT’s next-generation mobile trading app for Android has been deployed to Google Play Store. It’s still in pre-release and available only to beta testers, but we are getting closer every day. It’s very stable and usable. The overall look has deviated slightly from my original design, but I like it better this way. It’s a little bit more intuitive. Below are the main functions of the app so far.

  • Watchlist of instruments
  • Instrument-centric view of orders and positions
  • Trading from order ticket
  • Trading and order management from price ladder (MD Trader)
  • Order management screen
  • Fills and Positions
  • Forever Audit Trail

The users can input trades from order ticket and MD Trader, monitor orders, have a watchlist of instruments, inspect their positions and watch the forever audit trail. Not too shabby for a mobile app! Very full featured, especially when compared to what’s out there. The team did an outstanding job. Oh, and iOS app is coming along as well.

If you have a @tradingtechnologies email address, head over to the link below and download your copy for Android.
https://play.google.com/apps/testing/com.tradingtechnologies.ntm
(pssst – can’t access the page? Make sure you’re logged in only with your TT account. Try incognito mode)

For those of you who don’t yet have access, take a look at some screenshots below.

8 years at Trading Technologies

I just noticed it has been a whole 8 years since I started working for Trading Technologies. I was hired fresh out of college and began my journey on May 15, 2006 (well, I did some consulting on the side before coming to ChiTown).

trading_technologies

Company logo when I started

 

New TT logo

New TT logo

 

 

During my career at TT, I pretty much worked on everything the company has to offer.

I spent countless hours massaging our flagship X_TRADER product. I was a key player in bringing .NET into the program and integrating it with native C++ and MFC. This really made adding new windows easier (have you ever had to deal with Win32/MFC?!) and allowed for tight X_STUDY integration.

X_TRADER's .NET toolbar

X_TRADER’s .NET toolbar. Click for larger image

 

In order to achieve maximum performance, I completely rewrote the Time & Sales window. Both the stand-alone and one integrated into MD Trader. While working on T&S I learned a lot about grids and data virtualization.

Time & Sales window

Blazing fast Time & Sales window with the default (butt-ugly) X_TRADER color scheme

 

Every trader who’s copying/pasting links to and from Microsoft Excel goes through my Link Manager. That was a very fun project which definitely provided a ton of value for our customers. There are thousands of traders who design their strategies in Excel spreadsheets and want their numbers to be shown on grids, charts, ladders and algos. And this works both ways – I allow them to copy cells from X_TRADER and insert them into Excel. The data flows flawlessly and everything just magically works.

X_STUDY OLE linking

Look ma! I has Excel linkage! (Click for larger image)

For fun I also added preview to the Color settings window, which finally made it usable.
I wrote so many things for X_TRADER that I actually lost track. Not to mention countless prototypes to fool around with new features. Definitely good times 🙂

 

I am the architect and author of TT API – our high performance trading API for Windows. It was a great few years designing and implementing all the different features. I certainly learned a lot. TT API lets you trade any exchange that TT supports, including Autospreader SE and Synthetic SE engines. You can really go to town. Just check out TT API samples on GitHub.

It’s also worth mentioning that internally our Algo SE server and ADL (Algo Design Lab) are both powered by my TT API.

 

Two years ago I was selected to start on TT’s future platform. The codename for it used to be “Nextrader“, but due to trademark conflicts a new name was chosen. I coined the name and designed many low-level communication and security details (EdgeServer-to-client path, authorization, protocols, etc) which are now the foundation of the new system. I also led and directed the client-side team.  The TT platform is written from the ground up using modern technologies. It’s optimized for speed. Trust me – you will feel it 🙂

In addition to web-based interface, TT Platform will ship with an Android mobile app. That’s another one of my babies. I designed the flow and general layout of the main screens for both phone and tablet form factors. Our in-house designer Kevin made them look awesome. I’m sure you will love it! Working on mobile is challenging, as it forces you to think from a different perspective and face a whole new set of problems. Limited screen real-estate, battery life, disconnect scenarios, butt dialing (or shall I say: butt trading) are all issues you have to deal with. I had a blast 🙂

Side menu

“Nextrader” for Android prototype. Side menu. Click for larger image. The name has since been changed to “TT Mobile”.

 

MD Trader on Android

TT Mobile for Android. MD Trader on a phone. Click for larger picture.

 

I started writing iOS version of TT Mobile with my team, but I didn’t get too far (enough to master Objective-C). I was needed on the new Algo project. Currently I am working with Andrew Gottemoller on our next-generation trading API, which we internally call TT SDK. The plan is to allow our customers to hand-craft their algos and run them in our co-lo facilities for minimum latency and maximum speed.

 

TT SDK is lean. It is fast. Linux and plain C. It is powerful, yet feels delightfully simple.  In addition to C we will eventually provide wrappers for higher-level languages. I, naturally, already have a C++14 and Mono C# version going. Stay tuned!

 

As you see, I’ve been having fun. Trading Technologies is a great company, but its most important asset are definitely the people. Everyone is smart and easy-going. I made many good friends at TT and I’m happy to see them every day.
Let’s see what the future will bring 🙂

SafeBuffer and UnmanagedMemoryStream

At work I have a situation where I have some binary data allocated in the native code. It’s pretty much a raw char*. I then would like to access that same information from the managed side. But how? Of course I can just copy the data to a byte[] but that’s just wasteful.

I did some googling around and found the obvious solution – UnmanagedMemoryStream. It can take pointers, or a SafeBuffer. The latter is basically a smart wrapper around memory handle. Take a look at the code I came up with. I hope somebody will find it useful. It’s still work in progress and can use some love, so any comments are welcome.

I needed to pass the std::unique_ptr as r-value, otherwise the linker complains (thunks for non-existent copy constructor). I still need to clean this code up to handle custom deleters. But it serves my needs for now.

Edit: There is a bug in this code. Can you spot it? 😉

Async keyword alternative

Unfortunately, both MonoTouch and Mono for Android still don’t support the async keyword. Raw TPL is rather inconvenient to use. You have to remember to catch exceptions, return faulted tasks, etc. ContinueWith can also be inefficient due to thread switching.

Today while browsing the interwebs I came across Brad Wilson’s blog post which led me to these two files. TaskHelpers are (no pun intended) very very helpful! The extension methods emulate the await goodness pretty well.

I modified them a little bit. Here is a gist.

Mo Calc “clone” detected

I was checking up on Mo Calc over at Windows Phone 7 marketplace today and I came across an interesting finance app.

It’s called Loanster. Check out these screenshots below:

Loanster - cheap Mo Calc clone Loanster - cheap Mo Calc clone Loanster - cheap Mo Calc clone Loanster - cheap Mo Calc clone

Despite drawing inspiration from Mo Calc, I am assured that Loanster is a completly legit and independently written app. Its author Tony was nice enough and agreed to tweak the UI in the next version in order to differentiate Loanster from Mo Calc a bit more.