{"id":37119922,"url":"https://github.com/breaded-xyz/alphakit","last_synced_at":"2026-01-14T13:58:50.409Z","repository":{"id":37848458,"uuid":"472687160","full_name":"breaded-xyz/alphakit","owner":"breaded-xyz","description":"Framework for developing sound algorithmic trading strategies in the Go language.","archived":true,"fork":false,"pushed_at":"2024-06-12T18:04:09.000Z","size":13141,"stargazers_count":201,"open_issues_count":2,"forks_count":28,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-12-28T18:51:18.341Z","etag":null,"topics":["algorithmic-trading","crypto","cryptocurrency","finance","go","golang","trading"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/breaded-xyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-22T09:04:04.000Z","updated_at":"2025-12-25T00:16:10.000Z","dependencies_parsed_at":"2024-06-12T21:22:19.635Z","dependency_job_id":"957e7500-3206-483e-8310-a8f44e380ace","html_url":"https://github.com/breaded-xyz/alphakit","commit_stats":null,"previous_names":["breaded-xyz/alphakit","thecolngroup/alphakit"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/breaded-xyz/alphakit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breaded-xyz%2Falphakit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breaded-xyz%2Falphakit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breaded-xyz%2Falphakit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breaded-xyz%2Falphakit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/breaded-xyz","download_url":"https://codeload.github.com/breaded-xyz/alphakit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breaded-xyz%2Falphakit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithmic-trading","crypto","cryptocurrency","finance","go","golang","trading"],"created_at":"2026-01-14T13:58:49.731Z","updated_at":"2026-01-14T13:58:50.403Z","avatar_url":"https://github.com/breaded-xyz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n Copyright 2022 The Coln Group Ltd\n SPDX-License-Identifier: MIT\n--\u003e\n\n__!! Alphakit is now archived and is not maintained. See other repos in the org for our active projects. !!__\n\n# Alphakit\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/gomods/athens.svg)](https://github.com/gomods/athens)\n[![Go Report Card](https://goreportcard.com/badge/github.com/thecolngroup/alphakit)](https://goreportcard.com/report/github.com/thecolngroup/alphakit)\n[![Go](https://github.com/thecolngroup/alphakit/actions/workflows/go.yml/badge.svg)](https://github.com/thecolngroup/alphakit/actions/workflows/go.yml)\n\nIntroducing a framework for algorithmic trading in Go and serverless cloud\n\n```\n           /$$           /$$                 /$$       /$$   /$$    \n          | $$          | $$                | $$      |__/  | $$    \n  /$$$$$$ | $$  /$$$$$$ | $$$$$$$   /$$$$$$ | $$   /$$ /$$ /$$$$$$  \n |____  $$| $$ /$$__  $$| $$__  $$ |____  $$| $$  /$$/| $$|_  $$_/  \n  /$$$$$$$| $$| $$  \\ $$| $$  \\ $$  /$$$$$$$| $$$$$$/ | $$  | $$    \n /$$__  $$| $$| $$  | $$| $$  | $$ /$$__  $$| $$_  $$ | $$  | $$ /$$\n|  $$$$$$$| $$| $$$$$$$/| $$  | $$|  $$$$$$$| $$ \\  $$| $$  |  $$$$/\n \\_______/|__/| $$____/ |__/  |__/ \\_______/|__/  \\__/|__/   \\___/  \n              | $$                                                  \n              | $$                                                  \n              |__/                                                  \n```\n\n## Inspiration\n\nThe majority of open source algo trading frameworks, especially in Go, focus purely on trade execution - that's a sure fire way to get rekt. The most important precursor to a successful trading system is researching and validating practical market edges - which is the focus of alphakit. Furthermore, I wanted a composable architecture that could easily be executed serverless in the cloud using features such as cloud functions and messaging queues.\n\n## What's included?\n\nA complete starter kit for developing algorithmic trading strategies in the Go language:\n\n- Example buy-and-hold and trend-following algos\n- Backtest and walk-forward engine to evaluate algos\n- Performance reports and metrics\n- Brute force parameter optimization method\n- Command app to execute research studies from a config file\n- Scaffold for serverless production deployment in the cloud (coming soon)\n- Uses latest Go language (1.18) features including generics\n- Idiomatic Go style using community accepted best practices\n- Pragmatic use of concurrency, go routines and channels\n- Extensive test coverage where it matters\n\n## Install\n\n`go get \"github.com/thecolngroup/alphakit\"`\n\n## Getting started\n\n⚠️  API is pre v1 and is not stable\n\nThe canonical example that brings together many of the framework components is in the `optimize` package and reproduced below. A further well documented example in the `backtest` package demonstrates how to use a simulated dealer to study algos without an optimizer.\n\n```go\n\nfunc Example() {\n // Verbose error handling omitted for brevity\n\n // Identify the bot (algo) to optimize by supplying a factory function\n // Here we're using the classic moving average (MA) cross variant of trend bot\n bot := trend.MakeCrossBotFromConfig\n\n // Define the parameter space to optimize\n // Param names must match those expected by the MakeBot function passed to optimizer\n // Here we're optimizing the lookback period of a fast and slow MA\n // and the Market Meanness Index (MMI) filter\n paramSpace := ParamMap{\n  \"mafastlength\": []any{30, 90, 180},\n  \"maslowlength\": []any{90, 180, 360},\n  \"mmilength\":    []any{200, 300},\n }\n\n // Read price samples to use for optimization\n btc, _ := market.ReadKlinesFromCSV(\"testdata/btcusdt-1h/\")\n eth, _ := market.ReadKlinesFromCSV(\"testdata/ethusdt-1h/\")\n priceSamples := map[AssetID][]market.Kline{\"btc\": btc, \"eth\": eth}\n\n // Create a new brute style optimizer with a default simulated dealer (no broker costs)\n // The default optimization objective is the param set with the highest sharpe ratio\n optimizer := NewBruteOptimizer()\n optimizer.SampleSplitPct = 0.5   // Use first 50% as in-sample training data, and remainder for out-of-sample validation\n optimizer.WarmupBarCount = 360 // Set as maximum lookback of your param space - 360 is the longest lookback for slow MA\n optimizer.MakeBot = bot        // Tell the optimizer which bot to use\n\n // Prepare the optimizer and get an estimate on the number of trials (backtests) required\n trialCount, _ := optimizer.Prepare(paramSpace, priceSamples)\n fmt.Printf(\"%d backtest trials to run during optimization\\n\", trialCount)\n\n // Start the optimization process and monitor with a receive-only channel\n // Trials will execute concurrently with a default worker pool matching the num of CPUs\n trials, _ := optimizer.Start(context.Background())\n for range trials {\n   // Monitor for errors and progress\n }\n\n // Inspect the study results following optimization\n study := optimizer.Study()\n\n // Read out the optimal param set and results\n optimaPSet := study.Validation[0]\n fmt.Printf(\"Optima params: fast: %d slow: %d MMI: %d\\n\",\n  optimaPSet.Params[\"mafastlength\"], optimaPSet.Params[\"maslowlength\"], optimaPSet.Params[\"mmilength\"])\n optimaResult := study.ValidationResults[optimaPSet.ID]\n fmt.Printf(\"Optima sharpe ratio is %.2f\", optimaResult.Sharpe)\n\n // Output:\n // 38 backtest trials to run during optimization\n // Optima params: fast: 30 slow: 90 MMI: 200\n // Optima sharpe ratio is 2.46\n}\n\n```\n\n## Beware testing bias\n\nAlphakit's aim is to demonstrate best practice when developing algo strategies. This requires a sound approach to backtesting and performance analysis in order to mimimize bias, the most important of which is overfitting whereby you mistake random chance for edge. This is a good summary of the challenges: \u003chttps://robotwealth.com/backtesting-bias-feels-good-until-you-blow-up/\u003e.\n\nTo this end, the `BruteOptimizer` implementation enables you to split the given price samples into in-sample and out-of-sample buckets.\n\n```go\n\n// Use first 50% of data as in-sample training data, and remainder for out-of-sample validation\noptimizer.SampleSplitPct = 0.5 \n\n```\n\nTraining is conducted on the in-sample and performance validation on the out-of-sample. However, this is not a pancea and can still result in an overfitted algo if you attempt to optimize too many parameters at the same time.\n\nThere are a number of useful articles on \u003chttps://financial-hacker.com/\u003e that explore the pitfalls of backtesting in more detail.\n\n## Fundamental architecture patterns\n\nThe core assumption underlying the framework is that price data enters the system at a defined interval. Each time a new kline arrives it triggers an evaluation process owned by a bot that may result in 1 or more new orders being issued to a dealer.\n\nEvery component that participates in this processing implements the `market.Receiver` interface and accepts a kline (and a context to control long running operations).\n\nThe `broker` package offers an API to mediate the interaction between bot and trading venue. A bot creates market positions by placing orders through an implementation of `Dealer`. A simulated dealer in the `backtest` package (also a price receiver) allows you study and validate algos outsde of an optimizer.\n\nIn future releases new `Dealer` implementations will enable you to connect to specific trading venues.\n\n## Working with price data\n\nThe price data used in the unit tests and examples is sourced from Binance. It's a good source of clean crypto data going back to late 2017. See \u003chttps://github.com/binance/binance-public-data/\u003e.\n\nAlphakit offers an API for price data in the `market` package. The primary representation is in the form of a candlestick (OHLC) - also known as a kline. `CSVKlineReader` reads klines from a .csv file, it can be extended to decode data from various sources with a `CSVKlineDecoder`. The default decoder supports the Binance data format which uses a unix millisecond format. A further decoder is also provided for MetaTrader data files.\n\nConvenience functions for reading individual CSV files or walking a directory are also included.\n\n## Performance reports\n\nPackage `perf` provides comprehensive performance reporting for your algo, enabling you to track industry standard metrics such as CAGR, return rate, sharpe ratio, and drawdowns.\n\nTo create a new report use the equity history and trade history data from a dealer.\n\n## Trading costs\n\nMany algos appear to be viable until you correctly factor in trading costs! Package `backtest` offers a `PerpCoster` implementation that simulates typical costs you might expect when trading crypto perpetual futures, including an hourly funding rate fee. See the tests in package `backtest` to understand how costs are applied during backtesting.\n\n## Building a trading bot\n\nIn the `trader` package you will find a couple of example bots: hodl and trend. The hodl bot is useful for benchmarking an asset, and the trend bot serves as a template for developing your own algo.\n\nThe following notes refer to how the bot in the `trend` package operates.\n\n### Prediction\n\n`trader.Predicter` is a simple interface that returns a value between -1 and 1. A value of 1 signals maximum confidence in opening a long position, whilst -1 maximum confidence in opening a short position. 0 indicates no directional bias. Other values between -1 and 1 indicate varying confidence in direction.\n\n`CrossPredicter` uses a fast and slow moving average cross with a Market Meanness Index (MMI) filter to determine the prediction.\n\n`ApexPredicter` uses peak and valley detection in a smoothed price series with an MMI filter.\n\nTo understand more about trend following and MMI this is a great starting point: \u003chttps://financial-hacker.com/trend-and-exploiting-it/\u003e\n\nThe trend bot interprets the prediction value according to a set of threshold values for opening and closing positions, namely:\n\n- `EnterLong`\n- `EnterShort`\n- `ExitLong`\n- `ExitShort`\n\nBy varying these threshold values you can create asymmetric entry and exit conditions.\n\n### Risk Management\n\nPackage `risk` provides methods to calculate unit risk, used as an input to position sizing and stop loss specification.\n\nBy default 'full-risk' will be used which assumes no stop-loss. As an alternative a standard deviation method is also provided.\n\n### Money Management\n\nPackage `money` provides methods to size a position. By default (and recommended for initial backtesting) a position based on a fixed capital amount is used.\n\nA more sophisticated option is to a use a fixed fraction method given by the `SafeFSizer` type. You can determine the optimal value of 'f' by using the OptimalF or Kelly value from a performance report.\n\n## Command app: studyrun\n\nThe command app `studyrun` enables you to execute optimization studies by specifying a `.toml` config file.\n\nSee the test in `cmd/studyrun` to understand the syntax and play with a working example.\n\nIf you wish to use your own custom bots or price data decoders with the command app you'll need to update the contents of the type registry passed to the app from `main`.\n\nThe command app will execute an optimization study using `BruteOptimizer` and dump out the results in .csv format.\n\nIf you wish to execute the `studyrun` process from outside Alphakit, an entrypoint function is availble in the package `github.com/thecolngroup/alphakit/cmd/studyrun/app`.\n\n## Connecting to a live trading venue\n\nFuture releases will provide implementations of `broker.Dealer` for specific trading venues. Contributions welcome!\n\n## Further reading\n\n- \u003chttps://financial-hacker.com/\u003e\n- \u003chttps://robotwealth.com/\u003e\n- \u003chttps://quantocracy.com/\u003e\n- \u003chttps://zorro-project.com/manual/\u003e\n\n## Contributing\n\nPlease fork and raise a PR or submit an issue.\n\nContributions should comply with:\n\n- Default golangci linters (see config file in root)\n- Uber style guide: \u003chttps://github.com/uber-go/guide/blob/master/style.md\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreaded-xyz%2Falphakit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbreaded-xyz%2Falphakit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreaded-xyz%2Falphakit/lists"}