Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions docs/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
openapi: 3.0.3
info:
title: Aggr-server API
version: 1.0.0
servers:
- url: https://api.aggr.trade/
description: AGGR Trade server
- url: http://localhost:3000/
description: Default local server url
paths:
/alert:
post:
summary: Create or update an alert
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AlertPayload'
responses:
'201':
description: Alert created or updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/AlertResponse'
'400':
description: Invalid alert payload
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/products:
get:
summary: Get the list of products
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/ProductsResponse'

/historical/{from}/{to}/{timeframe}/{markets}:
get:
summary: Get historical data
parameters:
- in: path
name: from
schema:
type: integer
required: true
description: Start timestamp of the historical data
- in: path
name: to
schema:
type: integer
required: true
description: End timestamp of the historical data
- in: path
name: timeframe
schema:
type: string
required: true
description: Timeframe of the historical data
- in: path
name: markets
schema:
type: string
description: Markets to fetch historical data for
required: true
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/HistoricalDataResponse'
'400':
description: Invalid request or missing interval
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: No results found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
AlertPayload:
type: object
properties:
endpoint:
type: string
keys:
type: array
items:
type: string
market:
type: string
price:
type: number
required:
- endpoint
- keys
- market
- price
AlertResponse:
type: object

Error:
type: object
properties:
error:
type: string
ProductsResponse:
type: array
items:
type: string
HistoricalDataResponse:
type: object
properties:
format:
type: string
columns:
type: object
properties:
time:
type: integer
cbuy:
type: integer
close:
type: integer
csell:
type: integer
high:
type: integer
lbuy:
type: integer
low:
type: integer
lsell:
type: integer
market:
type: string
open:
type: integer
vbuy:
type: number
vsell:
type: number
nullable: true
results:
type: array
items:
type: array
items:
oneOf:
- type: integer
- type: number
- type: string
nullable: true

12 changes: 12 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EXAMPLE USAGE
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md
#

pre-commit:
parallel: true
commands:
prettier:
glob: '*.{js,jsx,ts,tsx,css,scss,md,html,json,yml}'
run: npx prettier --write "{staged_files}"
stage_fixed: true
14 changes: 5 additions & 9 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,11 @@ if (process.argv.length > 2) {

let userSettings = {}

const specificConfigFile = commandSettings.config
? commandSettings.config
: commandSettings.configFile
? commandSettings.configFile
: commandSettings.configPath
? commandSettings.configPath
: null

let configPath = specificConfigFile || 'config.json'
let configPath =
commandSettings?.config ||
commandSettings?.configFile ||
commandSettings?.configPath ||
'config.json'

try {
console.log('[init] using config file ' + configPath)
Expand Down
6 changes: 4 additions & 2 deletions src/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ class Exchange extends EventEmitter {

/**
* Link exchange to a pair
* @param {*} pair
* @param {string} pair
* @param {boolean} returnConnectedEvent
* @returns {Promise<WebSocket>}
*/
async link(pair, returnConnectedEvent) {
Expand Down Expand Up @@ -932,10 +933,11 @@ class Exchange extends EventEmitter {
}

/**
* Unsub
* Unsubscribe
* @param {WebSocket} api
* @param {string} pair
* @param {boolean} skipSending skip sending unsusbribe message
* @returns {boolean}
*/
async unsubscribe(api, pair, skipSending) {
if (!this.markPairAsDisconnected(api, pair)) {
Expand Down
Loading