Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"You have an excellent product !!!!!!" - Comment from Arely
"As a past ******* customer(and not a happy one), IQ Feed by DTN is a much better and cheaper product with great customer support. I have had no problems at all since switching over." - Comment from Public Forum
"And by the way, have to say this. I love the IQFeed software. It's rock solid and it has a really nice API." - Comment from Thomas via RT Chat
"I'm very glad I switched to IQFeed. It's working perfectly with no lag, even during fast market conditions." - Comment from Andy via Email
"This is an excellent value, the system is generous (allowing for 500 stocks) and stable (and really is tick-by-tick), and the support is fantastic." - Comment from Shirin via Email
"I use IQ Feed, Great stuff as far as data analysis information, storage and retrieval is concerned." - Comment from Public Forum
"You are much better than lawyers or the phone company because you answer the phone when I call! I just love your customer service." - Comment from Isreal
"IQ feed works very well, does not have all of the normal interruptions I have grown used to on *******" - Comment from Mark
"The service is great, I see a noticeable improvement in my volume profiles over [broker]'s data feed" - Comment from Larry
"For anyone considering using DTN.IQ for a data feed, my experience with the quality of data and the tech support has been very positive." - Comment from Public Forum
Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »NEW IQFEED FORUMS »Miscellaneous Messages »Kotlin code example
Author Topic: Kotlin code example (1 messages, Page 1 of 1)

DTN_Gary_Stephen
-DTN Guru-
Posts: 396
Joined: Jul 3, 2019


Posted: Sep 21, 2023 08:31 AM          Msg. 1 of 1

class IQFeedSocket : Socket() {
fun start() {
connect(InetSocketAddress("localhost", 9100))
val brBufferedReader = BufferedReader(InputStreamReader(this.inputStream))
val brBufferedWriter = BufferedWriter(OutputStreamWriter(this.outputStream))

// Initialize the protocol, this prepares us for commands to come and verifies that our socket is working as intended.
brBufferedWriter.write("S,SET PROTOCOL,6.2\r\n")
brBufferedWriter.flush()

brBufferedWriter.write("HDX,AAPL,30\r\n")
brBufferedWriter.flush()
thread {
var line: String
while (brBufferedReader.readLine().also { line = it } != null) {
println(line)
}
brBufferedReader.close()
brBufferedWriter.close()
close()
}
}
}


Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist
 

 

Time: Wed May 1, 2024 9:27 AM CFBB v1.2.0 13 ms.
© AderSoftware 2002-2003