cancel
Showing results for 
Search instead for 
Did you mean: 

Sending different system commands for each element in a list

Francisco
New Contributor
Hello I know that in q loops should be avoided but I don't see how to do this:

I have to send to a REST API a command like this:

q)system "curl -s -k -H \"Authorization: Bearer MyToken\" \"https://api-fxpractice.oanda.com/v1/candles?instrument=EUR_JPY&granularity=D&count=5&candleFormat=bidask\""

the command has to be sent count list times and the parameter instrument should carry sequentially each element in list

list:`EUR_USD`EUR_JPY`GBP_JPY

The information retrieved from the REST API should be stored in a unique table or in a table per element.

Cheers

Francisco
2 REPLIES 2

sohagan
New Contributor
use each.

system each {"curl -s -k -H \"Authorization: Bearer MyToken\" \"https://api-fxpractice.oanda.com/v1/candles?instrument=",string[x],"&granularity=D&count=5&candleFormat=bidask\""} each list

This will get the data. Then set it into a variables or do whatever you want with it...

`a1`a2`a3 set' {@[system;x;`cant]} each {"curl -s -k -H \"Authorization: Bearer MyToken\" \"https://api-fxpractice.oanda.com/v1/candles?instrument=",string[x],"&granularity=D&count=5&candleFormat=bidask\""} each list


Thanks,
Sean

Francisco
New Contributor
Wow... I'm speechless.

Thanks

Francisco