I would strongly recommend against doing tests against a live exchange, 
because there are just too many failure modes (network down, exchange down, 
exchange hostname changed, etc.) as well as the possibility to execute 
trades and lose money.

What I usually do is this:

* create stub requests/responses produced by the system you're integrating 
with - either in separate textfiles or generated with simple-check (now 
test.check)
* use the defined requests/responses when testing the code which integrates 
with the system
* create a mock system for use in repl environment (uses same 
requests/responses as the tests)

This requires some effort to set up, but really pays of with getting rid of 
a live dependency.

If you're worried about API changes, you can still have a very minimal live 
testcase which compares exchange's responses with your stubs, although it 
shouldn't test for any logic, only structure.

On Wednesday, 26 March 2014 09:18:40 UTC+2, JPH wrote:
>
> Hi all. I'm still relatively new to Clojure and I haven't spent much 
> time on testing before. I've recently written some libraries to talk to 
> Bitcoin exchanges (clj-havelock, clj-btce, cryptick), and I'd like to 
> add tests to them. 
>
> I'd like some advice around how to test against a live service (there is 
> not test service available) where there's a financial impact if 
> something goes wrong (someone buys/sells by accident). 
>
> My manual REPL-testing usually involve creating several orders with 
> price spreads that are unlikely to execute. For instance, selling 1 
> Litecoin for 1 Bitcoin. Buying 1 Bitcoin for $5 USD. 
>
> My concern is if someone runs the tests with bad inputs, resulting in 
> real orders being executed. 
>
> I can write tests that pull in API credentials from a file in my home 
> directory, and define price ranges for orders outside the normal spread. 
> These could then be fed into the tests. However, would it be better to 
> try and mock the trading API responses rather than do it live? Or 
> perhaps require a flag to run dangerous tests? 
>
> Ultimately I want to be able to demonstrate the libraries are mature 
> with good test coverage, but I'm worried about the right approach. Any 
> advice would be appreciated. 
>
> Thanks in advance, 
> JPH 
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to