OpenBook Candles is an open source trade scraper and candle batcher combined with web API for OpenBook frontends. The web API is largely based off of the code [here](https://github.com/Bonfida/agnostic-candles).
>⚠️ This repo requires that Postgres be used as the database to store trades and candles.
See the .env file for providing Postgres configuration options and a Solana RPC URL. Markets should be held in a JSON file in the repo's root as follows:
The worker directory contains the program that scrapes OpenBook trades and stores them. The worker is also responsible for batching the trades into OHLCV candles.
To run the worker locally:
```
cargo run --bin worker markets_json_path
```
-`markets_json_path` is the path to your JSON file that contains the markets you want to fetch
<br/>
The worker uses [getConfirmedSignaturesForAddress2](https://docs.solana.com/api/http#getconfirmedsignaturesforaddress2) to scrape OpenBook trades. Only trades from the specified markets will be saved. Each market will automatically batch 1,3,5,15,30 minute, 1,2,4 hour, and 1 day candles from the scraped trades.
<br/>
<aname="server"></a>
<h2align="center">Server</h2>
<br/>
The server uses [actix web](https://actix.rs/) and is served by default on port `8080` .
To run the server locally:
```
cargo run markets_json_path
```
-`markets_json_path` is the path to your JSON file that contains the markets you want to fetch