A Journey Through Prosperity: Lessons from a Trading Hackathon

A Journey Through Prosperity: Lessons from a Trading Hackathon

A few months ago, I started with a team of three to work on a hackathon called “Prosperity”. It is a trading hackathon where you learn the basics of algorithmic trading. In this blog, I will tell you about the hiccups we had, and what we learned. A teammate and I had no experience whatsoever with trading; luckily, there was one teammate who had some experience from another trading hackathon, and explained a lot of things that helped us out quite a lot. We used Python as our programming language.

What is Prosperity?

First of all, I will tell you what Prosperity is. This is from their wiki page:

Prosperity is a 15-day long trading challenge happening somewhere in a near-utopian future. You’re in control of an island in an archipelago and your goal is to bring your island to prosperity. You do so by earning as many SeaShells as possible, the main currency in the archipelago. The more SeaShells you earn, the more your island will prosper.

The Challenges

Every three days, we faced a new challenge. The first challenge was quite straightforward: make a trading algorithm that makes profit. There was one stable asset and one volatile asset. We first created the basic tools that we found out: the VMAP (Volume Weighted Average Price) and RSI (Relative Strength Index). These two algorithmic tools would determine if we had to BUY or SELL. This actually worked out quite well.

We were not allowed to use any libraries, so we had to create our own functions. We decided to make each tool a class. This way, everyone could easily differentiate each tool when coding. This actually went surprisingly well, and with a few hiccups, we made a profit with both assets. Great success!

Each three days also had another challenge. This challenge was less coding and more thinking. We did not really look at it and just guessed the riddle that was given to us, which later on we had some regrets about.

Here you can find a snippet of code of the code we have written:

class Amethysts:
    def __init__(self) -> None:
        self.indicators = Indicators(240, 14, 105)
        self.symbol = "AMETHYSTS"
        self.position_limit: Position = 20

    def get_orders(self) -> List[Order]:
        if self.indicators.mid_price == -1 or not self.indicators.atr.is_valid():
            return []

        orders: List[Order] = []
        biggest_order: int = self.position_limit * 2
        best_bid = self.indicators.highest_buy_price
        best_ask = self.indicators.lowest_ask_price
        if self.indicators.mid_price < self.indicators.vwap.get():
            max_quantity = get_max_quantity(
                self.indicators.current_position, self.position_limit, biggest_order
            )
            if max_quantity:
                orders.append(
                    create_order(
                        self.symbol,
                        round(best_bid) + self.indicators.atr.get(),
                        max_quantity,
                    )
                )
        if self.indicators.mid_price > self.indicators.vwap.get():
            max_quantity = get_max_quantity(
                self.indicators.current_position, self.position_limit, -biggest_order
            )
            if max_quantity:
                orders.append(
                    create_order(
                        self.symbol,
                        round(best_ask) - self.indicators.atr.get(),
                        max_quantity,
                    )
                )

        return orders

In short, we first check if we have enough information to trade, and once that is ready we take the mid-price and compare it with the VWAP. If the if-statement is true it will check how much it can possibly buy and buy it.