Skip to content

Instantly share code, notes, and snippets.

View miohtama's full-sized avatar
🏠
https://tradingstrategy.ai

Mikko Ohtamaa miohtama

🏠
https://tradingstrategy.ai
View GitHub Profile
@miohtama
miohtama / gist:fb3a942d84d658d92a50ccc67cfcf1d9
Created September 16, 2025 11:55
GMX Python API example
# github.com/tradingstrategy-ai/web3-ethereum-defi
from eth_defi.gmx.create_increase_order import IncreaseOrder
from eth_defi.gmx.trading import GMXTrading
from eth_defi.provider.multi_provider import create_multi_provider_web3
from eth_defi.gmx.config import GMXConfig
from eth_defi.hotwallet import HotWallet
from eth_account import Account
import os
You can append data to a Parquet dataset in PyArrow by using the `pyarrow.parquet.write_to_dataset()` function and setting the `existing_data_behavior` parameter to `'overwrite_or_append'`.
This function writes new Parquet files to the dataset directory. If the data belongs to a new partition, a new partition directory is created. If it belongs to an existing partition, a new file is added to that partition's directory.
-----
### \#\# How It Works
The key is the `existing_data_behavior` argument, which tells PyArrow how to handle the new data in relation to any data already at the destination.
@miohtama
miohtama / foundry-local-dev.sh
Last active July 28, 2025 13:20
Foundry local development with master
#!/bin/bash
#
# Set up a founry for local development, using faster dev profile for compilation
#
PROFILE=dev
# You need to delete the existing forge etc. commands, because even
# if the cargo install says "replacing" they did not really seem to replace and
# some old version was left around.
@miohtama
miohtama / grvt-ccxt-api.py
Last active May 7, 2025 11:53
Compare GRVT CCXT-compatibility API with a known similiar decentralised perp exchange
"""Compare GRVT CCXT-compatibility API with a known similiar decentralised perp exchange.
- Run the same CCXT API functions against know decentralised perp exchange and GRVT
and compare the results
"""
import logging
import os
from pprint import pprint
import ccxt
@indicators.define(dependencies=[ath, ath, daily_rsi])
def signal(
close: pd.Series,
ath_delay_bars: int,
ath_window_bars: int,
ath_threshold: float,
ath_span: int,
daily_rsi_bars: int,
daily_rsi_threshold: float,
pair: TradingPairIdentifier,
@miohtama
miohtama / yubikey.md
Last active February 17, 2025 13:16
How to use Yubikey with SSH and macOS

Guide to Setting Up and Using FIDO2 SSH Keys on macOS

About YubiKey and FIDO2

YubiKey is a hardware-authentication device that securely stores your SSH key. You need the physical device to login over SSH, which is protected with both touch (separate button on the device itself) and PIN code (need to be typed to unlock the SSH key).

FIDO2 (Fast Identity Online 2) is a set of standards for secure authentication that aims to replace password-based logins with more secure methods.

1. System Requirements

@miohtama
miohtama / gist:63e96ff6d7b61584284000ec4989a0af
Created October 5, 2024 09:05
Render a text mode progress bar in node.js
/**
* Render a text mode progress bar.
*
* For characters see
*
* - https://en.wikipedia.org/wiki/Geometric_Shapes_(Unicode_block)
* - https://en.wikipedia.org/wiki/Block_Elements
*
* @param {number} width Width in characters
* @param {number} progress Current progress as percent 0....1
@miohtama
miohtama / datalore-with-talib.dockerfile
Created October 3, 2024 10:31
Datalore agent Dockerfile w/Talib installed
FROM jetbrains/datalore-agent:2024.1
USER root
ENV DEBIAN_FRONTEND noninteractive
# add deadsnakes ppa and install python 3.11
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && \
apt-get install -y python3.11 python3.11-venv python3.11-dev && \
rm -rf /var/lib/apt/lists/* && \
@miohtama
miohtama / poetry-activate.zsh
Created October 1, 2024 18:51
Poetry activate virtual environment one-liner
# Does not create subshell
poetry-activate() {
source $( poetry env list --full-path | grep Activated | cut -d' ' -f1 )/bin/activate
}
This strategy is a momentum and breakout strategy.
- The strategy trades ETH and BTC over long term time horizon, doing only few trades per a year.
- The strategy delivers similar profits as buying and holding ETH and BTC, but with much less severe drawdowns.
- The strategy performs well in long-term Bitcoin [bull market](https://tradingstrategy.ai/glossary/bull-market).
- In [bear](https://tradingstrategy.ai/glossary/bear-market) and sideways markets the strategy does not perform well.
- It is based on [RSI technical indicator](https://tradingstrategy.ai/glossary/relative-strength-index-rsi), the strategy is buying when others are buying, and the strategy is selling when others are selling.
- The strategy deposits excess cash to Aave V3 USDC pool to gain interest on cash
- This is the second version of this strategy. [See the earlier version](https://tradingstrategy.ai/strategies/enzyme-polygon-eth-btc-usdc).
As the time-in-market os low, the Aave support was added to gain profits on the cash reserves.