aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/test/data_sources
diff options
context:
space:
mode:
authorXianny <8582774+xianny@users.noreply.github.com>2018-12-05 05:36:18 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-06 19:06:34 +0800
commit6f5787b2c43957c1c5db5a6123399e8baeb0ed78 (patch)
tree811b4c2269f716262d1263bf53d0e51d5a8a82a7 /packages/pipeline/test/data_sources
parentf96711bac373ac7caaca647defd68d91ba43a181 (diff)
downloaddexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar.gz
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar.bz2
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar.lz
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar.xz
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.tar.zst
dexon-sol-tools-6f5787b2c43957c1c5db5a6123399e8baeb0ed78.zip
pull OHLCV records from Crypto Compare (#1349)
* [WIP] pull OHLCV records from Crypto Compare * lint * refactor to pull logic out of script and into modules * add entity test for ohlcv_external entity * implement rate limit and chronological backfill for ohlcv * add unit tests; cleanup variable names * Fetch OHLCV pairs params from events table * better method names * fix outdated test * lint * Clean up after review * oops * fix failing test * better filtering of most recent records * fix bug when generating pairs * fix default earliest backfill date * fix bug with retrieving backfill time * prettier
Diffstat (limited to 'packages/pipeline/test/data_sources')
-rw-r--r--packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts b/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts
new file mode 100644
index 000000000..cb374bbb1
--- /dev/null
+++ b/packages/pipeline/test/data_sources/ohlcv_external/crypto_compare_test.ts
@@ -0,0 +1,47 @@
+import * as chai from 'chai';
+import 'mocha';
+import * as R from 'ramda';
+
+import { CryptoCompareOHLCVSource } from '../../../src/data_sources/ohlcv_external/crypto_compare';
+import { TradingPair } from '../../../src/utils/get_ohlcv_trading_pairs';
+import { chaiSetup } from '../../utils/chai_setup';
+
+chaiSetup.configure();
+const expect = chai.expect;
+
+// tslint:disable:custom-no-magic-numbers
+describe('ohlcv_external data source (Crypto Compare)', () => {
+ describe('generateBackfillIntervals', () => {
+ it('generates pairs with intervals to query', () => {
+ const source = new CryptoCompareOHLCVSource();
+ const pair: TradingPair = {
+ fromSymbol: 'ETH',
+ toSymbol: 'ZRX',
+ latestSavedTime: new Date().getTime() - source.interval * 2,
+ };
+
+ const expected = [
+ pair,
+ R.merge(pair, { latestSavedTime: pair.latestSavedTime + source.interval }),
+ R.merge(pair, { latestSavedTime: pair.latestSavedTime + source.interval * 2 }),
+ ];
+
+ const actual = source.generateBackfillIntervals(pair);
+ expect(actual).deep.equal(expected);
+ });
+
+ it('returns single pair if no backfill is needed', () => {
+ const source = new CryptoCompareOHLCVSource();
+ const pair: TradingPair = {
+ fromSymbol: 'ETH',
+ toSymbol: 'ZRX',
+ latestSavedTime: new Date().getTime() - source.interval + 5000,
+ };
+
+ const expected = [pair];
+
+ const actual = source.generateBackfillIntervals(pair);
+ expect(actual).deep.equal(expected);
+ });
+ });
+});