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)




"I had always used ******* but for the past 2 weeks have been trying DTN IQFeed. Customer support has been extraordinary. They call just to make sure your problem hasn't recurred." - Comment from Public Forum
"I just wanted to tell you what a fine job you have been doing. While *******, from what I hear, has been down and out, off and on, IQ feed has held like a champ this week." - Comment from Shirin
"I was with ******* for 4 years at $230 a month, this is a huge savings for me, GOD BLESS YOU PEOPLE," - Comment from T.S. via Email
"If you want customer service that answers the phone, your best bet is IQFeed. I cannot stop praising them or their technical support. They are always there for you, and they are quick. I have used ****** too but the best value is IQFeed." - Comment from Public Forum
"I just wanted to let u know that your data feed/service is by far the best!!! Your unfiltered tick data is excellent for reading order flow and none of your competitors delivers this quality of data!" - Comment from Peter via Email
"I am enjoying the feed very much - so superior to the broker provided feed I was previously using." - Comment from George
"Interactive Brokers tick data was inconsistent, so I have switched to using DTN exclusively. It is great to no longer have to worry about my datafeed all day long." - Comment from Philippe
"I've never had DTN go out on me since switching. ******* would go down a couple times every month when I was using them." - Comment from Bryce in AL.
"Everything is working great with the API. I love it." - Comment from Calvin
"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 6:43 PM CFBB v1.2.0 13 ms.
© AderSoftware 2002-2003