Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

CCXT Historical Data Retrieval Methods + Tests #60

Merged
merged 7 commits into from
Oct 22, 2017

Conversation

Ameobea
Copy link
Contributor

@Ameobea Ameobea commented Oct 19, 2017

This PR adds two CCXT-specific methods to the CCXTExchangeWrapper for downloading OHLCV candlestick data and historical trades. I've also added some tests for the CCXT wrapper for these two added features as well as orderbook+ticker fetching.

 * Added two methods for fetching historical trade data as well as OHLCV data from exchanges using the underlying CCXT wrapper
 * Created a test for CCXT testing the functionality of the two added methods
   * Tests don't currently pass due to a couple of reasons.  First one is a lack of support in CCXT for OHLCV data fetching, and the other is strange mapping of symbols
 * Add tests for fetching orderbook and ticker
 * Update CCXT dependency's version to latest
Copy link
Contributor

@CjS77 CjS77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great; Can you please update tests so that they don't hit the internet and then we should be good.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "gdax-trading-toolkit",
"version": "0.1.18",
"version": "0.1.19",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us manage versioning; we can then batch a bunch of PRs together in a release.

});

it('is able to fetch historical trade data from an exchange', async () => {
const data = await wrapper.fetchHistTrades(productId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the tests, but it looks like these requests are hitting the internet. This leads to slow and flaky tests (what if bitmex is down / delist the product?). We use the nock library for mocking out HTTP requests, and you can see examples of its use in some of the other tests here.

Copy link

@kroitor kroitor Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delist the product

That's why we don't hardcode pairs and fetch them online where possible... Outdated product lists can be painful to maintain in the long term. Though we still have to keep unique product id ←→ common symbol mapping to remain consistent across exchanges... Did you know that CoinMarketCap lists BTM for two different coins (Bytom (HitBtc) vs Bitmark (Poloniex), ccxt/ccxt#348, ccxt/ccxt#350, etc...) ? There's plenty of that across exchanges...

Just my 2 cents.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Then there's BCH and BCC..

For the GTT, which is an abstraction layer, I think it's ok to maintain a canonical list of coin names and map them behind the interfaces.
So for example, if GTT users define and expect BCC to represent 'Bitcoin cash' then mappings to BCH should happen behind the scenes where appropriate. Then users only have to learn one set of ticker names and the GTT does most of the work. ccxt, being pretty close to the apis needs to work with this more carefully.

Copy link

@kroitor kroitor Oct 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CjS77 we do the BCC → BCH mapping on the fly and the user doesn't have to know/learn it. We use BCH everywhere in our API because BCH is most widely used for Bitcoin Cash, while BCC also stands for Bitconnect sometimes, that causes confusion. If you notice BCC somewhere in CCXT let us know, but you should expect unified symbols from CCXT as written here: https://github.com/ccxt-dev/ccxt/wiki/Manual#naming-consistency ;) The unification mapping is overrideable per exchange, of course.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so we're advocating the same thing. I was just using BCH/BCC as an example and wasn't favoring one ticker over the other.

@Ameobea
Copy link
Contributor Author

Ameobea commented Oct 19, 2017

All network requests have been eliminated and mock data has been set up for all of the URLs requested internally by CCXT. I've also reverted the version bump.

Ameobea and others added 2 commits October 19, 2017 18:20
 * Newer versions of CCXT seem to use a different route for fetching the product list.  A regular expression is used to match both.
@CjS77
Copy link
Contributor

CjS77 commented Oct 22, 2017

LGTM, nice work!

@CjS77 CjS77 merged commit 4f2ae61 into coinbase:master Oct 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants