Skip to content

Commit

Permalink
Merge various improvements from genbtc's version
Browse files Browse the repository at this point in the history
* group orders below 0.6 (we really should make this configurable at
  some point)
* remove USD volumes (I kind of liked them, but I'll admit they're not 
  crucial for trading)
* gain screen estate by tabbing authentication stuff
* customizable application log (filters)
* add bitcoin icon
* make the price column 5 decimals 
* make buy/sell price edit box 5 decimals
* correct windows start script
* fix the code that inserts order-Id's into the edit box to better
  identify the last order
  • Loading branch information
Sebastian committed Apr 20, 2013
1 parent 34bcb33 commit 9eab13a
Show file tree
Hide file tree
Showing 10 changed files with 388 additions and 206 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
2 changes: 2 additions & 0 deletions goxgui/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import goxapi
import sys

from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import SIGNAL
from view import View
Expand Down Expand Up @@ -66,4 +67,5 @@ def __quit(self):

if __name__ == '__main__':
app = Application(sys.argv)
app.setWindowIcon(QIcon('bitcoin.png'))
app.exec_()
41 changes: 27 additions & 14 deletions goxgui/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Model(QAbstractTableModel):
Model representing a collection of orders.
'''

# orders smaller than this value will be grouped
GROUP_ORDERS = 0.6

def __init__(self, gox, headerdata):
QAbstractTableModel.__init__(self)
self.gox = gox
Expand All @@ -31,16 +34,29 @@ def __parse_data(self, book):
data_in = self._get_data_from_book(book)
data_out = []

total_sum = 0

total = 0
count = 1
vwap = 0
vsize = 0
for x in data_in:

price = utilities.gox2internal(x.price, 'USD')
size = utilities.gox2internal(x.volume, 'BTC')
total = utilities.multiply_internal(price, size)
total_sum += total
price = x.price
size = x.volume

data_out.append([price, size, total, total_sum])
vsize += size
vwap += price * size

total += size
if vsize > utilities.float2internal(self.GROUP_ORDERS):
vwap = utilities.gox2internal(vwap / vsize, 'USD')
vsize = utilities.gox2internal(vsize, 'BTC')
total = utilities.gox2internal(total, 'BTC')
data_out.append([vwap, vsize, total])
count = 1
vwap = 0
vsize = 0
else:
count += 1

return data_out

Expand All @@ -61,9 +77,6 @@ def get_size(self, index):
def get_total(self, index):
return self.__data[index][2]

def get_sum_total(self, index):
return self.__data[index][3]

# START Qt methods

def rowCount(self, parent):
Expand All @@ -89,8 +102,6 @@ def data(self, index, role):
return QVariant(utilities.internal2str(self.get_size(row)))
if col == 2:
return QVariant(utilities.internal2str(self.get_total(row), 5))
if col == 3:
return QVariant(utilities.internal2str(self.get_sum_total(row), 5))

def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
Expand All @@ -103,7 +114,8 @@ def headerData(self, col, orientation, role):
class ModelAsk(Model):

def __init__(self, gox):
Model.__init__(self, gox, ['Ask', 'Size', 'Total', 'Sum Total'])
Model.__init__(self, gox, ['Ask $', 'Size ' + utilities.BITCOIN_SYMBOL,
'Total ' + utilities.BITCOIN_SYMBOL])

def _get_data_from_book(self, book):
return book.asks
Expand All @@ -112,7 +124,8 @@ def _get_data_from_book(self, book):
class ModelBid(Model):

def __init__(self, gox):
Model.__init__(self, gox, ['Bid', 'Size', 'Total', 'Sum Total'])
Model.__init__(self, gox, ['Bid $', 'Size ' + utilities.BITCOIN_SYMBOL,
'Total ' + utilities.BITCOIN_SYMBOL])

def _get_data_from_book(self, book):
return book.bids
Loading

0 comments on commit 9eab13a

Please sign in to comment.