# deribit-crawler
**Repository Path**: HTMLgtMK/deribit-crawler
## Basic Information
- **Project Name**: deribit-crawler
- **Description**: Deribit Information Crawler.
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-06-04
- **Last Updated**: 2021-06-05
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Deribit Crawler
运行命令:
```shell script
node run.js
```
返回的数据中,
- `[prepLastOpts]` 表示服务器主动更新 Recent Trades.
- `[appLastOptsCall]` 表示滑动 Recent Trade Calls 时返回的数据.
- `[appLastOptsPut]` 表示滑动 Recent Trade Puts 时返回的数据.
Node.js 代码的爬虫,原因是服务器下发的数据需要 JS 语言的 `eval()` 函数执行。
目前进展:
- [x] 找到目标数据;
- [x] 获取目标数据:
- 已解析数据,了解得到的数据中每一字段代表的含义;
- [x] 数据持久化:
- [x] 存储到了 SQLite 数据库;
- [x] 对 `trade_id` 唯一判断的问题;
- [ ] 插入数据时,for 循环插入慢的问题。
一条示例数据数据:
```text
"BTC-25JUN21-32000-P","0.0395","0.10","06-04 08:36:58","36636.07",1622795818723,159911665,"101.4%",false
```
| pos | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8|
| --- | ---- | ------ | ---- | ---------- | -------- | ----- | ------| --- | -- |
| 字段 | `name` | `price`| `Qty`| `date time` | `volumn` | `datetime` | `trade id` | `IV` | `unk` |
- assets(交易总额): ``(parseFloat(d[1])*parseFloat(d[4])) .toFixed(2)``
- datetime(交易时间): ``format_date(new Date(d[5]), {year: false})``
**`trade id` 字段可以作为 UNIQUE KEY.**
---
2021.06.04
1. 更新 `lastTradeCallId`/`lastTradePutId` 的 update. (`./deribit/main_app.js`).
2. 使用 `better-sqlite-pool` 连接 sqlite。 为什么不使用 `sqlite-pool`? 装不上。
3. 运行爬取命令前,需要先在 `sqlite3` 命令行中导入表 (`.read ./sql/database.sql`).
4. 数据表中添加了 `record_time` 字段。