@xyo-network/tzero-stock-market-plugin 5.1.2 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +24 -21
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/lib/spec/tryMapToSnapshot.spec.d.ts +0 -2
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/lib/spec/tryMapToSnapshot.spec.d.ts.map +0 -1
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.ApiCallWitnessManifest.spec.d.ts +0 -2
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.ApiCallWitnessManifest.spec.d.ts.map +0 -1
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.spec.d.ts +0 -2
- package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.spec.d.ts.map +0 -1
- package/src/Diviner/ApiCallJsonResultToSnapshot/lib/spec/tryMapToSnapshot.spec.ts +0 -58
- package/src/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.ApiCallWitnessManifest.spec.ts +0 -72
- package/src/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.spec.ts +0 -68
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/tzero-stock-market-plugin",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,30 +30,33 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/exists": "~5.0.
|
|
37
|
-
"@xylabs/promise": "~5.0.
|
|
38
|
-
"@xyo-network/api-call-witness": "~5.1.
|
|
39
|
-
"@xyo-network/diviner-abstract": "~5.1.
|
|
40
|
-
"@xyo-network/diviner-model": "~5.1.
|
|
41
|
-
"@xyo-network/module-model": "~5.1.
|
|
42
|
-
"@xyo-network/payload-model": "~5.1.
|
|
43
|
-
"@xyo-network/tzero-stock-market-payload-plugin": "~5.1.
|
|
39
|
+
"@xylabs/exists": "~5.0.33",
|
|
40
|
+
"@xylabs/promise": "~5.0.33",
|
|
41
|
+
"@xyo-network/api-call-witness": "~5.1.4",
|
|
42
|
+
"@xyo-network/diviner-abstract": "~5.1.23",
|
|
43
|
+
"@xyo-network/diviner-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
45
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
46
|
+
"@xyo-network/tzero-stock-market-payload-plugin": "~5.1.4"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
|
-
"@xylabs/assert": "~5.0.
|
|
47
|
-
"@xylabs/hex": "~5.0.
|
|
48
|
-
"@xylabs/object": "~5.0.
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
50
|
-
"@xylabs/tsconfig": "~7.
|
|
51
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
52
|
-
"@xyo-network/manifest": "~5.1.
|
|
53
|
-
"@xyo-network/module-factory-locator": "~5.1.
|
|
54
|
-
"@xyo-network/sentinel-model": "~5.1.
|
|
55
|
-
"@xyo-network/wallet": "~5.1.
|
|
56
|
-
"@xyo-network/witness-model": "~5.1.
|
|
49
|
+
"@xylabs/assert": "~5.0.33",
|
|
50
|
+
"@xylabs/hex": "~5.0.33",
|
|
51
|
+
"@xylabs/object": "~5.0.33",
|
|
52
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
53
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
54
|
+
"@xylabs/vitest-extended": "~5.0.33",
|
|
55
|
+
"@xyo-network/manifest": "~5.1.23",
|
|
56
|
+
"@xyo-network/module-factory-locator": "~5.1.23",
|
|
57
|
+
"@xyo-network/sentinel-model": "~5.1.23",
|
|
58
|
+
"@xyo-network/wallet": "~5.1.23",
|
|
59
|
+
"@xyo-network/witness-model": "~5.1.23",
|
|
57
60
|
"typescript": "~5.9.2",
|
|
58
61
|
"vitest": "~3.2.4"
|
|
59
62
|
},
|
package/dist/neutral/Diviner/ApiCallJsonResultToSnapshot/lib/spec/tryMapToSnapshot.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tryMapToSnapshot.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/Diviner/ApiCallJsonResultToSnapshot/lib/spec/tryMapToSnapshot.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.ApiCallWitnessManifest.spec.d.ts","sourceRoot":"","sources":["../../../../../src/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.ApiCallWitnessManifest.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.spec.d.ts","sourceRoot":"","sources":["../../../../../src/Diviner/ApiCallJsonResultToSnapshot/spec/Diviner.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Hash } from '@xylabs/hex'
|
|
4
|
-
import type { ApiCallResult } from '@xyo-network/api-call-witness'
|
|
5
|
-
import {
|
|
6
|
-
describe, expect,
|
|
7
|
-
it,
|
|
8
|
-
} from 'vitest'
|
|
9
|
-
|
|
10
|
-
import { tryMapToSnapshot } from '../tryMapToSnapshot.ts'
|
|
11
|
-
|
|
12
|
-
describe('mapToPublicSnapshot', () => {
|
|
13
|
-
describe('with successful response', () => {
|
|
14
|
-
const cases: ApiCallResult[] = [
|
|
15
|
-
{
|
|
16
|
-
call: 'bae563e08bfa3030815cba08fad61237355e147aa41f9912b7321dadcb9a0085' as Hash,
|
|
17
|
-
contentType: 'application/json',
|
|
18
|
-
data: {
|
|
19
|
-
askPrice: 0.25,
|
|
20
|
-
askPriceRate: null,
|
|
21
|
-
askQtyBookTotal: 54_213,
|
|
22
|
-
askQuantity: 13_370,
|
|
23
|
-
bidPrice: 0.23,
|
|
24
|
-
bidPriceRate: null,
|
|
25
|
-
bidQtyBookTotal: 36_048,
|
|
26
|
-
bidQuantity: 1000,
|
|
27
|
-
high: 0.25,
|
|
28
|
-
lastPrice: 0.23,
|
|
29
|
-
lastQuantity: 1000,
|
|
30
|
-
low: 0.23,
|
|
31
|
-
open: 0.25,
|
|
32
|
-
prevClosePx: 0.25,
|
|
33
|
-
symbol: 'XYLB',
|
|
34
|
-
timestamp: '2024-05-29T17:41:16.944090431-04:00',
|
|
35
|
-
volume: 1002,
|
|
36
|
-
},
|
|
37
|
-
schema: 'network.xyo.api.call.result',
|
|
38
|
-
},
|
|
39
|
-
]
|
|
40
|
-
it.each(cases)('maps to Public Snapshot', (response) => {
|
|
41
|
-
const result = tryMapToSnapshot(response)
|
|
42
|
-
expect(result).toBeDefined()
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
describe('with unsuccessful response', () => {
|
|
46
|
-
const cases: ApiCallResult[] = [
|
|
47
|
-
{
|
|
48
|
-
call: 'a04445ce5b67bca9bf1da8d2f85eea60c9baf566342cf29ffd3bdfbb01c8fcfe' as Hash,
|
|
49
|
-
http: { status: 404 },
|
|
50
|
-
schema: 'network.xyo.api.call.result',
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
it.each(cases)('maps to Public Snapshot', (response) => {
|
|
54
|
-
const result = tryMapToSnapshot(response)
|
|
55
|
-
expect(result).toBeUndefined()
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { assertEx } from '@xylabs/assert'
|
|
4
|
-
import type { ApiCallWitnessParams, ApiUriTemplateCallPayload } from '@xyo-network/api-call-witness'
|
|
5
|
-
import { ApiCallSchema, ApiCallWitness } from '@xyo-network/api-call-witness'
|
|
6
|
-
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
7
|
-
import { ManifestWrapper } from '@xyo-network/manifest'
|
|
8
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
9
|
-
import { ModuleFactory } from '@xyo-network/module-model'
|
|
10
|
-
import type { SentinelInstance } from '@xyo-network/sentinel-model'
|
|
11
|
-
import { asSentinelInstance } from '@xyo-network/sentinel-model'
|
|
12
|
-
import { isSnapshot } from '@xyo-network/tzero-stock-market-payload-plugin'
|
|
13
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
14
|
-
import { asWitnessInstance } from '@xyo-network/witness-model'
|
|
15
|
-
import {
|
|
16
|
-
beforeAll, describe, expect, it,
|
|
17
|
-
} from 'vitest'
|
|
18
|
-
|
|
19
|
-
import { TZeroApiCallJsonResultToSnapshotDiviner } from '../Diviner.ts'
|
|
20
|
-
import tzeroMarketdataManifest from './ApiCallWitnessManifest.json' with { type: 'json' }
|
|
21
|
-
|
|
22
|
-
describe('tZero', () => {
|
|
23
|
-
const symbol = 'XYLB'
|
|
24
|
-
const apiKey = process.env.TZERO_MARKETDATA_API_KEY
|
|
25
|
-
describe.skipIf(!apiKey)('snapshots', () => {
|
|
26
|
-
let sentinel: SentinelInstance
|
|
27
|
-
beforeAll(async () => {
|
|
28
|
-
const wallet = await HDWallet.random()
|
|
29
|
-
const locator = new ModuleFactoryLocator()
|
|
30
|
-
locator.register(new ModuleFactory(ApiCallWitness, { config: {}, headers: { 'x-apikey': apiKey } } as ApiCallWitnessParams))
|
|
31
|
-
locator.register(TZeroApiCallJsonResultToSnapshotDiviner.factory())
|
|
32
|
-
const manifest = new ManifestWrapper(tzeroMarketdataManifest as PackageManifestPayload, wallet, locator)
|
|
33
|
-
const node = await manifest.loadNodeFromIndex(0)
|
|
34
|
-
const mods = await node.resolve('*')
|
|
35
|
-
expect(mods.length).toBeGreaterThan(1)
|
|
36
|
-
const resolvedWitness = await node.resolve('ApiCallWitness')
|
|
37
|
-
expect(resolvedWitness).toBeDefined()
|
|
38
|
-
const witness = asWitnessInstance(resolvedWitness)
|
|
39
|
-
expect(witness).toBeDefined()
|
|
40
|
-
const sentinelInstance = asSentinelInstance(await node.resolve('ApiCallSentinel'))
|
|
41
|
-
expect(sentinelInstance).toBeDefined()
|
|
42
|
-
sentinel = assertEx(sentinelInstance)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line complexity
|
|
46
|
-
it('specifying symbol', async () => {
|
|
47
|
-
const call: ApiUriTemplateCallPayload = { params: { symbol }, schema: ApiCallSchema }
|
|
48
|
-
|
|
49
|
-
const report = await sentinel?.report([call])
|
|
50
|
-
|
|
51
|
-
const data = report?.find(isSnapshot)
|
|
52
|
-
expect(data).toBeDefined()
|
|
53
|
-
expect(data?.askPrice === null || typeof data?.askPrice === 'number').toBe(true)
|
|
54
|
-
expect(data?.askPriceRate === null || typeof data?.askPriceRate === 'number').toBe(true)
|
|
55
|
-
expect(data?.askQtyBookTotal === null || typeof data?.askQtyBookTotal === 'number').toBe(true)
|
|
56
|
-
expect(data?.askQuantity === null || typeof data?.askQuantity === 'number').toBe(true)
|
|
57
|
-
expect(data?.bidPrice === null || typeof data?.bidPrice === 'number').toBe(true)
|
|
58
|
-
expect(data?.bidPriceRate === null || typeof data?.bidPriceRate === 'number').toBe(true)
|
|
59
|
-
expect(data?.bidQtyBookTotal === null || typeof data?.bidQtyBookTotal === 'number').toBe(true)
|
|
60
|
-
expect(data?.bidQuantity === null || typeof data?.bidQuantity === 'number').toBe(true)
|
|
61
|
-
expect(data?.high === null || typeof data?.high === 'number').toBe(true)
|
|
62
|
-
expect(data?.lastPrice === null || typeof data?.lastPrice === 'number').toBe(true)
|
|
63
|
-
expect(data?.lastQuantity === null || typeof data?.lastQuantity === 'number').toBe(true)
|
|
64
|
-
expect(data?.low === null || typeof data?.low === 'number').toBe(true)
|
|
65
|
-
expect(data?.open === null || typeof data?.open === 'number').toBe(true)
|
|
66
|
-
expect(typeof data?.prevClosePx === 'number').toBe(true)
|
|
67
|
-
expect(typeof data?.symbol === 'string').toBe(true)
|
|
68
|
-
expect(typeof data?.timestamp === 'string').toBe(true)
|
|
69
|
-
expect(typeof data?.volume === 'number').toBe(true)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Hash } from '@xylabs/hex'
|
|
4
|
-
import type { ApiCallResult } from '@xyo-network/api-call-witness'
|
|
5
|
-
import { SnapshotSchema } from '@xyo-network/tzero-stock-market-payload-plugin'
|
|
6
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
7
|
-
import {
|
|
8
|
-
describe, expect,
|
|
9
|
-
it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { TZeroApiCallJsonResultToSnapshotDiviner } from '../Diviner.ts'
|
|
13
|
-
import { TZeroApiCallJsonResultToSnapshotDivinerConfigSchema } from '../Schema.ts'
|
|
14
|
-
|
|
15
|
-
describe('TZeroApiCallJsonResultToSnapshotDiviner', () => {
|
|
16
|
-
const config = { schema: TZeroApiCallJsonResultToSnapshotDivinerConfigSchema }
|
|
17
|
-
describe('with API Response', () => {
|
|
18
|
-
const cases: ApiCallResult[] = [
|
|
19
|
-
{
|
|
20
|
-
call: 'bae563e08bfa3030815cba08fad61237355e147aa41f9912b7321dadcb9a0085' as Hash,
|
|
21
|
-
contentType: 'application/json',
|
|
22
|
-
data: {
|
|
23
|
-
askPrice: 0.25,
|
|
24
|
-
askPriceRate: null,
|
|
25
|
-
askQtyBookTotal: 54_213,
|
|
26
|
-
askQuantity: 13_370,
|
|
27
|
-
bidPrice: 0.23,
|
|
28
|
-
bidPriceRate: null,
|
|
29
|
-
bidQtyBookTotal: 36_048,
|
|
30
|
-
bidQuantity: 1000,
|
|
31
|
-
high: 0.25,
|
|
32
|
-
lastPrice: 0.23,
|
|
33
|
-
lastQuantity: 1000,
|
|
34
|
-
low: 0.23,
|
|
35
|
-
open: 0.25,
|
|
36
|
-
prevClosePx: 0.25,
|
|
37
|
-
symbol: 'XYLB',
|
|
38
|
-
timestamp: '2024-05-29T17:41:16.944090431-04:00',
|
|
39
|
-
volume: 1002,
|
|
40
|
-
},
|
|
41
|
-
schema: 'network.xyo.api.call.result',
|
|
42
|
-
},
|
|
43
|
-
]
|
|
44
|
-
it.each(cases)('with API Response', async (payload) => {
|
|
45
|
-
const account = await HDWallet.random()
|
|
46
|
-
const sut = await TZeroApiCallJsonResultToSnapshotDiviner.create({ account, config })
|
|
47
|
-
const result = await sut.divine([payload])
|
|
48
|
-
expect(result).toBeArrayOfSize(1)
|
|
49
|
-
const [actual] = result
|
|
50
|
-
expect(actual.schema).toBe(SnapshotSchema)
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
describe('with non API Response', () => {
|
|
54
|
-
const cases: ApiCallResult[] = [
|
|
55
|
-
{
|
|
56
|
-
call: 'a04445ce5b67bca9bf1da8d2f85eea60c9baf566342cf29ffd3bdfbb01c8fcfe' as Hash,
|
|
57
|
-
http: { status: 404 },
|
|
58
|
-
schema: 'network.xyo.api.call.result',
|
|
59
|
-
},
|
|
60
|
-
]
|
|
61
|
-
it.each(cases)('with non API Response', async (payload) => {
|
|
62
|
-
const account = await HDWallet.random()
|
|
63
|
-
const sut = await TZeroApiCallJsonResultToSnapshotDiviner.create({ account, config })
|
|
64
|
-
const result = await sut.divine([payload])
|
|
65
|
-
expect(result).toBeArrayOfSize(0)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
})
|