Post
Topic
Board Project Development
Re: Need help making my first volume monitor bot
by
Xypherian
on 28/09/2017, 22:02:03 UTC
You won't find an specific tutorial for this anywhere.

I personally have been working on something like this lately for Bittrex. Here is some code to get you started (Python) it listens to the Bittrex Socket and pushes updates from the SubscribeToExchangeDeltas. This one listens only to the OMG pairs on Bittrex (BTC-OMG, ETH-OMG, USDT-OMG) but it works, from there you have to do your logic  Cheesy. This prints the market with the amount of the base currency that has been bought/sold live
https://i.gyazo.com/7d937019383a5b7911cd55ec6b7582d5.png

Code:

from requests import Session
from signalr import Connection
import time, json

markets = ['BTC-OMG', 'ETH-OMG', 'USDT-OMG']

def orderPrinter(update):
    orderUnparsed = json.dumps(update)
    JSONOrder = json.loads(orderUnparsed)

    try:
        MarketName = JSONOrder[0]['MarketName']
        Fills = JSONOrder[0]['Fills']
        for order in Fills:
            OrderType = order['OrderType']
            Rate = order['Rate']
            Quantity = order['Quantity']
            Total = Rate * Quantity

            print MarketName, OrderType, Total
    except Exception as e:
        print e
        pass



with Session() as session:
connection = Connection('http://socket.bittrex.com/signalr', session)

corehub = connection.register_hub('coreHub')

#create error handler
def print_error(error):
print('error: ', error)


# debug information, show all data
def print_raw_data(*args, **kwargs):
print (args, kwargs)

def ticker_data(*args, **kwargs):
print "ticker", (args, kwargs)
def market_data(*args, **kwargs):
#print "ticker", (args, kwargs)
            orderPrinter(args)

connection.error += print_error

connection.start()
print "sending subscription request"
for market in markets:
corehub.server.invoke('SubscribeToExchangeDeltas', market)

#corehub.client.on('updateSummaryState', ticker_data)
corehub.client.on('updateExchangeState', market_data)

connection.wait(150000)