Tradingview documentation can be found here this is a private repository, you must ask Tradingview to get access to it.
This repository uses TimescaleDB to store candles. Full documentation can be found on their website
Markets should be passed in a JSON file as follow
address | name | isPyth | baseDecimals | quoteDecimals | min_mov | price_scale |
---|---|---|---|---|---|---|
string | string | bool | u8 | u8 | u8 | u16 |
Pyth feed or AOB market address | Name of the market | true if this a Pyth feed |
Base token decimals (for Pyth only) | Quote token decimals (for Pyth only) | Min move (cf TV doc) | Price scale (cf TV doc) |
min_mov
and price_scale
are parameters required by the Tradingview specification, see the exact definition on Tradingview documentation
min_mov = 1
is equivalent to a tick size of 0.01price_scale = 100
is equivalent to 1.01
For instance
[
{
"address": "ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",
"name": "FIDA-USDC-PYTH",
"isPyth": true,
"baseDecimals": 6,
"quoteDecimals": 6,
"minMov": 1,
"priceScale": 100
}
]
The worker directory contains the program that fetches price information from the blockchain and stores it in the database.
It takes the following parameters in input:
cargo run markets_json_path rpc refresh_period
markets_json_path
is the path to your JSON file that contains the markets you want to fetchrpc
The URL of your Solana RPC endpointrefresh_period
interval at which candles are fetched (in ms)
So for instance
cargo run ./markets.json https://solana-api.projectserum.com 10000
The worker handles Pyth and AOB markets in separate threads. This program uses getMultipleAccountInfo
RPC requests to optimize the number of RPC calls. However, certain RPC nodes have limits to how many accounts can be passed in 1 request (usually 100) this is why the array of accounts are split in chunks of MAX_ACCOUNT_CHUNK
and spawned in different threads.
For AOB markets, bids and asks account addresses are being fetched at the start of the program and are cached for more efficient polling.
The server uses actix web and is served by default on port 8080
.
It takes the following parameters in input:
cargo run markets_json_path user password host port dbname
For instance
cargo run ./market.json my_user my_password 127.0.0.1 5432 my_db
it has the following endpoints required by the Tradingview specification
Request:
GET /tradingview/config
It exposes the tradingview configuration of your server If you want to change the available resolutions of your server you will have to modify this configuration
Response:
{
"supported_resolutions": [
"1",
"3",
"5",
"15",
"30",
"60",
"120",
"240",
"360",
"480",
"720",
"960",
"D"
],
"supports_group_request": false,
"supports_marks": false,
"supports_search": true,
"supports_timescale_marks": false
}
Request:
GET /tradingview/symbols?symbol={symbol}
Serve information for a requested symbol
Response:
{
"name": "FIDA-USDC-PYTH",
"ticker": "FIDA-USDC-PYTH",
"description": "FIDA-USDC-PYTH",
"type": "Spot",
"session": "24x7",
"exchange": "Bonfida",
"listed_exchange": "Bonfida",
"timezone": "Etc/UTC",
"has_intraday": true,
"supported_resolutions": [
"1",
"3",
"5",
"15",
"30",
"60",
"120",
"240",
"360",
"480",
"720",
"960",
"D"
],
"minmov": 1.0,
"pricescale": 100.0
}
GET /tradingview/search?query={query}&search_type={search_type}&exchange={exchange}&limit={limit}
Can be used to search existing market
Response:
[
{
"symbol": "FIDA-USDC-PYTH",
"full_name": "FIDA-USDC-PYTH",
"description": "Name:FIDA-USDC-PYTH - Address: ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF",
"exchange": "Bonfida",
"ticker": "FIDA-USDC-PYTH",
"type": "Spot"
}
]
Request:
GET /tradingview/time
Returns the current unix timestamp (in seconds!) of the server
Response:
1651188181
Request:
GET /tradingview/history?symbol={symbol}&from={from}&to={to}&resolution={resolution}
Returns historical candles for a given symbol
Response:
{
"s": "ok",
"time": [1651189320, 1651189380],
"close": [1.2090027797967196, 1.2083083698526025],
"open": [1.2090027797967196, 1.208549999864772],
"high": [1.2090027797967196, 1.208549999864772],
"low": [1.2090027797967196, 1.208055029856041],
"volume": [0, 0]
}
GET /tradingview/pairs
This endpoint returns all pairs available on the server (not required by Tradingview)
This repository can be deployed using docker compose (recommended) or natively.