kline

command module
v0.0.0-...-20fee0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 6 Imported by: 0

README

Kline

根据成交日志,计算不同时间周期的k线数据。

输入

该程序从redis队列获取成交记录(默认redis key= list:trade_log),队列值如下:

{
	"symbol": "BTC_USDT",
	"ask_order_id": "a-8e75f8b6-205b-4f97-abc6-8a9f53d7b1de",
	"bid_order_id": "b-41a93e90-d773-469e-8e84-c951baf76848",
	"trade_quantity": "10",
	"trade_price": "18",
	"trade_amount": "180",
	"trade_time": 1656310734986289000
}
  • 默认redis key可以通过配置文件config.toml中修改

支持的k线周期

  • 分钟级k线数据 [m1,m3,m5,m15,m30]
  • 小时级k线数据 [h1,h2,h4,h6,h8,h12]
  • 天级别k线数据 [d1,d3]
  • 周级别 [w1]
  • 月级别 [mn]

API

程序运行默认会在locahost:8081开放一个http服务 接口地址: /api/v1/klines?symbol={symbol}&period={period}&start_time=&end_time=&limit=500

名称 类型 是否必须 描述
symbol string YES
period ENUM YES 参考k线周期ENUM
start_time long NO
end_time long NO
limit int NO min:500 max:1000
  • 如果未发送start_time 和end_time,默认返回最近的成交记录

返回数据:

  [
      [
          1655887320, //开盘时间
          "1.00",  //开盘价格
          "1.00", //最高价
          "1.00", //最低价
          "1.00", //收盘价
          "190",  //成交量
          "190.00", //成交额
          1655887380 //收盘时间
      ],
      [
          1655887140,
          "1.00",
          "1.00",
          "1.00",
          "1.00",
          "20",
          "20.00",
          1655887200
      ]
  ]

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL