Controtto

by contre95
Verified

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Supports configuration through environment variables stored in .env files for simplified setup and configuration.

  • Fetches cryptocurrency price data from Binance's public API to calculate asset values and profit/loss metrics.

  • Provides a container image available on Docker's public registry for easy deployment and management.

📊 康特罗托

Controtto 是一个自托管的损益跟踪器,使用 Go、HTMX 和JavaScript编写。它会跟踪您的交易并将其保存在 SQLite 文件中,并返回各种计算结果,包括:

  • 平均买入价
  • 当前资产价值
  • 交易历史记录
  • 进出口交易(见样本
  • 盈亏

为了获取资产的价格,Controtto 主要依赖于 4 个 API(参见代码)。

  • Binance——公共 API,无需令牌。
  • BingX - 公共 API,不需要令牌。
  • Alpha Vantage - 股票,免费但利率限制较短。(获取代币并设置CONTROTTO_AVANTAGE_TOKEN
  • Tiingo - 股票、加密货币和外汇。(创建帐户/代币并设置CONTROTTO_TIINGO_TOKEN

演示

您还可以查看demo.contre.io上的演示,数据库每小时重置一次。

所有配置均在.env文件中设置,并作为环境变量传递。变量CONTROTTO_PORTCONTROTTO_DB_PATH可用。

# Install the dependencies go mod tidy # Set the .env mv .env.example .env # Source the env variables . <(cat .env | grep -v -e '^$' | grep -v "#" | awk '{}')

构建并运行

go run ./cmd/main.go # go build ./cmd/main.go to just build it

开发环境

go install github.com/cosmtrek/air@latest # Download air air -c air.toml

并访问localhost:3000

使用 Podman 运行

Docker 的公共镜像仓库中提供了容器镜像。如果您想使用 Docker,只需将podman替换为docker即可。

mkdir data podman container run --rm -p 8000:8000 -v $(pwd)/data:/data contre95/controtto

运行测试

go test -cover ./... # Expected result # ? controtto/cmd [no test files] # ? controtto/src/app/managing [no test files] # ? controtto/src/domain/pnl [no test files] # ? controtto/src/gateways/markets [no test files] # ? controtto/src/gateways/sqlite [no test files] # ? controtto/src/presenters [no test files] # ok controtto/src/app/querying 0.003s coverage: 40.7% of statements

待办事项

  • 更多测试
  • 用于日志记录和指标的包装器也很好。
  • 添加帐户以跟踪总净值。
  • 删除所有 CSS 并使用自定义style.css + Tailwind CDN。
-
security - not tested
A
license - permissive license
-
quality - not tested

你有能力解释 golang 代码,并在最严格的 ddd 和清晰的架构范式下对其进行判断

  1. Demo
    1. Build and Run
      1. Development env
        1. Run with Podman
          1. Run tests
            1. TODO
          ID: 10z262ljps