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

[New Exchange] Add Bitmart exchange #42

Open
wants to merge 20 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

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ data/*
*.config.json
persistence.json
coinalize.key
events.log
.env
Empty file removed data/.gitkeep
Empty file.
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

9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,13 @@ if (process.env.pmx) {
reply(`FAILED to disconnect ${markets} (${err.message})`)
})
})
tx2.action('triggeralert', function (user, reply) {
// offline webpush testing
try {
const result = server.triggerAlert(user)
reply(result)
} catch (error) {
console.error('FAILED to trigger alert', user, error.message)
}
})
}
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
Loading