Latest Posts

Simulation: from weapon systems to trading

When I first became interested in algorithmic trading, I didn’t have any kind of trading experience. I did however have some very limited experience with flight simulation and weapons systems as an evolution from working in game development.

Although I didn’t know this at the time, simulation is just about the most important thing when it comes to developing trading strategies.

In weapon systems, simulation allows to estimate how reachable a target is. This can be used either to extrapolate fundamental formulas to be applied in real-time, or the simulation itself can be executed in real-time, if a weapons system has enough mobile computing power.

In the first case, simulation can help to build tables of parameters for quick retrieval when a weapon needs to be used. Let’s say that one has a cannon with a new kind of ammo. A well-established analytical solution can be adapted for the new ammo. But for more complex cases (i.e. different aerodynamical profile of the projectile) a computer simulation can find a more precise solution. A machine learning system can try millions of possible variations of parameters, such as elevation of the gun and amount of propellant, find the best possible one for given distances, and build a table that can then be consulted when the time comes to use the cannon to hit a target at a specific location.

Below is a ballistic table used in World War 2:

WW2 ballistic tables courtesy of tankarchives.ca

Here‘s an interesting explanation of bomb drops procedure in Vietnam using a F-4, which didn’t have a computer for the task.

In the second case, a more advanced weapon system, let’s say one in a modern jet fighter or in a modern tank, could forgo with most precalculations and instead have the simulation running live. The benefit of this second solution is that it can adapt to more variables and it can improve with a software upgrade.

In practice, setting up a simulation that is accurate enough to replace most of the experimental work, is not a simple thing, unless one is already developing a simulation, such as a flight simulation game. When the time came to build a believable weapons system in my experimental flight sim, it was only natural to use the simulation logic already developed for the game to calculate the launch envelope for a bomb or a missile, or the homing guidance for a missile.

Why manually extract a formula, when you can simply use the already existing simulation engine to test thousands of trial-runs and find the best parameters for the optimal launch envelope ? This was my epiphany in regard to the power of building a simulation to solve problems in a more generic and simpler way. Once you have a simulation for something, then you can use raw computing power to search for the best variables, whether that’s to built a table to consult at a later time, or whether it’s to be used actively up to the point of launch of a projectile, or even during flight of a guided missile.

Practical application of simulation in the real world is probably something in between. Supercomputers can be used to analyze more complicated matters such as the aerodynamics of a particular kind of fins of a missile, while on-board computers can work on launch envelopes and homing guidance. For sure, once a problem is shifted into software, chances for improvement increase sensibly.

This does connect neatly to algorithmic trading and how fundamentally dependent it is (or it should be) on the concept of simulation. No sane person should ever attempt to trade without first having a computer model. Some may disagree, but I can’t imagine how having an analytical model would hurt success.

The only drawback would be the issue of the reliability of a computer model of something that is very stochastic in nature. A weapon has little room for error. Simulating a projectile may be difficult, but the outcome is immediate and straightforward. With trading, instead, success can only be found in odds with large numbers in an highly dynamic setting. This makes the process of optimization more difficult and often counterproductive, but this is a discussion for another post.

Women and children

In 2022, war is now truly a live event. With cell phones, body cams and quad-copter drones, social media is filled with an abundance of the most disturbing footage that one can imagine.

This is certainly shocking from the perspective of societies that have lowered the bar for conflict to that of verbal micro-aggressions. At the same time, this is also very educative. It’s a perspective into what humans are and can be (see also “The explosive ‘boredom’ problem of civilized societies“).

I see interviews of people living underground and struggling simply to stay alive and find water and food, and I think of what I pictured from the WW2 stories from my grandparents.

Image courtesy of Alexander Turnbull Library

Everything checks… that’s the war I’ve been hearing about, a war where human cost is obvious, one that feels close enough, because it’s not happening to the third world. We’re used to ignore the homeless in the streets, but if it’s someone that looks like he has a job like us, then that’s a different matter. Affinity with race also helps a lot to mobilize millions of voices on Twitter. As much as we can pretend that we don’t care, we all instinctively feel more empathy towards living beings that look more like us. Our level of empathy and altruism varies in a continuous scale from two extremes, where most affinity is generated by our own children, and least affinity is probably some sort of alien insect coming from another galaxy.

Another major reality check from this war is how biological gender suddenly matters. Although some women are involved, they are very few and are usually relegated to being snipers, the kind of activity that requires less direct conflict. Most women are instead grouped with children and elders, while men are actually forced to go in combat, at least from the Ukrainian side. I think that we can safely assume that when shit truly hits the fan, the gender equity construct that has evolved in western societies goes straight into the pooper.

One could say that if there were no wars, then men and women could almost become interchangeable, but to expect a natural world without conflict is even more utopic than to expect a natural world without biological predispositions. Those that seek total equity for humanity have a better chance looking for it in the after-life, or in some fictional far future where any form of individualism is crushed together with all major human traits that make us what we are.

Meanwhile, in the real world, it would be wise to keep in touch with reality, because sooner or later the protective shield under which we are born and raised, will falter, and at that point understanding human nature will become a matter of survival.

An actual phobia, for a change

I’m not a fan of the “phobia” suffix. I think that it’s easily abused these days.

One classical misuse of “phobia” is with the term “homophobia”, as if straight men had nightmares of being chased at night by a cosmopolitan gay man holding a pair of sharp scissors !

Jokes aside, the presumed fear in this case would be that of the potential for straight men to find out that they may actually be attracted to the same sex. The idea is that it would be some sort of fear of the unknown. Calling someone an homophobe is an attempt to paint that person as unrefined and uncultured, someone that dismisses same-sex intercourse instinctively, someone that has not evolved to the point of going beyond his natural instincts, and that is afraid of doing so.

That is some cheap psychology that unfortunately has become mainstream and has indeed helped to put straight people on the defensive. This is the kind of propaganda that drives many men to pledge some kind of allyship just to look more socially aware.

Now for an example of an actual phobia, these days I’d put Russophobia on top. I’m impressed by the amount of people, especially in the United States, but apparently also in some countries in Europe, that suddenly appear to be fanatically anti-Russian. The 80s are back, with a vengeance !

The reason why I think that this is a legitimate phobia, is because the hate that is displayed is borne out of actual fear. Deep inside, these people realize that Russia is a force to be reckoned with. Russia is a country that even after the fall of the Soviet Union has continued to develop its own technology. This is most notable with aerospace engineering and weapon systems. I’m a big proponent of developing your own technology. In my case that would be software technology, but that’s truly essential when it comes to tech that is vital to the security of a nation.

At the same time, the Russian culture hasn’t been as softened as in the west. The average Russian is culturally more resilient to the concept of a full-scale war. The human cost that Russia is paying is unthinkable for the average American or European citizen. This is shocking for a population that has been so detached from conflict and that has a relatively comfortable life. A life so comfortable to the point in which public discourse has shifted towards complicated social and environmental issues that are not as consequential as they are made out to be.

Photo by Matt Hrkac/Flickr, CC BY-ND

Perhaps the most important source of this phobia is the realization that the current generation of US and Europe military have little experience with conflicts that are not asymmetrical. Simply put, America has been picking fights with 3rd world countries, bombing them to smithereens with virtually no opposition, and with no real repercussion for civilian casualties. I’m not going to say that any war is easy, but I’m sure that it’s a lot scarier when your opponent also has tanks, jets, drones, cruise missiles and everything in between.

It should be noted that technology isn’t simply about developing the smartest bomb or the jet with the coolest AR helmet. Technology is also essential in optimizing production of such weapons, as well as building systems that are resilient and don’t require too much maintenance. F-22s and F-35s are fantastic on paper, but they are very expensive to produce and they tend to waste precious time on the ground for continuous maintenance. I’m sure that a similar argument can be made for other vehicles of the west vs those that are Russian-made.

The American and European population is scared of an adversary that isn’t from the 3rd world. Meanwhile, the “emperors” that pull the strings of those respective regimes, are afraid to be found out as having no clothes. The survival of the elites of the west depends on the population to believe that those elites are virtuous, strong and powerful, but at the same time they cannot ask to their people to accept casualties, because they now live in a soft world, a world where every dead service…person is a tragedy.

The fear is real, and it’s not misplaced. Hopefully the people will move from the stage of fear into one of acceptance, and will perhaps wake up from whatever dream they’ve been pulled into. Unfortunately it’s in the human nature to wake up only when it’s too late. A lot of people will have to suffer very grave conditions before they finally stop believing the cheap Hollywood action-flick narrative that they have been fed for decades.

What’s your vote really worth ?

When the time comes for some major political elections, there’s always a big push to “get out and vote”. A big deal is made about how every vote counts, and how if you don’t participate, someone else will vote for you, meaning that the vote from others will have relatively more power. For example, in a pool of 1 million voters, if you don’t cast your ballot, each voter will have a stronger impact, albeit by a mere 1 millionth of a vote.

Voting is pushed as empowering and individualistic. In reality it’s a completely statistical issue. Your own vote by itself is irrelevant in the context of millions of other votes. From a purely individual point of view, you may or may not cast your ballot, and the outcome of the election will be exactly the same for all intents and purposes. No butterfly effect applies here.

To make a pop-science analogy, this can be seen as some sort of poor-man’s quantum superposition. The voting booth can be considered as a closed system, where anything that happens there has no effect on the outcome of the election. The “you” that votes A, B, C or abstains, can coexist with no practical effect to the outside, all because of the extreme dilution of a single vote.

There is some value however in the intent to cast a vote in a certain way, and that is to apply self-reflection to have an estimate of the outcome of the election, at least as far as your own demographic goes. That in itself is not a greatly applicable knowledge, being in itself only a guess of a portion of the voting population, but it’s more consequential than actually casting a ballot.

To me this is interesting as it highlights the duality between perceived direct decisional power and actually usable power. We’re sold the idea that we have a say on things as active participants, while in reality the only true power resides in the ability to self-reflect and predict the direction of a herd, but even that is not something that is directly applicable in most cases (maybe guess how the markets will react the next day ?). The greater power is that of introspection. The act itself of realizing and reasoning over the actual practical effect, or lack thereof, of voting, is further knowledge into understanding the place of the self amidst a collective.

If the power structures were honest, they would plainly state that civic duty is not about casting a ballot, but it’s actually to behave like a statistical sample. It would not be a good civic duty to behave as an observer of yourself and to act out of left field, driven by some sort of superego. It’s a good civic duty instead to act predictably, as it makes things easier for the manager class in the governmental institutions, as well as for the private ones.

In practice, one could still go and vote, but at least, as a thought experiment, it’s worth considering why the actual practice of casting a ballot is not an act of free-will, rather it’s a statistical sampling of a collective mind that is an amalgam of popular culture shaped by mass media.

DuckDuckGo cheated on me. I’m now dating Presearch

I recently moved from DuckDuckGo to Presearch.

The reason for the move was the announcement that the engine would filter results to favor a specific party on the Russia – Ukraine conflict.

Last year DuckDuckGo did already show its cards with “woke” discrimination of potential employees, where they’d favor less skilled employees as long as they had enough melanin in their skin and relatively uncommon sexual preferences.

DuckDuckGo supposedly still shields its users from being tracked for advertisement, but I think that most users went in expecting relatively unbiased results.

It should be noted that, as far as I understand, DuckDuckGo itself is a little more than a customer of Google and other major search engines. In practice, DuckDuckGo simply buys search engine usage from Google. For this reason, it was always a temporary solution, because Google’s bias its already built-in in the results, plus they could pull the plug at any time, transforming DuckDuckGo into a sitting duck. Remember: if you don’t build your own technology, you’re just a power user.

Presearch looks more interesting, it’s decentralized, it has its own search engine and also allows to quickly select other classical search engines.
Presearch was founded by people that already years ago had issues with Google’s search engine result manipulation (see: “Google Penalizes Local Businesses On City’s ’Shop Local’ Website”), so, hopefully the founders are in it for the long run.

It’s important to keep in mind that Presearch is just another offer. I don’t plan to get married to it, but my time as a user is better spent on a new interesting decentralized project, than supporting DuckDuckGo, which is no more than a gate keeper.

On the Moon landing

In a previous post I reasoned on the importance to entertain the wildest theories and to listen to those that propose them.
I truly believe that it’s important to keep an open mind, either to learn something new or as an exercise on how to find holes on such theories. It’s all brain food.

I was recently listening to an interview to a relatively public figure that would normally be labeled as a conspiracy theorist. At some point, the subject of the 1969 Moon landing came up. Unsurprisingly, the interviewee was skeptical about it.

The general reaction of most would be that of disbelief, with an immediate rejection on the basis of pure reverence of NASA as an organization, but I don’t think that that’s enough. As I said, I think that it’s a good mental exercise to try and find why certain claims can’t be sustained, even if the conclusion is probably the same as the mainstream belief. Forming your own reasoning is a valuable experience, something from which new tools for reasoning can be acquired.

Onto my defense of the Moon landing, the simplest validation that I can think of is the argument against the visual effects that would have been needed to simulate a different gravity while filming on Earth. Believable representation of different forces of gravity has been the hardest thing to do in science fiction for many years. It has basically been impossible until we achieved photorealism in computer graphics.
Some say that Stanley Kubrick did that well in “2001: A Space Odyssey”, but that’s an exaggeration. The film was exceptional in many ways, but the visual effects used in it are a far cry from what’s seen in the broadcast of the first Moon walk.

The reason why low gravity VFX took decades to start to become believable is due to our innate ability to judge certain physical phenomena. Our brain is wired to recognize dynamics, in fact we are naturally excited when we see movement, collisions, explosions, even rag dolls, because we can instinctively recognize the realism of the physical world.

I don’t know to which degree our ability to recognize and appreciate dynamics is innate or learned. For sure, we show awareness from an early age, and it constitutes the bulk of child play. This also gives us the apparently uncanny ability to recognize a friend from afar and from behind, if he’s simply walking.

It’s very hard to trick the brain about dynamical phenomena. Any sort of wired complex rigging that would have been required to simulate low gravity on video in 1969, would have looked unnatural if not downright silly.

That’s my reasoning on the subject. It’s not a sophisticated approach, but I think that is one that has possibly the best ratio of believability and relatability vs the amount of time invested in research.

Happily ever after

One year ago I wrote the “My Space !” blog post, where I was giving my reasoning for leaving social media, meaning Twitter, Facebook and Instagram.

I erased my Instagram account, since I had truly no use for it. I kept my Twitter and Facebook accounts as a notification tool, to post links to content about my trading system and my blog posts. Eventually, one day I’ll stop doing that as well.

At the time I downloaded a backup of my Twitter and FB feeds. The backup was easy to obtain, erasing years of history however is a different matter. It was easy on Twitter, but on Facebook it turned out to be a multi-day effort.

Last year, the only option to erase FB activity in bulk was to download a Chrome script that would emulate manual deletion of the timeline, one item at the time. On top of that, because the plug-in relied on an older FB design, I had to use a plug-in to also transform the UI of FB to an older version. The operation was long and error-prone. The plug-in even had a speed setting. Too slow and it could take forever, too fast and the procedure would miss deletion of items.

A couple of months ago I looked again into my FB feed, and noticed that I still had my 2017 posts and comments. FB now allows to batch-delete up to 50 posts at once, however the interface can get incredibly slow, and it would only delete 8-10 posts at once. For sure, the batch cleaning feature in FB is the most buggy of the whole site. It’s obviously something that they put there to check a box for some demand, without any real effort to make it usable.

I opted not to completely delete my accounts, because a few people still find it useful to reach me via the occasional DM, and because I wanted to use my existing connections to keep people on the loop about the progress of my trading system project, that I obviously want to promote.

I don’t miss social interaction one bit. In fact, it’s a weight that was lifted from my shoulders. At some point, daily social media activity became a chore. Quick blurbs of text and funny or interesting videos can quickly become repetitive. It’s a kind of interaction that is pointless and, of course, incredibly time consuming.

Maybe if I were a hot chick, I’d think differently, but for someone that has always had a self-image centered around his R&D as well as his interest in sharing his own “deep thoughts” (“deep thoughts and simple food” was my mantra already 30 years ago), reducing my publishing activity to “tweets”, was a lobotomizing experience.

I’d be lying if I said that I’m above the need of validation. I like for my work to be appreciated as much as the next guy, but it’s much more meaningful to have a blog with three readers instead of thousands of “contacts” scrolling past your name every day.

What makes things worse, is that Twitter and Facebook are controlled platforms built to serve interests of shadowy entities (including your own “democratic” government), and that believe in selective free speech (that would be an oxymoron, btw). It’s like being a guest at a shitty party… I’d rather be home doing my own party with a couple of friends. It’s a no-brainer for me.

Early on, Twitter had the power to get me loosely connected to people with common interests, mostly other game developers. Today however everything reeks of politics, making some Twitter feeds look like endless passive-aggressive rants. Get me out of here.

Facebook is the worst social platform of the two. It’s a nostalgia platform. Though it can be cool to keep in touch with virtually anyone across decades, there are reasons why some people normally lose track of each other in life, even if they care for and respect each other. Keeping in touch today is very easy, but it’s healthier if it’s done privately, with the intent to keep in touch, rather than simply living in the same cyber-neighborhood.

Monkeys with lipstick

For a kid, the revelation that Santa Claus is indeed not real is a bit of a rite of passage. Welcome to the real world, there’s no magic, you’re now an adult like us. It’s almost as if one wakes up from a dream to start his or her new life as an adult on planet Earth. A few decades after that revelatory event for me, I’m starting to see some irony in it.

The world of adults is a mixed bag. Adults with a developed brain are able to think rationally and to execute rational tasks, while also living ordinary lives immersed in irrationality. I suppose that we could all be excused for engaging in suspension of disbelief, given how inexplicable is the wider context of the universe in which we’re living in, both in terms of space and, even more puzzling, in terms of time.

Anyone that has ever paused to rationalize their existence, had to eventually crawl out of that rabbit hole and suspend their disbelief in order to go back to have a life. This is a prime example of how we’re able to engage in suspension of disbelief. It’s not just something that we can do, but it’s something that we must do.

Another, perhaps less profound reason on why our mind is able to put objectivity on the side, is a predisposition to skepticism towards what’s new and unproven. Prejudice is a necessary component for survival. Occasionally one may be better off selecting for the unknown, but the risk is higher, so, there’s a predisposition to go for what’s known.

At the societal level this can be seen with political movements or ideals. We tend to pick a side and stick with it. A person will defend their political party to extremes because, for example, some accusation of some misconduct may turn out to be invalid, or there might be a noble justification, or maybe one simply doesn’t want the other party to get a win, because they are perceived to be inherently and fundamentally wrong, if not evil.

There are many reasons why one may be willing to consciously or unconsciously allow for exceptions to the integrity of an ideal. Nevertheless, this happens and it’s part of how we function. Things get worse from here: although suspension of disbelief is a necessary trait of our minds, it’s also something that can be hacked and used. Any sufficiently unscrupulous and clever individual or small organized group, can target the mind of another person or group and get them to suspend their disbelief to an exceptional degree. This makes for a dangerous world. One where large swaths of the population may get hacked to operate against others and against themselves.

We study history and see how we’ve advanced, how enlightened we’ve come to be. To me, this is only a facade. We judge our progress by great practical achievements in the field of science, engineering and architecture, but I’d argue that great achievements were obtained by exceptional people, in spite of how primitive we are, not because humanity as a whole has made much progress. Literacy has elevated the level of mediocrity, but better mediocrity is not progress. You can train people to do exceptional things, but that only shows how good we’ve become to impart knowledge, how good we’ve become at producing very advanced robots, but robots nonetheless.

When we’re welcome in the world of adults, we leave Santa Claus behind, only to enter a world made of bigger, more sophisticated and much more consequential lies. At the top of the chain, there’s probably the lie that we’re following a path of progress for humanity. We’re like pigs in a stall that get excited for a new feeding machine, and don’t you dare complain about your living arrangements. You ungrateful pig ! You would be nothing without our democratically elected leaders and their appointed experts. Stop grunting and get your new tastier feed.

From time to time enough people find the collective energy to question the status quo, and maybe even gather some political power. But the system has a way to digest those flukes, either from the outside with oppression, or from the inside with corruption.

Happy New Year !