Trial and Epic Fail

Ventures of an indie game developer


Gah! Had made an off-by-one error which made my "real" trade data invalid and overly optimistic. Bah! So in the last four days I re-tweaked and started measuring again. If the yield is at all positive, it will probably be a more step-wise gain than the smooth sailing I had anticipated when the bug was fogging my vision.

An hour ago I started working on the automated trade bit. Login first. To be able to log in on the trading site, they use RSA-encryption of the password in JavaScript (over https), so had to reverse engineer that a piece of code as I want Python, not JS. Js2Py to the rescue! It did the trick right out of the box on the minified, horrid encryption source, and was able to generate working Python code. Albeit really slow - it takes seven seconds to poke around with the public key and encrypt some data. Even though there's no need for speed here, I still feel the urge to do some optimization. Never could stand slow code.


If I can expect the trade robot to work as well as it has in the last fifteen days, the output will approximately pan out around 19% at best. That may not sound like much until you realize we're talking 19% in fifteen days. Which roughly corresponds to 6000% per year.

I shan't be expecting that, but somewhere around 250%-1500% per year might be feasible.

I will be doing the automated trade in multiple sites, as for instance the Swedish bank Nordea Investor only takes 0,06% commission, while most other trading sites takes 0.25% commission. That may not sound like much, but makes a huge difference. If I for instance deposit 5,000 SEK (=$550) I'd have payed around $3,400 more in commission in a year's time, corresponding to a yearly "tax" of 54%.

Only one feature remaining. Performing the actual buying and selling of instruments.


I've spent a week implementing cross-checks for the profits of my robot stock trader. If I would have used real cash in the last two weeks, this is (approximately) the performance I would expected to see:

The top curve shows what an ideal trade curve would look like if the bank didn't deduct any commission. The second highest reflects a 17% increase (50 kSEK ≈ 5.5 kUSD); using 10 kSEK ≈ 1.1 kUSD would have resulted in a 12% profit; and 1 kSEK ≈ 110 USD had resulted in a 43% loss.

The above view only looks at stock trading, but adding other instruments would only make the end-result even more sensitive to low amounts for two reasons. 1) The robot on average wants to buy and sell 48 instruments each day. 2) The commission for buying and selling non-stock instruments are a lot higher.

I don't know anything about stock trading yet, but I think that the stock part of a portfolio acts as a risk-mitigating cushion, since the value doesn't fluctuate much. Leverage certificates, on the other hand, can fluctuate massively. So keeping a small portion of high-risk instruments can give a fairly high yield, while at the same time causing very little risk with a constant commission. I just need to add calculations of other types of instruments+commissions and I can do a prognosis of where I might be in a few months time. That should be a piece of cake.

When that is completed there is only one thing remaining. Walk the walk. Having the robot execute the actual trade. I'll start small, loose a high percentage to commission. When things are flying, it's just to insert more cash. That should prove interesting. Probably a little too interesting for me, you know on that hard-to-sleep level of interesting. But taking it slow, double and triple checking things. When the time comes this baby is going to fly. Fuckin' high! :)

New Rich: First Run

I had to implement a whole bunch of stuff which I hadn't anticipated. I still haven't executed a full 24-hour cycle due to the poor quality of the code where off-by-one-index-out-of-bounds lead to crashes. A bit disappointing since I estimate I've spent around 100 hours getting things running.

Time zones, daylight savings, varying closing times, etc. are my main headaches, and when I have the time I'll refactor and write some delicate unit tests which should remedy most of this cwap.

The best feature of Hasselhof ("I've been looking for freedom") is that I'm able to simulate runs from historic data. That way I can check what algorithms works best over time and I've implemented genetic and mutating algorithms to help me along.

This first version is not really a robot yet, it only gathers the information on what stock to invest in and sends them in a daily e-mail digest to me and an interested colleague. When it looks promising (and when the unit tests are done) I'll need two more features:
  • calculate factual profit (selling price - buying price - commission?), alternative facts are not advantageous;
  • add automated buying and selling.
Then it's time to pitch in a few dahlarrzz.

Where nightmares of iOS goes to die

After six years as a paying participant of the Apple developer program I finally draw the line.

Units downloaded    Title
12.3K    Kill Cutie
2.16K    Downwash
1.79K    Bound 3D
1.49K    SlimeBall
357    NSAgent
273    Tevesilen
234    Trabant
59    Levels (Kill Cutie)
55    Additional Vehicles (Kill Cutie)

Not a poor choice considering the obvious fail. Next time, if there is one, I'll release for Steam instead. But first I'll turn Putin rich, write my book on parapsychology, go trippin and evolve. So this blog is not going to be about games for a long time. I think I'll keep the label as a constant reminder of this failure though.

Da riches

Guess I've spent at least fifty hours writing some code which will eventually become some automated stock trading software. I've found some really awesome trading instruments, and possibly some algorithms too. I need to do further testing, and I'm sure there are confusing bugs everywhere, but thus far it looks like this might be profitable:

The green lines are my top algorithms so far, the reds are the best-performing instruments. I'm pretty sure that a 80,000% yearly interest is just a little bit much and due to some sorry-ass bugs, but the 300% I had set as a minimum is sure to be exceeded. If I can get a big enough profit, I don't care about the Sharpe ratio or risk. In a few weeks I'll know more.

Hao 2 git rich fast

I've been up to no good for too long. While I spent years making shitty games and a stupid game engine at the cost of immense sleep deprivation, relationships and elimination of spare time, a colleague/competitor instead make a good game (and no game engine, surprise!). Obviously he's a lot smarter than I am. Since then he's dug into stock trading, as have so many programmers in the past. Now it's my turn, I neither have time, energy nor finances to build games. So I'll just get rich on algorithmic stock trading myself, even though I think it's just a horrible way to make money as it doesn't contribute to society one bit. But as long as the system's there I'm going to use it for my benefit. Game-wise I'll just let my Apple account expire. My next game will be a computer/console only, my patience has grown extremely thin with casual gaming, touch interfaces and Apple, all of which I loath.

In pursuit of my trading robot, I've gone through the hassle of building some components and an application in Python. From scratch, of course - reinventing the wheel is my cup of tea (otherwise I could have just taken the 100 lines required). It's taken me 20 hours or around there. Now I'll start working on algorithms, the fun part.

I've never been very interested in being rich until now, so this change has taken me aback. I guess I'm mostly tired of shitty jobs with incompetent management. And also I'd like to ensure two things: that I can work on whatever I want, and that I can go on vacation whenever and wherever I want. And although I dislike cars in general, I've become infatuated with Tesla, so I'll get a model S. And pay the mortgage. And refurbish the house. And donate to charitable causes. That kinda shit that the middle class gets off on.

Without knowing jack about trading I'm hoping for a 300%+ yield with a Sharpe ratio of 3+. Will let you know what yields and risk I can push my algorithms into.

About the author

Mitt foto
Gothenburg, Sweden