this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 111 lines 2.2 kB view raw view rendered
1# proxycon 2 3## Overview 4 5proxycon is a performant Golang proxy service that returns the bitcoin 6historical data as fast as possible. This proxy service is used by a machine 7learning blackbox to do bitcoin trading. It is mission critical. 8 9As for now it uses only Go stdlib and may be improved with external libraries. 10 11## Datasource 12 13The data is available at 14[https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2](https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2) 15 16The data format is a JSON payload, with the price and timestamp in RFC3339 17format. 18 19```bash 20curl -fsS https://europe-west1-bitstack-test.cloudfunctions.net/coding-challenge-v2 | jq . 21``` 22 23```json 24{ 25 "data": [ 26 { 27 "price": "8773698", 28 "timestamp": "2021-11-19T12:22:51Z" 29 }, 30 { 31 "price": "6920238", 32 "timestamp": "2021-11-19T12:26:11Z" 33 }, 34 { 35 "price": "5218360", 36 "timestamp": "2021-11-19T12:29:31Z" 37 } 38 ] 39} 40``` 41 42## API 43 44> GET `/list` endpoint to get min and max prices with pagination 45 46```json 47{ 48 "start": "timestamp", 49 "end": "timestamp", 50 "max": "2108300", 51 "min": "2108300", 52 "data": [ 53 { 54 "amount": "2108300", 55 "timestamp": "timestamp", 56 }, 57 ... 58 ], 59} 60``` 61 62> GET `/price?at=<timestamp>` endpoint to get a price at the given timestamp 63 64```json 65{ 66 "data": [ 67 { 68 "amount": "2108300", 69 "timestamp": "timestamp" 70 } 71 ] 72} 73``` 74 75> GET `/average?start=<timestamp>&end=<timestamp>` endpoint that computes the 76> average price over a certain arbitrary period 77 78```json 79{ 80 "start": "timestamp", 81 "end": "timestamp", 82 "avg": "2108300", 83 "data": [ 84 { 85 "amount": "2108300", 86 "timestamp": "timestamp", 87 }, 88 ... 89 ], 90} 91``` 92 93> GET `/prices` SSE endpoint to push price updates 94 95## CLI 96 97```bash 98proxycon --port 8080 --verbose --page 10 99``` 100 101> proxycon args 102 103- port: define the HTTP listening port (TCP/8080 default) 104- verbose: manage slog verbosity (INFO default) 105- page: page size for listing endpoint (10 default) 106 107### Build 108 109```bash 110go 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 . 111```