rhettre / coinbase-advancedtrade-python

This is the unofficial Python client for the Coinbase Advanced Trade API. It allows users to interact with the API to manage their cryptocurrency trading activities on the Coinbase platform.
https://rhett.blog/youtube
MIT License
44 stars 22 forks source link

An idea - Receive webhook alerts from TradingView #11

Open novapietro opened 8 months ago

novapietro commented 8 months ago

Just an idea. It would be useful to connect your code to TradingView Webhook alerts to then automate buy/sell signals thanks for your work on this. pietro

kaush4l commented 7 months ago

This should be possible by using AWS lambda.

jauel1 commented 6 months ago

Great job with your code framework, Rhett!

Here is my attempt thus far at incorporating TradingView webhook alerts and AWS lamda, but I've not been successful. I've used TradingView webhook alerts, Chalice/AWS/Lambda (deployed through WSL windows subsystem for Linux commands), and AWS Secrets Manager with Alpaca quite successfully, but I'm having a lot of trouble with Coinbase!

Feel free to review and definitely let me know if you find a way to make it work.

Main.txt (rename it to Main.py) is my main trading file, and config.JSON is my AWS config file. I used Rhett's cb_auth.py and util.py files in addition to mine. I also attached my TradingView JSON payload as well.

Let me know if you have any luck!

main.txt requirements.txt config.json tradingview.JSON

jauel1 commented 6 months ago

Okay guys, I figured it out! I am successfully trading tradingview webhook alerts, AWS Lamda and Coinbase with the following:

  1. TradingView webhook alerts (running 4 crypto under the same bot)
  2. WSL - Created new AWS Lamdba project using Chalice (chalice new-project "name")
  3. Updated the JSON.config (you'll need to change the name of the IAM user that you create with permissions for Lamda)
  4. Added a chalicelib folder
  5. Added a coinbase_advanced_traded folder under chalicelib
  6. Add the following files in this folder: init.py (empty file), cb_auth.py (modified), coinbase_client.py (modified), portfolio_detais.py (new file I created), utils.py (modified)
  7. Created a new main trading bot script (app.py) that handles TradingView webhook alerts for long buy and sell orders
  8. Updated the requirements.txt file for use with webhook alerts

I use a Heiken Ashi candle ATR Trailing stop strategy that basically swing trades, printing buy and sell signals (and alerts - webhook messages) that I then receive on AWS Lamda (after deploying with chalice deploy in WSL).

I've attached .txt versions of all files I'm using. Feel free to ask questions, and happy trading!

cb_auth.txt coinbase_client.txt config.json utils.txt app.txt tradingview webhook alert.json