From b8fed347d68b81153c82dd5d4a949365e3c279fa Mon Sep 17 00:00:00 2001 From: foolcage <5533061@qq.com> Date: Mon, 9 Jul 2018 13:44:35 +0800 Subject: [PATCH] update md --- docs/subscription.md | 441 ++++++++++++++++++++++++++++++------------- 1 file changed, 315 insertions(+), 126 deletions(-) diff --git a/docs/subscription.md b/docs/subscription.md index b7ff4b0..68ab59c 100644 --- a/docs/subscription.md +++ b/docs/subscription.md @@ -1,185 +1,374 @@ -## 订阅 +## 获取支持的数字货币 ``` -curl -XPUT "localhost:5000/subscription" -H 'Content-Type: application/json' -d '{ - "userId": "aaa", - "securityType": "cryptocurrency", - "exchange": "kraken", - "code": "BCH-USD", - "email": "5533061@qq.com", - "condition": { - "upPct": 0.01, - "downPct": -0.02, - "up": 7000, - "down": 6000, - "cross": 0.02 - }, - "repeat": false -}' - +curl 'http://localhost:5000/security?securityType=cryptocurrency' { "code": 0, "msg": "success", "payload": { - "_id": "bf1SaWQBfBeKI-v8T-EK", - "_index": "subscription", - "_source": { - "code": "BCH-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 + "hits": [ + { + "_id": "cryptocurrency_binance_EOS-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "EOS-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_EOS-USDT", + "name": "EOS/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" }, - "email": "5533061@qq.com", - "exchange": "kraken", - "repeat": false, - "securityType": "cryptocurrency", - "userId": "aaa" - }, - "_type": "doc", - "_version": 1 + { + "_id": "cryptocurrency_bitfinex_BTC-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "BTC-USDT", + "exchange": "bitfinex", + "id": "cryptocurrency_bitfinex_BTC-USDT", + "name": "BTC/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_bitfinex_EOS-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "EOS-USDT", + "exchange": "bitfinex", + "id": "cryptocurrency_bitfinex_EOS-USDT", + "name": "EOS/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_bitfinex_BCH-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "BCH-USDT", + "exchange": "bitfinex", + "id": "cryptocurrency_bitfinex_BCH-USDT", + "name": "BCH/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_binance_BTC-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "BTC-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_BTC-USDT", + "name": "BTC/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_huobipro_EOS-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "EOS-USDT", + "exchange": "huobipro", + "id": "cryptocurrency_huobipro_EOS-USDT", + "name": "EOS/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_bitfinex_ETH-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "ETH-USDT", + "exchange": "bitfinex", + "id": "cryptocurrency_bitfinex_ETH-USDT", + "name": "ETH/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_binance_ETH-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "ETH-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_ETH-USDT", + "name": "ETH/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_huobipro_BCH-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "BCH-USDT", + "exchange": "huobipro", + "id": "cryptocurrency_huobipro_BCH-USDT", + "name": "BCH/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_huobipro_XRP-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "XRP-USDT", + "exchange": "huobipro", + "id": "cryptocurrency_huobipro_XRP-USDT", + "name": "XRP/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + } + ], + "max_score": 0.0, + "total": 15 } } ``` -## 查询 -curl -XGET "localhost:5000/subscription?userId=aaa" + +## 指定交易所 ``` +curl 'http://localhost:5000/security?securityType=cryptocurrency&exchange=binance' { "code": 0, "msg": "success", "payload": { "hits": [ { - "_id": "af1jZGQBfBeKI-v8aeFw", - "_index": "subscription", + "_id": "cryptocurrency_binance_EOS-USDT", + "_index": "crypto_currency_meta", "_score": 0.0, "_source": { - "code": "BCH-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 - }, - "email": "5533061@qq.com", - "exchange": "kraken", - "repeat": false, - "securityType": "cryptocurrency", - "userId": "aaa" + "code": "EOS-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_EOS-USDT", + "name": "EOS/USDT", + "type": "cryptocurrency" }, "_type": "doc" }, { - "_id": "Zf1aZGQBfBeKI-v8buGQ", - "_index": "subscription", + "_id": "cryptocurrency_binance_BTC-USDT", + "_index": "crypto_currency_meta", "_score": 0.0, "_source": { - "code": "BCH-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 - }, - "email": "5533061@qq.com", - "exchange": "kraken", - "repeat": false, - "securityType": "cryptocurrency", - "userId": "aaa" + "code": "BTC-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_BTC-USDT", + "name": "BTC/USDT", + "type": "cryptocurrency" }, "_type": "doc" }, { - "_id": "aP1iZGQBfBeKI-v8AeHP", - "_index": "subscription", + "_id": "cryptocurrency_binance_ETH-USDT", + "_index": "crypto_currency_meta", "_score": 0.0, "_source": { - "code": "BCH-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 - }, - "email": "5533061@qq.com", - "exchange": "kraken", - "repeat": false, - "securityType": "cryptocurrency", - "userId": "aaa" + "code": "ETH-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_ETH-USDT", + "name": "ETH/USDT", + "type": "cryptocurrency" }, "_type": "doc" }, { - "_id": "bf1SaWQBfBeKI-v8T-EK", - "_index": "subscription", + "_id": "cryptocurrency_binance_BCH-USDT", + "_index": "crypto_currency_meta", "_score": 0.0, "_source": { - "code": "BCH-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 - }, - "email": "5533061@qq.com", - "exchange": "kraken", - "repeat": false, - "securityType": "cryptocurrency", - "userId": "aaa" + "code": "BCH-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_BCH-USDT", + "name": "BCH/USDT", + "type": "cryptocurrency" + }, + "_type": "doc" + }, + { + "_id": "cryptocurrency_binance_XRP-USDT", + "_index": "crypto_currency_meta", + "_score": 0.0, + "_source": { + "code": "XRP-USDT", + "exchange": "binance", + "id": "cryptocurrency_binance_XRP-USDT", + "name": "XRP/USDT", + "type": "cryptocurrency" }, "_type": "doc" } ], "max_score": 0.0, - "total": 4 + "total": 5 } } + ``` + +## 订阅 +``` +curl -XPUT "localhost:5000/subscription" -H 'Content-Type: application/json' -d '{ + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q", + "type": "price", + "securityType": "cryptocurrency", + "exchange": "binance", + "code": "XRP-USDT", + "upPct": 0.02, + "downPct": -0.02, + "up": 6500, + "down": 6700, + "actions": ["weixin", "email", "shortMsg"], + "repeat": false + }' +{ + "code": 0, + "msg": "success", + "payload": { + "_id": "FPWGfWQB7OYj2Pz1vY8U", + "_index": "price_subscription", + "_source": { + "actions": [ + "weixin", + "email", + "shortMsg" + ], + "code": "XRP-USDT", + "down": 6700, + "downPct": -0.02, + "exchange": "binance", + "repeat": false, + "securityType": "cryptocurrency", + "type": "price", + "up": 6500, + "upPct": 0.02, + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q" + }, + "_type": "doc", + "_version": 1 + } +} + +``` + ## 更新 ``` -curl -XPUT "localhost:5000/subscription/bf1SaWQBfBeKI-v8T-EK" -H 'Content-Type: application/json' -d '{ - "userId": "aaa", - "securityType": "cryptocurrency", - "exchange": "kraken", - "code": "BTC-USD", - "email": "5533061@qq.com", - "condition": { - "upPct": 0.01, - "downPct": -0.02, - "up": 7000, - "down": 6000, - "cross": 0.02 - }, - "repeat": false -}' +curl -XPUT "localhost:5000/subscription/FPWGfWQB7OYj2Pz1vY8U" -H 'Content-Type: application/json' -d '{ + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q", + "type": "price", + "securityType": "cryptocurrency", + "exchange": "binance", + "code": "XRP-USDT", + "upPct": 0.05, + "downPct": -0.02, + "up": 6500, + "down": 6700, + "actions": ["weixin", "email", "shortMsg"], + "repeat": false + }' { "code": 0, "msg": "success", "payload": { - "_id": "bf1SaWQBfBeKI-v8T-EK", - "_index": "subscription", + "_id": "FPWGfWQB7OYj2Pz1vY8U", + "_index": "price_subscription", "_source": { - "code": "BTC-USD", - "condition": { - "cross": 0.02, - "down": 6000, - "downPct": -0.02, - "up": 7000, - "upPct": 0.01 - }, - "email": "5533061@qq.com", - "exchange": "kraken", + "actions": [ + "weixin", + "email", + "shortMsg" + ], + "code": "XRP-USDT", + "down": 6700, + "downPct": -0.02, + "exchange": "binance", "repeat": false, "securityType": "cryptocurrency", - "userId": "aaa" + "type": "price", + "up": 6500, + "upPct": 0.05, + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q" }, "_type": "doc", "_version": 2 } } ``` +## 查询 +``` +curl -XGET "localhost:5000/subscription?userId=oRvNP0XIb9G3g6a-2fAX9RHX5--Q" +{ + "code": 0, + "msg": "success", + "payload": { + "hits": [ + { + "_id": "FPWGfWQB7OYj2Pz1vY8U", + "_index": "price_subscription", + "_score": 0.0, + "_source": { + "actions": [ + "weixin", + "email", + "shortMsg" + ], + "code": "XRP-USDT", + "down": 6700, + "downPct": -0.02, + "exchange": "binance", + "repeat": false, + "securityType": "cryptocurrency", + "type": "price", + "up": 6500, + "upPct": 0.05, + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q" + }, + "_type": "doc" + }, + { + "_id": "FfWLfWQB7OYj2Pz1q4-n", + "_index": "price_subscription", + "_score": 0.0, + "_source": { + "actions": [ + "weixin", + "email", + "shortMsg" + ], + "code": "BTC-USDT", + "down": 6700, + "downPct": -0.02, + "exchange": "binance", + "repeat": false, + "securityType": "cryptocurrency", + "type": "price", + "up": 6500, + "upPct": 0.02, + "userId": "oRvNP0XIb9G3g6a-2fAX9RHX5--Q" + }, + "_type": "doc" + } + ], + "max_score": 0.0, + "total": 2 + } +} +```