【发布时间】:2020-09-27 10:44:49
【问题描述】:
我对编程有点陌生,并将其作为工作任务。我需要运行一个使用多个数据集多次发送消息(FIX 格式)的方法。以下是我使用其各自数据构建并发送消息的方式:
private void testCaseAttempt(String testCaseName) throws Exception {
StringBuilder errorBuilder = new StringBuilder();
// Read test case arguments
new Arguments(testCaseName);
QuoteRequestBuilder builder = app.builders().quoteRequest();
BigDecimal b1;
b1 = new BigDecimal(10000);
//Date transactTime;
//transactTime = new Date(0);
//expireTime 10 minutes from now
Calendar now = Calendar.getInstance();
now.add(Calendar.MINUTE, 10);
Date expireTime = now.getTime();
//BUILD THE MESSAGE
builder
.setField(131, "5EB26EAAC074000D0000")
.symbol("DANBNK")
.securityID("SE0011116474")
.currency("SEK")
.securityIDSource("4")
.setField(54, "2")
.expireTime(expireTime)
.orderQty(b1)
.setField(64, "20200508")
.setField(1629, "10")
.setField(1916, "0")
.setField(60, "20200526-15:48:53.006")
.setField(761, "1")
.partyID("13585922", PartyIDSource.PROPRIETARY_CUSTOM_CODE, 11, null)
.partyID("1270", PartyIDSource.PROPRIETARY_CUSTOM_CODE, 13, null)
.partyID("SEB", PartyIDSource.PROPRIETARY_CUSTOM_CODE, 1, null)
.partyID("1786343", PartyIDSource.PROPRIETARY_CUSTOM_CODE, 117, null);
Message quoteRequestMessage = builder.getMessage();
//SEND THE MESSAGE
app.sendMessage(quoteRequestMessage, app.getSession(session));
long timeout = Properties.getLong(0L, "waitForMessage", "FIX");
Message responseMessage;
}
我使用“setfield”指令构建 FIX 消息,然后发送它。这工作得很好,除了我需要做 20-30 次(所以 20-30 条消息)而且我每次都需要稍微改变值或参数。 我有一个想法,如何使用带有“示例”表的功能文件和我想要的数据来处理黄瓜,所以它调用了这个方法,但现在感觉有点矫枉过正。我正在考虑使用带有表格的 excel 文件,这样我就可以轻松地更改每一行中的值,并以某种方式将其提供给这个函数。
顺便说一句,我没有复制函数中的所有代码,我只是复制了构建和发送msg的行。
知道我该怎么做吗?非常感谢您的回复!
提前致谢。
【问题讨论】:
-
试试看能不能循环播放