Crypto Trading Framework

https://github.com/itsff/m3f-trading-system

In my free time, I’ve been messing around with cryptocurrencies. Bitcoin, Ether, Litecoin as well as a couple of other, lesser known altcoins. I am mainly using GDAX and Bitfinex for my trades. It’s a lot of fun!

Pretty much all exchanges offer some sort of API. I created a simple .NET client for the GDAX and wrote a simple trading framework. I decided to learn the Akka.net actor model for this project, as it makes writing trading bots easier. Speed is not an issue, as I’ve noticed GDAX’s position tracking system cannot keep up with my apps.

Today I have open sourced my framework on GitHub under revised BSD license. You can clone it from here. It ships with a simple “buy low sell high” strategy which illustrates how to consume prices and interact with orders.  More exchange backends to come (or feel free to contribute more).

Trump Wall, the game

Political satire

I had too much time on my hands in-between jobs, so I figured I would have some fun. I went to Florida to babysit my teenage sister during her spring break, but I quickly realized it was a pretty boring task. When we weren’t at the beach or driving, we would watch election coverage on TV. Political tensions were flying high. In-fighting within both political parties. Just bring out the popcorn. I was really rooting for Bernie, yet it was Trump who was getting the most press.

I decided to code up a little game in order to capitalize on the Trump love/hatred that was sweeping the country.

Enter: Trump Wall, the game!

Trump Wall has a very trivial gameplay. You are helping the newly elected President Donald J. Trump fulfill his (filthy) promise to build the wall along US-Mexican border. You do so by tapping the square outline of bricks. Obviously, the wall is built from the bottom up (you’ll be surprised how many people get confused by that). And since you start from the bottom, that’s a perfect place for me to place an advertisement banner. The more clicks, the better 😉
You complete the level by filling in all the bricks. Once you get all the bricks, you hear Trump proclaim that “the wall just got 10 feel taller”, and the background moves up towards the sky.

The background is usually a random “Welcome to xyz” sign for the southern states that share a border with Mexico. As you complete more levels, you eventually reach one of Trump’s planes or helicopters. Naturally, the game does not have score “points”. Instead, the score represents a number of pesos spent on building the wall.

 

It obviously wouldn’t be a Trump game, if it didn’t feature Trump’s (in)famous sound clips! (“Who’s gonna pay for the wall? Mexico! Who? Mexico!” “We’re going to have strong, incredible borders!”, and so on). I went through countless YouTube videos of his actual speeches to collect them. I cannot believe people are buying this racist stuff. What a world we are living in!

But what about Bernie? Well, I included Bernie in the game too! As the levels get harder, Bernie’s election stickers stand in the way of some of the bricks. You then really need to mash them in order to make Bernie disappear.

Overall it was a fun side project. Political satire is a great way of poking fun at our presidential candidates. I had no issues publishing the game to Google Play, but Apple gave me some serious grief. I was rejected multiple times and had to remove a majority of the controversial content. I understand they are just protecting themselves, but how is it my fault that we have such a “tremendous” presidential candidate? 😉

You can download the game here.

Continue reading

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 🙂

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 😉

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 😀

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 😀 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 😉