Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nomics-platform

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nomics-platform - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

16

example/index.js

@@ -10,2 +10,3 @@ const express = require('express')

app.get('/trades', trades)
app.get('/trades-by-timestamp', tradesByTimestamp)
app.get('/orders/snapshot', ordersSnapshot)

@@ -29,2 +30,3 @@

trades: true,
tradesByTimestamp: true,
tradesSocket: false,

@@ -92,2 +94,16 @@ orders: false,

function tradesByTimestamp (req, res) {
if (req.query.market !== 'btc-usd') {
res.status(404).send({error: 'unknown market'})
return
}
let since
if (req.query.since) {
since = new Date(req.query.since)
} else {
since = new Date(0)
}
res.send(allTrades.filter((t) => (new Date(t.timestamp)).getTime() > since.getTime()))
}
function ordersSnapshot (req, res) {

@@ -94,0 +110,0 @@ if (req.query.market !== 'btc-usd') {

40

lib/audit/test/audit.js

@@ -24,2 +24,3 @@ const au = require('../au')

au.assertBooleanProperty(capability, 'trades', {required: false})
au.assertBooleanProperty(capability, 'tradesByTimestamp', {required: false})
au.assertBooleanProperty(capability, 'tradesSocket', {required: false})

@@ -79,4 +80,41 @@ au.assertBooleanProperty(capability, 'orders', {required: false})

const second = await au.get(`/trades?market=${encodeURIComponent(market.id)}&since=${trades[0].id}`)
const since = trades[0].id
const second = await au.get(`/trades?market=${encodeURIComponent(market.id)}&since=${since}`)
au.assert(second.length > 0, `Trades with since=${since} didn't return any trades`)
au.assert(
!second.find((t) => t.id === since),
`Trades with since=${since} contained a trade with the same id as the since parameter. Only trades *after* the since id should be returned`
)
au.assert(
second.find((t) => t.id === trades[1].id),
`Trades with since=${since} didn't contain an overlap with the first page. Expected to see trade with id ${trades[1].id}`
)
},
tradesByTimestamp: async () => {
if (!this.info.capability || !this.info.capability.markets || !this.info.capability.tradesByTimestamp) {
return
}
const markets = await au.get('/markets')
if (markets.length === 0) {
// If there are no markets, pass, since markets spec will fail
return
}
const market = markets[0]
const trades = await au.get(`/trades-by-timestamp?market=${encodeURIComponent(market.id)}`)
au.assert(trades.length > 2, 'Expected more than two trades')
trades.forEach((t) => au.assertStringProperty(t, 'id'))
trades.forEach((t) => au.assertTimestampProperty(t, 'timestamp'))
trades.forEach((t) => au.assertNumericStringProperty(t, 'price'))
trades.forEach((t) => au.assertNumericStringProperty(t, 'amount'))
trades.forEach((t) => au.assertStringProperty(t, 'order', {required: false}))
trades.forEach((t) => au.assertPropertyInSet(t, 'type', ['market', 'limit', 'ask', 'bid'], {required: false}))
trades.forEach((t) => au.assertPropertyInSet(t, 'side', ['buy', 'sell'], {required: false}))
const since = trades[0].timestamp
const second = await au.get(`/trades-by-timestamp?market=${encodeURIComponent(market.id)}&since=${encodeURIComponent(since)}`)
au.assert(second.length > 0, `Trades with since=${since} didn't return any trades`)
au.assert(
!second.find((t) => t.id === trades[0].id),

@@ -83,0 +121,0 @@ `Trades with since=${trades[0].id} contained a trade with the same id as the since parameter. Only trades *after* the since id should be returned`

2

package.json
{
"name": "nomics-platform",
"version": "0.8.0",
"version": "0.9.0",
"description": "Nomics Platform Toolkit",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc