Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitstamp exchange gateway #253

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions env
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@ BitfinexOrderDestination=Bitfinex
## Coinbase
#CoinbaseRestUrl=https://api.gdax.com
#CoinbaseWebsocketUrl=wss://ws-feed.gdax.com

## Bitstamp
#BitstampWsUrl=wss://ws.bitstamp.net
#BitstampRestUrl=https://www.bitstamp.net/api/
#BitstampClientId=NULL
#BitstampApiKey=NULL
#BitstampSecretKey=NULL
#BitstampOrderDestination=Bitstamp
7,565 changes: 5,142 additions & 2,423 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
"test": "test"
},
"dependencies": {
"@types/angular": "^1.6.14",
"@types/angular-ui-bootstrap": "^0.13.41",
"@types/angular": "^1.7.3",
"@types/angular-ui-bootstrap": "^0.13.47",
"@types/basic-auth": "0.0.31",
"@types/body-parser": "^1.16.3",
"@types/body-parser": "^1.19.0",
"@types/bunyan": "0.0.36",
"@types/compression": "0.0.33",
"@types/connect": "^3.4.30",
"@types/express": "^4.0.35",
"@types/express-serve-static-core": "^4.0.44",
"@types/connect": "^3.4.33",
"@types/express": "^4.17.8",
"@types/express-serve-static-core": "^4.17.12",
"@types/form-data": "0.0.33",
"@types/jquery": "^2.0.41",
"@types/lodash": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.62.tgz",
"@types/jquery": "^2.0.54",
"@types/lodash": "^4.14.161",
"@types/mime": "0.0.29",
"@types/mongodb": "^2.1.43",
"@types/node": "^7.0.12",
"@types/q": "^1.0.0",
"@types/mongodb": "^2.2.26",
"@types/node": "^14.6.4",
"@types/q": "^1.5.4",
"@types/request": "0.0.46",
"@types/serve-static": "^1.7.31",
"@types/socket.io": "^1.4.29",
"@types/socket.io-client": "^1.4.29",
"@types/serve-static": "^1.13.5",
"@types/socket.io": "^1.4.42",
"@types/socket.io-client": "^1.4.33",
"@types/ws": "0.0.39",
"agentkeepalive": "3.1.0",
"angular": "1.6.4",
Expand All @@ -35,8 +35,8 @@
"basic-auth": "1.1.0",
"basic-auth-connect": "1.0.0",
"body-parser": "1.17.1",
"bufferutil": "^1.2.1",
"bunyan": "1.8.10",
"bufferutil": "^4.0.1",
"bunyan": "1.8.14",
"collections": "5.0.6",
"compression": "1.6.2",
"connect": "3.6.0",
Expand All @@ -45,7 +45,7 @@
"grunt-browserify": "5.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-watch": "1.0.0",
"grunt-ts": "6.0.0-beta.15",
"grunt-ts": "6.0.0-beta.22",
"jquery": "3.2.1",
"lodash": "4.17.4",
"moment": "2.18.1",
Expand All @@ -54,15 +54,16 @@
"q": "1.5.0",
"request": "2.81.0",
"shortid": "2.2.8",
"socket.io": "^1.4.5",
"socket.io": "^2.3.0",
"socket.io-client": "1.7.3",
"typescript": "^2.4.1",
"typescript": "^4.0.2",
"typings": "2.1.0",
"utf-8-validate": "^1.2.1",
"ws": "^1.0.1"
"utf-8-validate": "^5.0.2",
"ws": "^7.3.1"
},
"devDependencies": {
"mocha": "3.2.0"
"dtrace-provider": "^0.8.8",
"mocha": "8.1.3"
},
"scripts": {
"test": "mocha"
Expand Down
10 changes: 9 additions & 1 deletion sample-dev-tribeca.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"WebClientPassword": "NULL",
"WebClientListenPort": "3000",
"ShowAllOrders": "true",
"NullGatewayTick": 100,

"HitBtcPullUrl": "http://demo-api.hitbtc.com",
"HitBtcOrderEntryUrl": "ws://demo-api.hitbtc.com:8080",
Expand All @@ -32,5 +33,12 @@
"BitfinexHttpUrl": "https://api.bitfinex.com/v1",
"BitfinexKey": "NULL",
"BitfinexSecret": "NULL",
"BitfinexOrderDestination": "Bitfinex"
"BitfinexOrderDestination": "Bitfinex",

"BitstampWsUrl": "wss://ws.bitstamp.net",
"BitstampRestUrl": "https://www.bitstamp.net/api/",
"BitstampClientId": "NULL",
"BitstampApiKey": "NULL",
"BitstampSecretKey": "NULL",
"BitstampOrderDestination": "Bitstamp"
}
10 changes: 9 additions & 1 deletion sample-prod-tribeca.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"WebClientPassword": "NULL",
"WebClientListenPort": "3000",
"ShowAllOrders": "false",
"NullGatewayTick": 100,

"HitBtcPullUrl": "http://api.hitbtc.com",
"HitBtcOrderEntryUrl": "wss://api.hitbtc.com:8080",
Expand All @@ -32,5 +33,12 @@
"BitfinexHttpUrl": "https://api.bitfinex.com/v1",
"BitfinexKey": "NULL",
"BitfinexSecret": "NULL",
"BitfinexOrderDestination": "Bitfinex"
"BitfinexOrderDestination": "Bitfinex",

"BitstampWsUrl": "wss://ws.bitstamp.net",
"BitstampRestUrl": "https://www.bitstamp.net/api/",
"BitstampClientId": "NULL",
"BitstampApiKey": "NULL",
"BitstampSecretKey": "NULL",
"BitstampOrderDestination": "Bitstamp"
}
22 changes: 11 additions & 11 deletions src/admin/market-trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ var MarketTradeGrid = ($scope: MarketTradeScope,
{ width: 80, field: 'time', displayName: 't', cellFilter: "momentShortDate",
sortingAlgorithm: Shared.fastDiff,
sort: { direction: uiGridConstants.DESC, priority: 1} },
{ width: 50, field: 'price', displayName: 'px' },
{ width: 40, field: 'size', displayName: 'sz' },
{ width: 40, field: 'make_side', displayName: 'ms' },
{ width: 40, field: 'qBz', displayName: 'qBz' },
{ width: 50, field: 'qB', displayName: 'qB' },
{ width: 50, field: 'qA', displayName: 'qA' },
{ width: 40, field: 'qAz', displayName: 'qAz' },
{ width: 40, field: 'mBz', displayName: 'mBz' },
{ width: 50, field: 'mB', displayName: 'mB' },
{ width: 50, field: 'mA', displayName: 'mA' },
{ width: 40, field: 'mAz', displayName: 'mAz' }
{ width: 65, field: 'price', displayName: 'px' },
{ width: 70, field: 'size', displayName: 'sz' },
{ width: 50, field: 'make_side', displayName: 'ms' },
{ width: 55, field: 'qBz', displayName: 'qBz' },
{ width: 65, field: 'qB', displayName: 'qB' },
{ width: 65, field: 'qA', displayName: 'qA' },
{ width: 55, field: 'qAz', displayName: 'qAz' },
{ width: 70, field: 'mBz', displayName: 'mBz' },
{ width: 70, field: 'mB', displayName: 'mB' },
{ width: 70, field: 'mA', displayName: 'mA' },
{ width: 70, field: 'mAz', displayName: 'mAz' }
]
};

Expand Down
12 changes: 6 additions & 6 deletions src/admin/orderlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,22 @@ var OrderListController = ($scope: OrderListScope,
sortingAlgorithm: Shared.fastDiff,
sort: { direction: uiGridConstants.DESC, priority: 1} },
{ width: 90, field: 'orderId', displayName: 'id' },
{ width: 35, field: 'version', displayName: 'v' },
{ width: 40, field: 'version', displayName: 'v' },
{ width: 120, field: 'orderStatus', displayName: 'status' },
{ width: 65, field: 'price', displayName: 'px' },
{ width: 60, field: 'quantity', displayName: 'qty' },
{ width: 50, field: 'side', displayName: 'side' },
{ width: 50, field: 'orderType', displayName: 'type' },
{ width: 55, field: 'side', displayName: 'side' },
{ width: 58, field: 'orderType', displayName: 'type' },
{ width: 50, field: 'tif', displayName: 'tif' },
{ width: 35, field: 'computationalLatency', displayName: 'lat' },
{ width: 50, field: 'computationalLatency', displayName: 'lat' },
{ width: 60, field: 'lastQuantity', displayName: 'lQty' },
{ width: 65, field: 'lastPrice', displayName: 'lPx' },
{ width: 60, field: 'leavesQuantity', displayName: 'lvQty' },
{ width: 60, field: 'cumQuantity', displayName: 'cum' },
{ width: 65, field: 'averagePrice', displayName: 'avg' },
{ width: 40, field: 'liquidity', displayName: 'liq' },
{ width: 45, field: 'liquidity', displayName: 'liq' },
{ width: "*", field: 'rejectMessage', displayName: 'msg' },
{ width: 40, name: "cancel", displayName: 'cxl', cellTemplate: '<button type="button" class="btn btn-danger btn-xs" ng-click="row.entity.cancel()"><span class="glyphicon glyphicon-remove"></span></button>' },
{ width: 50, name: "cancel", displayName: 'cxl', cellTemplate: '<button type="button" class="btn btn-danger btn-xs" ng-click="row.entity.cancel()"><span class="glyphicon glyphicon-remove"></span></button>' },
]
};

Expand Down
10 changes: 5 additions & 5 deletions src/admin/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ var TradesListController = ($scope : TradesScope, $log : ng.ILogService, subscri
{width: 80, field:'time', displayName:'t', cellFilter: 'momentShortDate',
sortingAlgorithm: Shared.fastDiff,
sort: { direction: uiGridConstants.DESC, priority: 1} },
{width: 55, field:'price', displayName:'px' },
{width: 50, field:'quantity', displayName:'qty'},
{width: 30, field:'side', displayName:'side', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
{width: 60, field:'price', displayName:'px' },
{width: 60, field:'quantity', displayName:'qty'},
{width: 55, field:'side', displayName:'side', cellClass: (grid, row, col, rowRenderIndex, colRenderIndex) => {
if (grid.getCellValue(row, col) === 'B') {
return 'buy';
}
Expand All @@ -69,8 +69,8 @@ var TradesListController = ($scope : TradesScope, $log : ng.ILogService, subscri
return "unknown";
}
}},
{width: 30, field:'liquidity', displayName:'liq'},
{width: 60, field:'value', displayName:'val', cellFilter: 'currency:"$":3'}
{width: 50, field:'liquidity', displayName:'liq'},
{width: 70, field:'value', displayName:'val', cellFilter: 'currency:"$":3'}
]
};

Expand Down
7 changes: 5 additions & 2 deletions src/common/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class MarketTrade implements ITimestamped {
export enum Currency {
USD,
BTC,
BCH,
LTC,
EUR,
GBP,
Expand Down Expand Up @@ -88,7 +89,9 @@ export enum Currency {
WAVES,
BTU,
MAID,
AMP
AMP,
PAX,
XLM
}

export function toCurrency(c: string) : Currency|undefined {
Expand All @@ -103,7 +106,7 @@ export function fromCurrency(c: Currency) : string|undefined {

export enum GatewayType { MarketData, OrderEntry, Position }
export enum ConnectivityStatus { Connected, Disconnected }
export enum Exchange { Null, HitBtc, OkCoin, AtlasAts, BtcChina, Coinbase, Bitfinex }
export enum Exchange { Null, HitBtc, OkCoin, AtlasAts, BtcChina, Coinbase, Bitfinex, Bitstamp }
export enum Side { Bid, Ask, Unknown }
export enum OrderType { Limit, Market }
export enum TimeInForce { IOC, FOK, GTC }
Expand Down
9 changes: 4 additions & 5 deletions src/service/backtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import mongo = require("mongodb");
import Persister = require("./persister");
import Q = require("q");
import stream = require("stream");
import { AddressInfo } from 'net'

var shortId = require("shortid");
var Deque = require("collections/deque");
Expand Down Expand Up @@ -357,10 +358,8 @@ var backtestServer = () => {
app.use(require("compression")());

var server = app.listen(5001, () => {
var host = server.address().address;
var port = server.address().port;

console.log('Backtest server listening at http://%s:%s', host, port);
const { port, address } = server.address() as AddressInfo
console.log('Backtest server listening at http://%s:%s', address, port);
});

app.get("/inputData", (req, res) => {
Expand All @@ -380,7 +379,7 @@ var backtestServer = () => {

console.log("Serving parameters id =", served.id, " to", req.ip);
res.json(served);
fs.writeFileSync(savedProgressFile, parameters.length, {encoding: 'utf8'});
fs.writeFileSync(savedProgressFile, parameters.length.toString(), {encoding: 'utf8'});

if (!_.some(parameters)) {
console.log("Done serving parameters");
Expand Down
Loading