2
我想用nock在Oanda的交易API编写的代码上运行backtest。要做到这一点,我需要模拟流媒体价格API(请参阅价格流http://developer.oanda.com/rest-practice/streaming/)。然而,看起来nock只允许你用单个回复做出响应,即使响应是一个流。有没有办法将数以千计的价格事件作为个人对单个请求的回应发送出去?用nock模拟一个开放的网络套接字
var scopeStream = nock('https://stream-fxpractice.oanda.com')
.persist()
.filteringPath(function(path) {
return '/stream';
})
.get('/stream')
.reply(function(uri, requestBody) {
return [200, {"tick":{"instrument":"AUD_CAD","time":"2014-01-30T20:47:08.066398Z","bid":0.98114,"ask":0.98139}}]
})
蟋蟀:-(没有想法? – greymatter