Trial and Epic Fail

Ventures of an indie game developer

Fortune bump

I found out why I wasn't able to place even a manual warrant purchase: the issuer had decommissioned the instrument. Ah crap! Yet another practicality to take into account. My solution to instrument decommissioning is to search through all other stock (maximized on least-squares delta) for the one that most closely resembles the original. I have no clue of what else might be a good solution.

One other practical problem I've found is that my trading site, and I'm guessing others too, have a 15 minute delay on their stock data. I made a script to check it:

...
[2017-06-15T08:51:13.727333] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T08:56:14.455338] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T09:01:15.127336] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T09:06:15.847333] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T09:11:16.620408] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T09:16:17.395114] [bull-tesla-x5-von] has last value 58.26 @ time 2017-06-14T17:20:00
[2017-06-15T09:21:18.103349] [bull-tesla-x5-von] has last value 57.4 @ time 2017-06-15T09:05:00
...

Trading begins at 09:00 Swedish time and closes at 17:30, but best is to buy at 09:05 and sell at 17:10. However, the numbers for stocks at 09:00 don't arrive until after 09:20! I'm pretty sure they have this rule to reduce impact of robotic traders. If I can make the purchase fifteen minutes earlier, the yearly increase in value could be as much as 13-fold!

Right now the numbers look insanely good. If I'm able to make half the interest of what the prognosis says on a regular basis (which I have to assume is totally unrealistic), I'll be able to pay off my mortgage in 14 months. There's bound to be bottlenecks preventing this, and possibly I still have a bunch of off-by-one bugs.

Bugs or no bugs, soon it's time to start auto-trading. The algorithm should be fairly straight-forward to implement, but there are many third-party inputs which can go wrong. Such as bugs in trading site's software, balance checks, disallowed trading, network & other outages, instrument valuation jitter (stock go up at the same time as trying to sell, or down at the same time as trying to buy), problems cancelling orders, commission fees vary depending on "market" (which doesn't mean what you think), timing issues, trading site may introduce robotic trader prevention (requiring manual login or anti-cracking techniques). The reverse engineering may take some time as well.

The coming week it's my turn with the kids, so not much done in the next few days, but in eight days I will start focusing on auto-trading, and I bet I'll have the auto-trader in place within a fortnight.

Trading tips in the future

This is my simple recipe for trading success:
  • buy only bull contracts, turbos, warrants - never plain ol' stock nor bear contracts;
  • buy early morning, sell late afternoon;
  • pick a good instrument every day.
To begin with I'll trade with anything that fits the above description. If I start getting some yield I'll blacklist all unethical instruments, such as Turbo Short Oljy V12. Oil is sheit but hard to resist - when the leverage tripled in value last two weeks.

I haven't still managed to trade a single warrant manually yet. Perhaps I need to fill out some agreement with the bank; the system tells me that the "trading site disallowed" my attempt at buying the warrants. Nonetheless, it should only be days away from launch now.

Last few weeks I've let the trading robot source code slip into some version of mayhem. Some time in the future I'll clean it up. Future. The place where things happen.

Double-wrong

... my first assumption was also wrong, the one about the algorithm being totally off. In 64 days it's generated 43% interest, which corresponds to 600% interest on a yearly basis. Not bad at all:


However, I think my other approach of directly analyzing the stock might be even better. Not sure exactly where to go with this, have to do some more evaluation first.

Wooot?!? Yes!!! Eh?

I was absolutely wrong about not being able to use my plain genetic algorithms on stock trading. From the looks of it, I was also wrong about "everybody else doing this thing" too. Probably I've got some serious bugs due to high code churn/hacking, but let's ignore that for now.

Using only bull/bear contracts and turbo shorts, think I'll be able to reach the 500% yearly profit mark. Plain old stock won't get me anywhere though.

Unfortunately I only have three months worth of data right now, as that's all anonymous login gets me on my current trading site. I need to fill in some earlier stock data so I don't overfit my algorithms.

PS. This time 'round verification will be a lot simpler, as each low-level algorithm at any given time will correspond directly to N trading instruments, which means I can simulate actual profits right away, without having to wait and see how successful the trader is in real instruments.

Last major setback

I wasn't able to filter out the input noise, at least in the last few days. Which means low yield, if any. Here is May:


SHIT!

Anyhow, the algorithms seem to do a good job, as they were able to predict the right instruments. I'll try applying this concept to normal trading instruments (stock, warrants, turbos, etc.) and see if that can get me anywhere. I'm less optimistic about this approach as that's close to what everyone else is doing, but of course I've got to give it a shot.

I've spent three months evaluating this line of inquiry, which might not be considered "fail fast," but at least I followed through on my trial-and-epic-fail. Evaluation of normal stock trade should be much quicker. Let you know.

Nth setback

Always suspected the instrument data I'm fetching was flawed, and sure enough I have realized that purchases and sales of the instruments are added to and subtracted from the value of the instrument - which has a huge impact when a lot of trade is going on.

The double-checking I implemented has had very little correlation with the instruments, which I somehow shrugged off. Oh the cognitive dissonance! I so bad wanted it to work, I simply ignored the double-check trial and epic fail.

So what does this mean? One of two things. Either I'm able to reduce the trade effects and possibly end up around the 500% mark, or this just proves that I need to use the same shit stock as everybody else. I'm still optimistic about finding the beautiful golden calf, just a little bit rattled...

Yearly yield

I have yet to implement the automated trading, but I have created a simulation of the historical data over the three weeks since I fixed my off-by-one bug. The data set is very small, and it's only showing information from a Swedish hausse, and the risk is very high. That said the yearly yield looks like it's in the range of -81% to +13,857%, with an average of +4,057%.

I'm probably going to start off with a very high risk which will give me a fantastic start, but soon after everything will go to shit and I'll be back to square one (or probably a little bit worse). Then I'll revise my plan, and after a few iterations I know more about what I can expect on a yearly basis. 500%+ doesn't seem overly optimistic, at least not during hausse.

If I land on 500%, I need to inject a minimum of 150kSEK = 16kEUR = 18kUSD to be able to withdraw as little salary as I charge today on a monthly basis. It will be tempting to keep the money sitting there. Just to give you an example. Say the yearly value increase is 500%. That means that investing 100 coins at the beginning of the year will get you 16 new coins in January. But if you save your stash, December will yield 83 coins. If you however wait until December next year, that month alone will yield 500 coins. You can probably see where this is headed.

"Please fill my orifices with The Juice, your highness!"

Worth noting is that somewhere along the line I'll hit a breaking point where I won't be able to procure and sell instruments at the initial rate and price without me affecting the price, but I have no idea where that level is. I'm guessing some of the instruments I'm speculating in is run by small finance institutes (which in turn is bought by trading sites?). Right now it seems like that threshold determines if my current thinking will get me filthy rich, or if I'll just have a better-than average savings account.

About the author

Mitt foto
Gothenburg, Sweden