Tag: python

  • Day 1: Backtesting Fish, Fighting Python

    If you came here from Medium, then you’re aware that I’m trying to set up a very rudimentary and dumb multi-strat hedge fund in the world of Runescape. The plan is to apply real-world quantitative trading strategies to the game’s economy, turning virtual fish and logs into a compounding GP machine.

    The core strategies I’m exploring include:

    • Macro Thesis Trades: Capitalizing on game updates and seasonal events.
    • Processing Arbitrage: Exploiting inefficiencies in in-game item transformations.
    • Seasonality-Driven Statistical Arbitrage: Analyzing microseasonal patterns influenced by player behavior and bot activity.

    It’s day 1, but this endeavor has led me down a rabbit hole of Python scripting, API interactions, and the occasional existential crisis. For context, I consider myself a very novice programmer — took three years of computer science in high school and used some Python and R, but mostly for statistics applications, and I’ve since been using my programming skills very sparingly; in my prior life as an investment analyst, we had a very talented intern who we left our programming needs to, and who later started his own (very effective) business on this (shoutout to Rohit at Durable Alpha! – if you happen to be an institutional investor who has data analysis needs, I highly recommend reaching out to him here: https://www.trydurablealpha.com/). As a consequence, I’m ashamed to say I’ve gotten very rusty — I’ve forgotten how tough even setting up an Anaconda environment is. The entire process felt like trying to remember how to ride a bike, except the bike is on fire, the road is made of error logs, and conda keeps yelling at me about environment conflicts.

    First hurdle? Figuring out whether I had Python installed. Spoiler: I did. But it was the Microsoft Store version, which apparently exists only to ruin lives and break python commands. So I uninstalled that, reinstalled the “real” version, then realized that broke all my previous associations. Small victories.

    Then came Anaconda. If you haven’t tried installing it recently, imagine installing something that simultaneously offers you a GUI (Navigator), a command line tool (conda), a virtual environment system, a notebook runner, and about four different broken ways to manage packages. It’s the Home Depot of Python tools — everything’s there, but god help you if you try to find a nail.

    Eventually, I got a virtual environment spun up. I called it statarbrs, short for “Statistical Arbitrage RuneScape”, because I like pretending this is serious. Installed pandas, numpy, requests, statsmodels, and of course, jupyter, which I still irrationally believe will make me smarter just by opening it.

    From there, I tried running some of my scripts through JupyterLab, only to remember that notebooks are a deeply cursed way to handle command-line arguments. (Nothing like debugging a --backfill flag in a notebook cell at 1AM.) So I switched over to VS Code — which, in fairness, has come a long way — only to spend another hour trying to convince it to recognize my conda environment like a stubborn child refusing to acknowledge bedtime.

    After manually browsing to the right interpreter path (because auto-detect absolutely did not work), I was finally able to run a simple fetch_prices.py script. And by “simple” I mean: it pulls 5-minute price ticks from the OSRS Wiki API, checks for duplicates, appends to a local CSV, and logs progress per item.

    It wrote zero rows.

    Turns out I had a malformed timestamp from a test run that silently caused the script to skip every single historical row. Of course. After some grunting, printing, and reverting to caveman-style debugging, I fixed that too.

    I’ve now got a functioning system that fetches both live and historical data, stores it locally, and (in theory) sets me up for seasonality analysis and backtesting. It’s running. It’s saving files. I have no idea how I got here.

    All I wanted was to build a statistical arbitrage model on fish.

    Anyways, I filled my frustration quota for the day and went back to the much more sophisticated world of real finance, where data is clean and you get tick-by-tick data, as opposed to the 5 minute bars you get (at best). Not an auspicious start to what I’m calling Zaros Capital (after one of the in-game gods of Runescape), stalling out at just pulling historical data and getting it to update a CSV in real time!

    Meanwhile, back in the real world, I’ve got some thoughts on autonomous vehicles and the impact on trucking, as well as what to invest in in a world where we’ve outsourced our brains and our labor to AGI and robotics respectively. So if you’re interested in that, stay tuned, I’ll probably get that developed over the next day or two. See you then!