/btc-alert

Tracks stock and crypto prices and outputs change by minute. Can send alerts based on percentage changes and chosen lengths of time.

Primary LanguageGo

Usage

go get github.com/tsny/btc-alert

Follow the configuration section below, go build, and run it

Configuration

Create a config.json file in the root of the project.

config.json houses each 'interval' which represents an interval that is checked every minute. If an interval lapses, then a notification is sent if the absolute value of the overall percentage change in the asset is more than the percentThreshold field.

occurences are minutes.

Config file will look like this:

{
    "bootNotification": false,
    "discord": {
        "enabled": false,
        "token": "token.WgvCew.ObvImI8RA0HAn-kf2u8omFQGINI",
        "channelId": "715135158184218",
    },
    "yahooTickers":[
        "MSFT",
        "GM",
        "GME"
    ],
    "thresholds": [
        {
            "threshold": 500
        }
    ],
    "intervals": [
        {
            "maxOccurences": 5,
            "percentThreshold": 1
        },
        {
            "maxOccurences": 20,
            "percentThreshold": 2
        },
        {
            "maxOccurences": 60,
            "percentThreshold": 3
        }
    ]
}

API

Checkout routes.go for a few of the endpoints, port defaults to 8080

GET /crypto Returns the publishers associated with all tracked crypto coins Example API

Graphs!

I'm working on rudimentary caching that allows me to do stuff like plot over a graph You can hit GET /symbol/{symbol/graph to get a bare bones chart of the recent price of the stock

Example BTC Graph

Discord

If you have a Discord bot, you can redirect to there!

Example Screenshot

Discord Commands

{ticker}'s can be either be something like BTC or BTC-USD or btc

!get {ticker}

Returns the last minute candlestick for the provided ticker

!trade {ticker}

Returns the current price with a 1% and 2% difference for helping calculate trade costs

!sub {ticker} {price}

Subscribes to the event of a certin price point

!stat {ticker}

Returns the last 24 hour candlestick

!gainers !losers

Returns the top market movers (gainers/losers) from Yahoo Finance

Movers

!whois {ticker}

Returns the company summary from MarketWatch

Summary

Logs Example

Example Screenshot

Dependencies

  • github.com/gen2brain/beeep - Notifications

  • github.com/bwmarrin/discordgo - Discord API

  • github.com/PuerkitoBio/goquery - Tables

  • Yahoo Finance - Ticker prices

  • CoindeskAPI - Coin Price Data

  • CoinbaseAPI - Coins