Username: Password:

Author Topic: Python script for push notifications on buy/sell events  (Read 6847 times)

Offline gambcl

  • Rookie
  • *
  • Posts: 7
    • View Profile
Python script for push notifications on buy/sell events
« on: November 28, 2017, 02:08:33 PM »
Here is my Python script for sending push notifications on buy/sell events.

Instructions:
- Create a Pushover account (https://pushover.net).
- Add an app called "Gunbot" to your Pushover account.
- Install Pushover app to your iOS or Android device.
- Edit the script to use a suitable hostname where gunbot is running, and insert your own Pushover User and App keys where it says REPLACE_ME.
- Install latest Python 3.
- Run "pip3 install requests".
- Run "pip3 install websocket-client".
- Run "python3 gunbot-websocket-listener.py".

You should receive a push notification straight away when the script successfully connects to gunbot. If not then check your Pushover User/App keys are correct.

Enjoy

This was just a quick-n-dirty script, if there is enough interest I might make a proper app out of it with a UI.

Offline dMike_Delorian

  • Rookie
  • *
  • Posts: 6
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #1 on: November 29, 2017, 12:02:47 AM »
Hey, first off BIG THANKS, I am in no way complaining about your script. So THANKS again! My question is it a way to only alert on verified buys? I get a ton of alerts for buys that don't ever take place for whatever reason. They aren't there when checking the log books.

Offline gambcl

  • Rookie
  • *
  • Posts: 7
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #2 on: November 29, 2017, 12:06:06 AM »
I see this occasionally too.

Sometimes a buy might not actually happen due to not enough BTC, or the startup timeout being in effect, etc.

Basically I can only report what gunbot reports via its websocket.

I think of it more as an "intention to buy" notification.

Offline dMike_Delorian

  • Rookie
  • *
  • Posts: 6
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #3 on: November 29, 2017, 12:25:57 AM »
OK thanks!

Offline cryptosticks

  • Contributor
  • **
  • Posts: 229
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #4 on: November 29, 2017, 04:40:38 AM »
Thanks for sharing this.  I went ahead and installed it to test.   Looks good. 

Definitely sending a few notifications of "GunBot intent to trade".

Offline tblim

  • Rookie
  • *
  • Posts: 42
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #5 on: December 29, 2017, 05:57:19 PM »
Thank you for sharing this. I have added a new function for sending through Pushbullet. See attached file.

@gambcl it would be good to put this on Github.

Offline MagicDude4Eva

  • Rookie
  • *
  • Posts: 13
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #6 on: December 29, 2017, 07:55:39 PM »
Thank you for sharing this. I have added a new function for sending through Pushbullet. See attached file.

@gambcl it would be good to put this on Github.

This is great, I was just looking for this. Could you perhaps create a Gist and then link it to my issue: https://github.com/GuntharDeNiro/BTCT/issues/355

FWIW - I could not get the original Pushbullet script to work (I am running OSX). I also noticed that retry did not work and the script threw errors on some conditions. Update of my hacked Python script: https://gist.github.com/magicdude4eva/440fe56fe39e80029f73c5f73a0e7642
« Last Edit: December 30, 2017, 10:36:50 AM by MagicDude4Eva »

Offline tblim

  • Rookie
  • *
  • Posts: 42
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #7 on: December 30, 2017, 12:32:20 PM »
@MagicDude4Eva Thanks for the update.

It would be great to integrate this with https://github.com/liiight/notifiers to abstract the notification service.

Offline MagicDude4Eva

  • Rookie
  • *
  • Posts: 13
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #8 on: December 30, 2017, 02:44:04 PM »
@MagicDude4Eva Thanks for the update.

It would be great to integrate this with https://github.com/liiight/notifiers to abstract the notification service.

I actually stopped using the notifications, as the websocket provides ambiguous information and it is currently not possible to discriminate between a buy-intent, an actual buy and a possible cancelled buy.

I logged a issue and perhaps once that issue is resolved, I will revisit: https://github.com/GuntharDeNiro/BTCT/issues/362

Offline tblim

  • Rookie
  • *
  • Posts: 42
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #9 on: December 30, 2017, 02:56:00 PM »
I actually stopped using the notifications, as the websocket provides ambiguous information and it is currently not possible to discriminate between a buy-intent, an actual buy and a possible cancelled buy.

Agreed but it's better than nothing.

Offline MagicDude4Eva

  • Rookie
  • *
  • Posts: 13
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #10 on: December 30, 2017, 04:56:53 PM »
I actually stopped using the notifications, as the websocket provides ambiguous information and it is currently not possible to discriminate between a buy-intent, an actual buy and a possible cancelled buy.

Agreed but it's better than nothing.

I am currently rewriting this using Binance Websockets. This will provide real-time updates of balances an orders. I will post an update/Gist once I have it working. This will be in PHP (I am a Java Dev and I get the PHP syntax, but Python is beyond me and will take too much time to get into). If anyone has knowledge of a generic PHP notification library, let me know (I could not find anything similar to what @tblim posted for PHP)

Offline MagicDude4Eva

  • Rookie
  • *
  • Posts: 13
    • View Profile
Re: Python script for push notifications on buy/sell events
« Reply #11 on: December 30, 2017, 06:14:19 PM »
Okay, so here is my PHP script. It can run anywhere where PHP is installed and does not need to run with GunBot as it uses Binance websockets directly. This means no more wrong orders.

https://gist.github.com/magicdude4eva/b910562342d2085ece184e09345b8685

I have not had many trades fired, so I will probably adjust the Gist over time. If you have changes/improvements, let me know...