Solution to MacBook storage problems

At Trading Technologies we recently switched to laptop-centric culture. Our desktops got lugged away and everyone can choose what kind of laptop they would like to have. I was one of the pilot MacBook Pro users and I got mine over 18 months ago. It took me a while to get used to it, but it completely changed the way I work. It’s so easy to just grab a laptop and crash a meeting room with two other devs. This makes communication so much easier. Not to mention I can now work on the train. Every company should consider this!

Unfortunately my Mac came with only 256 gigs of storage. For a developer that’s not that much. Especially that I use a lot of OSs on many VMs. I asked our IT, and they listened. It came earlier today. LaCie external SSD with USB 3.0 and Thunderbolt. It’s a speedy ~250MB/sec.

 

I really had a lot of fun velcroing it to my Mac. What do you think? Geeky enough for you? ;-)

Behold:

External SSD

External SSD velcroed to my MacBook Pro. Match made in heaven ;)

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 – Nextrader. 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 Nextrader 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, Nextrader 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.

 

MD Trader on Android

Nextrader for Android prototype. MD Trader on a phone. Click for larger picture.

 

I started writing iOS version of Nextrader 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.

HID Card and Android phone

At my workplace we use HID ProxCard II cards to enter the building and to open individual doors. Everybody has a card with their picture printed on it. The problem is that I keep forgetting mine, plus I’ve had it for such a long time that the card started to disintegrate and it looks rather nasty.

HID card

I really wanted to just use my Android phone in lieu of the card, but it seems like HID cards are not compatible with NFC :-(
This of course wasn’t going to stop me. Somehow I wanted to “fuse” the card with my phone. If my phone had a plastic case or cover, I could just slip the card inside of it. But I own an HTC Once and since it’s made out of aluminium and gorilla glass, I don’t really need (or want) a cover for it. I decided to use a sticker to attach the card instead. I ordered a custom-fit sticker from SkinIt with a cute picture of my boys on it. Now I could finally start my project :)

Costom skin for HTC One

 

First I cut off a small strip of plastic along every edge of the card, starting with the top. Then I removed the front layer with the printed picture. It was clear that there were two additional layers to the card. Finally, I carefully separated the two remaining layers, exposing a copper coil and something that looked like a microchip.

Removed sticker and cut sides

Coil

 

Next step was to affix the layer with coil to the back of my HTC One. I chose not to remove the coil from the plastic it was glued to, and instead to attach the whole thing to the back of the phone with scotch tape. Of course I rounded it off a little bit witch scissors, just to make it look better.

HTC One

Coil from HID card affixed to back of HTC One

The final step was to place the SkinIt sticker over the back of the phone. Sadly that didn’t go as smooth as I hoped. Since the coil and microchip are not perfectly flat, you can see a small bulge. It will take some time to get used to it, but ultimately it should not be a big deal. A small price to pay for the convinience.
Here is a photo of the finished product. Now I just need to remember to carry my phone around with me at all times at work :D

2013-10-07 17.56.12

NFC Extravaganza

What’s cool about the new Android phones is that they support Near Field Communication (NFC) technology. This was actually one of the reasons I got my HTC One.

Payments

I can now use Google Wallet to pay with my phone, simply by tapping on NFC-enabled credit card terminal. Hopefully soon every point of sale will be accepting NFC payments, especially after Apple jumps on board and ships iPhones with NFC.

NFC payment

Tap to pay is pretty cool, but I was curious what else NFC can be used for. There is the obvious tap to share pictures, or contacts, but what else?

I did some googling and came across this website: http://www.tagstand.com/. TagStand not only sells physical NFC tags, but also provides neat Android apps for interacting with the tags. One can read and write data to NFC tags, and later use them as triggers to execute various actions. What does that mean? What can it be used for? Well, check this out.

NFC-enabled sticker

Car mode

Every time I get into my car I turn on navigation and Bluetooth, so that I can listen to music through car speakers. I also turn on the “car dock” app, so that the screen doesn’t lock while I’m driving. Of course when I leave the car I need to remember to turn all that stuff off. Pretty repetitive… NFC to the rescue!

I got myself several NFC stickers from TagStand and installed NFC Task Launcher app to my phone. I placed a circular, water-proof tag right next to the gear shifter. Now all I have to do is to tap the sticker once I get into the vehicle.

2013-10-07 15.51.27

The NFC Task Launcher app is programmed to execute these tasks when phone is near my “car mode” tag:

Car mode taskIt’s pretty awesome. I don’t need WiFi, since I’m on the road. But I want GPS, Bluetooth, car dock, loud volume. Just for fun I have the phone say “Car mode activated. Have fun but drive carefully.” The only thing to watch is space. The NFC tag I’m using has only 144 bytes ;)

I also use my car’s Bluetooth as a trigger – when the phone detects car is no longer connected, it will execute the following steps:

Out of car

I never need to worry about doing this manually again :-D Next I need to consider buying an NFC-enabled cradle; then I think the project will be complete.

NFC cradle

Other possible uses

I can picture placing the tag at work for time-keeping reasons, or at the church entrance. First tap to activate the “church mode”, second tap to disable it (vibrate mode, Bluetooth off, GPS off, WiFi off, Bible app on). Although for these you could use a “geo-fence”, but constantly checking location brains the battery.

I promise to write more once I come up with any more clever uses for the NFC awesomeness.

 

Edit: I was hoping to use my phone’s NFC as smart HID card at work, but the frequencies do not match. Came up with an alternate solution.

Update: I found a good website (http://www.buynfctags.com) which offers cheap NFC stickers, as well as high quality custom made NFC business cards. Definitely a must for high tech companies ;)

Hello (and goodbye) Tumblr, WordPress it is

After years of using BlogEngine.net, I decided I’m tired of hosting my own content and dealing with the lack of themes.

There were many contenders for replacement, but ultimately I settled on Tumblr. It’s easy, let’s me use custom domain name for free and, ever since it got acquired by Yahoo, it seems fast enough.

The only downside was importing content. I was very surprised it does not support BlogML! That’s just crazy. I had to hand code a simple importer in Python. Not a big deal, but still… Unfortunately all my permalinks are gone :-(
Not the end of the world, since I don’t have that much content.

I guess we will see how it goes. I can always switch to something that gives me more flexibility.

Edit: And so it happened. I didn’t really like the way editing of posts happens on Tumblr, especially that it’s difficult to insert images into text posts. So I decided to switch to WordPress. Still didn’t bother with the permalinks (someday I will remap them), but I’m quite happy for now.

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.