priceproxy

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT

README

Price Proxy

priceproxy fetches prices periodically from sources as listed in its config file. It provides a simple REST API for fetching prices.

Vega trading bots use the price proxy to place orders with real-world prices while avoiding hitting API rate limits on upstream price sources. The bots can then provide liquidity on Testnet, and help make the charts look realistic.

Install - from a release

See the releases page.

Install - from source

Either run go get:

go get github.com/vegaprotocol/priceproxy/cmd/priceproxy@latest

Or clone the repository:

git clone https://github.com/vegaprotocol/priceproxy.git
cd priceproxy
go install ./cmd/priceproxy

A compiled priceproxy binary should now be in $GOPATH/bin.

See also:

  • Makefile - contains useful commands for running builds, tests, etc.

Running

priceproxy -config /path/to/your/config.yml

Config

Save the following as config.yml:

server:
  listen: ":8080"
  logformat: text  # json, text
  loglevel: info  # debug, info, warn, error, fatal
  env: prod  # dev, prod

sources:

  - name: bitstamp
    sleepReal: 60  # seconds
    sleepWander: 2  # seconds
    url:
      scheme: https
      host: www.bitstamp.net
      path: "/api/v2/ticker/{base}{quote}/"
      # "{base}" and "{quote}" are replaced at runtime.

prices:

  - source: bitstamp
    base: BTC
    quote: USD
    factor: 1.0
    wander: true

Supported price sources

The following price sources are currently supported. Pull requests are gratefully received for more sources.

priceproxy API Endpoints

Method Location Description
GET /prices?params... List some/all prices
GET /sources List all sources
GET /sources/[name string] List one source
GET /status Resturn status=true
Query parameters for GET /prices
  • source string: Limit the results to ones with the given source.
  • base string: Limit the results to ones with the given base.
  • quote string: Limit the results to ones with the given quote.
  • wander bool: Limit the results to ones with the given wander setting.

Licence

Distributed under the MIT License. See LICENSE for more information.

Directories

Path Synopsis
cmd
priceproxy
Command priceproxy runs a REST webserver that serves prices that are periodically updated from other sources.
Command priceproxy runs a REST webserver that serves prices that are periodically updated from other sources.
Package config contains structures used in retrieving app configuration from disk.
Package config contains structures used in retrieving app configuration from disk.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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