hammertoe

A coffee-loving software developer.

This is a write-up to follow the video of the second episode in my series of writing an algorithmic trading bot. You can find out more about this project on the first post in the series:

https://coil.com/p/hammertoe/Writing-an-Algorithmic-Trading-Bot/juWpy7ofn

In this second post I start to get into the actual code. Looking at the data we are going to need to feed into the system and what the machine learning algorithm is going to work with.

The rest of this post and the video of the live coding session are below exclusively for Coil subscribers.

Read more...

Whenever I have do a BBQ I have to do this as a desert. It's just kind of become a “thing” now. So going off camping I have a bunch of bananas, some chocolate and some whisky with me. And some tin foil.

Make a pouch out of the foil (I use a double layer just in case) and put the banana in the middle. Cut the banana down the middle lengthwise and put a load of squares of chocolate in:

Then pout in a good slug of whisky (ruuum would work too). Have a glug yourself. Mmmmm...

Than fuld the foil up and schtik it on tha BBQ...

Than leaf it fur a bit and drunk some moar whischy...

Then take it off... OWwwww f^&k... thas hot! Get tongs and trey agin to take it oof the BBQ.

Drink some mure whischy...

Tha upin it up.... look s a bit like sssshih... is lovely... really good. Ish hot! Be carefullll.

Grab spon. Dig in... Drink maour whusky.

Luv yu all!

I'm currently taking a few days break off camping. Just me and the dog for 3 nights on a campsite about 1.5 hours away from where I live. Usually my wife and daughter comes with me, but they said I should go on my own to relax as an early birthday present.

And it is lovely :)

Yes, I love them both, but it is so nice to just be here with me and the dog and not have to worry about when anyone else wants to do apart from myself (and the dog!).

And that includes cooking :) One thing that I love doing when camping is making my own bread. Usually just some simple flatbreads to eat with dinner, or a replacement for burger buns. But this time I decided to make a pizza. I used the basic recipe concept from my Flammkuchen recipe. A simple mixture of flour, olive oil, salt and water.

I used some stoneground wholemeal bread flour I got at the supermarket on the way here. And I just mixed it all up by guesswork.

I got the BBQ going, it is a charcoal one with a lid that shuts to keep the heat in. And once the coals were hot I pushed them right to the edges to try and simulate a pizza oven somewhat.

I poured some flour into a bowl. Probably about 100-150g worth, then a glug of olive oil (maybe 2 tbsp?), a good sprinkling of salt. Then added water slowly bit by bit until it formed a dough. I also sprinkled some fresh rosemary into it as well... just because.

Once the dough camp together I rolled it out using an empty beer bottle as a rolling pin and then put on some toppings. I brought with me some passata, mozzarella and some chorizo slices. So on they went in that order, and then I chucked it on the BBQ. Maybe “chucked” was a bit too energetic for it as the toppings all slide off and I had to hastily recover them and rearrange them.

I then shut the lid of the BBQ and left it a while... maybe 5 minutes? And then checked it every few minutes to make sure it wasn't burning on the bottom. Once side got slightly overdone. But otherwise it came out well. The cheese all melted and the chorizo all oozing its lovely oils everywhere.

And washed down with a yet-to-become-empty bottle of beer.

Delicious!

It won't make any Napolitanos happy, but it made me happy :)

Background

I've got a VW T5 campervan. It is both my “daily driver” (not that I drive much... even before lockdown... I cycle most places)... but I also use it for trips away. Mostly just a few days camping around the UK, but I've been over to the Netherlands a couple of times for XRP community meetups.

You might have noticed I spend a fair amount of time online ;) and so having good connectivity is something I like. Even when going away camping. My daughter still wants to be able to access Youtube and Netflix etc. And quite often I like going away camping and writing code for certain projects (yes, amazingly it is my way of relaxing).

So to cater for my mobile connectivity requirements, I have build a mobile base station into the van. This consists of several parts

  • A Raspberry Pi running Plex as a media server and acting as a wifi base station.
  • A Mikrotik Groove 52 2.4/5Ghz outdoor wifi unit with a 15dB omnidirectional antenna to connect to a campsite wifi

The goals of this setup were to achieve two things:

  1. Whilst on the move, or away from connectivity, allowing my daughter (and my wife and I) to be able to access a library of films/TV shows via the Plex server in the van. All my daughter's favourite Disney films are on there, and my wife's addiction to Columbo is taken care of (“Just one more thing...”)
  2. When we are camped on a campsite with WiFi that we can get a decent signal despite distance / obstacles in the way / many other users.

The Raspberry Pi runs all the time, and it powered by the leisure battery under the driver's seat, which in turn is charged by two 120W solar panels on the roof and/or the engine alternator.

So the laptop/ipad/phones connect to the Raspberry Pi, and then if we are onsite, the Mikrotik is connected via an ethernet cable to the Rasbperry Pi and in turn it connects to the campsite wifi. I have a 3 meter extendable mast that the external antenna can attach to to get above the height of other vans / caravans / terrain. The 15dB antenna is comically large, and looks like a light sabre. But it was what was in stock when I ordered, so I went for it (“It won't be that big, will it?“).

Problems

I am planning on heading off camping for a few days this week, and as I've not used the van much recently I thought I'd check all was working. As it happened the Wifi was not working and I remembered I'd not quite finished off the actual grand plan above. So set about fixing it.

Everything it mounted under the drivers seat, so took that out to get to it easier:

In the photo below, we have the leisure battery, a Banner Energybull 110Ah battery. Then left to right in front of it: Victron Bluesolar solar regulator, Raspberry Pi, fusebox.

The solar regulator is really nice, as you can connect to it via Bluetooth and get various stats as to how much power you are getting from the solar panels and the charging state of the battery, and how much load you are drawing from it:

Turned out the power supply to the Raspberry Pi had died. It is designed to take 12v feed from the van and drop it down to 5v for the Rasbperry Pi. Every month the solar regulator does a “balancing” charge of the battery cells and takes it up to 16v for a short period of time. I'm suspecting that may have fried the power supply.

As I'm going away in a few days, I didn't have time to wait for a replacement. Whilst I could get the same one again, I have ordered a much more capable “buck boost” converter from eBay which can take a much wider range of input voltages, and supply up to 10A output:

But I needed something right away whilst I wait for the above PSU to arrive. Hunting through the garage I found a cigarette lighter socket style USB supply. It is only rated to 2.1A, but might be just enough to power the Raspberry Pi (recommended 2.5A minimum). So set about breaking the plastic case open to get to the guts of it. I clipped it to the battery to test it, and sure enough it worked enough to power the Raspberry Pi:

So I set about soldering on some wires to it. I cut the wires off the old supply to re-use, as they already had ring terminals on the end. I even found some shrink wrap to put around the terminals. Professional!

I connected it up to the fusebox and plugged the Raspberry Pi in... all still worked. You can see at the bottom the white connector, that is a RJ45 connector in which to plug the Miktotik unit into. That is a power over ethernet injector cable also wired into the 12v fusebox. So the Mikrotik is powered directly from 12v along the ethernet cable.

So for the actual final test, I plugged the Mikrotik in along with it's external antenna (I told you it looked like a light sabre!) and grabbed my laptop to see if it could connect to the wifi back in the house.

Yay! It worked :)

I then tidied everything up and put the seat back in the van. Here is how it looks if you peer under the seat. The cat5 socket is just there read to plug the external wifi into when needed.

I did plan on putting a wooden panel on the front to just tidy it up and stop random stuff rolling under the seat, but the panel socket RJ45 connector I bought for the job is hiding somewhere in the dark recesses of my garage. So that will have to wait for another time.

And for Coil subscribers, you can see the wonderful bit of kludging together I did to create a simple way to attach the 15dB external antenna to the 3m extendable mast I have:

Read more...

Processing File Uploads with IBM Cloud Functions

TQDM: Adding a Progress Bar to Smiler

So, this is an idea I've had for a while... doing a video and blog series on writing algorithmic trading bots.

I have been writing these bots for the past 3 years now, and made many different sorts of bots using various different strategies and trading on various different platforms. Some profitable, some not. So I thought I'd do a series of videos following me writing the next one.

I'm not an “expert” in these things, and have no education in finance or trading. But I am a software developer and have some experience with data science, stats and machine learning (AI) and it has been a constant interest and side project of mine over the past few years.

The cartoon above is the punchline to a joke about two campers in a forest that come across a bear. One starts running, and the other says “What are you doing?! You can't outrun a bear!” to which the running camper says “I don't have to outrun the bear, I just have to outrun you!”

This is my basic philosophy about my experiments with algorithmic trading. I don't have to beat everyone, but just have to “outrun” the “average Joe” in order to make a profit.

The first bot I wrote in 2017, a market maker that traded on the decentralised exchange on the XRP Ledger, was very profitable in the 2017 and start of 2018. But it relied on a certain trade volume that unfortunately is not there any more (although does seem to be returning slowly). I have since written many other bots, some trying to predict price moves over days, some over seconds. Some arbitrage bots working between exchanges. Some exploiting pricing discrepancies on a single exchange.

So this series of posts and videos is going to chronicle the next one that I'm writing, and hoping to put into production. All of these posts will be for Coil subscribers only, and the videos on Cinnamon as subscriber only videos. So if you want to see what's going on you will need to have a Coil subscription.

The first video, is all about my experiences so far, and talks about the background of algorithmic trading and some of the strategies that can be used. I don't go into any code in this video, it is just a video to set the scene. And might be of interest to those interested in trading, finance, and/or cryptocurrencies regardless of technical level.

The first episide, the introduction to the series is available for Coil / Cinnamon subscribers below

Read more...

Have you every tried to take a snapshot of a video and yet you get an image where everyone is looking glum?

Wouldn't it be great if somehow you could find the “smiliest” frame from a video and extract that for the snapshot?

Well, that is what I try to build in this video!

This is a video taken from my weekly show “ML for Everyone” that broadcasts live on Twitch every Tuesday at 2pm UK time.

To detect the faces and the smiles we are using the open source computer vision library OpenCV.

The results came out pretty well, but I've got an idea of how to improve it even further next week

For full details on the technical run down on how this was developed, see my post on DEV:

https://dev.to/hammertoe/smile-detector-using-opencv-to-detect-smiling-faces-in-a-video-4l80

Next week I'll be developing it further, come join me on the live stream:

https://developer.ibm.com/technologies/artificial-intelligence/events/training-a-convolutional-neural-network-cnn-to-detect-happy-faces/

Header photo by Omar Lopez on Unsplash

Read more...

A few days ago a colleague of mine, Si, tweeted to another colleague about a task organiser / reminder / todo system he'd seen:

It looked pretty cool. It is a very simple system of pre-printed 3x5” cards with room to write todo items on, and a little circle to colour in to indicate status.

The idea is that you write a todo list each day, with the date written at the top. And at the start of each day you can reflect on the previous day's card and copy over tasks still to be done. It is this copying that appeals to me. I think it will help me focus on what needs to be done each day.

I really liked the analogue nature of it (it is actually called analog). I am surrounded by tech, but I still very much like the physical act of writing todo lists. Although I'm not very good at doing this. I used to work with someone who had lists and lists and lists. I was always jealous of how organised he was.

The Analog system looked good, but is a kick starter and not shipping for a while and also a not insignificant price. I think the price is worth it for the craftsmanship, and it certainly is a lovely looking thing. But I just wanted to test out the process to see how I got on.

So I ordered some A7 blank cards online which arrived yesterday and this mornign went out the garage on this slightly rainy day. I grabbed a bit of offcut wood from a desk I cut down a while back and grabbed some tools.

I used a router to route out the middle bit where the cards were going to sit. Then chiseled the corners square. Then cut it out and sanded it down.

I'm not a great woodworker. I like woodwork, but I didn't want to spend too much time on this. I just wanted to create a prototype and just take an hour this morning doing some woodwork.

The end result?

The cards don't quite fit. I made the tray big enough, but the corners still slightly too rounded for them to fit properly.

I was going to go back out and try and chisel them out a bit further... but actually I decided not. I'm keeping it like that. Also if I do another iteration, I'll cut the back out to make it easier to slide blank cards out.

The Japanese have a thing called Wabi-Sabi, which is celebrating imperfections in things. The Japanese are also master craftsmen, so I don't think wabi-sabi really applies to my shitty woodworking... but I'm going to go with it.

I'm going to keep it this way to celebrate the folly of mankind, and to remind me everytime I write my todo lists each day, that things don't always go to plan. And whilst perfection is a laudable goal, remember that Voltaire said “Perfect is the enemy of good”.

So, one of the teams I'm on at work started doing this thing called “Five for Friday” in which you have to list 5 things on a topic. So last week was food, etc. This week was “random”.

  1. I was born in Singapore. Lived in Singapore, Malaysia, Indonesia, Scotland, US, UK.

  2. I used to do marathon kayaking. 125 mile races. Over 4 days as I was a junior at the time. But still. Came 2nd place in my category one year. I was also a qualified kayaking instructor and used to paddle whitewater in the winter. Myself and friend 'Spud' still hold the record to this day for junior touring doubles on the Exe Descent race, finishing in 2 hours 59 minutes and 59 seconds crossing the finishing line upside down (managed to roll back other side)

  3. I don't eat fish or seafood. Apart from tinned tuna and mayo. That doesn't count in my brain. Or swordfish/tuna steak. I wish I did, as I see such fresh fish being landed when on my travels. But just the taste and thought repulses me.

  4. I am a big BSD unix fan, and my servers all run a mix of FreeBSD and OpenBSD. It was the first Unix I cut my teeth on, and Linux still feels not quite right to me.

  5. Just before joining IBM two years ago, I thought I was going to get rich from a cryptocurrency trading bot I'd written. But my wife said I should probably get a 'proper job' as otherwise I'd be sat at home on the sofa in my underpants all day. Market crashed shortly after. As usual she was right.

Previous Five for Friday – Work.

Header photo by Francis Nie on Unsplash