Skip to content

Commit 06ed295

Browse files
committed
Merge branch 'develop'
2 parents 1e1530e + 3b2e30d commit 06ed295

File tree

4 files changed

+150
-3
lines changed

4 files changed

+150
-3
lines changed

Cryptsy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _public_api_query(self, method, marketid=None):
2121
rv = urllib2.urlopen(urllib2.Request(request_url))
2222
return json.loads(rv.read())
2323

24-
def _api_query(self, method, request_data=None):
24+
def _api_query(self, method, request_data={}):
2525
""" Call to the "private" api and return the loaded json. """
2626
request_data['method'] = method
2727
request_data['nonce'] = int(round(time.time() * 1000))
@@ -180,7 +180,7 @@ def my_orders(self, marketid=None):
180180
:param marketid: If provided, orders will be filtered by this marketid.
181181
"""
182182
if marketid is None:
183-
return self.api_query('allmyorders')
183+
return self._api_query('allmyorders')
184184
return self._api_query('myorders', request_data={'marketid': marketid})
185185

186186
def depth(self, marketid):

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ API for Cryptsy.com Exchange utilizing completely built-in functions and utiliti
66
Note: the next version of this API wrapper will introduce A LOT of API changes
77
so be warned, here be dragons.
88

9+
[![Dependency Status](https://gemnasium.com/jaapz/CryptsyPythonAPI.png)](https://gemnasium.com/jaapz/CryptsyPythonAPI)
910
[![Build Status](https://api.travis-ci.org/jaapz/CryptsyPythonAPI.png)](https://travis-ci.org/jaapz/CryptsyPythonAPI)
11+
[![PyPI Version](https://pypip.in/v/Cryptsy/badge.png)](https://pypi.python.org/pypi/Cryptsy)
1012

1113
Author's Note
1214
-------------
@@ -39,6 +41,8 @@ Some things that I intend to add in future versions:
3941
* MOAR TESTS
4042
* sphinx reference generation
4143
* error handling
44+
* add some unofficial api endpoints because the official ones may suck
45+
* add travis ci builds
4246

4347
Running the tests
4448
-----------------

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='Cryptsy',
6-
version='0.2',
6+
version='0.2.1',
77
license='GNU GPL2',
88
url='https://github.com/jaapz/CryptsyPythonAPI',
99
author='Jaap Broekhuizen <jaapz.b@gmail.com>, '

test_cryptsy.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,146 @@ def test_market_data_v2(api, public_api_query_mock):
112112
""" Should use the old marketdata method if v2 is not set to True. """
113113
api.market_data(v2=True)
114114
public_api_query_mock.assert_called_with('marketdatav2')
115+
116+
117+
def test_order_book_data_no_marketid(api, public_api_query_mock):
118+
""" Should call orderdata if no marketid is provided. """
119+
api.order_book_data()
120+
public_api_query_mock.assert_called_with('orderdata')
121+
122+
123+
def test_order_book_data_with_marketid(api, public_api_query_mock):
124+
""" Should call singleorderdata if marketid is provided. """
125+
api.order_book_data(marketid=10)
126+
public_api_query_mock.assert_called_with('singleorderdata', marketid=10)
127+
128+
129+
def test_info(api, api_query_mock):
130+
""" Should call getinfo. """
131+
api.info()
132+
api_query_mock.assert_called_with('getinfo')
133+
134+
135+
def test_markets(api, api_query_mock):
136+
""" Should call getmarkets. """
137+
api.markets()
138+
api_query_mock.assert_called_with('getmarkets')
139+
140+
141+
def test_my_transactions(api, api_query_mock):
142+
""" Should call mytransactions. """
143+
api.my_transactions()
144+
api_query_mock.assert_called_with('mytransactions')
145+
146+
147+
def test_market_trades(api, api_query_mock):
148+
""" Should call markettrades with the provided marketid. """
149+
api.market_trades(marketid=10)
150+
api_query_mock.assert_called_with('markettrades',
151+
request_data={'marketid': 10})
152+
153+
154+
def test_market_orders(api, api_query_mock):
155+
""" Should call mytransactions. """
156+
api.market_orders(marketid=10)
157+
api_query_mock.assert_called_with('marketorders',
158+
request_data={'marketid': 10})
159+
160+
161+
def test_my_trades_no_marketid(api, api_query_mock):
162+
""" If no marketid is provided, it should call allmytrades. """
163+
api.my_trades()
164+
api_query_mock.assert_called_with('allmytrades')
165+
166+
167+
def test_my_trades_with_marketid(api, api_query_mock):
168+
""" If a marketid is provided, it should call mytrades. """
169+
api.my_trades(marketid=10)
170+
api_query_mock.assert_called_with('mytrades',
171+
request_data={
172+
'marketid': 10,
173+
'limit': 200
174+
})
175+
176+
177+
def test_my_trades_with_marketid_and_limit(api, api_query_mock):
178+
""" If limit is provided, use it.. """
179+
api.my_trades(marketid=10, limit=10)
180+
api_query_mock.assert_called_with('mytrades',
181+
request_data={
182+
'marketid': 10,
183+
'limit': 10
184+
})
185+
186+
187+
def test_my_orders_no_marketid(api, api_query_mock):
188+
""" If no marketid is provided, it should call allmyorders. """
189+
api.my_orders()
190+
api_query_mock.assert_called_with('allmyorders')
191+
192+
193+
def test_my_orders_with_marketid(api, api_query_mock):
194+
""" If a marketid is provided, it should call myorders. """
195+
api.my_orders(marketid=10)
196+
api_query_mock.assert_called_with('myorders',
197+
request_data={
198+
'marketid': 10,
199+
})
200+
201+
202+
def test_depth(api, api_query_mock):
203+
""" Should call depth with given marketid. """
204+
api.depth(marketid=10)
205+
api_query_mock.assert_called_with('depth', request_data={'marketid': 10})
206+
207+
208+
def test_cancel_order(api, api_query_mock):
209+
""" Should call cancelorders with given orderid. """
210+
api.cancel_order(orderid=10)
211+
api_query_mock.assert_called_with('cancelorder',
212+
request_data={'orderid': 10})
213+
214+
215+
def test_cancel_all_market_orders(api, api_query_mock):
216+
""" Should call cancelmarketorders with given marketid. """
217+
api.cancel_all_market_orders(marketid=10)
218+
api_query_mock.assert_called_with('cancelmarketorders',
219+
request_data={'marketid': 10})
220+
221+
222+
def test_cancel_all_orders(api, api_query_mock):
223+
""" Should call cancelallorders. """
224+
api.cancel_all_orders()
225+
api_query_mock.assert_called_with('cancelallorders')
226+
227+
228+
def test_calculate_fees(api, api_query_mock):
229+
""" Should call calculatefees with the correct parameters. """
230+
api.calculate_fees('Buy', 200, 10)
231+
api_query_mock.assert_called_with('calculatefees',
232+
request_data={
233+
'ordertype': 'Buy',
234+
'quantity': 200,
235+
'price': 10
236+
})
237+
238+
def test_my_transfers(api, api_query_mock):
239+
""" Should call mytransfers. """
240+
api.my_transfers()
241+
api_query_mock.assert_called_with('mytransfers')
242+
243+
244+
def test_wallet_status(api, api_query_mock):
245+
""" Should call getwalletstatus. """
246+
api.wallet_status()
247+
api_query_mock.assert_called_with('getwalletstatus')
248+
249+
250+
def test_make_withdrawal(api, api_query_mock):
251+
""" Should call makewithdrawal with the given parameters. """
252+
api.make_withdrawal('address', 100)
253+
api_query_mock.assert_called_with('makewithdrawal',
254+
request_data={
255+
'address': 'address',
256+
'amount': 100
257+
})

0 commit comments

Comments
 (0)