新增mql5接口
parent
51c29c89c3
commit
304b2408d6
@ -0,0 +1,66 @@
|
||||
package com.sztzjy.forex.trading_trading.common.mql5API;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sztzjy.forex.trading_trading.entity.mql5Entity.CurrencyEntity;
|
||||
import com.sztzjy.forex.trading_trading.entity.mql5Entity.ExchangeFrateEntity;
|
||||
import com.sztzjy.forex.trading_trading.entity.mql5Entity.RmbquotEntity;
|
||||
import com.sztzjy.forex.trading_trading.util.HttpUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class Mql5API {
|
||||
|
||||
//货币代码APPKEY
|
||||
private String CurrencyCode = "35510fd564e5b1a3455fe53e96cdce2e";
|
||||
//汇率APPKEY
|
||||
private String ExchangeRate = "41a4467c339f65ca86978cf5feb5f683";
|
||||
//查询货币代码地址
|
||||
private String CurrencyAddr = "http://op.juhe.cn/onebox/exchange/list?key=35510fd564e5b1a3455fe53e96cdce2e";
|
||||
//查询人民币牌价地址
|
||||
private String RmbquotAddr = "http://web.juhe.cn/finance/exchange/rmbquot?key=41a4467c339f65ca86978cf5feb5f683";
|
||||
//查询外汇汇率地址
|
||||
private String ExchangeFrateAddr = "http://web.juhe.cn/finance/exchange/frate?key=41a4467c339f65ca86978cf5feb5f683";
|
||||
|
||||
|
||||
//查询常见货币代码
|
||||
public CurrencyEntity getCurrencyList() {
|
||||
try {
|
||||
String returnStr = HttpUtils.sendGet(CurrencyAddr);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
CurrencyEntity currency = objectMapper.readValue(returnStr, CurrencyEntity.class);
|
||||
return currency;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//查询人民币牌价
|
||||
public RmbquotEntity getRmbquot() {
|
||||
try {
|
||||
String returnStr = HttpUtils.sendGet(RmbquotAddr);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
RmbquotEntity rmbquot = objectMapper.readValue(returnStr, RmbquotEntity.class);
|
||||
return rmbquot;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//查询外汇汇率
|
||||
public ExchangeFrateEntity getExchangeFrate() {
|
||||
try {
|
||||
String returnStr = HttpUtils.sendGet(ExchangeFrateAddr);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ExchangeFrateEntity exchangeFrate = objectMapper.readValue(returnStr, ExchangeFrateEntity.class);
|
||||
return exchangeFrate;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.sztzjy.forex.trading_trading.entity.mql5Entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
//常见货币代码实体类
|
||||
public class CurrencyEntity {
|
||||
private String reason;
|
||||
private Result result;
|
||||
private int error_code;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Result {
|
||||
private List<Currency> list;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Currency {
|
||||
private String name;
|
||||
private String code;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.sztzjy.forex.trading_trading.entity.mql5Entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
//外汇汇率实例
|
||||
public class ExchangeFrateEntity {
|
||||
private int error_code;
|
||||
private String resultcode;
|
||||
private String reason;
|
||||
private List<Data> result;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Data {
|
||||
private ForexData data1;
|
||||
private ForexData data2;
|
||||
private ForexData data3;
|
||||
private ForexData data4;
|
||||
private ForexData data5;
|
||||
private ForexData data6;
|
||||
private ForexData data7;
|
||||
private ForexData data8;
|
||||
private ForexData data9;
|
||||
private ForexData data10;
|
||||
private ForexData data11;
|
||||
private ForexData data12;
|
||||
private ForexData data13;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ForexData {
|
||||
private String buyPic;
|
||||
private String closePri;
|
||||
private String code;
|
||||
private String color;
|
||||
private String currency;
|
||||
private String datatime;
|
||||
private String date;
|
||||
private String diffAmo;
|
||||
private String diffPer;
|
||||
private String highPic;
|
||||
private String lowPic;
|
||||
private String openPri;
|
||||
private String range;
|
||||
private String sellPic;
|
||||
private String yesPic;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.sztzjy.forex.trading_trading.entity.mql5Entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
//人民币牌价实体类
|
||||
public class RmbquotEntity {
|
||||
private int error_code;
|
||||
private String resultcode;
|
||||
private String reason;
|
||||
private List<ResultData> result;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ResultData {
|
||||
private RmbquotData data1;
|
||||
private RmbquotData data2;
|
||||
private RmbquotData data3;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class RmbquotData {
|
||||
private String bankConversionPri;
|
||||
private String date;
|
||||
private String fBuyPri;
|
||||
private String fSellPri;
|
||||
private String mBuyPri;
|
||||
private String mSellPri;
|
||||
private String name;
|
||||
private String time;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue