proxycon#
Overview#
proxycon is a performant Golang proxy service that returns the bitcoin historical data as fast as possible. This proxy service is used by a machine learning blackbox to do bitcoin trading. It is mission critical.
As for now it uses only Go stdlib and may be improved with external libraries.
Datasource#
The data is available at https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2
The data format is a JSON payload, with the price and timestamp in RFC3339 format.
curl -fsS https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2 | jq .
{
"data": [
{
"price": "8773698",
"timestamp": "2021-11-19T12:22:51Z"
},
{
"price": "6920238",
"timestamp": "2021-11-19T12:26:11Z"
},
{
"price": "5218360",
"timestamp": "2021-11-19T12:29:31Z"
}
]
}
API#
GET
/listendpoint to get min and max prices with pagination
{
"start": "timestamp",
"end": "timestamp",
"max": "2108300",
"min": "2108300",
"data": [
{
"amount": "2108300",
"timestamp": "timestamp",
},
...
],
}
GET
/price?at=<timestamp>endpoint to get a price at the given timestamp
{
"data": [
{
"amount": "2108300",
"timestamp": "timestamp"
}
]
}
GET
/average?start=<timestamp>&end=<timestamp>endpoint that computes the average price over a certain arbitrary period
{
"start": "timestamp",
"end": "timestamp",
"avg": "2108300",
"data": [
{
"amount": "2108300",
"timestamp": "timestamp",
},
...
],
}
GET
/pricesSSE endpoint to push price updates
CLI#
proxycon --port 8080 --verbose --page 10
proxycon args
- port: define the HTTP listening port (TCP/8080 default)
- verbose: manage slog verbosity (INFO default)
- page: page size for listing endpoint (10 default)
Build#
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 .