Algosm: Algorithmic trading protocol for Osmosis

The Algosm hackathon team consisting of Mikko Ohtamaa (CEO & Co-founder, Trading Strategy) and Mike Purvis (ex-NEAR Protocol) participated in HackAtom Seoul 2022, sponsored by Osmosis. The hackathon project received second prize in the Osmosis category. Let’s take a look at the project and how it fits within the DeFi ecosystem.

HackAtom 2022 teams in Seoul

About the Algosm project

Algosm is a hackathon project for HackAtom Seoul 2022 and is an algorithmic trading protocol demo for Osmosis. Algosm enables the development of non-custodial active trading strategies on Osmosis using CosmWasm smart contracts and Trading Strategy oracles.

If you are familiar with DeFi yield farming you will understand the concept of yield-generating smart contracts. However, in yield farming, the strategies generating yield are passive income based: either liquidity mining based (not long-term sustainable) or automated market-making trading fees (usually very thin margins).

A familiar smart contract vault interface when investing to trading algorithms. This is a familiar user experience for DeFi investors who already know yield farming.

Algosm offers a different approach to generating yield: automated trading. Algosm runs different algorithmic trading strategies where trades are based on technical indicators and attempt to buy low and sell high. Unlike passive strategies, active strategies are directional and risk-taking — there is always a risk that the trade won’t close for a profit. However, we believe that with tight enough risk parameters, and well-managed vault AUM caps, these strategies will be the future of DeFi because they are more sustainable than passive strategies. The yield earned this way is also “real yield”, comes from the trading profit and is not artificially sustained.

An example of the performance of one trading strategy on ATOM/OSMO trading pair on Osmosis. This is a historical backtest.

The hackathon demo is a work-in-progress, currently only runs proof of concept on testnet and cannot be used to trade your tokens. You can find the demo site here and Github source code here. The hackathon project is based on Trading Strategy framework for algorithmic DeFi trading and CosmWasm Beaker smart contracts for the vault smart contract.

What is algorithmic trading?

Algorithmic trading is a derivative of technical analysis; taking trading positions based on pure mathematics and data. Algorithmic trading is part of quantitative finance, the opposite of value investing where trading decisions are made based on fundamentals. Algorithmic trading provides a systematic approach to trading compared to methods based on trader intuition or instinct. Whereas technical analysis often aids humans to take trading positions, in its purest form in algorithmic trading a trading program follows a set of trading rules and independently executes trades on the market 24/7.

An example of strategy doing trades

Algorithmic trading can follow several different types of strategies, for example, directional strategies anticipating market moves based on trends or mean reversion or market neutral strategies where the algorithm seeks to make a risk-free profit over arbitration and dislocations over different markets.

An example of a trading strategy Python code

Why Osmosis?

Osmosis is the first decentralized exchange (DEX) running as an independent cosmos SDK-built appchain. While there are other appchain DEXes coming up soon or already live, Osmosis is the first.

The major benefit of the appchain exchange model over the smart contract model is native support for interchain communications. Furthermore, fee models, throughput, latency and such parameters critical for automated trading are more aligned through governance between the exchange users and validators.

Next steps

Based on the positive feedback received in HackAtom about Osmosis and Cosmos ecosystem, Trading Strategy is looking to deploy its market data feeds and strategy trading framework on Osmosis as a full product that Osmosis users can tap into. For information about the progress, you can hop on the Trading Strategy Discord server. operated by Trading Strategy Operations Ltd., Victoria, Mahe, Seychelles.