{"id":18300904,"url":"https://github.com/bonfida/agnostic-candles","last_synced_at":"2025-04-05T14:30:46.842Z","repository":{"id":40481305,"uuid":"484405294","full_name":"Bonfida/agnostic-candles","owner":"Bonfida","description":"Fetch and serve tradingview candles for any AOB and Pyth markets","archived":false,"fork":false,"pushed_at":"2022-06-07T09:40:40.000Z","size":53,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T05:32:52.487Z","etag":null,"topics":["actix-web","pyth","solana","tradingview"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bonfida.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-22T11:17:42.000Z","updated_at":"2024-09-30T06:12:09.000Z","dependencies_parsed_at":"2022-08-09T21:50:10.099Z","dependency_job_id":null,"html_url":"https://github.com/Bonfida/agnostic-candles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bonfida%2Fagnostic-candles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bonfida%2Fagnostic-candles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bonfida%2Fagnostic-candles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bonfida%2Fagnostic-candles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bonfida","download_url":"https://codeload.github.com/Bonfida/agnostic-candles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247352249,"owners_count":20925236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actix-web","pyth","solana","tradingview"],"created_at":"2024-11-05T15:13:48.709Z","updated_at":"2025-04-05T14:30:46.358Z","avatar_url":"https://github.com/Bonfida.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eAgnostic candles\u003c/h1\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"250\" src=\"https://i.imgur.com/nn7LMNV.png\"/\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://twitter.com/bonfida\"\u003e\n\u003cimg src=\"https://img.shields.io/twitter/url?label=Bonfida\u0026style=social\u0026url=https%3A%2F%2Ftwitter.com%2Fbonfida\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge\u0026logo=rust\u0026logoColor=white\" /\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003ch2 align=\"center\"\u003eTable of contents\u003c/h2\u003e\n\u003cbr /\u003e\n\n1. [Timescaledb](#timescaledb)\n2. [Configuration](#configuration)\n3. [Worker](#worker)\n4. [Server](#server)\n5. [Deployment](#deployment)\n\nTradingview documentation can be found [here](https://github.com/tradingview/charting_library/wiki/UDF) this is a private repository, you must ask Tradingview to get access to it.\n\n\u003cbr /\u003e\n\u003ca name=\"timescaledb\"\u003e\u003c/a\u003e\n\u003ch2 align=\"center\"\u003eTimescaledb\u003c/h2\u003e\n\u003cbr /\u003e\n\nThis repository uses TimescaleDB to store candles. Full documentation can be found on their [website](https://www.timescale.com/)\n\n\u003cbr /\u003e\n\u003ca name=\"configuration\"\u003e\u003c/a\u003e\n\u003ch2 align=\"center\"\u003eConfiguration\u003c/h2\u003e\n\u003cbr /\u003e\n\nMarkets should be passed in a JSON file as follow\n\n| address                         | name               | isPyth                     | baseDecimals                        | quoteDecimals                        | min_mov              | price_scale             |\n| ------------------------------- | ------------------ | -------------------------- | ----------------------------------- | ------------------------------------ | -------------------- | ----------------------- |\n| string                          | string             | bool                       | u8                                  | u8                                   | u8                   | u16                     |\n| 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) |\n\n`min_mov` and `price_scale` are parameters required by the Tradingview specification, see the exact definition on [Tradingview documentation](https://github.com/tradingview/charting_library/wiki/UDF)\n\n- `min_mov = 1` is equivalent to a tick size of 0.01\n- `price_scale = 100` is equivalent to 1.01\n\nFor instance\n\n```json\n[\n  {\n    \"address\": \"ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF\",\n    \"name\": \"FIDA-USDC-PYTH\",\n    \"isPyth\": true,\n    \"baseDecimals\": 6,\n    \"quoteDecimals\": 6,\n    \"minMov\": 1,\n    \"priceScale\": 100\n  }\n]\n```\n\n\u003cbr /\u003e\n\u003ca name=\"worker\"\u003e\u003c/a\u003e\n\u003ch2 align=\"center\"\u003eWorker\u003c/h2\u003e\n\u003cbr /\u003e\n\nThe worker directory contains the program that fetches price information from the blockchain and stores it in the database.\n\nIt takes the following parameters in input:\n\n```\ncargo run markets_json_path rpc refresh_period\n```\n\n- `markets_json_path` is the path to your JSON file that contains the markets you want to fetch\n- `rpc` The URL of your Solana RPC endpoint\n- `refresh_period` interval at which candles are fetched (in ms)\n\nSo for instance\n\n```\ncargo run ./markets.json https://solana-api.projectserum.com 10000\n```\n\nThe 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.\n\nFor AOB markets, bids and asks account addresses are being fetched at the start of the program and are cached for more efficient polling.\n\n\u003cbr /\u003e\n\u003ca name=\"server\"\u003e\u003c/a\u003e\n\u003ch2 align=\"center\"\u003eServer\u003c/h2\u003e\n\u003cbr /\u003e\n\nThe server uses [actix web]() and is served by default on port `8080` .\n\nIt takes the following parameters in input:\n\n```\ncargo run markets_json_path user password host port dbname\n```\n\nFor instance\n\n```\ncargo run ./market.json my_user my_password 127.0.0.1 5432 my_db\n```\n\nit has the following endpoints required by the Tradingview [specification](https://github.com/tradingview/charting_library/wiki/UDF)\n\n### Config\n\n**Request:**\n\n`GET /tradingview/config`\n\nIt exposes the tradingview configuration of your server\nIf you want to change the available resolutions of your server you will have to modify this configuration\n\n**Response:**\n\n```json\n{\n  \"supported_resolutions\": [\n    \"1\",\n    \"3\",\n    \"5\",\n    \"15\",\n    \"30\",\n    \"60\",\n    \"120\",\n    \"240\",\n    \"360\",\n    \"480\",\n    \"720\",\n    \"960\",\n    \"D\"\n  ],\n  \"supports_group_request\": false,\n  \"supports_marks\": false,\n  \"supports_search\": true,\n  \"supports_timescale_marks\": false\n}\n```\n\n### Symbols\n\n**Request:**\n\n`GET /tradingview/symbols?symbol={symbol}`\n\nServe information for a requested symbol\n\n**Response:**\n\n```json\n{\n  \"name\": \"FIDA-USDC-PYTH\",\n  \"ticker\": \"FIDA-USDC-PYTH\",\n  \"description\": \"FIDA-USDC-PYTH\",\n  \"type\": \"Spot\",\n  \"session\": \"24x7\",\n  \"exchange\": \"Bonfida\",\n  \"listed_exchange\": \"Bonfida\",\n  \"timezone\": \"Etc/UTC\",\n  \"has_intraday\": true,\n  \"supported_resolutions\": [\n    \"1\",\n    \"3\",\n    \"5\",\n    \"15\",\n    \"30\",\n    \"60\",\n    \"120\",\n    \"240\",\n    \"360\",\n    \"480\",\n    \"720\",\n    \"960\",\n    \"D\"\n  ],\n  \"minmov\": 1.0,\n  \"pricescale\": 100.0\n}\n```\n\n### Search\n\n`GET /tradingview/search?query={query}\u0026search_type={search_type}\u0026exchange={exchange}\u0026limit={limit}`\n\nCan be used to search existing market\n\n**Response:**\n\n```json\n[\n  {\n    \"symbol\": \"FIDA-USDC-PYTH\",\n    \"full_name\": \"FIDA-USDC-PYTH\",\n    \"description\": \"Name:FIDA-USDC-PYTH - Address: ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF\",\n    \"exchange\": \"Bonfida\",\n    \"ticker\": \"FIDA-USDC-PYTH\",\n    \"type\": \"Spot\"\n  }\n]\n```\n\n### Time\n\n**Request:**\n\n`GET /tradingview/time`\n\nReturns the current unix timestamp (in seconds!) of the server\n\n**Response:**\n\n```json\n1651188181\n```\n\n### History\n\n**Request:**\n\n`GET /tradingview/history?symbol={symbol}\u0026from={from}\u0026to={to}\u0026resolution={resolution}`\n\nReturns historical candles for a given symbol\n\n**Response:**\n\n```json\n{\n  \"s\": \"ok\",\n  \"time\": [1651189320, 1651189380],\n  \"close\": [1.2090027797967196, 1.2083083698526025],\n  \"open\": [1.2090027797967196, 1.208549999864772],\n  \"high\": [1.2090027797967196, 1.208549999864772],\n  \"low\": [1.2090027797967196, 1.208055029856041],\n  \"volume\": [0, 0]\n}\n```\n\n### Pairs\n\n`GET /tradingview/pairs`\n\nThis endpoint returns all pairs available on the server (not required by Tradingview)\n\n\u003cbr /\u003e\n\u003ca name=\"deployment\"\u003e\u003c/a\u003e\n\u003ch2 align=\"center\"\u003eDeployment\u003c/h2\u003e\n\u003cbr /\u003e\n\nThis repository can be deployed using docker compose (recommended) or natively.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonfida%2Fagnostic-candles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbonfida%2Fagnostic-candles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonfida%2Fagnostic-candles/lists"}