diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f495319 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +.PHONY: format help + +# Help system from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.DEFAULT_GOAL := help + +help: + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + +setup: ## Establish local environment with dependencies installed + python3 -m venv .venv + .venv/bin/pip install -r requirements.txt + +up: ## Run Grafana container + docker-compose up -d diff --git a/data/mm.db b/data/mm.db new file mode 100644 index 0000000..e491245 Binary files /dev/null and b/data/mm.db differ diff --git a/data/mm.db-shm b/data/mm.db-shm new file mode 100644 index 0000000..d9cf459 Binary files /dev/null and b/data/mm.db-shm differ diff --git a/data/mm.db-wal b/data/mm.db-wal new file mode 100644 index 0000000..8a5a43e Binary files /dev/null and b/data/mm.db-wal differ diff --git a/docker-compose.yaml b/docker-compose.yaml index e132f72..05fd7d0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,7 +5,7 @@ volumes: services: grafana: image: grafana/grafana:6.5.0 - container_name: trader_grafana + container_name: marketmaker_dashboard ports: - 127.0.0.1:3000:3000 environment: @@ -19,15 +19,4 @@ services: GF_USERS_ALLOW_ORG_CREATE: "false" GF_LOG_LEVEL: "debug" volumes: - - grafana:/var/lib/grafana - postgres: - image: postgres:9.6.15-alpine - container_name: trader_postgres - ports: - - 5432:5432 - environment: - POSTGRES_PASSWORD: ${DB_PASS} - POSTGRES_USER: ${DB_USER} - POSTGRES_DB: ${DB_NAME} - volumes: - - postgres:/var/lib/postgresql/data + - ./data/grafana:/var/lib/grafana \ No newline at end of file diff --git a/env-example b/env-example index cf7ffaf..1cd2a0e 100644 --- a/env-example +++ b/env-example @@ -4,8 +4,8 @@ DB_PASS=yyyyy DB_USER=trader DB_NAME=trader_xmr DB_HOST=127.0.0.1 -TO_USER=zzzzzzzzz -TO_PASS=vvvvvvvvv +TO_KEY=zzzzzzzzz +TO_SECRET=vvvvvvvvv TRADE_CURRENCY=WOW TRADE_AMOUNT=300 SPREAD_TARGET=4 diff --git a/grafana/dashboards.yaml b/grafana/dashboards.yaml deleted file mode 100644 index ce46f5a..0000000 --- a/grafana/dashboards.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: 1 - -providers: -- name: 'default' - orgId: 1 - folder: '' - type: file - disableDeletion: true - editable: true - updateIntervalSeconds: 60 - allowUiUpdates: true - options: - path: /var/lib/grafana/dashboards diff --git a/grafana/prometheus.yaml b/grafana/prometheus.yaml deleted file mode 100644 index 75672ce..0000000 --- a/grafana/prometheus.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: 1 - -datasources: -- name: PostgreSQL - type: postgresql - url: http://prometheus:9090 - access: proxy - isDefault: true - timeInterval: 10s diff --git a/grafana/wow_trader.json b/grafana/wow_trader.json deleted file mode 100644 index 3740652..0000000 --- a/grafana/wow_trader.json +++ /dev/null @@ -1,1891 +0,0 @@ -{ - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": 1, - "iteration": 1599632620157, - "links": [], - "panels": [ - { - "content": "\n# Orders\n\nOrders placed on TradeOgre\n\n\n\n", - "datasource": null, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 22, - "mode": "markdown", - "options": {}, - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n date AS \"time\",\n total\nFROM balance\nWHERE\n $__timeFilter(date)\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "cacheTimeout": null, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 18, - "x": 0, - "y": 3 - }, - "hiddenSeries": false, - "id": 20, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pluginVersion": "6.5.0", - "pointradius": 6, - "points": true, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "A Buy Orders", - "color": "#C4162A" - }, - { - "alias": "B Sell Orders", - "color": "#E0B400" - }, - { - "alias": "C Fulfilled Orders", - "color": "rgb(0, 0, 0)", - "pointradius": 3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - }, - { - "params": [ - "buy" - ], - "type": "column" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Buy Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n buy = 'true'\nGROUP BY 1, buy,2\nORDER BY 1,2", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Buy Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "buy", - "=", - "'true'" - ], - "type": "expression" - } - ] - }, - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Sell Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n buy = 'false'\nGROUP BY 1,2\nORDER BY 1,2", - "refId": "B", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Sell Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "buy", - "=", - "'false'" - ], - "type": "expression" - } - ] - }, - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Fulfilled Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n active = 'false'\nGROUP BY 1,2\nORDER BY 1,2", - "refId": "C", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Fulfilled Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'false'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Orders", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorPrefix": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": null, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 8, - "w": 3, - "x": 18, - "y": 3 - }, - "id": 24, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "pluginVersion": "6.5.0", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "repeat": null, - "repeatDirection": "h", - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false, - "ymax": null, - "ymin": null - }, - "tableColumn": "", - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n count(price) AS \"price\"\nFROM \"order\"\nWHERE\n active = 'false' AND\n cancelled = 'false'\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "count" - ], - "type": "aggregate" - }, - { - "params": [ - "price" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'false'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'false'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Completed Orders", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "total" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorPrefix": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": null, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 8, - "w": 3, - "x": 21, - "y": 3 - }, - "id": 25, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "pluginVersion": "6.5.0", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "repeatDirection": "h", - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false, - "ymax": null, - "ymin": null - }, - "tableColumn": "", - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n count(price) AS \"price\"\nFROM \"order\"\nWHERE\n active = 'true' AND\n cancelled = 'false'\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "count" - ], - "type": "aggregate" - }, - { - "params": [ - "price" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'true'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'false'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Active Orders", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "total" - }, - { - "content": "\n# Balances\n\nBalances and trade info of your account.\n\n\n\n", - "datasource": null, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 11 - }, - "id": 17, - "mode": "markdown", - "options": {}, - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 14 - }, - "hiddenSeries": false, - "id": 12, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "maxPerRow": 2, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "repeat": "currency", - "repeatDirection": "h", - "scopedVars": { - "currency": { - "selected": false, - "text": "WOW", - "value": "WOW" - } - }, - "seriesOverrides": [ - { - "alias": "total", - "color": "#FF9830" - }, - { - "alias": "available", - "color": "#1F60C4" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(total) AS \"total\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "total" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - }, - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(available) AS \"available\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "B", - "select": [ - [ - { - "params": [ - "available" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "available" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "$currency Balance", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 14 - }, - "hiddenSeries": false, - "id": 26, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "maxPerRow": 2, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "repeat": null, - "repeatDirection": "h", - "repeatIteration": 1599632620157, - "repeatPanelId": 12, - "scopedVars": { - "currency": { - "selected": false, - "text": "BTC", - "value": "BTC" - } - }, - "seriesOverrides": [ - { - "alias": "total", - "color": "#FF9830" - }, - { - "alias": "available", - "color": "#1F60C4" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(total) AS \"total\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "total" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - }, - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(available) AS \"available\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "B", - "select": [ - [ - { - "params": [ - "available" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "available" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "$currency Balance", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "content": "\n# Markets\n\nGeneral stats and metrics of the $currency markets\n\n\n\n", - "datasource": null, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 22 - }, - "id": 15, - "mode": "markdown", - "options": {}, - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 25 - }, - "hiddenSeries": false, - "id": 4, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(current_price) AS \"current_price\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "current_price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "current_price" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Price", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 0, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 25 - }, - "hiddenSeries": false, - "id": 6, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(spread_sats) AS \"spread_sats\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "spread_sats" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "spread_sats" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Spread (sats)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 0, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 32 - }, - "hiddenSeries": false, - "id": 2, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": false, - "min": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(ask) AS \"ask\",\n avg(bid) AS \"bid\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "ask" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "ask" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "bid" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "bid" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Bid / Ask", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 32 - }, - "hiddenSeries": false, - "id": 8, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(spread_perc) AS \"spread_perc\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "spread_perc" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "spread_perc" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Spread (%)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": null, - "decimals": null, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 39 - }, - "hiddenSeries": false, - "id": 10, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/.*/", - "color": "#B877D9" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(volume) AS \"volume\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "volume" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "volume" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Volume (BTC)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "decimals": 6, - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "refresh": "30s", - "schemaVersion": 21, - "style": "dark", - "tags": [], - "templating": { - "list": [ - { - "allValue": null, - "current": { - "tags": [], - "text": "All", - "value": "$__all" - }, - "datasource": "PostgreSQL", - "definition": "SELECT currency FROM balance", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "currency", - "options": [ - { - "selected": true, - "text": "All", - "value": "$__all" - }, - { - "selected": false, - "text": "WOW", - "value": "WOW" - }, - { - "selected": false, - "text": "BTC", - "value": "BTC" - } - ], - "query": "SELECT currency FROM balance", - "refresh": 0, - "regex": "/.*/", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-2d", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ] - }, - "timezone": "", - "title": "WOW", - "uid": "1KF3M1DGz", - "version": 40 -} diff --git a/grafana/xmr_trader.json b/grafana/xmr_trader.json deleted file mode 100644 index 843518a..0000000 --- a/grafana/xmr_trader.json +++ /dev/null @@ -1,2094 +0,0 @@ -{ - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": 2, - "iteration": 1602880809008, - "links": [], - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 0 - }, - "hiddenSeries": false, - "id": 28, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/.*/", - "color": "#C4162A" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n avg(quantity) AS \"quantity\"\nFROM earning\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "quantity" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "quantity" - ], - "type": "alias" - } - ] - ], - "table": "earning", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Earnings (XMR)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "content": "\n# Orders\n\nOrders placed on TradeOgre\n\n\n\n", - "datasource": "PostgreSQL-xmr", - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 8 - }, - "id": 22, - "mode": "markdown", - "options": {}, - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n date AS \"time\",\n total\nFROM balance\nWHERE\n $__timeFilter(date)\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "cacheTimeout": null, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 18, - "x": 0, - "y": 11 - }, - "hiddenSeries": false, - "id": 20, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pluginVersion": "6.5.0", - "pointradius": 6, - "points": true, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "A Buy Orders", - "color": "#C4162A" - }, - { - "alias": "B Sell Orders", - "color": "#E0B400" - }, - { - "alias": "C Fulfilled Orders", - "color": "rgb(251, 251, 251)", - "pointradius": 3 - }, - { - "alias": "D Cancelled Orders", - "color": "rgb(0, 0, 0)", - "pointradius": 3 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - }, - { - "params": [ - "buy" - ], - "type": "column" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Buy Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n buy = 'true'\nGROUP BY 1, buy,2\nORDER BY 1,2", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Buy Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "buy", - "=", - "'true'" - ], - "type": "expression" - } - ] - }, - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Sell Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n buy = 'false'\nGROUP BY 1,2\nORDER BY 1,2", - "refId": "B", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Sell Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "buy", - "=", - "'false'" - ], - "type": "expression" - } - ] - }, - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Fulfilled Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n active = 'false' AND\n cancelled = 'false'\nGROUP BY 1,2\nORDER BY 1,2", - "refId": "C", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Fulfilled Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'false'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'false'" - ], - "type": "expression" - } - ] - }, - { - "format": "table", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "hide": false, - "metricColumn": "uuid", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n uuid AS metric,\n avg(price) AS \"Cancelled Orders\"\nFROM \"order\"\nWHERE\n $__timeFilter(date) AND\n active = 'false' AND\n cancelled = 'true'\nGROUP BY 1,2\nORDER BY 1,2", - "refId": "D", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "Cancelled Orders" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'false'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'true'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Orders", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorPrefix": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "PostgreSQL-xmr", - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 8, - "w": 3, - "x": 18, - "y": 11 - }, - "id": 24, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "pluginVersion": "6.5.0", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "repeat": null, - "repeatDirection": "h", - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false, - "ymax": null, - "ymin": null - }, - "tableColumn": "", - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n count(price) AS \"price\"\nFROM \"order\"\nWHERE\n active = 'false' AND\n cancelled = 'false'\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "count" - ], - "type": "aggregate" - }, - { - "params": [ - "price" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'false'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'false'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Completed Orders", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "total" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorPrefix": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "PostgreSQL-xmr", - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 8, - "w": 3, - "x": 21, - "y": 11 - }, - "id": 25, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "pluginVersion": "6.5.0", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "repeatDirection": "h", - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false, - "ymax": null, - "ymin": null - }, - "tableColumn": "", - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n count(price) AS \"price\"\nFROM \"order\"\nWHERE\n active = 'true' AND\n cancelled = 'false'\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "price" - ], - "type": "column" - }, - { - "params": [ - "count" - ], - "type": "aggregate" - }, - { - "params": [ - "price" - ], - "type": "alias" - } - ] - ], - "table": "\"order\"", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "datatype": "bool", - "name": "", - "params": [ - "active", - "=", - "'true'" - ], - "type": "expression" - }, - { - "datatype": "bool", - "name": "", - "params": [ - "cancelled", - "=", - "'false'" - ], - "type": "expression" - } - ] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Active Orders", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "total" - }, - { - "content": "\n# Balances\n\nBalances and trade info of your account.\n\n\n\n", - "datasource": "PostgreSQL-xmr", - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 19 - }, - "id": 17, - "mode": "markdown", - "options": {}, - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 22 - }, - "hiddenSeries": false, - "id": 12, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "maxPerRow": 2, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "repeat": "currency", - "repeatDirection": "h", - "scopedVars": { - "currency": { - "selected": false, - "text": "BTC", - "value": "BTC" - } - }, - "seriesOverrides": [ - { - "alias": "total", - "color": "#FF9830" - }, - { - "alias": "available", - "color": "#1F60C4" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(total) AS \"total\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "total" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - }, - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(available) AS \"available\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "B", - "select": [ - [ - { - "params": [ - "available" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "available" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "$currency Balance", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 22 - }, - "hiddenSeries": false, - "id": 29, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "maxPerRow": 2, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "repeat": null, - "repeatDirection": "h", - "repeatIteration": 1602880809008, - "repeatPanelId": 12, - "scopedVars": { - "currency": { - "selected": false, - "text": "XMR", - "value": "XMR" - } - }, - "seriesOverrides": [ - { - "alias": "total", - "color": "#FF9830" - }, - { - "alias": "available", - "color": "#1F60C4" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(total) AS \"total\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "total" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "total" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - }, - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(available) AS \"available\"\nFROM balance\nWHERE\n $__timeFilter(date) AND\n currency = $currency\nGROUP BY 1\nORDER BY 1", - "refId": "B", - "select": [ - [ - { - "params": [ - "available" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "available" - ], - "type": "alias" - } - ] - ], - "table": "balance", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - }, - { - "datatype": "varchar", - "name": "", - "params": [ - "currency", - "=", - "$currency" - ], - "type": "expression" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "$currency Balance", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "content": "\n# Markets\n\nGeneral stats and metrics of the $currency markets\n\n\n\n", - "datasource": "PostgreSQL-xmr", - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 30 - }, - "id": 15, - "mode": "markdown", - "options": {}, - "timeFrom": null, - "timeShift": null, - "title": "", - "type": "text" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 33 - }, - "hiddenSeries": false, - "id": 4, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(current_price) AS \"current_price\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "current_price" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "current_price" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Price", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 0, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 33 - }, - "hiddenSeries": false, - "id": 6, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(spread_sats) AS \"spread_sats\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "spread_sats" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "spread_sats" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Spread (sats)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 0, - "format": "none", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": 8, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 40 - }, - "hiddenSeries": false, - "id": 2, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": false, - "min": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(ask) AS \"ask\",\n avg(bid) AS \"bid\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "ask" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "ask" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "bid" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "bid" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Bid / Ask", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": 8, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 40 - }, - "hiddenSeries": false, - "id": 8, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(spread_perc) AS \"spread_perc\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "spread_perc" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "spread_perc" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Spread (%)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percent", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "PostgreSQL-xmr", - "decimals": null, - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 47 - }, - "hiddenSeries": false, - "id": 10, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "connected", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "/.*/", - "color": "#B877D9" - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "NULL" - ], - "type": "time" - } - ], - "metricColumn": "none", - "rawQuery": false, - "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval,NULL),\n avg(volume) AS \"volume\"\nFROM ticker\nWHERE\n $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "volume" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "volume" - ], - "type": "alias" - } - ] - ], - "table": "ticker", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Volume (BTC)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "decimals": null, - "format": "currencyBTC", - "label": null, - "logBase": 1, - "max": null, - "min": "0", - "show": true - }, - { - "decimals": 6, - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": false - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "refresh": "30s", - "schemaVersion": 21, - "style": "dark", - "tags": [], - "templating": { - "list": [ - { - "allValue": null, - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "PostgreSQL-xmr", - "definition": "SELECT currency FROM balance", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "currency", - "options": [], - "query": "SELECT currency FROM balance", - "refresh": 2, - "regex": "/.*/", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-3h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ] - }, - "timezone": "", - "title": "XMR", - "uid": "SKVAcXDGk", - "version": 9 -} diff --git a/requirements.txt b/requirements.txt index dce0993..bdc58ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ requests peewee -psycopg2-binary python-dotenv +hypercorn +quart \ No newline at end of file diff --git a/run.py b/run.py new file mode 100644 index 0000000..ec5ba12 --- /dev/null +++ b/run.py @@ -0,0 +1,7 @@ +from totrader.factory import create_app + + +app = create_app() + +if __name__ == '__main__': + app.run() diff --git a/static/xmr-dashboard-1.png b/static/xmr-dashboard-1.png deleted file mode 100644 index d2acbbe..0000000 Binary files a/static/xmr-dashboard-1.png and /dev/null differ diff --git a/static/xmr-dashboard-2.png b/static/xmr-dashboard-2.png deleted file mode 100644 index 53e126f..0000000 Binary files a/static/xmr-dashboard-2.png and /dev/null differ diff --git a/totrader/__init__.py b/totrader/__init__.py new file mode 100644 index 0000000..6e1d4e8 --- /dev/null +++ b/totrader/__init__.py @@ -0,0 +1 @@ +from totrader.factory import create_app \ No newline at end of file diff --git a/totrader/factory.py b/totrader/factory.py new file mode 100644 index 0000000..f3264b8 --- /dev/null +++ b/totrader/factory.py @@ -0,0 +1,16 @@ +import quart.flask_patch +from quart import Quart + + +def create_app(): + app = Quart(__name__) + app.config.from_envvar('FLASK_SECRETS', 'config.py') + + @app.before_serving + async def startup(): + from totrader.routes import meta + from totrader import filters + app.register_blueprint(meta.bp) + app.register_blueprint(filters.bp) + + return app \ No newline at end of file diff --git a/totrader/filters.py b/totrader/filters.py new file mode 100644 index 0000000..cba99f1 --- /dev/null +++ b/totrader/filters.py @@ -0,0 +1,15 @@ +from datetime import datetime + +from quart import Blueprint + + +bp = Blueprint('filters', 'filters') + + +@bp.app_template_filter('ts') +def from_ts(v): + return datetime.fromtimestamp(v) + +@bp.app_template_filter('xmr_block_explorer') +def xmr_block_explorer(v): + return f'https://www.exploremonero.com/transaction/{v}' \ No newline at end of file diff --git a/db.py b/totrader/models.py similarity index 68% rename from db.py rename to totrader/models.py index 4c39f1a..77342e1 100644 --- a/db.py +++ b/totrader/models.py @@ -1,23 +1,14 @@ -from os import getenv +from datetime import datetime + from dotenv import load_dotenv from peewee import * -from datetime import datetime, timedelta +from playhouse.sqliteq import SqliteQueueDatabase load_dotenv('.env') -db = PostgresqlDatabase( - getenv('DB_NAME', 'trader'), - user=getenv('DB_USER'), - password=getenv('DB_PASS'), - host=getenv('DB_HOST', '127.0.0.1'), - port=getenv('DB_PORT', 5432) -) +db = SqliteQueueDatabase('data/mm.db') -def get_time(): - now = datetime.now() - now = now + timedelta(hours=7) - return now class Ticker(Model): id = AutoField() @@ -32,7 +23,7 @@ class Ticker(Model): spread_btc = DoubleField() spread_sats = IntegerField() spread_perc = DoubleField() - date = DateTimeField(default=get_time) + date = DateTimeField(default=datetime.utcnow) class Meta: database = db @@ -41,7 +32,7 @@ class Balance(Model): total = DoubleField() available = DoubleField() currency = CharField() - date = DateTimeField(default=get_time) + date = DateTimeField(default=datetime.utcnow) class Meta: database = db @@ -55,7 +46,7 @@ class Order(Model): uuid = TextField(null=True) active = BooleanField(default=True) cancelled = BooleanField(default=False) - date = DateTimeField(default=get_time) + date = DateTimeField(default=datetime.utcnow) class Meta: database = db @@ -63,7 +54,7 @@ class Order(Model): class Earning(Model): trade_pair = CharField() quantity = DoubleField() - date = DateTimeField(default=get_time) + date = DateTimeField(default=datetime.utcnow) class Meta: database = db diff --git a/totrader/routes/__init__.py b/totrader/routes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/totrader/routes/meta.py b/totrader/routes/meta.py new file mode 100644 index 0000000..8ab31b5 --- /dev/null +++ b/totrader/routes/meta.py @@ -0,0 +1,9 @@ + +from quart import Blueprint, render_template + + +bp = Blueprint('meta', 'meta') + +@bp.route('/') +async def index(): + return await render_template('index.html') diff --git a/totrader/templates/index.html b/totrader/templates/index.html new file mode 100644 index 0000000..b6fc4c6 --- /dev/null +++ b/totrader/templates/index.html @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/trade.py b/totrader/trade.py similarity index 99% rename from trade.py rename to totrader/trade.py index 980d606..f97e6aa 100755 --- a/trade.py +++ b/totrader/trade.py @@ -2,13 +2,15 @@ import logging from os import getenv -from dotenv import load_dotenv from argparse import ArgumentParser from datetime import datetime from decimal import Decimal from random import uniform from time import sleep -from db import Ticker, Balance, Order, Earning + +from dotenv import load_dotenv + +from models import Ticker, Balance, Order, Earning from tradeogre import TradeOgre diff --git a/tradeogre.py b/totrader/tradeogre.py similarity index 95% rename from tradeogre.py rename to totrader/tradeogre.py index df5c261..1b6d96a 100644 --- a/tradeogre.py +++ b/totrader/tradeogre.py @@ -10,8 +10,8 @@ class TradeOgre(object): load_dotenv('.env') self.base = 'https://tradeogre.com/api/v1' self.auth = HTTPBasicAuth( - getenv('TO_USER'), - getenv('TO_PASS') + getenv('TO_KEY'), + getenv('TO_SECRET') ) def req(self, route, method='get', data={}):