https://github.com/synonymdev/slashtags-widget-price-feed
https://github.com/synonymdev/slashtags-widget-price-feed
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/synonymdev/slashtags-widget-price-feed
- Owner: synonymdev
- License: mit
- Archived: true
- Created: 2022-09-30T03:19:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T11:47:40.000Z (almost 2 years ago)
- Last Synced: 2025-05-18T13:02:03.120Z (11 months ago)
- Language: JavaScript
- Size: 26.5 MB
- Stars: 0
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slashtags-widget-price-feed
Provides price information as a slashtags feed.
## Usage
### Feed
Copy `config/config.example.json` to `config/config.json` then edit the relay address.
```bash
cp config/config.example.json config/config.json
```
Start the feed writer
```bash
npm start
```
It will generate a `keyPair` and persist that in `config/config.json` for future sessions.
It should print: `Running Bitcoin price feed: slashfeed:/Bitcoin Price?relay=`
### Reader
To read The price feed use the `Reader` helper class.
```js
const { Feed, Reader } = require('slashtags-widget-price-feed')
(async () => {
const client = new Client({ storage: './path/to/feed/storage', relay: 'https://web-relay.example.com' })
const feed = new Feed(client, config, { icon })
await feed.ready()
const client = new Client({ storage: './path/to/reader/storage'})
const readerClient = new Client({ storage: tmpdir() })
const reader = new Reader(readerClient, feed.url)
reader.subscribeLatestPrice('BTCUSD', price => {
// BTC/USD price (latest)
})
reader.subscribePastDayCandles('BTCUSD', candles => {
// BTC/USD price candles for the past day
})
reader.subscribePastWeekCandles('BTCUSD', candles => {
// BTC/USD price candles for the past week
})
reader.subscribePastMonthCandles('BTCUSD', candles => {
// BTC/USD price candles for the past month
})
})
```