Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (2)
......@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="5.0.5"></a>
## [5.0.5](https://gitlab.com/nash-io-public/api-client-typescript/compare/v5.0.3...v5.0.5) (2020-04-02)
<a name="5.0.3"></a>
## [5.0.3](https://gitlab.com/nash-io-public/api-client-typescript/compare/v4.0.6...v5.0.3) (2020-04-01)
......
......@@ -9,8 +9,8 @@ node orderbook.js
# Running against production
To run this example against production the `orderbook.js` must be edited to use a different config. Edit line 4 to the following:
To run this example against sandbox the `orderbook.js` must be edited to use a different config. Edit line 4 to the following:
```
const client = new Nash.Client(Nash.EnvironmentConfiguration.production)
const client = new Nash.Client(Nash.EnvironmentConfiguration.sandbox)
```
const Nash = require('@neon-exchange/api-client-typescript')
const blessed = require('blessed')
const client = new Nash.Client(Nash.EnvironmentConfiguration.sandbox)
const client = new Nash.Client(Nash.EnvironmentConfiguration.production)
// Create a screen object.
const screen = blessed.screen({
......@@ -12,9 +12,9 @@ screen.key('q', function() {
})
screen.title = 'Orderbook'
const bidList = blessed.list({
const askList = blessed.list({
parent: screen,
label: ' {bold}{green-fg}Bids{/green-fg}{/bold} ',
label: ' {bold}{red-fg}Asks{/red-fg}{/bold} ',
tags: true,
top: 0,
mouse: true,
......@@ -34,7 +34,7 @@ const bidList = blessed.list({
},
style: {
item: {
bg: 'green',
bg: 'red',
fg: 'black',
hover: {
bg: 'cyan'
......@@ -47,9 +47,9 @@ const bidList = blessed.list({
}
})
const askList = blessed.list({
const bidList = blessed.list({
parent: screen,
label: ' {bold}{red-fg}Asks{/red-fg}{/bold} ',
label: ' {bold}{green-fg}Bids{/green-fg}{/bold} ',
tags: true,
mouse: true,
top: '50%',
......@@ -69,7 +69,7 @@ const askList = blessed.list({
},
style: {
item: {
bg: 'red',
bg: 'green',
fg: 'black',
hover: {
bg: 'cyan'
......@@ -94,7 +94,7 @@ async function run() {
function update() {
const askValues = [...askOrderBook.values()]
askValues.sort(
(l, r) => parseFloat(l.price.amount) - parseFloat(r.price.amount)
(r, l) => parseFloat(l.price.amount) - parseFloat(r.price.amount)
)
askList.setItems(
askValues.map(
......@@ -106,7 +106,7 @@ async function run() {
)
const bidValues = [...bidOrderBook.values()]
bidValues.sort(
(l, r) => parseFloat(l.price.amount) - parseFloat(r.price.amount)
(r, l) => parseFloat(l.price.amount) - parseFloat(r.price.amount)
)
bidList.setItems(
bidValues.map(
......@@ -121,26 +121,28 @@ async function run() {
update()
try {
const sub = client.createSocketConnection()
sub.onUpdatedOrderbook('neo_eth', order => {
order.data.updatedOrderBook.asks.forEach(ask => {
if (parseFloat(ask.amount.amount) === 0.0) {
if (askOrderBook.has(ask.price.amount)) {
askOrderBook.delete(ask.price.amount)
sub.onUpdatedOrderbook({ marketName: 'neo_eth' }, {
onResult: order => {
order.data.updatedOrderBook.asks.forEach(ask => {
if (parseFloat(ask.amount.amount) === 0.0) {
if (askOrderBook.has(ask.price.amount)) {
askOrderBook.delete(ask.price.amount)
}
} else {
askOrderBook.set(ask.price.amount, ask)
}
} else {
askOrderBook.set(ask.price.amount, ask)
}
})
order.data.updatedOrderBook.bids.forEach(bid => {
if (parseFloat(bid.amount.amount) === 0.0) {
if (bidOrderBook.has(bid.price.amount)) {
bidOrderBook.delete(bid.price.amount)
})
order.data.updatedOrderBook.bids.forEach(bid => {
if (parseFloat(bid.amount.amount) === 0.0) {
if (bidOrderBook.has(bid.price.amount)) {
bidOrderBook.delete(bid.price.amount)
}
} else {
bidOrderBook.set(bid.price.amount, bid)
}
} else {
bidOrderBook.set(bid.price.amount, bid)
}
})
update()
})
update()
}
})
} catch (e) {
console.error(e)
......
......@@ -9,7 +9,7 @@
"node": ">=8.9"
},
"dependencies": {
"@neon-exchange/api-client-typescript": "5.0.2",
"@neon-exchange/api-client-typescript": "5.0.3",
"blessed": "0.1.81"
}
}
This diff is collapsed.
{
"name": "@neon-exchange/api-client-typescript",
"version": "5.0.3",
"version": "5.0.5",
"description": "Official TypeScript client for interacting with the Nash exchange",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
......