···11+# proxycon
22+33+## Overview
44+55+proxycon is a performant Golang proxy service that returns the bitcoin
66+historical data as fast as possible. This proxy service is used by a machine
77+learning blackbox to do bitcoin trading. It is mission critical.
88+99+## Datasource
1010+1111+The data is available at
1212+[https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2](https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2)
1313+1414+The data format is a JSON payload, with the price and timestamp in RFC3339
1515+format.
1616+1717+```bash
1818+curl -fsS https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2 | jq .
1919+```
2020+2121+```json
2222+{
2323+ "data": [
2424+ {
2525+ "price": "8773698",
2626+ "timestamp": "2021-11-19T12:22:51Z"
2727+ },
2828+ {
2929+ "price": "6920238",
3030+ "timestamp": "2021-11-19T12:26:11Z"
3131+ },
3232+ {
3333+ "price": "5218360",
3434+ "timestamp": "2021-11-19T12:29:31Z"
3535+ }
3636+ ]
3737+}
3838+```
3939+4040+## API
4141+4242+> GET `/list` endpoint to get min and max prices with pagination
4343+4444+```json
4545+{
4646+ "start": "timestamp",
4747+ "end": "timestamp",
4848+ "max": "2108300",
4949+ "min": "2108300",
5050+ "data": [
5151+ {
5252+ "amount": "2108300",
5353+ "timestamp": "timestamp",
5454+ },
5555+ ...
5656+ ],
5757+}
5858+```
5959+6060+> `/price?at=<timestamp>` endpoint to get a price at the given timestamp
6161+6262+```json
6363+{
6464+ "data": [
6565+ {
6666+ "amount": "2108300",
6767+ "timestamp": "timestamp"
6868+ }
6969+ ]
7070+}
7171+```
7272+7373+> GET `/average?start=<timestamp>&end=<timestamp>` endpoint that computes the
7474+> average price over a certain arbitrary period
7575+7676+```json
7777+{
7878+ "start": "timestamp",
7979+ "end": "timestamp",
8080+ "avg": "2108300",
8181+ "data": [
8282+ {
8383+ "amount": "2108300",
8484+ "timestamp": "timestamp",
8585+ },
8686+ ...
8787+ ],
8888+}
8989+```
9090+9191+> GET `/prices` endpoint that returns a websocket to subscribe to price updates
9292+9393+## CLI
9494+9595+```bash
9696+proxycon --port 8080 --verbose --page 10
9797+```
9898+9999+> proxycon args
100100+101101+- port: define the HTTP listening port (TCP/8080 default)
102102+- verbose: manage slog verbosity (INFO default)
103103+- page: page size for listing endpoint (10 default)
104104+105105+### Build
106106+107107+```bash
108108+go build -ldflags="-s -w -X main.version=$(git describe --tags --always) -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -trimpath -o bin/proxycon .
109109+```