├── .classpath ├── .gitattributes ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── pom.xml ├── src ├── main │ └── java │ │ └── com │ │ └── mumu │ │ ├── beans │ │ ├── AccountInfo.java │ │ ├── Cancel.java │ │ ├── Common.java │ │ ├── DealtInfo.java │ │ ├── GetOrder.java │ │ ├── ListOrders.java │ │ ├── Market.java │ │ ├── Order.java │ │ └── OrderInfo.java │ │ ├── common │ │ ├── BaseForm.java │ │ └── Constants.java │ │ └── exchange │ │ ├── MarketServiceFactory.java │ │ ├── TradingServiceFactory.java │ │ ├── api │ │ ├── BinanceAPI.java │ │ ├── CoinexAPI.java │ │ ├── HoubiAPI.java │ │ └── OkexAPI.java │ │ ├── coins │ │ ├── BinanceProfiles.java │ │ ├── CoinexProfiles.java │ │ ├── HuobiProfiles.java │ │ └── OkexProfiles.java │ │ ├── common │ │ ├── Constants.java │ │ ├── JacksonHelper.java │ │ └── RequestUtils.java │ │ ├── market │ │ ├── BinanceMarketService.java │ │ ├── CoinexMarketService.java │ │ ├── HuobiMarketService.java │ │ ├── IMarketService.java │ │ ├── MarketService.java │ │ └── OkexMarketService.java │ │ ├── signature │ │ ├── BinanceParamsSigner.java │ │ ├── CoinexParamsSigner.java │ │ ├── HoubiParamsSigner.java │ │ ├── HuobiParamsSigner.java │ │ ├── ISignature.java │ │ ├── OkexParamsSigner.java │ │ └── RequestParamsSigner.java │ │ └── trading │ │ ├── BinanceTradingService.java │ │ ├── CoinexTradingService.java │ │ ├── HuobiTradingService.java │ │ ├── ITradingService.java │ │ ├── OkexTradingService.java │ │ └── TradingService.java └── test │ └── java │ ├── MarketTest.java │ └── TradingTest.java ├── target ├── classes │ ├── META-INF │ │ ├── MANIFEST.MF │ │ └── maven │ │ │ └── com.mumu │ │ │ └── mm-vcoinSDK │ │ │ ├── pom.properties │ │ │ └── pom.xml │ └── com │ │ └── mumu │ │ ├── beans │ │ ├── AccountInfo$AssetItem.class │ │ ├── AccountInfo.class │ │ ├── Cancel$Response.class │ │ ├── Cancel.class │ │ ├── Common.class │ │ ├── DealtInfo.class │ │ ├── GetOrder$Response.class │ │ ├── GetOrder.class │ │ ├── ListOrders$Response.class │ │ ├── ListOrders.class │ │ ├── Market.class │ │ ├── Order$Response.class │ │ ├── Order.class │ │ └── OrderInfo.class │ │ ├── common │ │ ├── BaseForm.class │ │ ├── Constants$EXCHANGE_NAME.class │ │ ├── Constants$ORDER_STATUS.class │ │ ├── Constants$ORDER_TYPE.class │ │ ├── Constants$RESPONSE_STATUS.class │ │ ├── Constants$TRADING_DIRECTION.class │ │ └── Constants.class │ │ └── exchange │ │ ├── MarketServiceFactory.class │ │ ├── TradingServiceFactory$TradingServiceSPI.class │ │ ├── TradingServiceFactory.class │ │ ├── api │ │ ├── BinanceAPI$Api_allOrders_params.class │ │ ├── BinanceAPI$Api_cancel_order_params.class │ │ ├── BinanceAPI$Api_get_order_params.class │ │ ├── BinanceAPI$Api_openOrders_params.class │ │ ├── BinanceAPI$Api_order_params.class │ │ ├── BinanceAPI$Api_ticker_24hr_params.class │ │ ├── BinanceAPI$Api_trades_params.class │ │ ├── BinanceAPI$Api_userinfo_params.class │ │ ├── BinanceAPI$Wapi_depositHistory_params.class │ │ ├── BinanceAPI$Wapi_withdrawHistory_params.class │ │ ├── BinanceAPI.class │ │ ├── CoinexAPI$Balance_info_params.class │ │ ├── CoinexAPI$Market_deals_params.class │ │ ├── CoinexAPI$Market_ticker_params.class │ │ ├── CoinexAPI$Order_finished_params.class │ │ ├── CoinexAPI$Order_path$orderType_params.class │ │ ├── CoinexAPI$Order_pending_list_params.class │ │ ├── CoinexAPI$Order_pending_params.class │ │ ├── CoinexAPI$Order_status_params.class │ │ ├── CoinexAPI.class │ │ ├── HoubiAPI$Account_accounts_params.class │ │ ├── HoubiAPI$Accounts_p$accountId_balance_params.class │ │ ├── HoubiAPI$Market_detail_merged_params.class │ │ ├── HoubiAPI$Market_history_trade_params.class │ │ ├── HoubiAPI$Order_openOrders_params.class │ │ ├── HoubiAPI$Order_orders_params.class │ │ ├── HoubiAPI$Order_orders_path$orderId_params.class │ │ ├── HoubiAPI$Order_orders_path$orderId_submitcancel_params.class │ │ ├── HoubiAPI$Order_orders_place_params.class │ │ ├── HoubiAPI$Query_deposit_withdraw_params.class │ │ ├── HoubiAPI.class │ │ ├── OkexAPI$Api_cancel_order_params.class │ │ ├── OkexAPI$Api_order_history_params.class │ │ ├── OkexAPI$Api_order_info_params.class │ │ ├── OkexAPI$Api_orders_info_params.class │ │ ├── OkexAPI$Api_ticker_params.class │ │ ├── OkexAPI$Api_trade_params.class │ │ ├── OkexAPI$Api_trades_params.class │ │ ├── OkexAPI$Api_userinfo_params.class │ │ └── OkexAPI.class │ │ ├── coins │ │ ├── BinanceProfiles.class │ │ ├── CoinexProfiles.class │ │ ├── HuobiProfiles.class │ │ └── OkexProfiles.class │ │ ├── common │ │ ├── Constants$BINANCE_DEPOSIT_STATUS.class │ │ ├── Constants$BINANCE_ORDER_SIDE.class │ │ ├── Constants$BINANCE_ORDER_STATUS.class │ │ ├── Constants$BINANCE_ORDER_TYPE.class │ │ ├── Constants$BINANCE_RESP_TYPE.class │ │ ├── Constants$BINANCE_SYMBOL_STATUS.class │ │ ├── Constants$BINANCE_TIMEINFORCE.class │ │ ├── Constants$BINANCE_WITHDRAW_STATUS.class │ │ ├── Constants$COINEX_ORDER_DIRECTION.class │ │ ├── Constants$COINEX_ORDER_STATUS.class │ │ ├── Constants$COINEX_ORDER_TYPE.class │ │ ├── Constants$HUOBI_ACCOUNTS_TYPE.class │ │ ├── Constants$HUOBI_DEPOSIT_STATUS.class │ │ ├── Constants$HUOBI_ORDER_STATUS.class │ │ ├── Constants$HUOBI_ORDER_TYPE.class │ │ ├── Constants$HUOBI_WITHDRAW_STATUS.class │ │ ├── Constants$OKEX_COMMON_STATUS.class │ │ ├── Constants$OKEX_ORDER_STATUS.class │ │ ├── Constants$OKEX_ORDER_TYPE.class │ │ ├── Constants.class │ │ ├── JacksonHelper.class │ │ └── RequestUtils.class │ │ ├── market │ │ ├── BinanceMarketService.class │ │ ├── CoinexMarketService.class │ │ ├── HuobiMarketService.class │ │ ├── IMarketService.class │ │ ├── MarketService.class │ │ └── OkexMarketService.class │ │ ├── signature │ │ ├── BinanceParamsSigner$1.class │ │ ├── BinanceParamsSigner.class │ │ ├── CoinexParamsSigner$1.class │ │ ├── CoinexParamsSigner.class │ │ ├── HoubiParamsSigner$1.class │ │ ├── HoubiParamsSigner.class │ │ ├── HuobiParamsSigner$1.class │ │ ├── HuobiParamsSigner.class │ │ ├── ISignature.class │ │ ├── OkexParamsSigner$1.class │ │ ├── OkexParamsSigner.class │ │ ├── RequestParamsSigner$1.class │ │ └── RequestParamsSigner.class │ │ └── trading │ │ ├── BinanceTradingService.class │ │ ├── CoinexTradingService.class │ │ ├── HuobiTradingService.class │ │ ├── ITradingService.class │ │ ├── OkexTradingService.class │ │ └── TradingService.class └── test-classes │ ├── MarketTest.class │ └── TradingTest.class └── transaction.log /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | mm-vcoinSDK 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/AccountInfo.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.io.Serializable; 4 | import java.util.Collections; 5 | import java.util.Map; 6 | 7 | import com.mumu.common.BaseForm; 8 | import com.mumu.common.Constants.RESPONSE_STATUS; 9 | 10 | public class AccountInfo extends BaseForm { 11 | 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = 3374677305748881668L; 17 | private RESPONSE_STATUS status; 18 | private String errorCode; 19 | private String errorMsg; 20 | 21 | /** 22 | * 帐户状态是否正常 23 | */ 24 | private String accountId; 25 | private boolean isNormal = true; 26 | private Map assetMap = null; 27 | 28 | 29 | 30 | public RESPONSE_STATUS getStatus() { 31 | return status; 32 | } 33 | 34 | 35 | 36 | public void setStatus(RESPONSE_STATUS status) { 37 | this.status = status; 38 | } 39 | 40 | 41 | 42 | public String getErrorCode() { 43 | return errorCode; 44 | } 45 | 46 | 47 | 48 | public void setErrorCode(String errorCode) { 49 | this.errorCode = errorCode; 50 | } 51 | 52 | 53 | 54 | public String getErrorMsg() { 55 | return errorMsg; 56 | } 57 | 58 | 59 | 60 | public void setErrorMsg(String errorMsg) { 61 | this.errorMsg = errorMsg; 62 | } 63 | 64 | 65 | 66 | public String getAccountId() { 67 | return accountId; 68 | } 69 | 70 | 71 | 72 | public void setAccountId(String accountId) { 73 | this.accountId = accountId; 74 | } 75 | 76 | 77 | 78 | public boolean isNormal() { 79 | return isNormal; 80 | } 81 | 82 | 83 | 84 | public void setNormal(boolean isNormal) { 85 | this.isNormal = isNormal; 86 | } 87 | 88 | 89 | 90 | public Map getAssetMap() { 91 | return Collections.unmodifiableMap(this.assetMap); 92 | } 93 | 94 | 95 | 96 | public void setAssetMap(Map assetMap) { 97 | if (null == this.assetMap) { 98 | this.assetMap = assetMap; 99 | } 100 | } 101 | 102 | 103 | 104 | public class AssetItem implements Serializable { 105 | 106 | 107 | /** 108 | * 109 | */ 110 | private static final long serialVersionUID = 2464994811180200234L; 111 | private String currency; 112 | private String available; 113 | private String frozen; 114 | public String getCurrency() { 115 | return currency; 116 | } 117 | public void setCurrency(String currency) { 118 | this.currency = currency; 119 | } 120 | public String getAvailable() { 121 | return available; 122 | } 123 | public void setAvailable(String available) { 124 | this.available = available; 125 | } 126 | public String getFrozen() { 127 | return frozen; 128 | } 129 | public void setFrozen(String frozen) { 130 | this.frozen = frozen; 131 | } 132 | 133 | 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/Cancel.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.mumu.common.Constants.RESPONSE_STATUS; 6 | 7 | public class Cancel extends Common { 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = -2401774342779032830L; 13 | private String symbol; 14 | private String tid; 15 | 16 | 17 | public String getSymbol() { 18 | return symbol; 19 | } 20 | 21 | public void setSymbol(String symbol) { 22 | this.symbol = symbol; 23 | } 24 | 25 | public String getTid() { 26 | return tid; 27 | } 28 | 29 | public void setTid(String tid) { 30 | this.tid = tid; 31 | } 32 | 33 | 34 | public static class Response implements Serializable { 35 | 36 | /** 37 | * 38 | */ 39 | private static final long serialVersionUID = 2870163071445336074L; 40 | private RESPONSE_STATUS status; 41 | private String errorCode; 42 | private String errorMsg; 43 | 44 | private String tid; 45 | 46 | public RESPONSE_STATUS getStatus() { 47 | return status; 48 | } 49 | 50 | public void setStatus(RESPONSE_STATUS status) { 51 | this.status = status; 52 | } 53 | 54 | public String getErrorCode() { 55 | return errorCode; 56 | } 57 | 58 | public void setErrorCode(String errorCode) { 59 | this.errorCode = errorCode; 60 | } 61 | 62 | public String getErrorMsg() { 63 | return errorMsg; 64 | } 65 | 66 | public void setErrorMsg(String errorMsg) { 67 | this.errorMsg = errorMsg; 68 | } 69 | 70 | public String getTid() { 71 | return tid; 72 | } 73 | 74 | public void setTid(String tid) { 75 | this.tid = tid; 76 | } 77 | 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/Common.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import com.mumu.common.BaseForm; 4 | 5 | public class Common extends BaseForm { 6 | 7 | private String accessKey; 8 | private String secretkey; 9 | private String accountId; 10 | private String requestId; 11 | 12 | public String getAccessKey() { 13 | return accessKey; 14 | } 15 | public void setAccessKey(String accessKey) { 16 | this.accessKey = accessKey; 17 | } 18 | public String getSecretkey() { 19 | return secretkey; 20 | } 21 | public void setSecretkey(String secretkey) { 22 | this.secretkey = secretkey; 23 | } 24 | public String getAccountId() { 25 | return accountId; 26 | } 27 | 28 | /** 29 | * 可不传 30 | * @param accountId 31 | */ 32 | public void setAccountId(String accountId) { 33 | this.accountId = accountId; 34 | } 35 | public String getRequestId() { 36 | return requestId; 37 | } 38 | public void setRequestId(String requestId) { 39 | this.requestId = requestId; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/DealtInfo.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import com.mumu.common.BaseForm; 4 | import com.mumu.common.Constants.TRADING_DIRECTION; 5 | 6 | public class DealtInfo extends BaseForm { 7 | 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = -7957675042135563397L; 13 | /** 14 | * "id": 成交id, 15 | */ 16 | private String id; 17 | /** 18 | * "price": 成交价, 19 | */ 20 | private double price; 21 | /** 22 | * "amount": 成交量, 23 | */ 24 | private double volume; 25 | /** 26 | * "direction": 主动成交方向, 27 | */ 28 | private TRADING_DIRECTION direction; 29 | /** 30 | * "ts": 成交时间 31 | */ 32 | private long ts; 33 | 34 | 35 | public String getId() { 36 | return id; 37 | } 38 | public void setId(String id) { 39 | this.id = id; 40 | } 41 | public double getPrice() { 42 | return price; 43 | } 44 | public void setPrice(double price) { 45 | this.price = price; 46 | } 47 | public double getVolume() { 48 | return volume; 49 | } 50 | public void setVolume(double volume) { 51 | this.volume = volume; 52 | } 53 | public TRADING_DIRECTION getDirection() { 54 | return direction; 55 | } 56 | public void setDirection(TRADING_DIRECTION direction) { 57 | this.direction = direction; 58 | } 59 | public long getTs() { 60 | return ts; 61 | } 62 | public void setTs(long ts) { 63 | this.ts = ts; 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/GetOrder.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.mumu.common.Constants.RESPONSE_STATUS; 6 | 7 | public class GetOrder extends Common { 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1638945906226887753L; 13 | private String symbol; 14 | private String tid; 15 | 16 | public String getSymbol() { 17 | return symbol; 18 | } 19 | public void setSymbol(String symbol) { 20 | this.symbol = symbol; 21 | } 22 | public String getTid() { 23 | return tid; 24 | } 25 | public void setTid(String tid) { 26 | this.tid = tid; 27 | } 28 | 29 | public static class Response implements Serializable { 30 | 31 | 32 | /** 33 | * 34 | */ 35 | private static final long serialVersionUID = -3153622022992531371L; 36 | private RESPONSE_STATUS status; 37 | private String errorCode; 38 | private String errorMsg; 39 | 40 | private OrderInfo orderInfo; 41 | 42 | public RESPONSE_STATUS getStatus() { 43 | return status; 44 | } 45 | 46 | public void setStatus(RESPONSE_STATUS status) { 47 | this.status = status; 48 | } 49 | 50 | public String getErrorCode() { 51 | return errorCode; 52 | } 53 | 54 | public void setErrorCode(String errorCode) { 55 | this.errorCode = errorCode; 56 | } 57 | 58 | public String getErrorMsg() { 59 | return errorMsg; 60 | } 61 | 62 | public void setErrorMsg(String errorMsg) { 63 | this.errorMsg = errorMsg; 64 | } 65 | 66 | public OrderInfo getOrderInfo() { 67 | return orderInfo; 68 | } 69 | 70 | public void setOrderInfo(OrderInfo orderInfo) { 71 | this.orderInfo = orderInfo; 72 | } 73 | 74 | 75 | 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/ListOrders.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.mumu.common.Constants.RESPONSE_STATUS; 7 | 8 | public class ListOrders extends Common { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 1049013488197872434L; 14 | private String symbol; 15 | 16 | public String getSymbol() { 17 | return symbol; 18 | } 19 | 20 | public void setSymbol(String symbol) { 21 | this.symbol = symbol; 22 | } 23 | 24 | public static class Response implements Serializable { 25 | 26 | 27 | /** 28 | * 29 | */ 30 | private static final long serialVersionUID = -4005463384102145276L; 31 | private RESPONSE_STATUS status; 32 | private String errorCode; 33 | private String errorMsg; 34 | private boolean hasNext = false; 35 | 36 | private List orderInfoList; 37 | 38 | public RESPONSE_STATUS getStatus() { 39 | return status; 40 | } 41 | 42 | public void setStatus(RESPONSE_STATUS status) { 43 | this.status = status; 44 | } 45 | 46 | public String getErrorCode() { 47 | return errorCode; 48 | } 49 | 50 | public void setErrorCode(String errorCode) { 51 | this.errorCode = errorCode; 52 | } 53 | 54 | public String getErrorMsg() { 55 | return errorMsg; 56 | } 57 | 58 | public void setErrorMsg(String errorMsg) { 59 | this.errorMsg = errorMsg; 60 | } 61 | 62 | public List getListOrderInfo() { 63 | return orderInfoList; 64 | } 65 | 66 | public void setListOrderInfo(List orderInfoList) { 67 | this.orderInfoList = orderInfoList; 68 | } 69 | 70 | public boolean isHasNext() { 71 | return hasNext; 72 | } 73 | 74 | public void setHasNext(boolean hasNext) { 75 | this.hasNext = hasNext; 76 | } 77 | 78 | 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/Market.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | 6 | import com.mumu.common.BaseForm; 7 | 8 | public class Market extends BaseForm { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 7592585925124568142L; 14 | private Calendar calendar = null;//Calendar.getInstance(); 15 | private String date = null; 16 | private String time = null; 17 | 18 | /** 19 | * 行情时间戳 20 | */ 21 | private long ts; 22 | /** 23 | * 标的 24 | */ 25 | private String symbol; 26 | /** 27 | * 开盘价 28 | */ 29 | private double open; 30 | /** 31 | * 最新价 32 | */ 33 | private double last; 34 | /** 35 | * 买价 36 | */ 37 | private double bid; 38 | /** 39 | * 买量 40 | */ 41 | private double bidVolume; 42 | /** 43 | * 卖价 44 | */ 45 | private double ask; 46 | /** 47 | * 卖量 48 | */ 49 | private double askVolume; 50 | /** 51 | * 最高价 52 | */ 53 | private double highest; 54 | /** 55 | * 最低价 56 | */ 57 | private double lowest; 58 | /** 59 | * 成交量 60 | */ 61 | private double volume; 62 | /** 63 | * 成交额 64 | */ 65 | private double amount; 66 | public long getTs() { 67 | return ts; 68 | } 69 | public void setTs(long ts) { 70 | if (null == calendar) { 71 | calendar = Calendar.getInstance(); 72 | calendar.setTimeInMillis(ts); 73 | } 74 | this.ts = ts; 75 | } 76 | public String getSymbol() { 77 | return symbol; 78 | } 79 | public void setSymbol(String symbol) { 80 | this.symbol = symbol; 81 | } 82 | public double getOpen() { 83 | return open; 84 | } 85 | public void setOpen(double open) { 86 | this.open = open; 87 | } 88 | public double getLast() { 89 | return last; 90 | } 91 | public void setLast(double last) { 92 | this.last = last; 93 | } 94 | public double getBid() { 95 | return bid; 96 | } 97 | public void setBid(double bid) { 98 | this.bid = bid; 99 | } 100 | public double getBidVolume() { 101 | return bidVolume; 102 | } 103 | public void setBidVolume(double bidVolume) { 104 | this.bidVolume = bidVolume; 105 | } 106 | public double getAsk() { 107 | return ask; 108 | } 109 | public void setAsk(double ask) { 110 | this.ask = ask; 111 | } 112 | public double getAskVolume() { 113 | return askVolume; 114 | } 115 | public void setAskVolume(double askVolume) { 116 | this.askVolume = askVolume; 117 | } 118 | public double getHighest() { 119 | return highest; 120 | } 121 | public void setHighest(double highest) { 122 | this.highest = highest; 123 | } 124 | public double getLowest() { 125 | return lowest; 126 | } 127 | public void setLowest(double lowest) { 128 | this.lowest = lowest; 129 | } 130 | public double getVolume() { 131 | return volume; 132 | } 133 | public void setVolume(double volume) { 134 | this.volume = volume; 135 | } 136 | public double getAmount() { 137 | return amount; 138 | } 139 | public void setAmount(double amount) { 140 | this.amount = amount; 141 | } 142 | 143 | public String getDate() { 144 | if (null == date) { 145 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 146 | date = dateFormat.format(this.calendar.getTime()); 147 | } 148 | 149 | return date; 150 | } 151 | 152 | public String getTime() { 153 | if (null == time) { 154 | SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); 155 | time = dateFormat.format(this.calendar.getTime()); 156 | } 157 | 158 | return time; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/Order.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.mumu.common.Constants.ORDER_TYPE; 6 | import com.mumu.common.Constants.RESPONSE_STATUS; 7 | import com.mumu.common.Constants.TRADING_DIRECTION; 8 | 9 | public class Order extends Common { 10 | 11 | 12 | /** 13 | * 14 | */ 15 | private static final long serialVersionUID = -4205844875425589379L; 16 | private String symbol; 17 | private String volume; 18 | /** 19 | * 市价单没有价格 20 | */ 21 | private String price; 22 | private TRADING_DIRECTION direction; 23 | private ORDER_TYPE type; 24 | 25 | 26 | public String getSymbol() { 27 | return symbol; 28 | } 29 | 30 | public void setSymbol(String symbol) { 31 | this.symbol = symbol; 32 | } 33 | 34 | public String getVolume() { 35 | return volume; 36 | } 37 | 38 | public void setVolume(String volume) { 39 | this.volume = volume; 40 | } 41 | 42 | public String getPrice() { 43 | return price; 44 | } 45 | 46 | public void setPrice(String price) { 47 | this.price = price; 48 | } 49 | 50 | public TRADING_DIRECTION getDirection() { 51 | return direction; 52 | } 53 | 54 | public void setDirection(TRADING_DIRECTION direction) { 55 | this.direction = direction; 56 | } 57 | 58 | public ORDER_TYPE getType() { 59 | return type; 60 | } 61 | 62 | public void setType(ORDER_TYPE type) { 63 | this.type = type; 64 | } 65 | 66 | 67 | 68 | public static class Response implements Serializable { 69 | 70 | /** 71 | * 72 | */ 73 | private static final long serialVersionUID = 7657654382832287880L; 74 | private RESPONSE_STATUS status; 75 | private String errorCode; 76 | private String errorMsg; 77 | 78 | private String tid; 79 | 80 | public RESPONSE_STATUS getStatus() { 81 | return status; 82 | } 83 | 84 | public void setStatus(RESPONSE_STATUS status) { 85 | this.status = status; 86 | } 87 | 88 | public String getErrorCode() { 89 | return errorCode; 90 | } 91 | 92 | public void setErrorCode(String errorCode) { 93 | this.errorCode = errorCode; 94 | } 95 | 96 | public String getErrorMsg() { 97 | return errorMsg; 98 | } 99 | 100 | public void setErrorMsg(String errorMsg) { 101 | this.errorMsg = errorMsg; 102 | } 103 | 104 | public String getTid() { 105 | return tid; 106 | } 107 | 108 | public void setTid(String tid) { 109 | this.tid = tid; 110 | } 111 | 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/beans/OrderInfo.java: -------------------------------------------------------------------------------- 1 | package com.mumu.beans; 2 | 3 | import com.mumu.common.BaseForm; 4 | import com.mumu.common.Constants.EXCHANGE_NAME; 5 | import com.mumu.common.Constants.ORDER_STATUS; 6 | import com.mumu.common.Constants.ORDER_TYPE; 7 | import com.mumu.common.Constants.TRADING_DIRECTION; 8 | 9 | public class OrderInfo extends BaseForm { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1822555787222340534L; 15 | private String id; 16 | private String symbol; 17 | private String accountId; 18 | /** 19 | * 委托量 20 | */ 21 | private String originalVolume; 22 | /** 23 | * 成交量 24 | */ 25 | private String volume; 26 | private String price; 27 | /** 28 | * 创建时间 29 | */ 30 | private String ts; 31 | private TRADING_DIRECTION direction; 32 | private ORDER_TYPE type; 33 | private ORDER_STATUS status; 34 | private EXCHANGE_NAME exchange; 35 | /** 36 | * 手续费 37 | */ 38 | private String fee; 39 | /** 40 | * 手续费币种 41 | */ 42 | private String feeSymbol; 43 | private String requestId; 44 | 45 | public String getId() { 46 | return id; 47 | } 48 | public void setId(String id) { 49 | this.id = id; 50 | } 51 | public String getSymbol() { 52 | return symbol; 53 | } 54 | public void setSymbol(String symbol) { 55 | this.symbol = symbol; 56 | } 57 | public String getAccountId() { 58 | return accountId; 59 | } 60 | public void setAccountId(String accountId) { 61 | this.accountId = accountId; 62 | } 63 | public String getOriginalVolume() { 64 | return originalVolume; 65 | } 66 | public void setOriginalVolume(String originalVolume) { 67 | this.originalVolume = originalVolume; 68 | } 69 | public String getVolume() { 70 | return volume; 71 | } 72 | public void setVolume(String volume) { 73 | this.volume = volume; 74 | } 75 | public String getPrice() { 76 | return price; 77 | } 78 | public void setPrice(String price) { 79 | this.price = price; 80 | } 81 | public String getTs() { 82 | return ts; 83 | } 84 | public void setTs(String ts) { 85 | this.ts = ts; 86 | } 87 | public TRADING_DIRECTION getDirection() { 88 | return direction; 89 | } 90 | public void setDirection(TRADING_DIRECTION direction) { 91 | this.direction = direction; 92 | } 93 | public ORDER_TYPE getType() { 94 | return type; 95 | } 96 | public void setType(ORDER_TYPE type) { 97 | this.type = type; 98 | } 99 | public ORDER_STATUS getStatus() { 100 | return status; 101 | } 102 | public void setStatus(ORDER_STATUS status) { 103 | this.status = status; 104 | } 105 | public EXCHANGE_NAME getExchange() { 106 | return exchange; 107 | } 108 | public void setExchange(EXCHANGE_NAME exchange) { 109 | this.exchange = exchange; 110 | } 111 | public String getFee() { 112 | return fee; 113 | } 114 | public void setFee(String fee) { 115 | this.fee = fee; 116 | } 117 | public String getRequestId() { 118 | return requestId; 119 | } 120 | public void setRequestId(String requestId) { 121 | this.requestId = requestId; 122 | } 123 | public String getFeeSymbol() { 124 | return feeSymbol; 125 | } 126 | public void setFeeSymbol(String feeSymbol) { 127 | this.feeSymbol = feeSymbol; 128 | } 129 | 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/common/BaseForm.java: -------------------------------------------------------------------------------- 1 | package com.mumu.common; 2 | 3 | import java.io.Serializable; 4 | 5 | public class BaseForm implements Serializable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/common/Constants.java: -------------------------------------------------------------------------------- 1 | package com.mumu.common; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | 8 | public class Constants { 9 | 10 | public static enum EXCHANGE_NAME { 11 | EXCHANGE_HOUBI("huobi"), 12 | EXCHANGE_COINEX("coinex"), 13 | EXCHANGE_OKEX("okex"), 14 | EXCHANGE_BINANCE("binance"); 15 | 16 | private final String code; 17 | 18 | private EXCHANGE_NAME(String code) { 19 | this.code = code; 20 | } 21 | public String getCode() { 22 | return code; 23 | } 24 | 25 | public static List> getKVPair() { 26 | EXCHANGE_NAME[] statuses = EXCHANGE_NAME.values(); 27 | List> kvPairList = new ArrayList>(statuses.length); 28 | HashMap kvPairMap = null; 29 | 30 | for (int i = 0; i < statuses.length; i++) { 31 | kvPairMap = new HashMap(2); 32 | kvPairMap.put("name", statuses[i].name()); 33 | kvPairMap.put("code", statuses[i].code); 34 | 35 | kvPairList.add(kvPairMap); 36 | } 37 | return kvPairList; 38 | } 39 | 40 | public static HashMap getCodeEnumMap() { 41 | EXCHANGE_NAME[] from = EXCHANGE_NAME.values(); 42 | HashMap kvPairMap = new HashMap();; 43 | for (int i = 0; i < from.length; i++) { 44 | kvPairMap.put(from[i].code, from[i]); 45 | } 46 | return kvPairMap; 47 | } 48 | } 49 | 50 | 51 | public static enum TRADING_DIRECTION { 52 | BUY("buy"), 53 | SELL("sell"); 54 | 55 | private final String code; 56 | 57 | private TRADING_DIRECTION(String code) { 58 | this.code = code; 59 | } 60 | public String getCode() { 61 | return code; 62 | } 63 | 64 | public static List> getKVPair() { 65 | TRADING_DIRECTION[] statuses = TRADING_DIRECTION.values(); 66 | List> kvPairList = new ArrayList>(statuses.length); 67 | HashMap kvPairMap = null; 68 | 69 | for (int i = 0; i < statuses.length; i++) { 70 | kvPairMap = new HashMap(2); 71 | kvPairMap.put("name", statuses[i].name()); 72 | kvPairMap.put("code", statuses[i].code); 73 | 74 | kvPairList.add(kvPairMap); 75 | } 76 | return kvPairList; 77 | } 78 | } 79 | 80 | /** 81 | * buy-limit-maker 82 | 当“下单价格”>=“市场最低卖出价”,订单提交后,系统将拒绝接受此订单; 83 | 当“下单价格”<“市场最低卖出价”,提交成功后,此订单将被系统接受。 84 | sell-limit-maker 85 | 当“下单价格”<=“市场最高买入价”,订单提交后,系统将拒绝接受此订单; 86 | 当“下单价格”>“市场最高买入价”,提交成功后,此订单将被系统接受。 87 | * 88 | */ 89 | public static enum ORDER_TYPE { 90 | LIMIT("limit"),// 91 | MARKET("market"),// 92 | IOC("ioc"),// 93 | LIMIT_MAKER("LIMIT-MAKER"),// 94 | STOP_LOSS("STOP_LOSS"),//市价止损 95 | STOP_LOSS_LIMIT("STOP_LOSS_LIMIT"),//限价止损 96 | TAKE_PROFIT("TAKE_PROFIT"),//市价止盈 97 | TAKE_PROFIT_LIMIT("TAKE_PROFIT_LIMIT");//限价止盈; 98 | 99 | private final String code; 100 | 101 | private ORDER_TYPE(String code) { 102 | this.code = code; 103 | } 104 | public String getCode() { 105 | return code; 106 | } 107 | 108 | public static List> getKVPair() { 109 | ORDER_TYPE[] statuses = ORDER_TYPE.values(); 110 | List> kvPairList = new ArrayList>(statuses.length); 111 | HashMap kvPairMap = null; 112 | 113 | for (int i = 0; i < statuses.length; i++) { 114 | kvPairMap = new HashMap(2); 115 | kvPairMap.put("name", statuses[i].name()); 116 | kvPairMap.put("code", statuses[i].code); 117 | 118 | kvPairList.add(kvPairMap); 119 | } 120 | return kvPairList; 121 | } 122 | } 123 | 124 | public static enum RESPONSE_STATUS { 125 | OK("ok"), 126 | ERROR("error"); 127 | 128 | private final String code; 129 | 130 | private RESPONSE_STATUS(String code) { 131 | this.code = code; 132 | } 133 | public String getCode() { 134 | return code; 135 | } 136 | 137 | public static RESPONSE_STATUS getByCode(String code) { 138 | RESPONSE_STATUS type = null; 139 | 140 | for (int i = 0; i < RESPONSE_STATUS.values().length; i++) { 141 | type = RESPONSE_STATUS.values()[i]; 142 | if (type.getCode().equals(code)) { 143 | break; 144 | } 145 | } 146 | 147 | return type; 148 | } 149 | 150 | public static List> getKVPair() { 151 | RESPONSE_STATUS[] statuses = RESPONSE_STATUS.values(); 152 | List> kvPairList = new ArrayList>(statuses.length); 153 | HashMap kvPairMap = null; 154 | 155 | for (int i = 0; i < statuses.length; i++) { 156 | kvPairMap = new HashMap(2); 157 | kvPairMap.put("name", statuses[i].name()); 158 | kvPairMap.put("code", statuses[i].code); 159 | 160 | kvPairList.add(kvPairMap); 161 | } 162 | return kvPairList; 163 | } 164 | } 165 | 166 | public static enum ORDER_STATUS { 167 | UNMATCHED("未成交"), 168 | MATCHED("全部成交"), 169 | CANCELED("已撤销"), 170 | CANCELING("撤销中"), 171 | PART_MATCHED("部分成交"), 172 | PART_CANCELED("部成部撤"); 173 | 174 | private final String code; 175 | 176 | private ORDER_STATUS(String code) { 177 | this.code = code; 178 | } 179 | public String getCode() { 180 | return code; 181 | } 182 | 183 | public static ORDER_STATUS getByCode(String code) { 184 | ORDER_STATUS type = null; 185 | 186 | for (int i = 0; i < ORDER_STATUS.values().length; i++) { 187 | type = ORDER_STATUS.values()[i]; 188 | if (type.getCode().equals(code)) { 189 | break; 190 | } 191 | } 192 | 193 | return type; 194 | } 195 | 196 | public static List> getKVPair() { 197 | ORDER_STATUS[] statuses = ORDER_STATUS.values(); 198 | List> kvPairList = new ArrayList>(statuses.length); 199 | HashMap kvPairMap = null; 200 | 201 | for (int i = 0; i < statuses.length; i++) { 202 | kvPairMap = new HashMap(2); 203 | kvPairMap.put("name", statuses[i].name()); 204 | kvPairMap.put("code", statuses[i].code); 205 | 206 | kvPairList.add(kvPairMap); 207 | } 208 | return kvPairList; 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/MarketServiceFactory.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange; 2 | 3 | import com.mumu.common.Constants; 4 | import com.mumu.exchange.market.BinanceMarketService; 5 | import com.mumu.exchange.market.CoinexMarketService; 6 | import com.mumu.exchange.market.HuobiMarketService; 7 | import com.mumu.exchange.market.IMarketService; 8 | import com.mumu.exchange.market.OkexMarketService; 9 | 10 | public class MarketServiceFactory { 11 | 12 | public static IMarketService getInstance(Constants.EXCHANGE_NAME exchange) { 13 | IMarketService iIMarketService = null; 14 | if (Constants.EXCHANGE_NAME.EXCHANGE_HOUBI.equals(exchange)) { 15 | iIMarketService = new HuobiMarketService(); 16 | } else if (Constants.EXCHANGE_NAME.EXCHANGE_COINEX.equals(exchange)) { 17 | iIMarketService = new CoinexMarketService(); 18 | } else if (Constants.EXCHANGE_NAME.EXCHANGE_OKEX.equals(exchange)) { 19 | iIMarketService = new OkexMarketService(); 20 | } else if (Constants.EXCHANGE_NAME.EXCHANGE_BINANCE.equals(exchange)) { 21 | iIMarketService = new BinanceMarketService(); 22 | } 23 | 24 | return iIMarketService; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/TradingServiceFactory.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange; 2 | 3 | import com.mumu.beans.AccountInfo; 4 | import com.mumu.beans.Cancel; 5 | import com.mumu.beans.GetOrder; 6 | import com.mumu.beans.ListOrders; 7 | import com.mumu.beans.Order; 8 | import com.mumu.exchange.common.Constants; 9 | import com.mumu.exchange.signature.BinanceParamsSigner; 10 | import com.mumu.exchange.signature.CoinexParamsSigner; 11 | import com.mumu.exchange.signature.HuobiParamsSigner; 12 | import com.mumu.exchange.signature.ISignature; 13 | import com.mumu.exchange.signature.OkexParamsSigner; 14 | import com.mumu.exchange.trading.BinanceTradingService; 15 | import com.mumu.exchange.trading.CoinexTradingService; 16 | import com.mumu.exchange.trading.HuobiTradingService; 17 | import com.mumu.exchange.trading.ITradingService; 18 | import com.mumu.exchange.trading.OkexTradingService; 19 | 20 | public class TradingServiceFactory { 21 | 22 | public static TradingServiceSPI getInstance(com.mumu.common.Constants.EXCHANGE_NAME exchange) { 23 | 24 | return new TradingServiceFactory.TradingServiceSPI(exchange); 25 | } 26 | 27 | public final static class TradingServiceSPI { 28 | 29 | private ITradingService tradingService; 30 | private ISignature signature; 31 | 32 | public TradingServiceSPI(com.mumu.common.Constants.EXCHANGE_NAME exchange) { 33 | if (com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI.equals(exchange)) { 34 | tradingService = new HuobiTradingService(); 35 | signature = new HuobiParamsSigner(); 36 | } else if (com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX.equals(exchange)) { 37 | tradingService = new CoinexTradingService(); 38 | signature = new CoinexParamsSigner(); 39 | } else if (com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX.equals(exchange)) { 40 | tradingService = new OkexTradingService(); 41 | signature = new OkexParamsSigner(); 42 | } else if (com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE.equals(exchange)) { 43 | tradingService = new BinanceTradingService(); 44 | signature = new BinanceParamsSigner(); 45 | } 46 | } 47 | 48 | public ISignature getSignature() { 49 | return signature; 50 | } 51 | 52 | /** 53 | * 54 | * @param clazz 55 | * @return 56 | */ 57 | public T getLocalTradingService(Class clazz) { 58 | 59 | return clazz.cast(tradingService); 60 | } 61 | 62 | // /** 63 | // * 64 | // * @param key 65 | // * @param value 66 | // * @return 67 | // */ 68 | // public TradingServiceSPI putParam(String key, String value) { 69 | // this.signature.putParam(key, value); 70 | // return this; 71 | // } 72 | // 73 | // /** 74 | // * 75 | // * @param params 76 | // * @return 77 | // */ 78 | // public TradingServiceSPI addAllParams(Map params) { 79 | // this.signature.addAllParams(params); 80 | // return this; 81 | // } 82 | // 83 | // /** 84 | // * 清空参数后,在保证线程安全的情况下,可以使用同一SPI实例请求其它接口 85 | // * @return 86 | // */ 87 | // public TradingServiceSPI clearParams() { 88 | // this.signature.clearParams(); 89 | // return this; 90 | // } 91 | 92 | /** 93 | * 94 | * @param accessKey 95 | * @param secretkey 96 | * @param accountId 可以传本地ID,用来标识返回数据所有者 97 | * @return 98 | */ 99 | public AccountInfo accountInfo(String accessKey, String secretkey, String accountId) { 100 | AccountInfo accountInfo = this.tradingService.accountInfo(accessKey, secretkey, signature); 101 | accountInfo.setAccountId(accountId); 102 | return accountInfo; 103 | } 104 | 105 | // public String orders(String accessKey, String secretkey) { 106 | // return this.tradingService.orders(accessKey, secretkey, signature); 107 | // } 108 | 109 | /** 110 | * h:{"status":"error","err-code":"account-frozen-balance-insufficient-error","err-msg":"余额不足,剩余:`0.0005`","data":null} 111 | * h:{"status":"ok","data":"10721786675"} 112 | * c:{ "code": 23, "data": {}, "message": "IP:66.42.71.205 is not allowed"} { "code": 107, "data": {}, "message": "Balance insufficient."} 113 | c: { 114 | "code": 0, 115 | "data": { 116 | "amount": "232.56235465", 117 | "asset_fee": "0", 118 | "avg_price": "0.00", 119 | "create_time": 1534845385, 120 | "deal_amount": "0", 121 | "deal_fee": "0", 122 | "deal_money": "0", 123 | "fee_asset": null, 124 | "fee_discount": "0", 125 | "id": 1371225525, 126 | "left": "232.56235465", 127 | "maker_fee_rate": "0.001", 128 | "market": "CETBCH", 129 | "order_type": "limit", 130 | "price": "0.00001880", 131 | "source_id": "", 132 | "status": "not_deal", 133 | "taker_fee_rate": "0.001", 134 | "type": "buy" 135 | }, 136 | "message": "Ok" 137 | } 138 | * o:{"error_code":1002} 139 | * o:{"result":true,"order_id":53649387} 140 | * b:{"symbol":"ETHUSDT","orderId":106437085,"clientOrderId":"PtIGmuYsIa3uIz7fOh7i17","transactTime":1534847895782,"price":"380.00000000","origQty":"0.04000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","fills":[]} 141 | * b:请求异常 142 | * @return 143 | */ 144 | public Order.Response orders(Order order) { 145 | this.signature.addAllParams(tradingService.getOrdersParamsMap(order)); 146 | return this.tradingService.orders(order.getAccessKey(), order.getSecretkey(), signature); 147 | } 148 | 149 | /** 150 | * 151 | * @param accessKey 152 | * @param secretkey 153 | * @return 154 | */ 155 | public Cancel.Response cancel(Cancel cancel) { 156 | this.signature.addAllParams(this.tradingService.getCancelParamsMap(cancel)); 157 | return this.tradingService.cancel(cancel.getAccessKey(), cancel.getSecretkey(), signature); 158 | } 159 | 160 | public GetOrder.Response orderInfo(GetOrder getOrder) { 161 | this.signature.addAllParams(this.tradingService.getGetOrderParamsMap(getOrder)); 162 | return this.tradingService.orderInfo(getOrder.getAccessKey(), getOrder.getSecretkey(), signature); 163 | } 164 | 165 | public ListOrders.Response unmatchedList(ListOrders listOrders) { 166 | this.signature.addAllParams(this.tradingService.getListUnMatchedParamsMap(listOrders)); 167 | return this.tradingService.unmatchedList(listOrders.getAccessKey(), listOrders.getSecretkey(), signature); 168 | } 169 | 170 | // public String dealtList(String accessKey, String secretkey, ISignature signature); 171 | 172 | public String historyList(String accessKey, String secretkey) { 173 | return this.tradingService.historyList(accessKey, secretkey, signature); 174 | } 175 | 176 | public String depositList(String accessKey, String secretkey) { 177 | return this.tradingService.depositList(accessKey, secretkey, signature); 178 | } 179 | 180 | public String withdrawList(String accessKey, String secretkey) { 181 | return this.tradingService.withdrawList(accessKey, secretkey, signature); 182 | } 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/api/BinanceAPI.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.api; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public final class BinanceAPI { 7 | 8 | //API-keys are passed into the Rest API via the X-MBX-APIKEY header. 9 | public static final String API_SIGN_KEY_AccessKeyId = "X-MBX-APIKEY"; 10 | public static final String API_SIGN_KEY_Secret_key = "secret_key"; 11 | public static final String API_SIGN_SignatureMethod = "HMACSHA256"; 12 | public static final String API_SIGN_KEY_authorization = "signature"; 13 | public static final String API_SIGN_KEY_Timestamp = "timestamp"; 14 | public static final String API_SIGN_KEY_recvWindow = "recvWindow";// 15 | public static final String API_SIGN_DEFVAL_recvWindow = "5000";// 16 | 17 | private static Map uriMethodMap = new HashMap(); 18 | public static final String rest_trading_root = "https://api.binance.com";//https://api.binance.com/api/v1/exchangeInfo 19 | public static final String ws_root = "wss://stream.binance.com:9443"; 20 | 21 | 22 | /** 23 | * 用户资产API 24 | */ 25 | public static final String api_account = "/api/v3/account"; 26 | public static final String api_account_method_get = "GET"; 27 | static { uriMethodMap.put(api_account, api_account_method_get); } 28 | public static enum Api_userinfo_params { 29 | 30 | } 31 | 32 | /** 33 | * POST /api/v3/order (HMAC SHA256) 34 | * Send in a new order. 35 | * Weight: 1 36 | */ 37 | public static final String api_order = "/api/v3/order"; 38 | public static final String api_order_method_post = "POST"; 39 | static { uriMethodMap.put(api_order, api_order_method_post); } 40 | public static enum Api_order_params { 41 | symbol("symbol"),// STRING YES 42 | side("side"),// ENUM YES 43 | type("type"),// ENUM YES 44 | timeInForce("timeInForce"),// ENUM NO 45 | quantity("quantity"),/// DECIMAL YES 46 | price("price"),// DECIMAL NO 47 | newClientOrderId("newClientOrderId"),// STRING NO A unique id for the order. Automatically generated if not sent. 48 | stopPrice("stopPrice"), //DECIMAL NO Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. 49 | icebergQty("icebergQty"),// DECIMAL NO Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order. 50 | newOrderRespType("newOrderRespType");// ENUM NO Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK. 51 | // recvWindow("recvWindow" LONG NO 52 | // timestamp LONG YES 53 | 54 | private final String code; 55 | 56 | private Api_order_params(String code) { 57 | this.code = code; 58 | } 59 | public String getCode() { 60 | return code; 61 | } 62 | } 63 | 64 | /** 65 | * Cancel order (TRADE) 66 | * DELETE /api/v3/order (HMAC SHA256) 67 | * Cancel an active order. 68 | */ 69 | public static final String api_cancel_order = "/api/v3/order"; 70 | public static final String api_cancel_order_alias = "api_cancel_order"; 71 | public static final String api_cancel_order_method_delete = "DELETE"; 72 | static { uriMethodMap.put(api_cancel_order_alias, api_cancel_order_method_delete); } 73 | public static enum Api_cancel_order_params { 74 | symbol("symbol"),// STRING YES 75 | orderId("orderId"),// LONG NO 76 | origClientOrderId("origClientOrderId"),// STRING NO 77 | newClientOrderId("newClientOrderId");// STRING NO Used to uniquely identify this cancel. Automatically generated by default. 78 | 79 | private final String code; 80 | 81 | private Api_cancel_order_params(String code) { 82 | this.code = code; 83 | } 84 | public String getCode() { 85 | return code; 86 | } 87 | } 88 | 89 | /** 90 | * GET /api/v3/order (HMAC SHA256) 91 | * Check an order's status. 92 | * Weight: 1 93 | */ 94 | public static final String api_get_order = "/api/v3/order"; 95 | public static final String api_get_order_alias = "api_get_order"; 96 | public static final String api_get_order_method_get = "GET"; 97 | static { uriMethodMap.put(api_get_order_alias, api_get_order_method_get); } 98 | public static enum Api_get_order_params { 99 | symbol("symbol"),// STRING YES 100 | orderId("orderId"),// LONG NO 101 | origClientOrderId("origClientOrderId");// STRING NO 102 | 103 | private final String code; 104 | 105 | private Api_get_order_params(String code) { 106 | this.code = code; 107 | } 108 | public String getCode() { 109 | return code; 110 | } 111 | } 112 | 113 | 114 | /** 115 | * 116 | *GET /api/v3/openOrders (HMAC SHA256) 117 | *Get all open orders on a symbol. Careful when accessing this with no symbol. 118 | *Weight: 1 for a single symbol; 40 when the symbol parameter is omitted 119 | *If the symbol is not sent, orders for all symbols will be returned in an array. 120 | When all symbols are returned, the number of requests counted against the rate limiter is equal to the number of symbols currently trading on the exchange. 121 | */ 122 | public static final String api_openOrders = "/api/v3/openOrders"; 123 | public static final String api_openOrders_method_get = "GET"; 124 | static { uriMethodMap.put(api_openOrders, api_openOrders_method_get); } 125 | public static enum Api_openOrders_params { 126 | symbol("symbol"); 127 | 128 | private final String code; 129 | 130 | private Api_openOrders_params(String code) { 131 | this.code = code; 132 | } 133 | public String getCode() { 134 | return code; 135 | } 136 | } 137 | 138 | /** 139 | * GET /api/v3/allOrders (HMAC SHA256) 140 | * Get all account orders; active, canceled, or filled. 141 | * Weight: 5 with symbol 142 | */ 143 | public static final String api_allOrders = "/api/v3/allOrders"; 144 | public static final String api_allOrders_method_get = "GET"; 145 | static { uriMethodMap.put(api_allOrders, api_allOrders_method_get); } 146 | public static enum Api_allOrders_params { 147 | symbol("symbol"), 148 | orderId("orderId"), //LONG NO 149 | startTime("startTime"), //LONG NO 150 | endTime("endTime"), //LONG NO 151 | limit("limit");// INT NO Default 500; max 1000. 152 | 153 | private final String code; 154 | 155 | private Api_allOrders_params(String code) { 156 | this.code = code; 157 | } 158 | public String getCode() { 159 | return code; 160 | } 161 | } 162 | 163 | /** 164 | * GET /wapi/v3/depositHistory.html (HMAC SHA256) 165 | Fetch deposit history. 166 | Weight: 1 167 | * 168 | */ 169 | public static final String wapi_depositHistory = "/wapi/v3/depositHistory.html"; 170 | public static final String wapi_depositHistory_method_get = "GET"; 171 | static { uriMethodMap.put(wapi_depositHistory, wapi_depositHistory_method_get); } 172 | public static enum Wapi_depositHistory_params { 173 | asset("asset"),// STRING NO 174 | status("status"),// INT NO 0(0:pending,1:success) 175 | startTime("startTime"),// LONG NO 176 | endTime("endTime");// LONG NO 177 | 178 | private final String code; 179 | 180 | private Wapi_depositHistory_params(String code) { 181 | this.code = code; 182 | } 183 | public String getCode() { 184 | return code; 185 | } 186 | } 187 | 188 | 189 | /** 190 | * GET /wapi/v3/withdrawHistory.html (HMAC SHA256) 191 | * Fetch withdraw history. 192 | * Weight: 1 193 | */ 194 | public static final String wapi_withdrawHistory = "/wapi/v3/withdrawHistory.html"; 195 | public static final String wapi_withdrawHistory_method_get = "GET"; 196 | static { uriMethodMap.put(wapi_withdrawHistory, wapi_withdrawHistory_method_get); } 197 | public static enum Wapi_withdrawHistory_params { 198 | asset("asset"),// STRING NO 199 | status("status"),// INT NO (0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6Completed) 200 | startTime("startTime"),// LONG NO 201 | endTime("endTime");// LONG NO 202 | 203 | private final String code; 204 | 205 | private Wapi_withdrawHistory_params(String code) { 206 | this.code = code; 207 | } 208 | public String getCode() { 209 | return code; 210 | } 211 | } 212 | 213 | /** 214 | * GET /api/v1/ticker/24hr 215 | 24 hour price change statistics. Careful when accessing this with no symbol. 216 | Weight: 1 for a single symbol; 40 when the symbol parameter is omitted 217 | */ 218 | public static final String api_ticker_24hr = "/api/v1/ticker/24hr"; 219 | public static final String api_ticker_24hr_method_get = "GET"; 220 | static { uriMethodMap.put(api_ticker_24hr, api_ticker_24hr_method_get); } 221 | public static enum Api_ticker_24hr_params { 222 | symbol("symbol");// STRING NO 223 | 224 | private final String code; 225 | 226 | private Api_ticker_24hr_params(String code) { 227 | this.code = code; 228 | } 229 | public String getCode() { 230 | return code; 231 | } 232 | } 233 | 234 | 235 | /** 236 | * Recent trades list 237 | *GET /api/v1/trades 238 | *Get recent trades (up to last 500). 239 | */ 240 | public static final String api_trades = "/api/v1/trades"; 241 | public static final String api_trades_method_get = "GET"; 242 | static { uriMethodMap.put(api_trades, api_trades_method_get); } 243 | public static enum Api_trades_params { 244 | symbol("symbol"),// STRING YES 245 | limit("limit");// INT NO Default 500; max 1000. 246 | 247 | private final String code; 248 | 249 | private Api_trades_params(String code) { 250 | this.code = code; 251 | } 252 | public String getCode() { 253 | return code; 254 | } 255 | } 256 | 257 | public static String getMethodByApiUri(String uri) { 258 | return uriMethodMap.get(uri); 259 | } 260 | } 261 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/api/CoinexAPI.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.api; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public final class CoinexAPI { 7 | 8 | public static final String API_SIGN_KEY_AccessKeyId = "access_id"; 9 | public static final String API_SIGN_KEY_Secret_key = "secret_key"; 10 | public static final String API_SIGN_SignatureMethod = "32-bit MD5"; 11 | public static final String API_SIGN_KEY_Timestamp = "tonce"; 12 | public static final String API_SIGN_KEY_authorization = "authorization"; 13 | 14 | private static Map uriMethodMap = new HashMap(); 15 | public static final String rest_trading_root = "https://api.coinex.com"; 16 | public static final String ws_root = "wss://socket.coinex.com"; 17 | 18 | 19 | /** 20 | * 用户资产API 21 | */ 22 | public static final String balance_info = "/v1/balance/info"; 23 | public static final String balance_info_method_get = "GET"; 24 | static { uriMethodMap.put(balance_info, balance_info_method_get); } 25 | public static enum Balance_info_params { 26 | 27 | } 28 | 29 | /** 30 | * Place Limit Order 31 | * Request description:place limit order. 32 | * Request type: POST 33 | * Signature required: Yes 34 | * Request Header: 35 | * authorization:"xxxx" (32-digit capital letters, see generating methos in ) 36 | * Request Url:https://api.coinex.com/v1/order/limit 37 | */ 38 | public static final String order_path$orderType = "/v1/order/{path$orderType}"; 39 | public static final String order_path$orderType_method_post = "POST"; 40 | static { uriMethodMap.put(order_path$orderType, order_path$orderType_method_post); } 41 | public static enum Order_path$orderType_params { 42 | path$orderType("{path$orderType}"), 43 | // access_id String Yes access_id 44 | market("market"),// String Yes See 45 | type("type"),// String Yes sell: sell order; buy: buy order; 46 | amount("amount"),// String Yes order amount, min. 0.001, accurate to 8 decimal places 47 | price("price"),// String Yes order amount, accurate to 8 decimal places 48 | source_id("source_id");// String no user defines number and return 49 | // tonce Integer Yes Tonce is a timestamp with a positive Interger that represents the number of milliseconds from Unix epoch to the current time. Error between tonce and server time can not exceed plus or minus 60s 50 | 51 | private final String code; 52 | 53 | private Order_path$orderType_params(String code) { 54 | this.code = code; 55 | } 56 | public String getCode() { 57 | return code; 58 | } 59 | } 60 | 61 | /** 62 | * Cancel Order 63 | * Request description: Cancel unexecuted order. 64 | * Request type: DELETE 65 | * Signature required: Yes 66 | * Request Header: authorization:"xxxx" (32-digit capital letters, see generating methos in ) 67 | * Request Url:https://api.coinex.com/v1/order/pending 68 | */ 69 | public static final String order_pending = "/v1/order/pending"; 70 | public static final String order_pending_method_delete = "DELETE"; 71 | static { uriMethodMap.put(order_pending, order_pending_method_delete); } 72 | public static enum Order_pending_params { 73 | // access_id String Yes access_id 74 | id("id"),// Integer Yes Unexecuted order No 75 | market("market");// String Yes See 76 | // tonce Integer Yes 77 | 78 | private final String code; 79 | 80 | private Order_pending_params(String code) { 81 | this.code = code; 82 | } 83 | public String getCode() { 84 | return code; 85 | } 86 | } 87 | 88 | 89 | /** 90 | * Acquire Order Status 91 | * Request description: Acquire order status. 92 | Request type: GET 93 | Signature required: Yes 94 | Request Header: 95 | authorization:"xxxx" (32-digit capital letters, see generating methos in ) 96 | Request Url:https://api.coinex.com/v1/order/status 97 | */ 98 | public static final String order_status = "/v1/order/status"; 99 | public static final String order_status_method_get = "GET"; 100 | static { uriMethodMap.put(order_status, order_status_method_get); } 101 | public static enum Order_status_params { 102 | // access_id String Yes access_id 103 | id("id"),// Integer Yes Unexecuted order No 104 | market("market");// String Yes See 105 | // tonce Integer Yes 106 | 107 | private final String code; 108 | 109 | private Order_status_params(String code) { 110 | this.code = code; 111 | } 112 | public String getCode() { 113 | return code; 114 | } 115 | } 116 | 117 | /** 118 | * Acquire Unexecuted Order List 119 | Request description: Acquire Unexecuted Order List. 120 | Request type: GET 121 | Signature required: Yes 122 | Request Header: 123 | authorization:"xxxx" (32-digit capital letters, see generating methos in ) 124 | Request Url:https://api.coinex.com/v1/order/pending 125 | */ 126 | public static final String order_pending_list = "/v1/order/pending"; 127 | public static final String order_pending_list_alias = "order_pending_list"; 128 | public static final String order_pending_list_method_get = "GET"; 129 | static { uriMethodMap.put(order_pending_list_alias, order_pending_list_method_get); } 130 | public static enum Order_pending_list_params { 131 | // access_id String Yes access_id 132 | market("market"),// String Yes See 133 | page("page"),// Interger Yes Page, start from 1 134 | limit("limit");// Interger Yes Amount per page(1-100) 135 | // tonce Integer Yes 136 | 137 | private final String code; 138 | 139 | private Order_pending_list_params(String code) { 140 | this.code = code; 141 | } 142 | public String getCode() { 143 | return code; 144 | } 145 | } 146 | 147 | /** 148 | * Acquire Executed Order List 149 | Request description: Acquire executed order list, including datas in last 2 days. 150 | Request type: GET 151 | Signature required: Yes 152 | Request Header: 153 | authorization:"xxxx" (32-digit capital letters, see generating methos in ) 154 | Request Url:https://api.coinex.com/v1/order/finished 155 | */ 156 | public static final String order_finished = "/v1/order/finished"; 157 | public static final String order_finished_method_get = "GET"; 158 | static { uriMethodMap.put(order_finished, order_finished_method_get); } 159 | public static enum Order_finished_params { 160 | // access_id String Yes access_id 161 | market("market"),// String Yes See 162 | page("page"),// Interger Yes Page, start from 1 163 | limit("limit");// Interger Yes Amount per page(1-100) 164 | // tonce Integer Yes 165 | 166 | private final String code; 167 | 168 | private Order_finished_params(String code) { 169 | this.code = code; 170 | } 171 | public String getCode() { 172 | return code; 173 | } 174 | } 175 | 176 | /** 177 | * Request description: Acquire real-time market data 178 | Request type: GET 179 | Signature required: No 180 | Request Url: https://api.coinex.com/v1/market/ticker?market=BTCBCH 181 | */ 182 | public static final String market_ticker = "/v1/market/ticker"; 183 | public static final String market_ticker_method_get = "GET"; 184 | static { uriMethodMap.put(market_ticker, market_ticker_method_get); } 185 | public static enum Market_ticker_params { 186 | market("market");// String Yes See 187 | 188 | private final String code; 189 | 190 | private Market_ticker_params(String code) { 191 | this.code = code; 192 | } 193 | public String getCode() { 194 | return code; 195 | } 196 | } 197 | 198 | 199 | /** 200 | * Acquire Latest Transaction Data 201 | Request description: Acquire latest transaction data,return up to 1000 202 | Request type: GET 203 | Signature required: No 204 | Request Url:https://api.coinex.com/v1/market/deals 205 | * 206 | */ 207 | public static final String market_deals = "/v1/market/deals"; 208 | public static final String market_deals_method_get = "GET"; 209 | static { uriMethodMap.put(market_deals, market_deals_method_get); } 210 | public static enum Market_deals_params { 211 | market("market"),// String Yes See 212 | last_id("last_id");// Interger No Transaction history id, send 0 to draw from the latest record. 213 | 214 | private final String code; 215 | 216 | private Market_deals_params(String code) { 217 | this.code = code; 218 | } 219 | public String getCode() { 220 | return code; 221 | } 222 | } 223 | 224 | public static String getMethodByApiUri(String uri) { 225 | return uriMethodMap.get(uri); 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/api/HoubiAPI.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.api; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public final class HoubiAPI { 7 | 8 | // POST请求头信息中必须声明 Content-Type:application/json; 9 | // GET请求头信息中必须声明 Content-Type:application/x-www-form-urlencoded。 10 | // (汉语用户建议设置 Accept-Language:zh-cn) 11 | // 12 | // 请务必在header中设置user agent为 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36' 13 | 14 | public static final String API_SIGN_KEY_AccessKeyId = "AccessKeyId";//=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx 15 | public static final String API_SIGN_KEY_SignatureMethod = "SignatureMethod";//=HmacSHA256 16 | public static final String API_SIGN_SignatureMethod = "HmacSHA256";//=HmacSHA256 17 | public static final String API_SIGN_KEY_SignatureVersion = "SignatureVersion";//=2 18 | public static final String API_SIGN_SignatureVersion = "2";//=2 19 | public static final String API_SIGN_KEY_Timestamp = "Timestamp";//=2017-05-11T15%3A19%3A30 20 | 21 | private static Map uriMethodMap = new HashMap(); 22 | public static final String rest_market_root = "https://api.huobi.pro"; 23 | public static final String rest_trading_root = "https://api.huobi.pro";//https://api.huobi.pro/v1/common/symbols 24 | public static final String ws_root = "wss://api.huobi.pro/ws"; 25 | 26 | 27 | /** 28 | * 用户资产API 29 | */ 30 | public static final String account_accounts = "/v1/account/accounts"; 31 | public static final String account_accounts_method_get = "GET"; 32 | static { uriMethodMap.put(account_accounts, account_accounts_method_get); } 33 | public static enum Account_accounts_params { 34 | 35 | } 36 | 37 | /** 38 | * 下单 39 | */ 40 | public static final String order_orders_place = "/v1/order/orders/place"; 41 | public static final String order_orders_place_method_post = "POST"; 42 | static { uriMethodMap.put(order_orders_place, order_orders_place_method_post); } 43 | public static enum Order_orders_place_params { 44 | // true string 账户 ID,使用accounts方法获得。币币交易使用‘spot’账户的accountid;借贷资产交易,请使用‘margin’账户的accountid 45 | account_id("account-id"), 46 | // true string 限价单表示下单数量,市价买单时表示买多少钱,市价卖单时表示卖多少币 47 | amount("amount"), 48 | // false string 下单价格,市价单不传该参数 49 | price("price"), 50 | // false string 订单来源 api,如果使用借贷资产交易,请填写‘margin-api’ 51 | source("source"), 52 | // true string 交易对 btcusdt, bchbtc, rcneth ... 53 | symbol("symbol"), 54 | // true string 订单类型 buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖, buy-ioc:IOC买单, sell-ioc:IOC卖单, buy-limit-maker, sell-limit-maker(详细说明见下) 55 | type("type"); 56 | 57 | private final String code; 58 | 59 | private Order_orders_place_params(String code) { 60 | this.code = code; 61 | } 62 | public String getCode() { 63 | return code; 64 | } 65 | } 66 | 67 | 68 | /** 69 | * 取消 70 | * /v1/order/orders/{order-id}/submitcancel 71 | */ 72 | public static final String order_orders_path$orderId_submitcancel = "/v1/order/orders/{path$orderId}/submitcancel"; 73 | public static final String order_orders_path$orderId_submitcancel_method_post = "POST"; 74 | static { uriMethodMap.put(order_orders_path$orderId_submitcancel, order_orders_path$orderId_submitcancel_method_post); } 75 | public static enum Order_orders_path$orderId_submitcancel_params { 76 | path$orderId("{path$orderId}"); 77 | 78 | private final String code; 79 | 80 | private Order_orders_path$orderId_submitcancel_params(String code) { 81 | this.code = code; 82 | } 83 | public String getCode() { 84 | return code; 85 | } 86 | 87 | } 88 | 89 | /** 90 | * 订单信息 91 | * GET /v1/order/orders/{order-id} 92 | */ 93 | public static final String order_orders_path$orderId = "/v1/order/orders/{path$orderId}"; 94 | public static final String order_orders_path$orderId_method_get = "GET"; 95 | static { uriMethodMap.put(order_orders_path$orderId, order_orders_path$orderId_method_get); } 96 | public static enum Order_orders_path$orderId_params { 97 | path$orderId("{path$orderId}"); 98 | 99 | private final String code; 100 | 101 | private Order_orders_path$orderId_params(String code) { 102 | this.code = code; 103 | } 104 | public String getCode() { 105 | return code; 106 | } 107 | 108 | } 109 | 110 | /** 111 | * GET /v1/order/openOrders 获取所有当前帐号下未成交订单 112 | * “account-id” 和 “symbol” 需同时指定或者二者都不指定。如果二者都不指定,返回最多500条尚未成交订单,按订单号降序排列。 113 | */ 114 | public static final String order_openOrders = "/v1/order/openOrders"; 115 | public static final String order_openOrders_method_get = "GET"; 116 | static { uriMethodMap.put(order_openOrders, order_openOrders_method_get); } 117 | public static enum Order_openOrders_params { 118 | // true string 账号ID 119 | account_id("account-id"), 120 | // true string 交易对 单个交易对字符串,缺省将返回所有符合条件尚未成交订单 121 | symbol("symbol"), 122 | // false string 主动交易方向 “buy”或者“sell”,缺省将返回所有符合条件尚未成交订单 123 | side("side"), 124 | // false int 所需返回记录数 10 [0,500] 125 | size("size"); 126 | 127 | private final String code; 128 | 129 | private Order_openOrders_params(String code) { 130 | this.code = code; 131 | } 132 | public String getCode() { 133 | return code; 134 | } 135 | 136 | } 137 | 138 | /** 139 | * GET /v1/order/orders 查询当前委托、历史委托 140 | */ 141 | public static final String order_orders = "/v1/order/orders"; 142 | public static final String order_orders_method_get = "GET"; 143 | static { uriMethodMap.put(order_orders, order_orders_method_get); } 144 | public static enum Order_orders_params { 145 | //true string 交易对 btcusdt, bchbtc, rcneth ... 146 | symbol("symbol"), 147 | //false string 查询的订单类型组合,使用','分割 buy-market:市价买, sell-market:市价卖, buy-limit:限价买, sell-limit:限价卖, buy-ioc:IOC买单, sell-ioc:IOC卖单 148 | types("types"), 149 | //false string 查询开始日期, 日期格式yyyy-mm-dd 150 | start_date("start-date"), 151 | //false string 查询结束日期, 日期格式yyyy-mm-dd 152 | end_date("end-date"), 153 | //true string 查询的订单状态组合,使用','分割 submitted 已提交, partial-filled 部分成交, partial-canceled 部分成交撤销, filled 完全成交, canceled 已撤销 154 | states("states"), 155 | //false string 查询起始 ID 156 | from("from"), 157 | //false string 查询方向 prev 向前,next 向后 158 | direct("direct"), 159 | //false string 查询记录大小 160 | size("size"); 161 | 162 | private final String code; 163 | 164 | private Order_orders_params(String code) { 165 | this.code = code; 166 | } 167 | public String getCode() { 168 | return code; 169 | } 170 | 171 | } 172 | 173 | /** 174 | * GET /v1/query/deposit-withdraw 查询虚拟币充提记录 175 | */ 176 | public static final String query_deposit_withdraw = "/v1/query/deposit-withdraw"; 177 | public static final String query_deposit_withdraw_method_get = "GET"; 178 | static { uriMethodMap.put(query_deposit_withdraw, query_deposit_withdraw_method_get); } 179 | public static enum Query_deposit_withdraw_params { 180 | //true string 币种 181 | currency("currency"), 182 | // //true string 'deposit' or 'withdraw' 183 | type("type"), 184 | //false string 查询起始 ID 185 | from("from"), 186 | //false string 查询记录大小 187 | size("size"); 188 | 189 | private final String code; 190 | 191 | private Query_deposit_withdraw_params(String code) { 192 | this.code = code; 193 | } 194 | public String getCode() { 195 | return code; 196 | } 197 | 198 | } 199 | 200 | 201 | 202 | /** 203 | * 查询Pro站指定账户的余额 204 | * /v1/account/accounts/4276741/balance 205 | */ 206 | public static final String accounts_p$accountId_balance = "/v1/account/accounts/{path$accountId}/balance"; 207 | public static final String accounts_p$accountId_balance_method_get = "GET"; 208 | static { uriMethodMap.put(accounts_p$accountId_balance, accounts_p$accountId_balance_method_get); } 209 | public static enum Accounts_p$accountId_balance_params { 210 | path$accountId("{path$accountId}"); 211 | 212 | private final String code; 213 | 214 | private Accounts_p$accountId_balance_params(String code) { 215 | this.code = code; 216 | } 217 | public String getCode() { 218 | return code; 219 | } 220 | 221 | } 222 | 223 | /** 224 | * GET /market/detail/merged 获取聚合行情(Ticker) 225 | */ 226 | public static final String market_detail_merged = "/market/detail/merged"; 227 | public static final String market_detail_merged_method_get = "GET"; 228 | static { uriMethodMap.put(market_detail_merged, market_detail_merged_method_get); } 229 | public static enum Market_detail_merged_params { 230 | symbol("symbol");// true string 交易对 btcusdt, bchbtc, rcneth ... 231 | 232 | private final String code; 233 | 234 | private Market_detail_merged_params(String code) { 235 | this.code = code; 236 | } 237 | public String getCode() { 238 | return code; 239 | } 240 | 241 | } 242 | 243 | /** 244 | * GET /market/history/trade 批量获取最近的交易记录 245 | */ 246 | public static final String market_history_trade = "/market/history/trade"; 247 | public static final String market_history_trade_method_get = "GET"; 248 | static { uriMethodMap.put(market_history_trade, market_history_trade_method_get); } 249 | public static enum Market_history_trade_params { 250 | symbol("symbol"),// true string 交易对 btcusdt, bchbtc, rcneth ... 251 | size("size");// false integer 获取交易记录的数量 1 [1, 2000] 252 | 253 | private final String code; 254 | 255 | private Market_history_trade_params(String code) { 256 | this.code = code; 257 | } 258 | public String getCode() { 259 | return code; 260 | } 261 | 262 | } 263 | 264 | public static String getMethodByApiUri(String uri) { 265 | return uriMethodMap.get(uri); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/api/OkexAPI.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.api; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public final class OkexAPI { 7 | 8 | 9 | public static final String API_SIGN_KEY_AccessKeyId = "api_key"; 10 | public static final String API_SIGN_KEY_Secret_key = "secret_key"; 11 | public static final String API_SIGN_SignatureMethod = "32-bit MD5"; 12 | public static final String API_SIGN_KEY_authorization = "sign"; 13 | 14 | private static Map uriMethodMap = new HashMap(); 15 | public static final String rest_trading_root = "https://www.okex.com"; 16 | public static final String ws_root = "wss://real.okex.com:10441/websocket"; 17 | 18 | 19 | /** 20 | * 用户资产API 21 | */ 22 | public static final String api_userinfo = "/api/v1/userinfo.do"; 23 | public static final String api_userinfo_method_post = "POST"; 24 | static { uriMethodMap.put(api_userinfo, api_userinfo_method_post); } 25 | public static enum Api_userinfo_params { 26 | 27 | } 28 | 29 | /** 30 | * POST /api/v1/trade 下单交易 31 | * URL https://www.okex.com/api/v1/trade.do 访问频率 20次/2秒 32 | */ 33 | public static final String api_trade = "/api/v1/trade.do"; 34 | public static final String api_trade_method_post = "POST"; 35 | static { uriMethodMap.put(api_trade, api_trade_method_post); } 36 | public static enum Api_trade_params { 37 | // api_key String 是 用户申请的apiKey 38 | symbol("symbol"),// String 是 币对如ltc_btc 39 | type("type"),// String 是 买卖类型:限价单(buy/sell) 市价单(buy_market/sell_market) 40 | price("price"),// Double 否 下单价格 市价卖单不传price 41 | amount("amount");// Double 否 交易数量 市价买单不传amount,市价买单需传price作为买入总金额 42 | // sign String 是 请求参数的签名 43 | 44 | private final String code; 45 | 46 | private Api_trade_params(String code) { 47 | this.code = code; 48 | } 49 | public String getCode() { 50 | return code; 51 | } 52 | } 53 | 54 | /** 55 | * POST /api/v1/cancel_order 撤销订单 56 | * URL https://www.okex.com/api/v1/cancel_order.do 访问频率 20次/2秒 57 | * result:true撤单请求成功,等待系统执行撤单;false撤单失败(用于单笔订单) 58 | * order_id:订单ID(用于单笔订单) 59 | * success:撤单请求成功的订单ID,等待系统执行撤单(用于多笔订单) 60 | * error:撤单请求失败的订单ID(用户多笔订单) 61 | */ 62 | public static final String api_cancel_order = "/api/v1/cancel_order.do"; 63 | public static final String api_cancel_order_method_post = "POST"; 64 | static { uriMethodMap.put(api_cancel_order, api_cancel_order_method_post); } 65 | public static enum Api_cancel_order_params { 66 | // api_key String 是 用户申请的apiKey 67 | symbol("symbol"),// String 是 币对如ltc_btc 68 | order_id("order_id");// 订单ID(多个订单ID中间以","分隔,一次最多允许撤消3个订单) 69 | // sign String 是 请求参数的签名 70 | 71 | private final String code; 72 | 73 | private Api_cancel_order_params(String code) { 74 | this.code = code; 75 | } 76 | public String getCode() { 77 | return code; 78 | } 79 | } 80 | 81 | /** 82 | * POST /api/v1/order_info 获取用户的订单信息 83 | * URL https://www.okex.com/api/v1/order_info.do 访问频率 20次/2秒(未成交) 84 | */ 85 | public static final String api_order_info = "/api/v1/order_info.do"; 86 | public static final String api_order_info_method_post = "POST"; 87 | static { uriMethodMap.put(api_order_info, api_order_info_method_post); } 88 | public static enum Api_order_info_params { 89 | // api_key String 是 用户申请的apiKey 90 | symbol("symbol"),// String 是 币对如ltc_btc 91 | order_id("order_id");// 订单ID -1:未完成订单,否则查询相应订单号的订单 92 | // sign String 是 请求参数的签名 93 | 94 | private final String code; 95 | 96 | private Api_order_info_params(String code) { 97 | this.code = code; 98 | } 99 | public String getCode() { 100 | return code; 101 | } 102 | } 103 | 104 | /** 105 | * POST /api/v1/orders_info 批量获取用户订单 106 | * URL https://www.okex.com/api/v1/orders_info.do 访问频率 20次/2秒 107 | */ 108 | public static final String api_orders_info = "/api/v1/orders_info.do"; 109 | public static final String api_orders_info_method_post = "POST"; 110 | static { uriMethodMap.put(api_orders_info, api_orders_info_method_post); } 111 | public static enum Api_orders_info_params { 112 | // api_key String 是 用户申请的apiKey 113 | type("type"),// Integer 是 查询类型 0:未完成的订单 1:已经完成的订单 114 | symbol("symbol"),// String 是 币对如ltc_btc 115 | order_id("order_id");// 订单ID(多个订单ID中间以","分隔,一次最多允许查询50个订单) 116 | // sign String 是 请求参数的签名 117 | 118 | private final String code; 119 | 120 | private Api_orders_info_params(String code) { 121 | this.code = code; 122 | } 123 | public String getCode() { 124 | return code; 125 | } 126 | } 127 | 128 | /** 129 | * POST /api/v1/order_history 获取历史订单信息,只返回最近两天的信息 130 | * URL https://www.okex.com/api/v1/order_history.do 131 | */ 132 | public static final String api_order_history = "/api/v1/order_history.do"; 133 | public static final String api_order_history_method_post = "POST"; 134 | static { uriMethodMap.put(api_order_history, api_order_history_method_post); } 135 | public static enum Api_order_history_params { 136 | // api_key String 是 用户申请的apiKey 137 | symbol("symbol"),// String 是 币对如ltc_btc 138 | status("status"),// Integer 是 查询状态 0:未完成的订单 1:已经完成的订单(最近两天的数据) 139 | current_page("current_page"),// Integer 是 当前页数 140 | page_length("page_length");// Integer 是 每页数据条数,最多不超过200 141 | // sign String 是 请求参数的签名 142 | 143 | private final String code; 144 | 145 | private Api_order_history_params(String code) { 146 | this.code = code; 147 | } 148 | public String getCode() { 149 | return code; 150 | } 151 | } 152 | 153 | /** 154 | * Get /api/v1/ticker 获取OKEx币币行情 155 | URL https://www.okex.com/api/v1/ticker.do 156 | * @param uri 157 | * @return 158 | */ 159 | public static final String api_ticker = "/api/v1/ticker.do"; 160 | public static final String api_ticker_method_get = "GET"; 161 | static { uriMethodMap.put(api_ticker, api_ticker_method_get); } 162 | public static enum Api_ticker_params { 163 | symbol("symbol");// String 是 币对如ltc_btc 164 | 165 | private final String code; 166 | 167 | private Api_ticker_params(String code) { 168 | this.code = code; 169 | } 170 | public String getCode() { 171 | return code; 172 | } 173 | } 174 | 175 | /** 176 | * Get /api/v1/trades 获取OKEx币币交易信息(60条) 177 | URL https://www.okex.com/api/v1/trades.do 178 | */ 179 | public static final String api_trades = "/api/v1/trades.do"; 180 | public static final String Api_trades_method_get = "GET"; 181 | static { uriMethodMap.put(api_trades, Api_trades_method_get); } 182 | public static enum Api_trades_params { 183 | symbol("symbol"), //String 是 币对如ltc_btc 184 | since("since");// Long 否(默认返回最近成交60条) tid:交易记录ID(返回数据不包括当前tid值,最多返回60条数据) 185 | 186 | private final String code; 187 | 188 | private Api_trades_params(String code) { 189 | this.code = code; 190 | } 191 | public String getCode() { 192 | return code; 193 | } 194 | } 195 | 196 | public static String getMethodByApiUri(String uri) { 197 | return uriMethodMap.get(uri); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/coins/BinanceProfiles.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.coins; 2 | 3 | import org.apache.http.client.fluent.Request; 4 | public class BinanceProfiles { 5 | 6 | /** 7 | * All requests based on the Https protocol should set the request header information Content-Type as:'application/json’. 8 | * Request header information must be declared: 9 | * User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 10 | * Request submission frequency: 20 times per second per IP (for Trading and Account API); no limit on Market API 11 | * 12 | * @param request 13 | */ 14 | public static void addHeader(Request request, String method) { 15 | request.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); 16 | request.addHeader("Content-Type", "application/x-www-form-urlencoded"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/coins/CoinexProfiles.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.coins; 2 | 3 | import org.apache.http.client.fluent.Request; 4 | 5 | public class CoinexProfiles { 6 | 7 | /** 8 | * All requests based on the Https protocol should set the request header information Content-Type as:'application/json’. 9 | * Request header information must be declared: 10 | * User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 11 | * Request submission frequency: 20 times per second per IP (for Trading and Account API); no limit on Market API 12 | * 13 | * @param request 14 | */ 15 | public static void addHeader(Request request, String method) { 16 | request.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); 17 | request.addHeader("Content-Type", "application/json"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/coins/HuobiProfiles.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.coins; 2 | 3 | import org.apache.http.client.fluent.Request; 4 | public class HuobiProfiles { 5 | 6 | /** 7 | * POST请求头信息中必须声明 Content-Type:application/json; 8 | * GET请求头信息中必须声明 Content-Type:application/x-www-form-urlencoded。 9 | * (汉语用户建议设置 Accept-Language:zh-cn) 10 | * 11 | * 请务必在header中设置user agent为 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36' 12 | * 13 | * Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36 14 | Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 《- 15 | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0 16 | * 17 | * @param request 18 | */ 19 | public static void addHeader(Request request, String method) { 20 | request.addHeader("Accept-Language", "zh-cn"); 21 | request.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); 22 | if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 23 | request.addHeader("Content-Type", "application/x-www-form-urlencoded"); 24 | } else { 25 | request.addHeader("Content-Type", "application/json"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/coins/OkexProfiles.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.coins; 2 | 3 | import org.apache.http.client.fluent.Request; 4 | 5 | public class OkexProfiles { 6 | 7 | /** 8 | * All requests based on the Https protocol should set the request header information Content-Type as:'application/json’. 9 | * Request header information must be declared: 10 | * User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 11 | * Request submission frequency: 20 times per second per IP (for Trading and Account API); no limit on Market API 12 | * 13 | * @param request 14 | */ 15 | public static void addHeader(Request request, String method) { 16 | // request.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); 17 | request.addHeader("Content-Type", "application/x-www-form-urlencoded"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/common/JacksonHelper.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.common; 2 | 3 | import java.io.IOException; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import com.fasterxml.jackson.annotation.JsonInclude; 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.core.type.TypeReference; 10 | import com.fasterxml.jackson.databind.DeserializationFeature; 11 | import com.fasterxml.jackson.databind.JavaType; 12 | import com.fasterxml.jackson.databind.JsonMappingException; 13 | import com.fasterxml.jackson.databind.ObjectMapper; 14 | import com.fasterxml.jackson.databind.PropertyNamingStrategy; 15 | import com.fasterxml.jackson.databind.SerializationFeature; 16 | 17 | public final class JacksonHelper { 18 | 19 | private static final ObjectMapper objectMapper = createObjectMapper(); 20 | public static final JavaType mapType = objectMapper.getTypeFactory().constructParametricType(HashMap.class, String.class, Object.class); 21 | 22 | public static String writeValueAsString(Object obj) throws IOException { 23 | return objectMapper.writeValueAsString(obj); 24 | } 25 | 26 | public static T readValue(String s, TypeReference ref) throws IOException { 27 | return objectMapper.readValue(s, ref); 28 | } 29 | 30 | public static ObjectMapper getMapper() { 31 | return objectMapper; 32 | } 33 | 34 | 35 | static ObjectMapper createObjectMapper() { 36 | final ObjectMapper mapper = new ObjectMapper(); 37 | mapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE); 38 | mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS); 39 | // disabled features: 40 | mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 41 | mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); 42 | mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); 43 | return mapper; 44 | } 45 | 46 | public static Map getJsonMap(String jsonStr) { 47 | Map jsonMap = null; 48 | try { 49 | jsonMap = (Map) objectMapper.readValue(jsonStr, JacksonHelper.mapType); 50 | } catch (JsonParseException e) { 51 | // TODO Auto-generated catch block 52 | e.printStackTrace(); 53 | } catch (JsonMappingException e) { 54 | // TODO Auto-generated catch block 55 | e.printStackTrace(); 56 | } catch (IOException e) { 57 | // TODO Auto-generated catch block 58 | e.printStackTrace(); 59 | } 60 | return jsonMap; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/common/RequestUtils.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.common; 2 | 3 | import java.io.IOException; 4 | import java.nio.charset.Charset; 5 | import java.nio.charset.UnsupportedCharsetException; 6 | import java.util.Map; 7 | 8 | import org.apache.http.HttpHost; 9 | import org.apache.http.client.fluent.Form; 10 | import org.apache.http.client.fluent.Request; 11 | import org.apache.http.entity.ContentType; 12 | 13 | public class RequestUtils { 14 | 15 | 16 | /** 17 | * 18 | * @param request 19 | * @param params 20 | * @param charset 21 | */ 22 | public static void addForm(Request request, Map params, String charset) { 23 | Form form = Form.form(); 24 | for(Map.Entry entry : params.entrySet()) { 25 | if (!entry.getKey().startsWith(Constants.PATH_PARAM_PREFIX)) { 26 | form.add(entry.getKey(), entry.getValue()); 27 | } 28 | } 29 | 30 | request.bodyForm(form.build(), Charset.forName(charset)); 31 | } 32 | 33 | public static void addJson(Request request, Map params, String charset) throws UnsupportedCharsetException, IOException { 34 | // Iterator> it = params.entrySet().iterator(); 35 | // while(it.hasNext()){ 36 | // Map.Entry entry = it.next(); 37 | // if (entry.getKey().startsWith(Constants.PATH_PARAM_PREFIX)) { 38 | // it.remove(); 39 | // } 40 | // } 41 | 42 | request.bodyString(JacksonHelper.writeValueAsString(params), ContentType.create("application/json", charset)); 43 | } 44 | 45 | /** 46 | * 47 | * @param request 48 | */ 49 | public static void setProxy(Request request) { 50 | HttpHost proxy = new HttpHost("localhost", 1080); 51 | request.viaProxy(proxy); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/BinanceMarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | 10 | import org.apache.commons.lang3.ArrayUtils; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.apache.http.client.fluent.Content; 13 | import org.apache.http.client.fluent.Form; 14 | import org.apache.http.client.fluent.Request; 15 | import com.mumu.beans.DealtInfo; 16 | import com.mumu.beans.Market; 17 | import com.mumu.exchange.api.BinanceAPI; 18 | import com.mumu.exchange.coins.BinanceProfiles; 19 | import com.mumu.exchange.common.JacksonHelper; 20 | import com.mumu.exchange.common.RequestUtils; 21 | import com.mumu.exchange.signature.BinanceParamsSigner; 22 | import com.mumu.exchange.signature.CoinexParamsSigner; 23 | import com.mumu.exchange.signature.ISignature; 24 | 25 | public class BinanceMarketService extends MarketService implements IMarketService { 26 | 27 | /** 28 | * If the symbol is not sent, tickers for all symbols will be returned in an array. 29 | * 30 | {"symbol":"BNBBTC", 31 | "priceChange":"0.00006740", 32 | "priceChangePercent":"4.465", 33 | "weightedAvgPrice":"0.00153351", 34 | "prevClosePrice":"0.00151040", 35 | "lastPrice":"0.00157690", 36 | "lastQty":"0.08000000", 37 | "bidPrice":"0.00157670", 38 | "bidQty":"1.11000000", 39 | "askPrice":"0.00157690", 40 | "askQty":"0.92000000", 41 | "openPrice":"0.00150950", 42 | "highPrice":"0.00158590", 43 | "lowPrice":"0.00148020", 44 | "volume":"900996.21000000", 45 | "quoteVolume":"1381.68836299", 46 | "openTime":1534388378877, 47 | "closeTime":1534474778877, 48 | "firstId":26740356, 49 | "lastId":26800274, 50 | "count":59919 51 | } 52 | */ 53 | @Override 54 | public List quotationTicker(String accessKey, String secretkey, String... symbols) { 55 | String param = null; 56 | if (ArrayUtils.isNotEmpty(symbols)) { 57 | param = Arrays.toString(symbols); 58 | } 59 | 60 | ISignature signature = new BinanceParamsSigner(); 61 | signature.setApiRoot(BinanceAPI.rest_trading_root); 62 | signature.setApiUri(BinanceAPI.api_ticker_24hr); 63 | if (StringUtils.isNotBlank(param)) { 64 | signature.putParam(BinanceAPI.Api_ticker_24hr_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 65 | } 66 | String uri = signature.getUri(BinanceAPI.api_ticker_24hr_method_get, CoinexParamsSigner.charset_utf8); 67 | logger.warn("uri=" + uri); 68 | Content content = null; 69 | try { 70 | Request request = Request.Get(uri); 71 | RequestUtils.setProxy(request); 72 | BinanceProfiles.addHeader(request, BinanceAPI.api_ticker_24hr_method_get); 73 | content = request 74 | .execute() 75 | .returnContent(); 76 | 77 | 78 | String result = "{\"list\":" +content.asString() +"}"; 79 | logger.warn("ticker=" + result); 80 | Map jsonMap = JacksonHelper.getJsonMap(result); 81 | List listMarket = null; 82 | Market market = null; 83 | if (null != symbols) { 84 | listMarket = new ArrayList(1); 85 | jsonMap = (Map) jsonMap.get("list"); 86 | 87 | market = new Market(); 88 | market.setAmount(new Double(jsonMap.get("volume").toString())); 89 | market.setAsk(new Double(jsonMap.get("askPrice").toString())); 90 | market.setAskVolume(new Double(jsonMap.get("askQty").toString())); 91 | market.setBid(new Double(jsonMap.get("bidPrice").toString())); 92 | market.setBidVolume(new Double(jsonMap.get("bidQty").toString())); 93 | market.setHighest(new Double(jsonMap.get("highPrice").toString())); 94 | market.setLast(new Double(jsonMap.get("lastPrice").toString())); 95 | market.setLowest(new Double(jsonMap.get("lowPrice").toString())); 96 | market.setOpen(new Double(jsonMap.get("openPrice").toString())); 97 | market.setSymbol(jsonMap.get("symbol").toString()); 98 | market.setTs(Long.valueOf(jsonMap.get("closeTime").toString())); 99 | market.setVolume(new Double(jsonMap.get("count").toString())); 100 | listMarket.add(market); 101 | 102 | return listMarket; 103 | } else { 104 | List> marketMap = (List>) jsonMap.get("list"); 105 | listMarket = new ArrayList(marketMap.size()); 106 | 107 | 108 | for (Iterator iterator = marketMap.iterator(); iterator.hasNext();) { 109 | Map map = (Map) iterator.next(); 110 | market = new Market(); 111 | market.setAmount(new Double(map.get("volume").toString())); 112 | market.setAsk(new Double(map.get("askPrice").toString())); 113 | market.setAskVolume(new Double(map.get("askQty").toString())); 114 | market.setBid(new Double(map.get("bidPrice").toString())); 115 | market.setBidVolume(new Double(map.get("bidQty").toString())); 116 | market.setHighest(new Double(map.get("highPrice").toString())); 117 | market.setLast(new Double(map.get("lastPrice").toString())); 118 | market.setLowest(new Double(map.get("lowPrice").toString())); 119 | market.setOpen(new Double(map.get("openPrice").toString())); 120 | market.setSymbol(map.get("symbol").toString()); 121 | market.setTs(Long.valueOf(map.get("closeTime").toString())); 122 | market.setVolume(new Double(map.get("quoteVolume").toString())); 123 | listMarket.add(market); 124 | } 125 | 126 | return listMarket; 127 | } 128 | 129 | } catch (Exception e) { 130 | e.printStackTrace(); 131 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE +":"+ BinanceAPI.api_ticker_24hr +" 请求失败", e); 132 | } 133 | 134 | return null; 135 | } 136 | 137 | /** 138 | * [ 139 | { 140 | "id": 28457, 141 | "price": "4.00000100", 142 | "qty": "12.00000000", 143 | "time": 1499865549590, 144 | "isBuyerMaker": true, 145 | "isBestMatch": true 146 | } 147 | ] 148 | {"id":64812920,"price":"6445.15000000","qty":"0.00155900","time":1534741270535,"isBuyerMaker":true,"isBestMatch":true} 149 | */ 150 | @Override 151 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String... symbols) { 152 | String param = null; 153 | if (ArrayUtils.isNotEmpty(symbols)) { 154 | param = Arrays.toString(symbols); 155 | } 156 | 157 | ISignature signature = new BinanceParamsSigner(); 158 | signature.setApiRoot(BinanceAPI.rest_trading_root); 159 | signature.setApiUri(BinanceAPI.api_trades); 160 | signature.putParam(BinanceAPI.Api_trades_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 161 | if (null != size) { 162 | signature.putParam(BinanceAPI.Api_trades_params.limit.getCode(), size.toString()); 163 | } 164 | String uri = signature.getUri(BinanceAPI.api_trades_method_get, CoinexParamsSigner.charset_utf8); 165 | logger.warn("uri=" + uri); 166 | Content content = null; 167 | try { 168 | Request request = Request.Get(uri); 169 | RequestUtils.setProxy(request); 170 | BinanceProfiles.addHeader(request, BinanceAPI.api_trades_method_get); 171 | content = request 172 | .execute() 173 | .returnContent(); 174 | 175 | 176 | String result = "{\"list\":" +content.asString() +"}"; 177 | logger.warn("ticker=" + result); 178 | Map jsonMap = JacksonHelper.getJsonMap(result); 179 | List> tickerList = (List>)jsonMap.get("list"); 180 | DealtInfo dealtInfo = null; 181 | Map item = null; 182 | 183 | long time = getSplittingTime();//确定应用服务器与交易所服务器时间一致 184 | // for (Entry entry : tickerMap.entrySet()) { 185 | // item = (Map) ((Map)entry.getValue()).get("data"); 186 | // if (Long.valueOf(item.get("ts").toString()).longValue() <= time) { 187 | // System.out.println("ts=" +Long.valueOf(item.get("ts").toString()).longValue()); 188 | // market = new Market(); 189 | // break; 190 | // } 191 | // } 192 | 193 | for (Map map : tickerList) { 194 | item = map;//((List>) map.get("data")).get(0); 195 | if (Long.valueOf(item.get("time").toString()).longValue() <= time) { 196 | System.out.println("ts=" +Long.valueOf(item.get("time").toString()).longValue()); 197 | dealtInfo = new DealtInfo(); 198 | dealtInfo.setDirection((Boolean.valueOf(item.get("isBuyerMaker").toString()) ? com.mumu.common.Constants.TRADING_DIRECTION.BUY : com.mumu.common.Constants.TRADING_DIRECTION.SELL)); 199 | dealtInfo.setId(item.get("id").toString()); 200 | dealtInfo.setPrice(new Double(item.get("price").toString())); 201 | dealtInfo.setTs(Long.valueOf(item.get("time").toString())); 202 | dealtInfo.setVolume(new Double(item.get("qty").toString())); 203 | break; 204 | } 205 | } 206 | 207 | return dealtInfo; 208 | } catch (Exception e) { 209 | e.printStackTrace(); 210 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE +":"+ BinanceAPI.api_trades +" 请求失败", e); 211 | } 212 | 213 | return null; 214 | } 215 | 216 | 217 | 218 | } 219 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/CoinexMarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.apache.http.client.fluent.Content; 11 | import org.apache.http.client.fluent.Form; 12 | import org.apache.http.client.fluent.Request; 13 | 14 | import com.mumu.beans.DealtInfo; 15 | import com.mumu.beans.Market; 16 | import com.mumu.exchange.api.CoinexAPI; 17 | import com.mumu.exchange.coins.CoinexProfiles; 18 | import com.mumu.exchange.common.JacksonHelper; 19 | import com.mumu.exchange.common.RequestUtils; 20 | import com.mumu.exchange.signature.CoinexParamsSigner; 21 | import com.mumu.exchange.signature.ISignature; 22 | 23 | public class CoinexMarketService extends MarketService implements IMarketService { 24 | 25 | /** 26 | * 为空的时候取所有的 27 | * Request Url:https://api.coinex.com/v1/market/ticker/all 28 | * 29 | * {"code": 0, "data": {"date": 1534495776723, "ticker": { 30 | * "vol": "4922.64386048", "low": "11.8980201", "open": "12.15", 31 | "high": "12.22", "last": "12.0614398", "buy": "12.04506", "buy_amount": "1.94674137", 32 | "sell": "12.07666", "sell_amount": "0.02747"}}, "message": "OK"} 33 | */ 34 | @Override 35 | public List quotationTicker(String accessKey, String secretkey, String... symbols) { 36 | String param = Arrays.toString(symbols); 37 | ISignature signature = new CoinexParamsSigner(); 38 | signature.setApiRoot(CoinexAPI.rest_trading_root); 39 | signature.setApiUri(CoinexAPI.market_ticker); 40 | signature.putParam(CoinexAPI.Market_ticker_params.market.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 41 | String authorization = signature.sign(accessKey, secretkey); 42 | String uri = signature.getUri(CoinexAPI.market_ticker_method_get, CoinexParamsSigner.charset_utf8); 43 | logger.warn("uri=" + uri); 44 | Content content = null; 45 | try { 46 | Request request = Request.Get(uri); 47 | RequestUtils.setProxy(request); 48 | CoinexProfiles.addHeader(request, CoinexAPI.balance_info_method_get); 49 | request.addHeader(CoinexAPI.API_SIGN_KEY_authorization, authorization); 50 | content = request 51 | .execute() 52 | .returnContent(); 53 | 54 | String result = content.asString(); 55 | logger.warn("ticker=" + result); 56 | Map jsonMap = JacksonHelper.getJsonMap(result); 57 | Map tickerMap = (Map) ((Map) jsonMap.get("data")).get("ticker"); 58 | List listMarket = new ArrayList(1); 59 | Market market = new Market(); 60 | // market.setAmount(null); 61 | market.setAsk(new Double(tickerMap.get("sell"))); 62 | market.setAskVolume(new Double(tickerMap.get("sell_amount"))); 63 | market.setBid(new Double(tickerMap.get("buy"))); 64 | market.setBidVolume(new Double(tickerMap.get("buy_amount"))); 65 | 66 | market.setHighest(new Double(tickerMap.get("high"))); 67 | market.setLowest(new Double(tickerMap.get("low"))); 68 | market.setLast(new Double(tickerMap.get("last"))); 69 | market.setOpen(new Double(tickerMap.get("open"))); 70 | market.setSymbol(symbols[0]); 71 | market.setTs(Long.valueOf(((Map)jsonMap.get("data")).get("date").toString())); 72 | market.setVolume(new Double(tickerMap.get("vol"))); 73 | 74 | listMarket.add(market); 75 | return listMarket; 76 | } catch (Exception e) { 77 | e.printStackTrace(); 78 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX +":"+ CoinexAPI.market_ticker +" 请求失败", e); 79 | } 80 | 81 | return null; 82 | } 83 | 84 | /** 85 | * { 86 | "code": 0, 87 | "data": [ 88 | { 89 | "amount": "0.0001", # Transaction amount 90 | "date": 1494214689, # Transaction time(s) 91 | "date_ms": 1494214689067, # Transaction time(ms) 92 | "id": 5, # Transaction No 93 | "price": "10.00", # Transaction price 94 | "type": "buy" # Transaction type: buy, sell 95 | } 96 | ], 97 | "message": "Ok" 98 | } 99 | {"id": 533912782, "type": "buy", "price": "11.45737771", "amount": "0.0002", "date": 1534742487, "date_ms": 1534742487664} 100 | * Transaction history id, send 0 to draw from the latest record. 101 | * return up to 1000 102 | */ 103 | @Override 104 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String... symbols) { 105 | String param = Arrays.toString(symbols); 106 | ISignature signature = new CoinexParamsSigner(); 107 | signature.setApiRoot(CoinexAPI.rest_trading_root); 108 | signature.setApiUri(CoinexAPI.market_deals); 109 | signature.putParam(CoinexAPI.Market_deals_params.market.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 110 | signature.putParam(CoinexAPI.Market_deals_params.last_id.getCode(), size.toString()); 111 | String authorization = signature.sign(accessKey, secretkey); 112 | String uri = signature.getUri(CoinexAPI.market_deals_method_get, CoinexParamsSigner.charset_utf8); 113 | logger.warn("uri=" + uri); 114 | Content content = null; 115 | try { 116 | Request request = Request.Get(uri); 117 | RequestUtils.setProxy(request); 118 | CoinexProfiles.addHeader(request, CoinexAPI.market_deals_method_get); 119 | request.addHeader(CoinexAPI.API_SIGN_KEY_authorization, authorization); 120 | content = request 121 | .execute() 122 | .returnContent(); 123 | 124 | String result = content.asString(); 125 | logger.warn("ticker=" + result); 126 | Map jsonMap = JacksonHelper.getJsonMap(result); 127 | List> tickerList = (List>)jsonMap.get("data"); 128 | DealtInfo dealtInfo = null; 129 | Map item = null; 130 | 131 | long time = getSplittingTime();//确定应用服务器与交易所服务器时间一致 132 | for (Map map : tickerList) { 133 | item = map;//((List>) map.get("data")).get(0); 134 | if (Long.valueOf(item.get("date_ms").toString()).longValue() <= time) { 135 | System.out.println("ts=" +Long.valueOf(item.get("date_ms").toString()).longValue()); 136 | dealtInfo = new DealtInfo(); 137 | dealtInfo.setDirection(com.mumu.common.Constants.TRADING_DIRECTION.valueOf(item.get("type").toString().toUpperCase())); 138 | dealtInfo.setId(item.get("id").toString()); 139 | dealtInfo.setPrice(new Double(item.get("price").toString())); 140 | dealtInfo.setTs(Long.valueOf(item.get("date_ms").toString())); 141 | dealtInfo.setVolume(new Double(item.get("amount").toString())); 142 | break; 143 | } 144 | } 145 | 146 | return dealtInfo; 147 | } catch (Exception e) { 148 | e.printStackTrace(); 149 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX +":"+ CoinexAPI.market_deals +" 请求失败", e); 150 | } 151 | 152 | return null; 153 | } 154 | 155 | 156 | 157 | } 158 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/HuobiMarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.http.client.fluent.Content; 9 | import org.apache.http.client.fluent.Form; 10 | import org.apache.http.client.fluent.Request; 11 | 12 | import org.apache.commons.lang3.StringUtils; 13 | 14 | import com.mumu.beans.DealtInfo; 15 | import com.mumu.beans.Market; 16 | import com.mumu.exchange.api.HoubiAPI; 17 | import com.mumu.exchange.coins.HuobiProfiles; 18 | import com.mumu.exchange.common.JacksonHelper; 19 | import com.mumu.exchange.common.RequestUtils; 20 | import com.mumu.exchange.signature.HuobiParamsSigner; 21 | import com.mumu.exchange.signature.ISignature; 22 | 23 | public class HuobiMarketService extends MarketService implements IMarketService { 24 | 25 | /** 26 | * 可传多个但必传 27 | * {"status":"ok","ch":"market.bchbtc.detail.merged","ts":1534497122571, 28 | * "tick":{"amount":101377.7608,"open":0.081960,"close":0.083042,"high":0.083878,"id":16636904119, 29 | * "count":12499,"low":0.081418,"version":16636904119, 30 | * "ask":[0.083053,0.5110],"vol":8375.8348273504,"bid":[0.082986,0.2000]}} 31 | */ 32 | @Override 33 | public List quotationTicker(String accessKey, String secretkey, String... symbols) { 34 | String param = Arrays.toString(symbols); 35 | 36 | ISignature signature = new HuobiParamsSigner(); 37 | signature.setApiRoot(HoubiAPI.rest_market_root); 38 | signature.setApiUri(HoubiAPI.market_detail_merged); 39 | signature.putParam(HoubiAPI.Market_detail_merged_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 40 | String uri = signature.sign(accessKey, secretkey); 41 | logger.warn("uri=" + uri); 42 | 43 | 44 | // StringBuilder uri = new StringBuilder(HoubiAPI.rest_market_root); 45 | // uri.append(HoubiAPI.market_detail_merged) 46 | // .append("?") 47 | // .append(HoubiAPI.Market_detail_merged_params.symbol.getCode()) 48 | // .append("=") 49 | // .append(StringUtils.trim(param.substring(1, (param.length() - 1)))); 50 | 51 | Content content = null; 52 | try { 53 | Request request = Request.Get(uri.toString()); 54 | RequestUtils.setProxy(request); 55 | HuobiProfiles.addHeader(request, HoubiAPI.market_detail_merged_method_get); 56 | content = request 57 | .execute() 58 | .returnContent(); 59 | 60 | 61 | String result = content.asString(); 62 | logger.warn("ticker=" + result); 63 | Map jsonMap = JacksonHelper.getJsonMap(result); 64 | Map tickerMap = (Map)jsonMap.get("tick"); 65 | List listMarket = new ArrayList(1); 66 | Market market = new Market(); 67 | market.setAmount(new Double(tickerMap.get("vol").toString())); 68 | market.setAsk(((List)tickerMap.get("ask")).get(0)); 69 | market.setAskVolume(((List)tickerMap.get("ask")).get(1)); 70 | market.setBid(((List)tickerMap.get("bid")).get(0)); 71 | market.setBidVolume(((List)tickerMap.get("bid")).get(1)); 72 | 73 | market.setHighest(new Double(tickerMap.get("high").toString())); 74 | market.setLowest(new Double(tickerMap.get("low").toString())); 75 | market.setLast(new Double(tickerMap.get("close").toString())); 76 | market.setOpen(new Double(tickerMap.get("open").toString())); 77 | market.setSymbol(symbols[0]); 78 | market.setTs(Long.valueOf(jsonMap.get("ts").toString())); 79 | market.setVolume(new Double(tickerMap.get("amount").toString())); 80 | 81 | listMarket.add(market); 82 | return listMarket; 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI+":"+HoubiAPI.market_detail_merged+" 请求失败", e); 86 | } 87 | 88 | return null; 89 | } 90 | 91 | /** 92 | * h: 93 | "data": { 94 | "id": 消息id, 95 | "ts": 最新成交时间, 96 | "data": [ 97 | { 98 | "id": 成交id, 99 | "price": 成交价, 100 | "amount": 成交量, 101 | "direction": 主动成交方向, 102 | "ts": 成交时间 103 | } 104 | ] 105 | } 106 | {"id":17019178043,"ts":1534740234226,"data":[{"amount":9.9011,"ts":1534740234226,"id":1701917804310646552255,"price":0.087349,"direction":"buy"}]} 107 | */ 108 | @Override 109 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String... symbols) { 110 | String param = Arrays.toString(symbols); 111 | 112 | ISignature signature = new HuobiParamsSigner(); 113 | signature.setApiRoot(HoubiAPI.rest_market_root); 114 | signature.setApiUri(HoubiAPI.market_history_trade); 115 | signature.putParam(HoubiAPI.Market_history_trade_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 116 | if (1 <= size && size <= 2000) { 117 | signature.putParam(HoubiAPI.Market_history_trade_params.size.getCode(), size.toString()); 118 | } else { 119 | signature.putParam(HoubiAPI.Market_history_trade_params.size.getCode(), "100"); 120 | } 121 | 122 | String uri = signature.sign(accessKey, secretkey); 123 | logger.warn("uri=" + uri); 124 | 125 | Content content = null; 126 | try { 127 | Request request = Request.Get(uri.toString()); 128 | RequestUtils.setProxy(request); 129 | HuobiProfiles.addHeader(request, HoubiAPI.market_history_trade_method_get); 130 | content = request 131 | .execute() 132 | .returnContent(); 133 | 134 | 135 | String result = content.asString(); 136 | logger.warn("ticker=" + result); 137 | Map jsonMap = JacksonHelper.getJsonMap(result); 138 | List> tickerList = (List>)jsonMap.get("data"); 139 | DealtInfo dealtInfo = null; 140 | Map item = null; 141 | 142 | long time = getSplittingTime();//确定应用服务器与交易所服务器时间一致 143 | // for (Entry entry : tickerMap.entrySet()) { 144 | // item = (Map) ((Map)entry.getValue()).get("data"); 145 | // if (Long.valueOf(item.get("ts").toString()).longValue() <= time) { 146 | // System.out.println("ts=" +Long.valueOf(item.get("ts").toString()).longValue()); 147 | // market = new Market(); 148 | // break; 149 | // } 150 | // } 151 | 152 | for (Map map : tickerList) { 153 | item = ((List>) map.get("data")).get(0); 154 | if (Long.valueOf(item.get("ts").toString()).longValue() <= time) { 155 | System.out.println("ts=" +Long.valueOf(item.get("ts").toString()).longValue()); 156 | dealtInfo = new DealtInfo(); 157 | dealtInfo.setDirection(com.mumu.common.Constants.TRADING_DIRECTION.valueOf(item.get("direction").toString().toUpperCase())); 158 | dealtInfo.setId(item.get("id").toString()); 159 | dealtInfo.setPrice(new Double(item.get("price").toString())); 160 | dealtInfo.setTs(Long.valueOf(item.get("ts").toString())); 161 | dealtInfo.setVolume(new Double(item.get("amount").toString())); 162 | break; 163 | } 164 | } 165 | 166 | return dealtInfo; 167 | } catch (Exception e) { 168 | e.printStackTrace(); 169 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI+":"+HoubiAPI.market_history_trade+" 请求失败", e); 170 | } 171 | 172 | return null; 173 | } 174 | 175 | 176 | 177 | } 178 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/IMarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.List; 4 | 5 | import com.mumu.beans.DealtInfo; 6 | import com.mumu.beans.Market; 7 | 8 | public interface IMarketService { 9 | 10 | // public Map quotationTicker(String accessKey, String secretkey, String ... symblos); 11 | 12 | public List quotationTicker(String accessKey, String secretkey, String ... symbols); 13 | 14 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String ... symbols); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/MarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.Calendar; 4 | import java.util.List; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | import com.mumu.beans.DealtInfo; 9 | import com.mumu.beans.Market; 10 | 11 | public class MarketService implements IMarketService { 12 | protected final Logger logger = Logger.getLogger(this.getClass()); 13 | 14 | @Override 15 | public List quotationTicker(String accessKey, String secretkey, String... symblos) { 16 | // TODO Auto-generated method stub 17 | return null; 18 | } 19 | 20 | @Override 21 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String... symbols) { 22 | // TODO Auto-generated method stub 23 | return null; 24 | } 25 | 26 | // @Override 27 | // public Map quotationTicker(String accessKey, String secretkey, String... symblos) { 28 | // // TODO Auto-generated method stub 29 | // return null; 30 | // } 31 | 32 | protected long getSplittingTime() { 33 | Calendar calendar = Calendar.getInstance(); 34 | calendar.add(Calendar.DATE, -1); 35 | calendar.set(Calendar.HOUR_OF_DAY, 23); 36 | calendar.set(Calendar.MINUTE, 59); 37 | calendar.set(Calendar.SECOND, 59); 38 | calendar.set(Calendar.MILLISECOND, 999); 39 | 40 | return calendar.getTimeInMillis(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/market/OkexMarketService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.market; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.http.client.fluent.Content; 9 | import org.apache.http.client.fluent.Form; 10 | import org.apache.http.client.fluent.Request; 11 | import org.apache.commons.lang3.StringUtils; 12 | 13 | import com.fasterxml.jackson.databind.JavaType; 14 | import com.fasterxml.jackson.databind.type.TypeFactory; 15 | import com.mumu.beans.DealtInfo; 16 | import com.mumu.beans.Market; 17 | import com.mumu.common.Constants.EXCHANGE_NAME; 18 | import com.mumu.exchange.api.OkexAPI; 19 | import com.mumu.exchange.coins.OkexProfiles; 20 | import com.mumu.exchange.common.JacksonHelper; 21 | import com.mumu.exchange.common.RequestUtils; 22 | import com.mumu.exchange.signature.ISignature; 23 | import com.mumu.exchange.signature.OkexParamsSigner; 24 | 25 | public class OkexMarketService extends MarketService implements IMarketService { 26 | 27 | /** 28 | *单一 29 | */ 30 | @Override 31 | public List quotationTicker(String accessKey, String secretkey, String... symbols) { 32 | String param = Arrays.toString(symbols); 33 | 34 | ISignature signature = new OkexParamsSigner(); 35 | signature.setApiRoot(OkexAPI.rest_trading_root); 36 | signature.setApiUri(OkexAPI.api_ticker); 37 | signature.putParam(OkexAPI.Api_ticker_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 38 | 39 | String authorization = signature.sign(accessKey, secretkey); 40 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 41 | String uri = signature.getUri(OkexAPI.api_ticker_method_get, OkexParamsSigner.charset_utf8); 42 | logger.warn("uri=" + uri); 43 | Content content = null; 44 | try { 45 | Request request = Request.Get(uri); 46 | RequestUtils.setProxy(request); 47 | OkexProfiles.addHeader(request, OkexAPI.api_ticker_method_get); 48 | content = request 49 | .execute() 50 | .returnContent(); 51 | 52 | String result = content.asString(); 53 | logger.warn("ticker=" + result); 54 | Map jsonMap = JacksonHelper.getJsonMap(result); 55 | Map tickerMap = (Map)jsonMap.get("ticker"); 56 | List listMarket = new ArrayList(1); 57 | Market market = new Market(); 58 | // market.setAmount(new Double(tickerMap.get("vol").toString())); 59 | market.setAsk(new Double(tickerMap.get("sell").toString())); 60 | // market.setAskVolume(((List)tickerMap.get("ask")).get(1)); 61 | market.setBid(new Double(tickerMap.get("buy").toString())); 62 | // market.setBidVolume(((List)tickerMap.get("bid")).get(1)); 63 | 64 | market.setHighest(new Double(tickerMap.get("high").toString())); 65 | market.setLowest(new Double(tickerMap.get("low").toString())); 66 | market.setLast(new Double(tickerMap.get("last").toString())); 67 | // market.setOpen(new Double(tickerMap.get("open").toString())); 68 | market.setSymbol(symbols[0]); 69 | market.setTs(Long.valueOf(jsonMap.get("date").toString()) * 1000); 70 | market.setVolume(new Double(tickerMap.get("vol").toString())); 71 | 72 | listMarket.add(market); 73 | return listMarket; 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | super.logger.error(EXCHANGE_NAME.EXCHANGE_OKEX.name() +":"+ OkexAPI.api_ticker +" 请求失败", e); 77 | } 78 | 79 | 80 | return null; 81 | } 82 | 83 | /** 84 | * date:交易时间 85 | date_ms:交易时间(ms) 86 | price: 交易价格 87 | amount: 交易数量 88 | tid: 交易生成ID 89 | type: buy/sell 90 | {"date":1534739097,"date_ms":1534739097042,"amount":7.1561,"price":0.08766501,"type":"buy","tid":293687005} 91 | */ 92 | @Override 93 | public DealtInfo getSettlementPrice(String accessKey, String secretkey, Integer size, String... symbols) { 94 | String param = Arrays.toString(symbols); 95 | 96 | ISignature signature = new OkexParamsSigner(); 97 | signature.setApiRoot(OkexAPI.rest_trading_root); 98 | signature.setApiUri(OkexAPI.api_trades); 99 | signature.putParam(OkexAPI.Api_trades_params.symbol.getCode(), StringUtils.trim(param.substring(1, (param.length() - 1)))); 100 | if (null != size) { 101 | signature.putParam(OkexAPI.Api_trades_params.since.getCode(), size.toString()); 102 | } 103 | 104 | String authorization = signature.sign(accessKey, secretkey); 105 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 106 | String uri = signature.getUri(OkexAPI.Api_trades_method_get, OkexParamsSigner.charset_utf8); 107 | logger.warn("uri=" + uri); 108 | Content content = null; 109 | try { 110 | Request request = Request.Get(uri); 111 | RequestUtils.setProxy(request); 112 | OkexProfiles.addHeader(request, OkexAPI.Api_trades_method_get); 113 | content = request 114 | .execute() 115 | .returnContent(); 116 | 117 | String result = content.asString(); 118 | logger.warn("ticker=" + result); 119 | 120 | JavaType listMap = TypeFactory.defaultInstance().constructParametricType(List.class, Map.class); 121 | List> tickerList = (List>) JacksonHelper.getMapper().readValue(result, listMap); 122 | DealtInfo dealtInfo = null; 123 | Map item = null; 124 | 125 | long time = getSplittingTime();//确定应用服务器与交易所服务器时间一致 126 | for (Map map : tickerList) { 127 | item = map; 128 | if (Long.valueOf(item.get("date_ms").toString()).longValue() <= time) { 129 | System.out.println("ts=" +Long.valueOf(item.get("date_ms").toString()).longValue()); 130 | dealtInfo = new DealtInfo(); 131 | dealtInfo.setDirection(com.mumu.common.Constants.TRADING_DIRECTION.valueOf(item.get("type").toString().toUpperCase())); 132 | dealtInfo.setId(item.get("tid").toString()); 133 | dealtInfo.setPrice(new Double(item.get("price").toString())); 134 | dealtInfo.setTs(Long.valueOf(item.get("date_ms").toString())); 135 | dealtInfo.setVolume(new Double(item.get("amount").toString())); 136 | break; 137 | } 138 | } 139 | 140 | return dealtInfo; 141 | } catch (Exception e) { 142 | e.printStackTrace(); 143 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_trades +" 请求失败", e); 144 | } 145 | 146 | 147 | return null; 148 | } 149 | 150 | 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/BinanceParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Comparator; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | import com.mumu.exchange.api.BinanceAPI; 10 | import com.mumu.exchange.common.Constants; 11 | 12 | public final class BinanceParamsSigner extends RequestParamsSigner { 13 | 14 | public static final String charset_utf8 = "UTF-8"; 15 | 16 | public BinanceParamsSigner() { 17 | } 18 | 19 | @Override 20 | public String sign(String accessKey, String secretkey) { 21 | TreeMap signMap =new TreeMap(new Comparator() { 22 | @Override 23 | public int compare(String o1, String o2) { 24 | return o1.compareTo(o2); 25 | } 26 | }); 27 | 28 | signMap.put(BinanceAPI.API_SIGN_KEY_recvWindow, BinanceAPI.API_SIGN_DEFVAL_recvWindow); 29 | signMap.put(BinanceAPI.API_SIGN_KEY_Timestamp, System.currentTimeMillis()+""); 30 | super.paramsMap.putAll(signMap); 31 | // String method = getMethodByChangeoverUri(this.apiUri, super.getParams()); 32 | StringBuilder sb = new StringBuilder(); 33 | String queryStr = null; 34 | 35 | // if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 36 | // queryStr = super.generateQryStr(charset_utf8); 37 | // sb.append(queryStr);//.append("&"+ BinanceAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 38 | // System.out.println("sign=" + sb.toString()); 39 | // 40 | // } else { 41 | queryStr = super.generateQryStr(charset_utf8);//super.generateSignStr(signMap, charset_utf8); 42 | sb.append(queryStr);//.append("&"+ BinanceAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 43 | System.out.println("sign=" + sb.toString()); 44 | // } 45 | return hmacSHA256ToHex(sb.toString(), secretkey); 46 | } 47 | 48 | private String getMethodByChangeoverUri(String apiUri, Map params) { 49 | String method = BinanceAPI.getMethodByApiUri(apiUri); 50 | String key = null; 51 | if (StringUtils.isBlank(method)) { 52 | for(Map.Entry entry : paramsMap.entrySet()) { 53 | key = entry.getKey(); 54 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 55 | apiUri = apiUri.replace(entry.getValue(), "{"+ key +"}"); 56 | } 57 | } 58 | method = BinanceAPI.getMethodByApiUri(apiUri); 59 | } 60 | 61 | return method; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/CoinexParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Comparator; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.apache.shiro.crypto.hash.Md5Hash; 9 | 10 | import com.mumu.exchange.api.CoinexAPI; 11 | import com.mumu.exchange.common.Constants; 12 | 13 | public final class CoinexParamsSigner extends RequestParamsSigner { 14 | 15 | public static final String charset_utf8 = "UTF-8"; 16 | 17 | public CoinexParamsSigner() { 18 | } 19 | 20 | @Override 21 | public String sign(String accessKey, String secretkey) { 22 | TreeMap signMap =new TreeMap(new Comparator() { 23 | @Override 24 | public int compare(String o1, String o2) { 25 | return o1.compareTo(o2); 26 | } 27 | }); 28 | 29 | signMap.put(CoinexAPI.API_SIGN_KEY_AccessKeyId, accessKey); 30 | signMap.put(CoinexAPI.API_SIGN_KEY_Timestamp, System.currentTimeMillis()+""); 31 | super.paramsMap.putAll(signMap); 32 | String method = getMethodByChangeoverUri(this.apiUri, super.getParams()); 33 | StringBuilder sb = new StringBuilder(); 34 | String queryStr = null; 35 | 36 | if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 37 | queryStr = super.generateQryStr(charset_utf8); 38 | sb.append(queryStr).append("&"+ CoinexAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 39 | System.out.println("sign=" + sb.toString()); 40 | 41 | } else { 42 | queryStr = super.generateQryStr(charset_utf8);//super.generateSignStr(signMap, charset_utf8); 43 | sb.append(queryStr).append("&"+ CoinexAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 44 | System.out.println("sign=" + sb.toString()); 45 | } 46 | org.apache.shiro.crypto.hash.Md5Hash md5Hash = new Md5Hash(sb.toString()); 47 | return md5Hash.toHex().toUpperCase(); 48 | } 49 | 50 | private String getMethodByChangeoverUri(String apiUri, Map params) { 51 | String method = CoinexAPI.getMethodByApiUri(apiUri); 52 | String key = null; 53 | if (StringUtils.isBlank(method)) { 54 | for(Map.Entry entry : paramsMap.entrySet()) { 55 | key = entry.getKey(); 56 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 57 | apiUri = apiUri.replace(entry.getValue(), "{"+ key +"}"); 58 | } 59 | } 60 | method = CoinexAPI.getMethodByApiUri(apiUri); 61 | } 62 | 63 | return method; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/HoubiParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Calendar; 4 | import java.util.Comparator; 5 | import java.util.Map; 6 | import java.util.TimeZone; 7 | import java.util.TreeMap; 8 | 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.apache.commons.lang3.time.DateFormatUtils; 11 | 12 | import com.mumu.exchange.api.HoubiAPI; 13 | import com.mumu.exchange.common.Constants; 14 | 15 | public final class HoubiParamsSigner extends RequestParamsSigner { 16 | 17 | public static final String charset_utf8 = "UTF-8"; 18 | 19 | public HoubiParamsSigner() { 20 | } 21 | 22 | @Override 23 | public String sign(String accessKey, String secretkey) { 24 | TreeMap signMap =new TreeMap(new Comparator() { 25 | @Override 26 | public int compare(String o1, String o2) { 27 | return o1.compareTo(o2); 28 | } 29 | }); 30 | 31 | signMap.put(HoubiAPI.API_SIGN_KEY_AccessKeyId, accessKey); 32 | signMap.put(HoubiAPI.API_SIGN_KEY_SignatureMethod, HoubiAPI.API_SIGN_SignatureMethod); 33 | signMap.put(HoubiAPI.API_SIGN_KEY_SignatureVersion, HoubiAPI.API_SIGN_SignatureVersion); 34 | String timestamp = DateFormatUtils.formatUTC(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime(), "yyyy-MM-dd'T'HH:mm:ss"); 35 | signMap.put(HoubiAPI.API_SIGN_KEY_Timestamp, timestamp); 36 | 37 | // org.apache.shiro.crypto.hash.Sha256Hash sha256 = null; 38 | String method = getMethodByChangeoverUri(this.apiUri, super.getParams()); 39 | String sign_rest_trading_root = this.apiRoot.replaceFirst("^(https://|http://)", ""); 40 | StringBuilder sb = new StringBuilder(); 41 | String queryStr = null; 42 | 43 | if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 44 | super.paramsMap.putAll(signMap); 45 | queryStr = super.generateQryStr(charset_utf8); 46 | sb.append(method).append("\n") 47 | .append(sign_rest_trading_root).append("\n") 48 | .append(this.apiUri).append("\n") 49 | .append(queryStr); 50 | System.out.println("sign=" + sb.toString()); 51 | 52 | // sha256 = new Sha256Hash(sb.toString(), secretkey); 53 | } else { 54 | queryStr = super.generateSignStr(signMap, charset_utf8); 55 | sb.append(method).append("\n") 56 | .append(sign_rest_trading_root).append("\n") 57 | .append(this.apiUri).append("\n") 58 | .append(queryStr); 59 | System.out.println("sign=" + sb.toString()); 60 | // sha256 = new Sha256Hash(sb.toString(), secretkey); 61 | } 62 | 63 | try { 64 | String signStr = super.hmacSHA256(sb.toString(), secretkey); 65 | sb = new StringBuilder(); 66 | sb.append(this.apiRoot) 67 | .append(this.apiUri).append("?") 68 | .append(queryStr) 69 | .append("&Signature=").append(java.net.URLEncoder.encode(signStr, charset_utf8)); 70 | } catch (Exception e) { 71 | e.printStackTrace(); 72 | } 73 | 74 | return sb.toString(); 75 | } 76 | 77 | private String getMethodByChangeoverUri(String apiUri, Map params) { 78 | String method = HoubiAPI.getMethodByApiUri(apiUri); 79 | String key = null; 80 | if (StringUtils.isBlank(method)) { 81 | for(Map.Entry entry : paramsMap.entrySet()) { 82 | key = entry.getKey(); 83 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 84 | apiUri = apiUri.replace(entry.getValue(), "{"+ key +"}"); 85 | } 86 | } 87 | method = HoubiAPI.getMethodByApiUri(apiUri); 88 | } 89 | 90 | return method; 91 | } 92 | 93 | 94 | 95 | public static void main(String[] args) { 96 | System.out.println("https://api.huobi.pro/v1".replaceFirst("^(https://|http://)", "")); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/HuobiParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Calendar; 4 | import java.util.Comparator; 5 | import java.util.Map; 6 | import java.util.TimeZone; 7 | import java.util.TreeMap; 8 | 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.apache.commons.lang3.time.DateFormatUtils; 11 | 12 | import com.mumu.exchange.api.HoubiAPI; 13 | import com.mumu.exchange.common.Constants; 14 | 15 | public final class HuobiParamsSigner extends RequestParamsSigner { 16 | 17 | public static final String charset_utf8 = "UTF-8"; 18 | 19 | public HuobiParamsSigner() { 20 | } 21 | 22 | @Override 23 | public String sign(String accessKey, String secretkey) { 24 | TreeMap signMap =new TreeMap(new Comparator() { 25 | @Override 26 | public int compare(String o1, String o2) { 27 | return o1.compareTo(o2); 28 | } 29 | }); 30 | 31 | signMap.put(HoubiAPI.API_SIGN_KEY_AccessKeyId, accessKey); 32 | signMap.put(HoubiAPI.API_SIGN_KEY_SignatureMethod, HoubiAPI.API_SIGN_SignatureMethod); 33 | signMap.put(HoubiAPI.API_SIGN_KEY_SignatureVersion, HoubiAPI.API_SIGN_SignatureVersion); 34 | String timestamp = DateFormatUtils.formatUTC(Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime(), "yyyy-MM-dd'T'HH:mm:ss"); 35 | signMap.put(HoubiAPI.API_SIGN_KEY_Timestamp, timestamp); 36 | 37 | // org.apache.shiro.crypto.hash.Sha256Hash sha256 = null; 38 | String method = getMethodByChangeoverUri(this.apiUri, super.getParams()); 39 | String sign_rest_trading_root = this.apiRoot.replaceFirst("^(https://|http://)", ""); 40 | StringBuilder sb = new StringBuilder(); 41 | String queryStr = null; 42 | 43 | if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 44 | super.paramsMap.putAll(signMap); 45 | queryStr = super.generateQryStr(charset_utf8); 46 | sb.append(method).append("\n") 47 | .append(sign_rest_trading_root).append("\n") 48 | .append(this.apiUri).append("\n") 49 | .append(queryStr); 50 | System.out.println("sign=" + sb.toString()); 51 | 52 | // sha256 = new Sha256Hash(sb.toString(), secretkey); 53 | } else { 54 | queryStr = super.generateSignStr(signMap, charset_utf8); 55 | sb.append(method).append("\n") 56 | .append(sign_rest_trading_root).append("\n") 57 | .append(this.apiUri).append("\n") 58 | .append(queryStr); 59 | System.out.println("sign=" + sb.toString()); 60 | // sha256 = new Sha256Hash(sb.toString(), secretkey); 61 | } 62 | 63 | try { 64 | String signStr = super.hmacSHA256(sb.toString(), secretkey); 65 | sb = new StringBuilder(); 66 | sb.append(this.apiRoot) 67 | .append(this.apiUri).append("?") 68 | .append(queryStr) 69 | .append("&Signature=").append(java.net.URLEncoder.encode(signStr, charset_utf8)); 70 | } catch (Exception e) { 71 | e.printStackTrace(); 72 | } 73 | 74 | return sb.toString(); 75 | } 76 | 77 | private String getMethodByChangeoverUri(String apiUri, Map params) { 78 | String method = HoubiAPI.getMethodByApiUri(apiUri); 79 | String key = null; 80 | if (StringUtils.isBlank(method)) { 81 | for(Map.Entry entry : paramsMap.entrySet()) { 82 | key = entry.getKey(); 83 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 84 | apiUri = apiUri.replace(entry.getValue(), "{"+ key +"}"); 85 | } 86 | } 87 | method = HoubiAPI.getMethodByApiUri(apiUri); 88 | } 89 | 90 | return method; 91 | } 92 | 93 | 94 | 95 | public static void main(String[] args) { 96 | System.out.println("https://api.huobi.pro/v1".replaceFirst("^(https://|http://)", "")); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/ISignature.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Map; 4 | 5 | public interface ISignature { 6 | 7 | public ISignature setApiRoot(String apiRoot); 8 | 9 | public ISignature setApiUri(String uri); 10 | 11 | public ISignature putParam(String key, String value); 12 | 13 | public ISignature addAllParams(Map params); 14 | 15 | /** 16 | * 清空参数后,在保证线程安全的情况下,可以使用同一SPI实例请求其它接口 17 | * @return 18 | */ 19 | public ISignature clearParams(); 20 | 21 | public String sign(String accessKey, String secretkey); 22 | 23 | public String getUri(String method, String charset); 24 | 25 | public Map getParams(); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/OkexParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Comparator; 4 | import java.util.Map; 5 | import java.util.TreeMap; 6 | 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.apache.shiro.crypto.hash.Md5Hash; 9 | 10 | import com.mumu.exchange.api.OkexAPI; 11 | import com.mumu.exchange.common.Constants; 12 | 13 | public final class OkexParamsSigner extends RequestParamsSigner { 14 | 15 | public static final String charset_utf8 = "UTF-8"; 16 | 17 | public OkexParamsSigner() { 18 | } 19 | 20 | @Override 21 | public String sign(String accessKey, String secretkey) { 22 | TreeMap signMap =new TreeMap(new Comparator() { 23 | @Override 24 | public int compare(String o1, String o2) { 25 | return o1.compareTo(o2); 26 | } 27 | }); 28 | 29 | signMap.put(OkexAPI.API_SIGN_KEY_AccessKeyId, accessKey); 30 | super.paramsMap.putAll(signMap); 31 | String method = getMethodByChangeoverUri(this.apiUri, super.getParams()); 32 | StringBuilder sb = new StringBuilder(); 33 | String queryStr = null; 34 | 35 | if (org.springframework.http.HttpMethod.GET.name().equalsIgnoreCase(method)) { 36 | queryStr = super.generateQryStr(charset_utf8); 37 | sb.append(queryStr).append("&"+ OkexAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 38 | System.out.println("sign=" + sb.toString()); 39 | 40 | } else { 41 | queryStr = super.generateQryStr(charset_utf8);//super.generateSignStr(signMap, charset_utf8); 42 | sb.append(queryStr).append("&"+ OkexAPI.API_SIGN_KEY_Secret_key +"=").append(secretkey); 43 | System.out.println("sign=" + sb.toString()); 44 | } 45 | org.apache.shiro.crypto.hash.Md5Hash md5Hash = new Md5Hash(sb.toString()); 46 | return md5Hash.toHex().toUpperCase(); 47 | 48 | // return getMD5String(sb.toString()); 49 | } 50 | 51 | private String getMethodByChangeoverUri(String apiUri, Map params) { 52 | String method = OkexAPI.getMethodByApiUri(apiUri); 53 | String key = null; 54 | if (StringUtils.isBlank(method)) { 55 | for(Map.Entry entry : paramsMap.entrySet()) { 56 | key = entry.getKey(); 57 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 58 | apiUri = apiUri.replace(entry.getValue(), "{"+ key +"}"); 59 | } 60 | } 61 | method = OkexAPI.getMethodByApiUri(apiUri); 62 | } 63 | 64 | return method; 65 | } 66 | 67 | // /** 68 | // * 生成32位大写MD5值 69 | // */ 70 | // private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', 71 | // '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; 72 | // 73 | // public static String getMD5String(String str) { 74 | // try { 75 | // if (str == null || str.trim().length() == 0) { 76 | // return ""; 77 | // } 78 | // byte[] bytes = str.getBytes(); 79 | // MessageDigest messageDigest = MessageDigest.getInstance("MD5"); 80 | // messageDigest.update(bytes); 81 | // bytes = messageDigest.digest(); 82 | // StringBuilder sb = new StringBuilder(); 83 | // for (int i = 0; i < bytes.length; i++) { 84 | // sb.append(HEX_DIGITS[(bytes[i] & 0xf0) >> 4] + "" 85 | // + HEX_DIGITS[bytes[i] & 0xf]); 86 | // } 87 | // return sb.toString(); 88 | // } catch (NoSuchAlgorithmException e) { 89 | // e.printStackTrace(); 90 | // } 91 | // return ""; 92 | // } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/signature/RequestParamsSigner.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.signature; 2 | 3 | import java.util.Collections; 4 | import java.util.Comparator; 5 | import java.util.HashMap; 6 | import java.util.Iterator; 7 | import java.util.Map; 8 | import java.util.TreeMap; 9 | 10 | import javax.crypto.Mac; 11 | import javax.crypto.spec.SecretKeySpec; 12 | 13 | import org.apache.commons.codec.binary.Base64; 14 | import org.apache.commons.codec.binary.Hex; 15 | import org.apache.log4j.Logger; 16 | 17 | import com.mumu.exchange.common.Constants; 18 | 19 | abstract class RequestParamsSigner implements ISignature { 20 | 21 | protected final Logger logger = Logger.getLogger(this.getClass()); 22 | protected String apiRoot = null; 23 | protected String apiUri = null; 24 | private Map macCacheMap = new HashMap(); 25 | 26 | protected TreeMap paramsMap =new TreeMap(new Comparator() { 27 | @Override 28 | public int compare(String o1, String o2) { 29 | return o1.compareTo(o2); 30 | } 31 | }); 32 | 33 | @Override 34 | public ISignature setApiRoot(String apiRoot) { 35 | this.apiRoot = apiRoot; 36 | return this; 37 | } 38 | 39 | @Override 40 | public ISignature setApiUri(String uri) { 41 | this.apiUri = uri; 42 | return this; 43 | } 44 | 45 | @Override 46 | public ISignature putParam(String key, String value) { 47 | this.paramsMap.put(key, value); 48 | return this; 49 | } 50 | 51 | /** 52 | * 53 | * @param charset 54 | * @return 55 | */ 56 | protected String generateQryStr(String charset) { 57 | StringBuilder sb = new StringBuilder(); 58 | String key = null; 59 | try { 60 | // for(Map.Entry entry : paramsMap.entrySet()) { 61 | // key = entry.getKey(); 62 | // if (!key.startsWith(Constants.PATH_PARAM_PREFIX)) { 63 | // sb.append(key).append("=").append(java.net.URLEncoder.encode(entry.getValue(), charset)).append("&"); 64 | // } 65 | // } 66 | // 67 | Iterator> it = paramsMap.entrySet().iterator(); 68 | while(it.hasNext()){ 69 | Map.Entry entry = it.next(); 70 | 71 | key = entry.getKey(); 72 | if (!key.startsWith(Constants.PATH_PARAM_PREFIX)) { 73 | sb.append(key).append("=").append(java.net.URLEncoder.encode(entry.getValue(), charset)).append("&"); 74 | } else { 75 | it.remove(); 76 | } 77 | } 78 | 79 | 80 | } catch (Exception e) { 81 | e.printStackTrace(); 82 | } 83 | if (0 < sb.length()) { 84 | sb.replace(sb.length() - 1, sb.length(), ""); 85 | } 86 | return sb.toString(); 87 | } 88 | 89 | /** 90 | * 91 | * @param signMap 92 | * @param charset 93 | * @return 94 | */ 95 | protected String generateSignStr(Map signMap, String charset) { 96 | StringBuilder sb = new StringBuilder(); 97 | String key = null; 98 | try { 99 | for(Map.Entry entry : signMap.entrySet()) { 100 | key = entry.getKey(); 101 | 102 | sb.append(key).append("=").append(java.net.URLEncoder.encode(entry.getValue(), charset)).append("&"); 103 | } 104 | 105 | Iterator> it = paramsMap.entrySet().iterator(); 106 | while(it.hasNext()){ 107 | Map.Entry entry = it.next(); 108 | 109 | key = entry.getKey(); 110 | if (key.startsWith(Constants.PATH_PARAM_PREFIX)) { 111 | it.remove(); 112 | } 113 | } 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | sb.replace(sb.length() - 1, sb.length(), ""); 118 | return sb.toString(); 119 | } 120 | 121 | @Override 122 | public Map getParams() { 123 | return Collections.unmodifiableMap(this.paramsMap); 124 | } 125 | 126 | protected String hmacSHA256(String message, String secretkey) { 127 | String hash = null; 128 | try { 129 | Mac sha256_HMAC = this.macCacheMap.get(secretkey); 130 | if (null == sha256_HMAC) { 131 | sha256_HMAC = Mac.getInstance("HmacSHA256"); 132 | SecretKeySpec secret_key = new SecretKeySpec(secretkey.getBytes(), "HmacSHA256"); 133 | sha256_HMAC.init(secret_key); 134 | 135 | macCacheMap.put(secretkey, sha256_HMAC); 136 | } 137 | 138 | hash = Base64.encodeBase64String(sha256_HMAC.doFinal(message.getBytes())); 139 | System.out.println(hash); 140 | 141 | } catch (Exception e){ 142 | logger.error("HmacSHA256:", e); 143 | } 144 | 145 | return hash; 146 | } 147 | 148 | protected String hmacSHA256ToHex(String message, String secretkey) { 149 | String hash = null; 150 | try { 151 | Mac sha256_HMAC = this.macCacheMap.get(secretkey); 152 | if (null == sha256_HMAC) { 153 | sha256_HMAC = Mac.getInstance("HmacSHA256"); 154 | SecretKeySpec secret_key = new SecretKeySpec(secretkey.getBytes(), "HmacSHA256"); 155 | sha256_HMAC.init(secret_key); 156 | 157 | macCacheMap.put(secretkey, sha256_HMAC); 158 | } 159 | hash = Hex.encodeHexString(sha256_HMAC.doFinal(message.getBytes())); 160 | System.out.println(hash); 161 | 162 | } catch (Exception e){ 163 | logger.error("HmacSHA256:", e); 164 | } 165 | 166 | return hash; 167 | } 168 | 169 | @Override 170 | public ISignature addAllParams(Map params) { 171 | this.paramsMap.putAll(params); 172 | return this; 173 | } 174 | 175 | @Override 176 | public ISignature clearParams() { 177 | this.paramsMap.clear(); 178 | return this; 179 | } 180 | 181 | @Override 182 | public String getUri(String method, String charset) { 183 | if (org.springframework.http.HttpMethod.POST.name().equalsIgnoreCase(method)) { 184 | StringBuilder uri = new StringBuilder(this.apiRoot); 185 | uri.append(this.apiUri); 186 | return uri.toString(); 187 | } else { 188 | StringBuilder uri = new StringBuilder(this.apiRoot); 189 | uri.append(this.apiUri).append("?").append(generateQryStr(charset)); 190 | return uri.toString(); 191 | 192 | } 193 | 194 | } 195 | 196 | @Override 197 | public String sign(String accessKey, String secretkey) { 198 | // TODO Auto-generated method stub 199 | return null; 200 | } 201 | 202 | 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/trading/ITradingService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.trading; 2 | 3 | import java.util.Map; 4 | 5 | import com.mumu.beans.AccountInfo; 6 | import com.mumu.beans.Cancel; 7 | import com.mumu.beans.GetOrder; 8 | import com.mumu.beans.ListOrders; 9 | import com.mumu.beans.Order; 10 | import com.mumu.exchange.signature.ISignature; 11 | 12 | public interface ITradingService { 13 | 14 | public AccountInfo accountInfo(String accessKey, String secretkey, ISignature signature); 15 | 16 | public Order.Response orders(String accessKey, String secretkey, ISignature signature); 17 | 18 | public Cancel.Response cancel(String accessKey, String secretkey, ISignature signature); 19 | 20 | public GetOrder.Response orderInfo(String accessKey, String secretkey, ISignature signature); 21 | 22 | public ListOrders.Response unmatchedList(String accessKey, String secretkey, ISignature signature); 23 | 24 | // public String dealtList(String accessKey, String secretkey, ISignature signature); 25 | 26 | public String historyList(String accessKey, String secretkey, ISignature signature); 27 | 28 | public String depositList(String accessKey, String secretkey, ISignature signature); 29 | 30 | public String withdrawList(String accessKey, String secretkey, ISignature signature); 31 | 32 | public Map getOrdersParamsMap(Order order); 33 | public Map getCancelParamsMap(Cancel cancel); 34 | public Map getGetOrderParamsMap(GetOrder getOrder); 35 | public Map getListUnMatchedParamsMap(ListOrders listOrders); 36 | public Map getListMatchedParamsMap(ListOrders listOrders); 37 | public Map getListHistoryParamsMap(ListOrders listOrders); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/trading/OkexTradingService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.trading; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.http.client.fluent.Content; 9 | import org.apache.http.client.fluent.Request; 10 | 11 | import com.mumu.beans.AccountInfo; 12 | import com.mumu.beans.AccountInfo.AssetItem; 13 | import com.mumu.beans.Cancel; 14 | import com.mumu.beans.GetOrder; 15 | import com.mumu.beans.ListOrders; 16 | import com.mumu.beans.Order; 17 | import com.mumu.beans.OrderInfo; 18 | import com.mumu.common.Constants.EXCHANGE_NAME; 19 | import com.mumu.common.Constants.ORDER_STATUS; 20 | import com.mumu.common.Constants.ORDER_TYPE; 21 | import com.mumu.common.Constants.RESPONSE_STATUS; 22 | import com.mumu.common.Constants.TRADING_DIRECTION; 23 | import com.mumu.exchange.api.OkexAPI; 24 | import com.mumu.exchange.coins.OkexProfiles; 25 | import com.mumu.exchange.common.Constants; 26 | import com.mumu.exchange.common.Constants.OKEX_ORDER_STATUS; 27 | import com.mumu.exchange.common.JacksonHelper; 28 | import com.mumu.exchange.common.RequestUtils; 29 | import com.mumu.exchange.signature.ISignature; 30 | import com.mumu.exchange.signature.OkexParamsSigner; 31 | 32 | public final class OkexTradingService extends TradingService implements ITradingService { 33 | 34 | /** 35 | * {"result":true,"info":{"funds":{"free":{"ssc":"0","okb":"0","kcash":"0","theta":"0", 36 | * "vib":"0","ugc":"0","trio":"0","egt":"0","brd":"0", 37 | */ 38 | @Override 39 | public AccountInfo accountInfo(String accessKey, String secretkey, ISignature signature) { 40 | signature.setApiRoot(OkexAPI.rest_trading_root); 41 | signature.setApiUri(OkexAPI.api_userinfo); 42 | String authorization = signature.sign(accessKey, secretkey); 43 | String uri = signature.getUri(OkexAPI.api_userinfo_method_post, OkexParamsSigner.charset_utf8); 44 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 45 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 46 | logger.warn("uri=" + uri); 47 | Content content = null; 48 | try { 49 | Request request = Request.Post(uri); 50 | RequestUtils.setProxy(request); 51 | OkexProfiles.addHeader(request, OkexAPI.api_userinfo_method_post); 52 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 53 | content = request 54 | .execute() 55 | .returnContent(); 56 | 57 | AccountInfo accountInfo = new AccountInfo(); 58 | AccountInfo.AssetItem assetItem = null; 59 | Map jsonMap = JacksonHelper.getJsonMap(content.asString()); 60 | if (Boolean.valueOf(jsonMap.get("result").toString())) { 61 | accountInfo.setStatus(RESPONSE_STATUS.OK); 62 | 63 | Map assetList = ((Map)((Map)jsonMap.get("info")).get("funds")); 64 | Map freeMap = (Map) assetList.get("free"); 65 | Map freezedMap = (Map) assetList.get("freezed"); 66 | Map assetMap = new HashMap(freeMap.size()); 67 | 68 | for (Map.Entry entry : freeMap.entrySet()) { 69 | assetItem = accountInfo.new AssetItem(); 70 | assetItem.setCurrency(entry.getKey()); 71 | assetItem.setAvailable(entry.getValue().toString()); 72 | assetItem.setFrozen(freezedMap.get(entry.getKey()).toString()); 73 | 74 | assetMap.put(entry.getKey().toUpperCase(), assetItem); 75 | } 76 | accountInfo.setAssetMap(assetMap); 77 | } else { 78 | accountInfo.setStatus(RESPONSE_STATUS.ERROR); 79 | accountInfo.setErrorCode(jsonMap.get("error_code").toString()); 80 | accountInfo.setErrorMsg(Constants.oKexErrorMap.get(accountInfo.getErrorCode())); 81 | } 82 | 83 | return accountInfo; 84 | } catch (Exception e) { 85 | e.printStackTrace(); 86 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_userinfo +" 请求失败", e); 87 | } 88 | 89 | return null; 90 | 91 | } 92 | 93 | 94 | 95 | /** 96 | * o:{"error_code":1002} 97 | * o:{"result":true,"order_id":53649387} 98 | */ 99 | @Override 100 | public Order.Response orders(String accessKey, String secretkey, ISignature signature) { 101 | signature.setApiRoot(OkexAPI.rest_trading_root); 102 | signature.setApiUri(OkexAPI.api_trade); 103 | String authorization = signature.sign(accessKey, secretkey); 104 | String uri = signature.getUri(OkexAPI.api_trade_method_post, OkexParamsSigner.charset_utf8); 105 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 106 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 107 | logger.warn("uri=" + uri); 108 | Content content = null; 109 | try { 110 | Request request = Request.Post(uri); 111 | RequestUtils.setProxy(request); 112 | OkexProfiles.addHeader(request, OkexAPI.api_trade_method_post); 113 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 114 | content = request 115 | .execute() 116 | .returnContent(); 117 | 118 | Order.Response response = new Order.Response(); 119 | Map jsonMap = JacksonHelper.getJsonMap(content.asString()); 120 | if (null != jsonMap.get("result") && Boolean.valueOf(jsonMap.get("result").toString())) { 121 | response.setStatus(RESPONSE_STATUS.OK); 122 | response.setTid(jsonMap.get("order_id").toString()); 123 | } else { 124 | response.setStatus(RESPONSE_STATUS.ERROR); 125 | response.setErrorCode(jsonMap.get("error_code").toString()); 126 | response.setErrorMsg(Constants.oKexErrorMap.get(response.getErrorCode())); 127 | } 128 | return response; 129 | } catch (Exception e) { 130 | e.printStackTrace(); 131 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_trade +" 请求失败", e); 132 | } 133 | 134 | return null; 135 | } 136 | 137 | 138 | 139 | @Override 140 | public Cancel.Response cancel(String accessKey, String secretkey, ISignature signature) { 141 | signature.setApiRoot(OkexAPI.rest_trading_root); 142 | signature.setApiUri(OkexAPI.api_cancel_order); 143 | String authorization = signature.sign(accessKey, secretkey); 144 | String uri = signature.getUri(OkexAPI.api_cancel_order_method_post, OkexParamsSigner.charset_utf8); 145 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 146 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 147 | logger.warn("uri=" + uri); 148 | Content content = null; 149 | try { 150 | Request request = Request.Post(uri); 151 | RequestUtils.setProxy(request); 152 | OkexProfiles.addHeader(request, OkexAPI.api_cancel_order_method_post); 153 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 154 | content = request 155 | .execute() 156 | .returnContent(); 157 | 158 | Cancel.Response response = new Cancel.Response(); 159 | Map jsonMap = JacksonHelper.getJsonMap(content.asString()); 160 | if (null != jsonMap.get("result") && Boolean.valueOf(jsonMap.get("result").toString())) { 161 | response.setStatus(RESPONSE_STATUS.OK); 162 | response.setTid(jsonMap.get("order_id").toString()); 163 | } else { 164 | response.setStatus(RESPONSE_STATUS.ERROR); 165 | response.setErrorCode(jsonMap.get("error_code").toString()); 166 | response.setErrorMsg(Constants.oKexErrorMap.get(response.getErrorCode())); 167 | } 168 | return response; 169 | } catch (Exception e) { 170 | e.printStackTrace(); 171 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_cancel_order +" 请求失败", e); 172 | } 173 | 174 | return null; 175 | } 176 | 177 | 178 | 179 | @Override 180 | public Map getGetOrderParamsMap(GetOrder getOrder) { 181 | Map params = new HashMap(); 182 | params.put(OkexAPI.Api_order_info_params.symbol.getCode(), getOrder.getSymbol()); 183 | params.put(OkexAPI.Api_order_info_params.order_id.getCode(), getOrder.getTid()); 184 | 185 | return params; 186 | } 187 | 188 | 189 | 190 | @Override 191 | public Map getCancelParamsMap(Cancel cancel) { 192 | Map params = new HashMap(); 193 | params.put(OkexAPI.Api_cancel_order_params.symbol.getCode(), cancel.getSymbol()); 194 | params.put(OkexAPI.Api_cancel_order_params.order_id.getCode(), cancel.getTid()); 195 | 196 | return params; 197 | } 198 | 199 | 200 | 201 | @Override 202 | public GetOrder.Response orderInfo(String accessKey, String secretkey, ISignature signature) { 203 | signature.setApiRoot(OkexAPI.rest_trading_root); 204 | signature.setApiUri(OkexAPI.api_order_info); 205 | String authorization = signature.sign(accessKey, secretkey); 206 | String uri = signature.getUri(OkexAPI.api_order_info_method_post, OkexParamsSigner.charset_utf8); 207 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 208 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 209 | logger.warn("uri=" + uri); 210 | Content content = null; 211 | try { 212 | Request request = Request.Post(uri); 213 | RequestUtils.setProxy(request); 214 | OkexProfiles.addHeader(request, OkexAPI.api_order_info_method_post); 215 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 216 | content = request 217 | .execute() 218 | .returnContent(); 219 | 220 | // {"result":true,"orders":[{"amount":0.068394,"avg_price":0,"create_date":1535073706000,"deal_amount":0, 221 | // "order_id":54614577,"orders_id":54614577,"price":0.18162686,"status":0,"symbol":"ltc_eth","type":"buy"}]} 222 | GetOrder.Response response = new GetOrder.Response(); 223 | Map jsonMap = JacksonHelper.getJsonMap(content.asString()); 224 | if (null != jsonMap.get("result") && Boolean.valueOf(jsonMap.get("result").toString())) { 225 | List> listMap = (List>) jsonMap.get("orders"); 226 | jsonMap = listMap.get(0); 227 | response.setStatus(RESPONSE_STATUS.OK); 228 | 229 | OrderInfo orderInfo = new OrderInfo(); 230 | String[] orderType = jsonMap.get("type").toString().split("_"); 231 | orderInfo.setDirection(TRADING_DIRECTION.valueOf(orderType[0].toUpperCase())); 232 | orderInfo.setExchange(EXCHANGE_NAME.EXCHANGE_OKEX); 233 | orderInfo.setId(jsonMap.get("order_id").toString()); 234 | orderInfo.setOriginalVolume(jsonMap.get("amount").toString()); 235 | orderInfo.setPrice(jsonMap.get("price").toString()); 236 | ORDER_STATUS status = ORDER_STATUS.valueOf(OKEX_ORDER_STATUS.getByCode(jsonMap.get("status").toString()).getStatus()); 237 | orderInfo.setStatus(status); 238 | orderInfo.setSymbol(jsonMap.get("symbol").toString()); 239 | orderInfo.setTs(jsonMap.get("create_date").toString()); 240 | ORDER_TYPE type = null; 241 | if (1 == orderType.length) { 242 | type = ORDER_TYPE.LIMIT; 243 | } else { 244 | type = ORDER_TYPE.MARKET; 245 | } 246 | orderInfo.setType(type); 247 | orderInfo.setVolume(jsonMap.get("deal_amount").toString()); 248 | 249 | response.setOrderInfo(orderInfo); 250 | } else { 251 | response.setStatus(RESPONSE_STATUS.ERROR); 252 | response.setErrorCode(jsonMap.get("error_code").toString()); 253 | response.setErrorMsg(Constants.oKexErrorMap.get(response.getErrorCode())); 254 | } 255 | return response; 256 | } catch (Exception e) { 257 | e.printStackTrace(); 258 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_order_info +" 请求失败", e); 259 | } 260 | 261 | return null; 262 | } 263 | 264 | 265 | 266 | @Override 267 | public ListOrders.Response unmatchedList(String accessKey, String secretkey, ISignature signature) { 268 | signature.setApiRoot(OkexAPI.rest_trading_root); 269 | signature.setApiUri(OkexAPI.api_order_info); 270 | signature.putParam(OkexAPI.Api_order_info_params.order_id.getCode(), "-1"); 271 | String authorization = signature.sign(accessKey, secretkey); 272 | String uri = signature.getUri(OkexAPI.api_order_info_method_post, OkexParamsSigner.charset_utf8); 273 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 274 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 275 | logger.warn("uri=" + uri); 276 | Content content = null; 277 | try { 278 | Request request = Request.Post(uri); 279 | RequestUtils.setProxy(request); 280 | OkexProfiles.addHeader(request, OkexAPI.api_order_info_method_post); 281 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 282 | content = request 283 | .execute() 284 | .returnContent(); 285 | 286 | ListOrders.Response response = new ListOrders.Response(); 287 | Map jsonMap = JacksonHelper.getJsonMap(content.asString()); 288 | if (null != jsonMap.get("result") && Boolean.valueOf(jsonMap.get("result").toString())) { 289 | List> listMap = (List>) jsonMap.get("orders"); 290 | List orderInfoList = new ArrayList(listMap.size()); 291 | OrderInfo orderInfo = null; 292 | 293 | for (Map jsonMap2 : listMap) { 294 | orderInfo = new OrderInfo(); 295 | String[] orderType = jsonMap2.get("type").toString().split("_"); 296 | orderInfo.setDirection(TRADING_DIRECTION.valueOf(orderType[0].toUpperCase())); 297 | orderInfo.setExchange(EXCHANGE_NAME.EXCHANGE_OKEX); 298 | orderInfo.setId(jsonMap2.get("order_id").toString()); 299 | orderInfo.setOriginalVolume(jsonMap2.get("amount").toString()); 300 | orderInfo.setPrice(jsonMap2.get("price").toString()); 301 | ORDER_STATUS status = ORDER_STATUS.valueOf(OKEX_ORDER_STATUS.getByCode(jsonMap2.get("status").toString()).getStatus()); 302 | orderInfo.setStatus(status); 303 | orderInfo.setSymbol(jsonMap2.get("symbol").toString()); 304 | orderInfo.setTs(jsonMap2.get("create_date").toString()); 305 | ORDER_TYPE type = null; 306 | if (1 == orderType.length) { 307 | type = ORDER_TYPE.LIMIT; 308 | } else { 309 | type = ORDER_TYPE.MARKET; 310 | } 311 | orderInfo.setType(type); 312 | orderInfo.setVolume(jsonMap2.get("deal_amount").toString()); 313 | 314 | orderInfoList.add(orderInfo); 315 | } 316 | 317 | response.setStatus(RESPONSE_STATUS.OK); 318 | response.setListOrderInfo(orderInfoList); 319 | } else { 320 | response.setStatus(RESPONSE_STATUS.ERROR); 321 | response.setErrorCode(jsonMap.get("error_code").toString()); 322 | response.setErrorMsg(Constants.oKexErrorMap.get(response.getErrorCode())); 323 | } 324 | return response; 325 | } catch (Exception e) { 326 | e.printStackTrace(); 327 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_order_info +" 请求失败", e); 328 | } 329 | 330 | return null; 331 | 332 | } 333 | 334 | 335 | 336 | @Override 337 | public Map getListUnMatchedParamsMap(ListOrders listOrders) { 338 | Map params = new HashMap(); 339 | params.put(OkexAPI.Api_order_info_params.symbol.getCode(), listOrders.getSymbol()); 340 | return params; 341 | } 342 | 343 | 344 | 345 | @Override 346 | public String historyList(String accessKey, String secretkey, ISignature signature) { 347 | signature.setApiRoot(OkexAPI.rest_trading_root); 348 | signature.setApiUri(OkexAPI.api_order_history); 349 | String authorization = signature.sign(accessKey, secretkey); 350 | String uri = signature.getUri(OkexAPI.api_order_history_method_post, OkexParamsSigner.charset_utf8); 351 | // uri = uri + "&" + OkexAPI.API_SIGN_KEY_authorization +"="+ authorization; 352 | signature.putParam(OkexAPI.API_SIGN_KEY_authorization, authorization); 353 | logger.warn("uri=" + uri); 354 | Content content = null; 355 | try { 356 | Request request = Request.Post(uri); 357 | RequestUtils.setProxy(request); 358 | OkexProfiles.addHeader(request, OkexAPI.api_order_history_method_post); 359 | RequestUtils.addForm(request, signature.getParams(), OkexParamsSigner.charset_utf8); 360 | content = request 361 | .execute() 362 | .returnContent(); 363 | 364 | } catch (Exception e) { 365 | e.printStackTrace(); 366 | super.logger.error(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX +":"+ OkexAPI.api_order_history +" 请求失败", e); 367 | } 368 | 369 | String result = content.asString(); 370 | return result; 371 | } 372 | 373 | 374 | 375 | 376 | @Override 377 | public Map getOrdersParamsMap(Order order) { 378 | Map params = new HashMap(); 379 | params.put(OkexAPI.Api_trade_params.amount.getCode(), String.valueOf(order.getVolume())); 380 | params.put(OkexAPI.Api_trade_params.price.getCode(), String.valueOf(order.getPrice())); 381 | params.put(OkexAPI.Api_trade_params.symbol.getCode(), order.getSymbol()); 382 | String type = order.getDirection().getCode().toLowerCase(); 383 | if (ORDER_TYPE.MARKET.equals(order.getType())) { 384 | type = com.mumu.exchange.common.Constants.OKEX_ORDER_TYPE.getByCode(order.getDirection().getCode().toLowerCase() +"_"+ order.getType().getCode().toLowerCase()).getCode().toLowerCase(); 385 | } 386 | params.put(OkexAPI.Api_trade_params.type.getCode(), type); 387 | 388 | return params; 389 | } 390 | } 391 | -------------------------------------------------------------------------------- /src/main/java/com/mumu/exchange/trading/TradingService.java: -------------------------------------------------------------------------------- 1 | package com.mumu.exchange.trading; 2 | 3 | import java.util.Map; 4 | 5 | import org.apache.log4j.Logger; 6 | 7 | import com.mumu.beans.AccountInfo; 8 | import com.mumu.beans.Cancel; 9 | import com.mumu.beans.GetOrder; 10 | import com.mumu.beans.ListOrders; 11 | import com.mumu.beans.Order; 12 | import com.mumu.exchange.signature.ISignature; 13 | 14 | 15 | public abstract class TradingService implements ITradingService { 16 | 17 | protected final Logger logger = Logger.getLogger(this.getClass()); 18 | // protected final JavaType mapType = JacksonUtils.getMapper().getTypeFactory().constructParametricType(HashMap.class, String.class, Object.class); 19 | 20 | 21 | 22 | @Override 23 | public AccountInfo accountInfo(String accessKey, String secretkey, ISignature signature) { 24 | // TODO Auto-generated method stub 25 | return null; 26 | } 27 | 28 | @Override 29 | public Order.Response orders(String accessKey, String secretkey, ISignature signature) { 30 | // TODO Auto-generated method stub 31 | return null; 32 | } 33 | 34 | @Override 35 | public Cancel.Response cancel(String accessKey, String secretkey, ISignature signature) { 36 | // TODO Auto-generated method stub 37 | return null; 38 | } 39 | 40 | @Override 41 | public GetOrder.Response orderInfo(String accessKey, String secretkey, ISignature signature) { 42 | // TODO Auto-generated method stub 43 | return null; 44 | } 45 | 46 | @Override 47 | public ListOrders.Response unmatchedList(String accessKey, String secretkey, ISignature signature) { 48 | // TODO Auto-generated method stub 49 | return null; 50 | } 51 | 52 | @Override 53 | public String historyList(String accessKey, String secretkey, ISignature signature) { 54 | // TODO Auto-generated method stub 55 | return null; 56 | } 57 | 58 | @Override 59 | public String depositList(String accessKey, String secretkey, ISignature signature) { 60 | // TODO Auto-generated method stub 61 | return null; 62 | } 63 | 64 | @Override 65 | public String withdrawList(String accessKey, String secretkey, ISignature signature) { 66 | // TODO Auto-generated method stub 67 | return null; 68 | } 69 | 70 | @Override 71 | public Map getOrdersParamsMap(Order order) { 72 | // TODO Auto-generated method stub 73 | return null; 74 | } 75 | 76 | @Override 77 | public Map getCancelParamsMap(Cancel cancel) { 78 | // TODO Auto-generated method stub 79 | return null; 80 | } 81 | 82 | @Override 83 | public Map getGetOrderParamsMap(GetOrder getOrder) { 84 | // TODO Auto-generated method stub 85 | return null; 86 | } 87 | 88 | @Override 89 | public Map getListUnMatchedParamsMap(ListOrders listOrders) { 90 | // TODO Auto-generated method stub 91 | return null; 92 | } 93 | 94 | @Override 95 | public Map getListMatchedParamsMap(ListOrders listOrders) { 96 | // TODO Auto-generated method stub 97 | return null; 98 | } 99 | 100 | @Override 101 | public Map getListHistoryParamsMap(ListOrders listOrders) { 102 | // TODO Auto-generated method stub 103 | return null; 104 | } 105 | 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/test/java/MarketTest.java: -------------------------------------------------------------------------------- 1 | import com.mumu.exchange.MarketServiceFactory; 2 | 3 | public class MarketTest { 4 | 5 | public static void main(String[] args) { 6 | String accessKey1 = ""; 7 | String secretkey1 = ""; 8 | // MarketServiceFactory.getInstance(Constants.EXCHANGE_HOUBI).quotationTicker(accessKey1, secretkey1, "bchbtc"); 9 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI).getSettlementPrice(accessKey1, secretkey1, 60, "bchbtc"); 10 | // 11 | String accessKey2 = ""; 12 | String secretkey2 = ""; 13 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX).quotationTicker(accessKey2, secretkey2, "bch_btc"); 14 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX).getSettlementPrice(accessKey2, secretkey2, 60, "bch_btc"); 15 | // 16 | String accessKey3 = ""; 17 | String secretkey3 = ""; 18 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX).quotationTicker(accessKey3, secretkey3, "BTCBCH");//BTCBCH 19 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX).getSettlementPrice(accessKey3, secretkey3, 60, "BTCBCH"); 20 | 21 | 22 | String accessKey4 = ""; 23 | String secretkey4 = ""; 24 | MarketServiceFactory.getInstance(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE).quotationTicker(accessKey4, secretkey4, "BTCUSDT");// "BNBBTC,LTCBTC" 25 | // MarketServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE).getSettlementPrice(accessKey4, secretkey4, 60, "BTCUSDT"); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/TradingTest.java: -------------------------------------------------------------------------------- 1 | import com.mumu.beans.ListOrders; 2 | import com.mumu.exchange.TradingServiceFactory; 3 | 4 | public class TradingTest { 5 | 6 | public static void main(String[] args) { 7 | //-----------------------------------------BINANCEBINANCEBINANCEBINANCEBINANCEBINANCE-----------------------------------------------------------------------// 8 | String accessKey4 = ""; 9 | String secretkey4 = ""; 10 | // 11 | accessKey4 = ""; 12 | secretkey4 = ""; 13 | // AccountInfo accountInfo = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE).accountInfo(accessKey4, secretkey4, "userid"); 14 | 15 | // Order order = new Order(); 16 | // order.setSymbol("ETHUSDT"); 17 | // order.setPrice("380"); 18 | // order.setVolume("0.04000"); 19 | // order.setAccessKey(accessKey4); 20 | // order.setDirection(TRADING_DIRECTION.SELL); 21 | // order.setRequestId(CommonUtils.genUniqueInt()+""); 22 | // order.setSecretkey(secretkey4); 23 | // order.setType(ORDER_TYPE.LIMIT); 24 | // Order.Response response = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 25 | // .orders(order); 26 | 27 | // Cancel cancel = new Cancel(); 28 | // cancel.setAccessKey(accessKey4); 29 | // cancel.setSecretkey(secretkey4); 30 | // cancel.setSymbol("ETHUSDT"); 31 | // cancel.setTid("106751148"); 32 | // Cancel.Response response = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 33 | // .cancel(cancel); 34 | 35 | 36 | // GetOrder getOrder = new GetOrder(); 37 | // getOrder.setSymbol("ETHUSDT"); 38 | // getOrder.setAccessKey(accessKey4); 39 | // getOrder.setSecretkey(secretkey4); 40 | // getOrder.setTid("107276381"); 41 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 42 | // .orderInfo(getOrder); 43 | 44 | // ListOrders listOrders = new ListOrders(); 45 | // listOrders.setAccessKey(accessKey4); 46 | // listOrders.setSecretkey(secretkey4); 47 | // listOrders.setSymbol("ETHUSDT"); 48 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 49 | // .unmatchedList(listOrders); 50 | 51 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 52 | // .putParam(BinanceAPI.Api_allOrders_params.symbol.getCode(), "ETHUSDT") 53 | // .historyList(accessKey, secretkey); 54 | // System.out.println(accountInfoJson); 55 | 56 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE) 57 | // .putParam(BinanceAPI.Wapi_depositHistory_params.asset.getCode(), "ETH") 58 | // .depositList(accessKey, secretkey); 59 | // System.out.println(accountInfoJson); 60 | 61 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_BINANCE)//xxxx 62 | // .putParam(BinanceAPI.Wapi_withdrawHistory_params.asset.getCode(), "ETH") 63 | // .putParam(BinanceAPI.Wapi_withdrawHistory_params.status.getCode(), Constants.BINANCE_WITHDRAW_STATUS.Completed.getCode()) 64 | // .withdrawList(accessKey, secretkey); 65 | // System.out.println(accountInfoJson); 66 | 67 | //-----------------------------------------COINEXCOINEXCOINEXCOINEX-----------------------------------------------------------------------// 68 | 69 | String accessKey2 = ""; 70 | String secretkey2 = ""; 71 | // AccountInfo accountInfo = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX).accountInfo(accessKey2, secretkey2,"2432432423"); 72 | // Order order = new Order(); 73 | // order.setSymbol("ETHBCH"); 74 | // order.setPrice("0.5466036"); 75 | // order.setVolume("0.0300"); 76 | // order.setAccessKey(accessKey2); 77 | // order.setDirection(TRADING_DIRECTION.BUY); 78 | // order.setRequestId(CommonUtils.genUniqueInt()+""); 79 | // order.setSecretkey(secretkey2); 80 | // order.setType(ORDER_TYPE.LIMIT); 81 | // System.out.println(TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX) 82 | // .orders(order).getTid()); 83 | 84 | // Cancel cancel = new Cancel(); 85 | // cancel.setAccessKey(accessKey2); 86 | // cancel.setSecretkey(secretkey2); 87 | // cancel.setSymbol("CETBCH"); 88 | // cancel.setTid("1371225525"); 89 | // Cancel.Response response = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX) 90 | // .cancel(cancel); 91 | 92 | // GetOrder getOrder = new GetOrder(); 93 | // getOrder.setAccessKey(accessKey2); 94 | // getOrder.setSecretkey(secretkey2); 95 | // getOrder.setTid("1392841140"); 96 | // getOrder.setSymbol("ETHBCH"); 97 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX).orderInfo(getOrder); 98 | 99 | //"id": 1293194399, 100 | // ListOrders listOrders = new ListOrders(); 101 | // listOrders.setAccessKey(accessKey2); 102 | // listOrders.setSecretkey(secretkey2); 103 | // listOrders.setSymbol("ETHBCH"); 104 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX) 105 | // .unmatchedList(listOrders); 106 | 107 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_COINEX) 108 | // .putParam(CoinexAPI.Order_finished_params.market.getCode(), "ETHBCH") 109 | // .putParam(CoinexAPI.Order_finished_params.page.getCode(), "1") 110 | // .putParam(CoinexAPI.Order_finished_params.limit.getCode(), "1") 111 | // .historyList(accessKey, secretkey); 112 | // System.out.println(accountInfoJson); 113 | //--------------------------------------------------火火火火火火火火火币--------------------------------------------------------------// 114 | String accessKey = ""; 115 | String secretkey = ""; 116 | // AccountInfo accountInfo = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI).accountInfo(accessKey, secretkey, "46915295"); 117 | // 118 | // Order order = new Order(); 119 | // order.setAccountId("4276741"); 120 | // order.setSymbol("bchbtc"); 121 | // order.setPrice("0.083489"); 122 | // order.setAccessKey(accessKey); 123 | // order.setDirection(TRADING_DIRECTION.BUY); 124 | // order.setRequestId(CommonUtils.genUniqueInt()+""); 125 | // order.setSecretkey(secretkey); 126 | // order.setType(ORDER_TYPE.LIMIT); 127 | // order.setVolume("0.0005"); 128 | // Order.Response response = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI).orders(order); 129 | 130 | // Cancel cancel = new Cancel(); 131 | // cancel.setAccessKey(accessKey); 132 | // cancel.setSecretkey(secretkey); 133 | // cancel.setTid("1371225525"); 134 | // Cancel.Response response = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI) 135 | // .cancel(cancel); 136 | 137 | // GetOrder getOrder = new GetOrder(); 138 | // getOrder.setTid("10721786675"); 139 | // getOrder.setAccessKey(accessKey); 140 | // getOrder.setSecretkey(secretkey); 141 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI).orderInfo(getOrder); 142 | 143 | // ListOrders listOrders = new ListOrders(); 144 | // listOrders.setAccessKey(accessKey); 145 | // listOrders.setSecretkey(secretkey); 146 | // listOrders.setSymbol("bchbtc"); 147 | // listOrders.setAccountId("4276741"); 148 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI) 149 | // .unmatchedList(listOrders); 150 | 151 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI) 152 | // .putParam(HoubiAPI.Order_orders_params.symbol.getCode(), "bchbtc") 153 | // .historyList(accessKey, secretkey); 154 | // System.out.println(accountInfoJson); 155 | 156 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI) 157 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.currency.getCode(), "btc") 158 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.size.getCode(), "10") 159 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.from.getCode(), "0") 160 | // .depositList(accessKey, secretkey); 161 | // System.out.println(accountInfoJson); 162 | // 163 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_HOUBI) 164 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.currency.getCode(), "btc") 165 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.size.getCode(), "10") 166 | // .putParam(HoubiAPI.Query_deposit_withdraw_params.from.getCode(), "0") 167 | // .withdrawList(accessKey, secretkey); 168 | // System.out.println(accountInfoJson); 169 | //-----------------------------------------OKEXOKEXOKEXOKEXOKEXOKEXOKEXOKEXOKEXOKEXOKEXOKEX-----------------------------------------------------------------------// 170 | 171 | String accessKey3 = ""; 172 | String secretkey3 = ""; 173 | // AccountInfo accountInfo = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX).accountInfo(accessKey3, secretkey3, "tewtes"); 174 | 175 | // Order order = new Order(); 176 | // order.setSymbol("ltc_eth"); 177 | // order.setPrice("0.18162686"); 178 | // order.setVolume("0.068394"); 179 | // order.setAccessKey(accessKey3); 180 | // order.setDirection(TRADING_DIRECTION.BUY); 181 | // order.setRequestId(CommonUtils.genUniqueInt()+""); 182 | // order.setSecretkey(secretkey3); 183 | // order.setType(ORDER_TYPE.LIMIT); 184 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX) 185 | // .orders(order); 186 | 187 | // Cancel cancel = new Cancel(); 188 | // cancel.setAccessKey(accessKey3); 189 | // cancel.setSecretkey(secretkey3); 190 | // cancel.setSymbol("ltc_eth"); 191 | // cancel.setTid("53649387"); 192 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX).cancel(cancel); 193 | 194 | // 54614577 195 | // GetOrder getOrder = new GetOrder(); 196 | // getOrder.setAccessKey(accessKey3); 197 | // getOrder.setSecretkey(secretkey3); 198 | // getOrder.setSymbol("ltc_eth"); 199 | // getOrder.setTid("54614577"); 200 | // TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX).orderInfo(getOrder); 201 | 202 | 203 | ListOrders listOrders = new ListOrders(); 204 | listOrders.setAccessKey(accessKey3); 205 | listOrders.setSecretkey(secretkey3); 206 | listOrders.setSymbol("ltc_eth"); 207 | TradingServiceFactory.getInstance(com.mumu.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX) 208 | .unmatchedList(listOrders); 209 | 210 | // accountInfoJson = TradingServiceFactory.getInstance(com.xinqidian.business.exchange.common.Constants.EXCHANGE_NAME.EXCHANGE_OKEX) 211 | // .putParam(OkexAPI.Api_order_history_params.symbol.getCode(), "bch_eth") 212 | // .putParam(OkexAPI.Api_order_history_params.status.getCode(), Constants.OKEX_COMMON_STATUS.done.getCode()) 213 | // .putParam(OkexAPI.Api_order_history_params.current_page.getCode(), "1") 214 | // .putParam(OkexAPI.Api_order_history_params.page_length.getCode(), "200") 215 | // .historyList(accessKey, secretkey); 216 | // System.out.println(accountInfoJson); 217 | } 218 | 219 | 220 | } 221 | -------------------------------------------------------------------------------- /target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Built-By: Administrator 3 | Build-Jdk: 1.8.0_152 4 | Created-By: Maven Integration for Eclipse 5 | 6 | -------------------------------------------------------------------------------- /target/classes/META-INF/maven/com.mumu/mm-vcoinSDK/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon Aug 27 11:15:15 CST 2018 3 | version=2.6.6-SNAPSHOT 4 | groupId=com.mumu 5 | m2e.projectName=mm-vcoinSDK 6 | m2e.projectLocation=E\:\\workspace\\mm-vcoinSDK 7 | artifactId=mm-vcoinSDK 8 | -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/AccountInfo$AssetItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/AccountInfo$AssetItem.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/AccountInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/AccountInfo.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Cancel$Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Cancel$Response.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Cancel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Cancel.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Common.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Common.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/DealtInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/DealtInfo.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/GetOrder$Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/GetOrder$Response.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/GetOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/GetOrder.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/ListOrders$Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/ListOrders$Response.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/ListOrders.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/ListOrders.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Market.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Market.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Order$Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Order$Response.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/Order.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/Order.class -------------------------------------------------------------------------------- /target/classes/com/mumu/beans/OrderInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/beans/OrderInfo.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/BaseForm.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/BaseForm.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants$EXCHANGE_NAME.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants$EXCHANGE_NAME.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants$ORDER_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants$ORDER_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants$ORDER_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants$ORDER_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants$RESPONSE_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants$RESPONSE_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants$TRADING_DIRECTION.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants$TRADING_DIRECTION.class -------------------------------------------------------------------------------- /target/classes/com/mumu/common/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/common/Constants.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/MarketServiceFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/MarketServiceFactory.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/TradingServiceFactory$TradingServiceSPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/TradingServiceFactory$TradingServiceSPI.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/TradingServiceFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/TradingServiceFactory.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_allOrders_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_allOrders_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_cancel_order_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_cancel_order_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_get_order_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_get_order_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_openOrders_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_openOrders_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_order_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_order_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_ticker_24hr_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_ticker_24hr_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_trades_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_trades_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Api_userinfo_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Api_userinfo_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Wapi_depositHistory_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Wapi_depositHistory_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI$Wapi_withdrawHistory_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI$Wapi_withdrawHistory_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/BinanceAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/BinanceAPI.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Balance_info_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Balance_info_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Market_deals_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Market_deals_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Market_ticker_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Market_ticker_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Order_finished_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Order_finished_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Order_path$orderType_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Order_path$orderType_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Order_pending_list_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Order_pending_list_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Order_pending_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Order_pending_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI$Order_status_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI$Order_status_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/CoinexAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/CoinexAPI.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Account_accounts_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Account_accounts_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Accounts_p$accountId_balance_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Accounts_p$accountId_balance_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Market_detail_merged_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Market_detail_merged_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Market_history_trade_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Market_history_trade_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Order_openOrders_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Order_openOrders_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_path$orderId_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_path$orderId_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_path$orderId_submitcancel_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_path$orderId_submitcancel_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_place_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Order_orders_place_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI$Query_deposit_withdraw_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI$Query_deposit_withdraw_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/HoubiAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/HoubiAPI.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_cancel_order_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_cancel_order_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_order_history_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_order_history_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_order_info_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_order_info_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_orders_info_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_orders_info_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_ticker_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_ticker_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_trade_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_trade_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_trades_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_trades_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI$Api_userinfo_params.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI$Api_userinfo_params.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/api/OkexAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/api/OkexAPI.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/coins/BinanceProfiles.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/coins/BinanceProfiles.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/coins/CoinexProfiles.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/coins/CoinexProfiles.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/coins/HuobiProfiles.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/coins/HuobiProfiles.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/coins/OkexProfiles.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/coins/OkexProfiles.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_DEPOSIT_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_DEPOSIT_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_SIDE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_SIDE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_ORDER_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_RESP_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_RESP_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_SYMBOL_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_SYMBOL_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_TIMEINFORCE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_TIMEINFORCE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$BINANCE_WITHDRAW_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$BINANCE_WITHDRAW_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_DIRECTION.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_DIRECTION.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$COINEX_ORDER_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$HUOBI_ACCOUNTS_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$HUOBI_ACCOUNTS_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$HUOBI_DEPOSIT_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$HUOBI_DEPOSIT_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$HUOBI_ORDER_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$HUOBI_ORDER_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$HUOBI_ORDER_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$HUOBI_ORDER_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$HUOBI_WITHDRAW_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$HUOBI_WITHDRAW_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$OKEX_COMMON_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$OKEX_COMMON_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$OKEX_ORDER_STATUS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$OKEX_ORDER_STATUS.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants$OKEX_ORDER_TYPE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants$OKEX_ORDER_TYPE.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/Constants.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/JacksonHelper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/JacksonHelper.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/common/RequestUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/common/RequestUtils.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/BinanceMarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/BinanceMarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/CoinexMarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/CoinexMarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/HuobiMarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/HuobiMarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/IMarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/IMarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/MarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/MarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/market/OkexMarketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/market/OkexMarketService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/BinanceParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/BinanceParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/BinanceParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/BinanceParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/CoinexParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/CoinexParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/CoinexParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/CoinexParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/HoubiParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/HoubiParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/HoubiParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/HoubiParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/HuobiParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/HuobiParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/HuobiParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/HuobiParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/ISignature.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/ISignature.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/OkexParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/OkexParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/OkexParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/OkexParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/RequestParamsSigner$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/RequestParamsSigner$1.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/signature/RequestParamsSigner.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/signature/RequestParamsSigner.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/BinanceTradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/BinanceTradingService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/CoinexTradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/CoinexTradingService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/HuobiTradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/HuobiTradingService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/ITradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/ITradingService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/OkexTradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/OkexTradingService.class -------------------------------------------------------------------------------- /target/classes/com/mumu/exchange/trading/TradingService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/classes/com/mumu/exchange/trading/TradingService.class -------------------------------------------------------------------------------- /target/test-classes/MarketTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/test-classes/MarketTest.class -------------------------------------------------------------------------------- /target/test-classes/TradingTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/target/test-classes/TradingTest.class -------------------------------------------------------------------------------- /transaction.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumusenlingongyuan/mm-vcoinSDK/f3035408a3370a5e707cff7fb1e2db67c3b4f0f1/transaction.log --------------------------------------------------------------------------------