-
Notifications
You must be signed in to change notification settings - Fork 240
CCXT Historical Data Retrieval Methods + Tests #60
Changes from 3 commits
28fa729
87fb8a3
256cfaf
abe4136
23c57a3
ed67a91
b22a669
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/********************************************************************************************************************** | ||
* @license * | ||
* Copyright 2017 Coinbase, Inc. * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * | ||
* with the License. You may obtain a copy of the License at * | ||
* * | ||
* http://www.apache.org/licenses/LICENSE-2.0 * | ||
* * | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on* | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * | ||
* License for the specific language governing permissions and limitations under the License. * | ||
**********************************************************************************************************************/ | ||
|
||
const assert = require('assert'); | ||
|
||
import { ExchangeAuthConfig } from '../../src/exchanges/AuthConfig'; | ||
import CCXTExchangeWrapper from '../../src/exchanges/ccxt'; | ||
import { NullLogger } from '../../src/utils/Logger'; | ||
|
||
describe('CCXT Exchange Wrapper', () => { | ||
const exchangeId = 'bitmex'; | ||
const productId = 'BTC-USD'; | ||
let wrapper: CCXTExchangeWrapper; | ||
|
||
before(async () => { | ||
const auth: ExchangeAuthConfig = { key: null, secret: null }; | ||
wrapper = CCXTExchangeWrapper.createExchange(exchangeId, auth, NullLogger); | ||
}); | ||
|
||
it('is able to fetch historical trade data from an exchange', async () => { | ||
const data = await wrapper.fetchHistTrades(productId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 Just my 2 cents. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
assert(data.length && data.length > 0); | ||
}); | ||
|
||
it('is able to fetch historical OHLCV candlestick data from an exchange', async () => { | ||
const data = await wrapper.fetchOHLCV(productId); | ||
assert.notEqual(data, null); | ||
assert(data.length && data.length > 0); | ||
}); | ||
|
||
it('is able to fetch a ticker', async () => { | ||
const data = await wrapper.loadTicker(productId); | ||
assert(data.bid > data.ask); | ||
}); | ||
|
||
it('is able to load an orderbook image', async () => { | ||
const data = await wrapper.loadOrderbook(productId); | ||
assert(data.numAsks > 0 && data.numBids > 0); | ||
}); | ||
}); |
There was a problem hiding this comment.
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.