Bitcoin Forum
July 28, 2024, 08:26:15 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Qt Bitcoin Trader  (Read 1873 times)
tebokiho (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 26, 2013, 11:32:22 PM
 #1

Hi,

I have a comment on https://bitcointalk.org/index.php?topic=201062.0 (Qt Bitcoin Trader [Open Source secure trading client for Mac/Windows/Linux])
Please, somebody who has privileges, post this to IGHOR, the author of the program below the line. It'd mean lots of help in his development process.

-------------------------------------

Hi IGHOR,
You've mention this in the TODO list:

Quote
Next TODO:
5 ) Develop server to collect all ticker and depth data to provide single websocket connection for realtime data updates

But maybe you don't know, that Bitstamp has a Pusher websocket interface, which is operating smoothly. (Pusher protocol is described here: http://pusher.com/docs/pusher_protocol)
You need't implement a server, just use the code which is already on their homepage. From their Javascript:

Code:
      var pusher = new Pusher('de504dc5763aeef9ff52');

      var trades_channel = pusher.subscribe('live_trades');
      trades_channel.bind('trade', update_index_live_trades);

      var order_book_channel = pusher.subscribe('order_book');
      order_book_channel.bind('data', update_index_order_book);

      //var orders_channel = pusher.subscribe('live_orders');
      //orders_channel.bind('order_deleted', add_to_ws_queue);
      //orders_channel.bind('order_created', add_to_ws_queue);
      //orders_channel.bind('order_changed', add_to_ws_queue);

You just have to subscribe to their Pusher channels with that de504dc5763aeef9ff52 ID, and you get the transaction stream live! Wink
I've downloaded a Python Pusher Client, subscribed to their channels, and got the same feed as seen on their website, all data which is public but undocumented on their API doc page.

Test python code, just to see how easy it is:

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.path.append('..')
import pusherclient #live stream client: https://github.com/ekulyk/PythonPusherClient
import logging
import time


def trade_callback(data): #some callbacs to do something when the event occours
    print "trade", data

def order_deleted_callback(data):
    print "delete", data

def order_created_callback(data):
    print "create", data

def order_changed_callback(data):
    print "changes", data
   
def order_book_callback(data):
    print "book", data

def connect_handler(data): #this gets called when the Pusher connection is established
    trades_channel = pusher.subscribe("live_trades")
    trades_channel.bind('trade', trade_callback)

    order_book_channel = pusher.subscribe('order_book');
    order_book_channel.bind('data', order_book_callback)

    orders_channel = pusher.subscribe("live_orders")
    orders_channel.bind('order_deleted', order_deleted_callback)
    orders_channel.bind('order_created', order_created_callback)
    orders_channel.bind('order_changed', order_changed_callback)


if __name__ == '__main__': #this is the main() function
    pusher = pusherclient.Pusher("de504dc5763aeef9ff52")
    pusher.connection.logger.setLevel(logging.WARNING) #no need for this line if you want everything printed out by the logger
    pusher.connection.bind('pusher:connection_established', connect_handler)
    pusher.connect()

    while True:  #run until ctrl+c interrupts
        time.sleep(1)

And that's all! Very easy in python, I think it can be done also in you program quickly Smiley It'd be a very very big improvement Smiley

Sample outputs of the previous program, all is well formed JSON that is in the data variabes printed out:

Code:
create {"price": "725.11", "amount": "48.65000000", "datetime": "1388100046", "id": 11927177, "order_type": 0}
delete {"price": "751.00", "amount": "0.49533954", "datetime": "1388099770", "id": 11926902, "order_type": 0}
delete {"price": "736.06", "amount": "6.95000000", "datetime": "1388100034", "id": 11927172, "order_type": 0}
delete {"price": "736.06", "amount": "48.65000000", "datetime": "1388100018", "id": 11927153, "order_type": 0}
create {"price": "736.07", "amount": "20.85000000", "datetime": "1388100053", "id": 11927178, "order_type": 0}
delete {"price": "774.99", "amount": "5.16121000", "datetime": "1388099872", "id": 11926993, "order_type": 1}
create {"price": "736.76", "amount": "27.67767160", "datetime": "1388100053", "id": 11927179, "order_type": 0}
book {"bids": [["758.08", "0.09000000"], ["757.71", "3.13735421"], ["757.70", "6.23629196"], ["757.46", "0.04700000
"], ["756.98", "0.00138704"], ["756.90", "1.00000000"], ["756.47", "0.05000000"]], "asks": [["760.78", "0.04800000"
], ["761.00", "1.47339631"], ["761.65", "0.14020557"], ["761.66", "1.67295194"], ["761.81", "0.04900000"], ["762.00
", "1.82159420"], ["762.85", "0.04900000"]]}
create {"price": "751.80", "amount": "6.95000000", "datetime": "1388100054", "id": 11927180, "order_type": 0}
create {"price": "690.00", "amount": "2.35905797", "datetime": "1388100055", "id": 11927181, "order_type": 0}
create {"price": "758.08", "amount": "0.04143494", "datetime": "1388100056", "id": 11927182, "order_type": 1}
changes {"price": "758.08", "amount": "0.04856506", "datetime": "1388100018", "id": 11927152, "order_type": 0}
delete {"price": "758.08", "amount": "0.00000000", "datetime": "1388100056", "id": 11927182, "order_type": 1}
trade {"price": 758.08000000000004, "amount": 0.041434940000000003, "id": 2760844}
create {"price": "771.65", "amount": "5.16121000", "datetime": "1388100058", "id": 11927183, "order_type": 1}
create {"price": "753.00", "amount": "0.49402390", "datetime": "1388100059", "id": 11927184, "order_type": 0}

You can even miss out the create/delete/change data, because the order_book contains the top 5 asks and bids, like on their website.

I hope this live trade watching feature gets implemented very guickly (I need it also:P), so I wish good luck for you and Merry Christmas of course Smiley
IGHOR
Legendary
*
Offline Offline

Activity: 1035
Merit: 1065



View Profile WWW
December 27, 2013, 12:12:22 AM
 #2

Hi. I see this is not official Bitstamp API.
I saw some push servers which bring realtime data, but when exchange in high load, data received with a big delay.
So there is no stability guaranties for this method.

Quote
Next TODO:
5 ) Develop server to collect all ticker and depth data to provide single websocket connection for realtime data updates

It required to receive data stream for selected currencies and exchanges. So if I'll use simple way, there will be a lot of connections, and it will works not as fast I want.
I have developed intelligent algorithm to join data from all currencies and exchanges and I'll bring it by single connection to you.
After I'll finish this planted work I'll add option to use only websocket and maybe pusher too.


Qt Bitcoin Trader
Verify digital signature of the app in the file properties every time you download it.
tebokiho (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 27, 2013, 12:58:13 AM
 #3

Oh, I see your opinion.
But a quick note: Undocumented API doesn't mean unofficial API. Even bitwisdom and other live graph drawer sites using their Pusher. The official (documented) API is behind the live stream, so when large bursts of trades occur, your program simply not quick enough to respond to the sudden changes in that couple of seconds while the price went down and up. I also run into this problem when I tried to implement a trading application in Python, I missed several trades when they were faster than the Bitstamp API's output refresh.
This post describes the exact same situation, when bitwisdom not used the Pusher interface, they falled behind the live trade data, so there was a chance of exploitation of this delay:
http://www.reddit.com/r/Bitcoin/comments/1r4d6t/bitstamps_streaming_api_and_exploitation/
This Pusher interface is only for the live orders and trades, so I think there could be an option in your program to choose between official trades data (not live) or Pusher data (live but not "official"). The rest (I mean the currencies and other data) can come from your algoritmus, as well Smiley
Anyways, until other options, I'll have a browser open behind the program to see the live data, however it won't help using the quick changes in the trades to profit from them (sometimes the bursts cause 8-10 dollars difference which could be very profitable sometimes).
infinitybo
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
December 27, 2013, 01:38:01 PM
 #4

@Tebokiho That's the point anyways this post describes quietly well this possible chance to exploit this delay.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!