Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Jan 31, 2018
1 parent ba960fe commit 9be2785
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion arbitrage/test/arbitrage_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def main():
testobs = TestObserver()
arbitrer.observers = [testobs]
arbitrer.arbitrage_opportunity("BitstampUSD", depths["BitstampUSD"]["asks"][0],
"MtGoxEUR", depths["MtGoxEUR"]["asks"][0])
"KrakenEUR", depths["KrakenEUR"]["asks"][0])
# FIXME: add asserts
elapsed = time.time() - start_time
print("Time: %.3f" % elapsed)
Expand Down
23 changes: 12 additions & 11 deletions arbitrage/test/arbitrage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
sys.path.append('../')
import unittest

import arbitrage
from arbitrage import arbitrer

depths1 = {
'PaymiumEUR':
'BitstampEUR':
{'asks': [{'amount': 4, 'price': 32.8},
{'amount': 8, 'price': 32.9},
{'amount': 2, 'price': 33.0},
Expand All @@ -14,7 +14,7 @@
{'amount': 4, 'price': 31.6},
{'amount': 6, 'price': 31.4},
{'amount': 2, 'price': 30}]},
'MtGoxEUR':
'KrakenEUR':
{'asks': [{'amount': 1, 'price': 34.2},
{'amount': 2, 'price': 34.3},
{'amount': 3, 'price': 34.5},
Expand All @@ -25,24 +25,24 @@
{'amount': 10, 'price': 32.3}]}}

depths2 = {
'PaymiumEUR':
'BitstampEUR':
{'asks': [{'amount': 4, 'price': 32.8},
{'amount': 8, 'price': 32.9},
{'amount': 2, 'price': 33.0},
{'amount': 3, 'price': 33.6}]},
'MtGoxEUR':
'KrakenEUR':
{'bids': [{'amount': 2, 'price': 33.2},
{'amount': 3, 'price': 33.1},
{'amount': 5, 'price': 32.6},
{'amount': 10, 'price': 32.3}]}}

depths3 = {
'PaymiumEUR':
'BitstampEUR':
{'asks': [{'amount': 1, 'price': 34.2},
{'amount': 2, 'price': 34.3},
{'amount': 3, 'price': 34.5},
{'amount': 3, 'price': 35.0}]},
'MtGoxEUR':
'KrakenEUR':
{'bids': [{'amount': 2, 'price': 33.2},
{'amount': 3, 'price': 33.1},
{'amount': 5, 'price': 32.6},
Expand All @@ -51,26 +51,27 @@

class TestArbitrage(unittest.TestCase):
def setUp(self):
self.arbitrer = arbitrage.Arbitrer()
self.arbitrer = arbitrer.Arbitrer()

def test_getprofit1(self):
self.arbitrer.depths = depths2
profit, vol, wb, ws = self.arbitrer.get_profit_for(
0, 0, 'PaymiumEUR', 'MtGoxEUR')
0, 0, 'BitstampEUR', 'KrakenEUR')
print(profit, vol, wb, ws)
assert(80 == int(profit * 100))
assert(vol == 2)

def test_getprofit2(self):
self.arbitrer.depths = depths2
profit, vol, wb, ws = self.arbitrer.get_profit_for(
2, 1, 'PaymiumEUR', 'MtGoxEUR')
2, 1, 'BitstampEUR', 'KrakenEUR')
assert(159 == int(profit * 100))
assert(vol == 5)

def test_getprofit3(self):
self.arbitrer.depths = depths3
profit, vol, wb, ws = self.arbitrer.get_profit_for(
2, 1, 'PaymiumEUR', 'MtGoxEUR')
2, 1, 'BitstampEUR', 'KrakenEUR')
assert(profit == 0)
assert(vol == 0)

Expand Down
2 changes: 1 addition & 1 deletion arbitrage/test/speed-test.json

Large diffs are not rendered by default.

0 comments on commit 9be2785

Please sign in to comment.