/captnHook

Server that allows users to place trades with tradingview's webhook alerts.

Primary LanguageGoMIT LicenseMIT

pirate

captnHook allows users to place trades with Tradingview's webhook alerts. The server is configurable to the most popular broker APIs (Alpaca, Binance, Coinbase, many more)


Website Coming Soon



Directories

  • cert A folder for housing a self-signed X.509 TLS certificate
  • cmd Main application for this project
  • docs Design and user documents
  • pkg Library code used by the main command

Installation

Clone the project to your machine

$ https://github.com/bareish/captnhook.git

Environment Variables

Copy the contents of .env.example and create a .env file from the contents - Then, fill in credentials that are required.

$ touch .env
$ cp .env.example .env

Directory tree should look as such:

  ├── .env
  ├── .env.example
  ├── Dockerfile
  ├── README.md
  ├── cmd
  ├── pkg
  ├── cert
  │   ├── cert.pem
  │   └── key.pem

Dotenv Example

# general configuration
MODE = dev  # can be dev/prod
BASE_URL=https://0.0.0.0
PORT=8000

# Path to self-signed X.509 TLS certificate
CERT_PATH=./cert/cert.pem
KEY_PATH=./cert/key.pem


# Alpaca Credentials
ALPACA_CLIENT_ID=nicetrygithubscraper
ALPACA_CLIENT_SECRET=nicetrygithubscraper
ALPACA_ACCOUNT_TYPE=Paper

#Binance Credentials
BINANCE_CLIENT_ID=nictrygithubscraper

Running locally

As simple as one command :)

$ docker-compose up

Output should look as such:

Successfully tagged captnhook_api:latest
Recreating captnhook_api ... done
Attaching to captnhook_api
api_1  |
api_1  |    ____    __
api_1  |   / __/___/ / ___
api_1  |  / _// __/ _ \/ _ \
api_1  | /___/\__/_//_/\___/ v4.2.0
api_1  | High performance, minimalist Go web framework
api_1  | https://echo.labstack.com
api_1  | ______________________________________________
api_1  |                                     
api_1  |http server started on [::]:8000

Webhook Settings

  1. Let's create a new alert in TradingView

Alert

  1. You can set the condition of the alert to whatever you want

Conditions

  1. Check the Webhook URL box and set it to your domain.

Hook

  1. Format your message as JSON, so the server can recognize it

JSON

Example:

{
  "ticker" : "{{ticker}}", 
  "price" : "{{close}}",
  "action": "Buy" 
}

📝 License

By contributing, you agree that your contributions will be licensed under its MIT License.

In short, when you submit code changes, your submissions are understood to be under the same MIT License that covers the project. Feel free to contact the maintainers if that's a concern.