This was done in many languages Delphi, C++, C#, VB, Borland C++
Builder and the examples exist on their website. Not in Fortran
though. I do not know these other languages good enough to make socket
connection myself.
QuoteTracker (one of the best trading programs which works with almost
all existing data feeds) Streaming API and its internal server allows
external program to retrieve the news, realtime Level II quotes, up-to-
the-tick or consolidated historic stock prices etc
Why Fortran? The code will be an order smaller, readable and
manageable then in any other languages. This is easy to prove creating
very similar to Streaming API examples the "HTTP requests" way
communication code. Having the same look and feel and the same GUI
written in Fortran too it is only 80-90 lines long compared to 1000 in
C++. Besides Fortran is great for text manipulation and dealing with
all kind of math problems.
The way of communication via HTTP requests allows almost the same
functionality but many of functions are missing (
http://www.quotetracker.com/help/qtserver.shtml )
I'd very appreciate a small Fortran example of how to make TCP/IP
socket connection via specific port and just one single function
working with QuoteTraker streaming API. This socket connection could
be done with some wrapped into DLL code written in other languages.
The link on Streaming API functions and examples is
https://www.quotetracker.com/help/QTStreamingAPI.shtml
2) Another approach is to get data directly into Fortran code from the
brokerages. Ameritrade has appropriate streaming API with needed DLL
or Activex available. One tiny 10-20-30 lines example of such code
written in Fortran is appreciated.
If you invoke your program with the netcat command the standard input
will be drawn from a socket, and its standard output can be sent to a
socket. It is all very easy.
nc host.example.com port -e command
Runs "command" with the standard output going to host.example.com:port
and the standard input coming back from that server. For some time I
was using this, but found that if the command did too much input and
output, the process would eventually hang. If the transfer was mostly
in one direction, there was no problem. There are several newer
implementaions of netcat now, perhaps one or more of them has overcome
this problem. Or perhaps it had to do with the sever. In any case, you
asked for no more than 20 lines - here it is in 1 line!
Note that many implementations of netcat have other names and some do
not implement the -e option.
Daniel Feenberg
feen...@nber.org
Thanks, the idea sounds cool.
Couldn't find netcat for latest Windows OS though, all are older
builds for Win 95/98/NT
and of course for Linux...
They may be old, but I think they will all work, at least with XP,
which is all I tried. I would be surprised if they failed with vista
or 7.
Daniel Feenberg
Well, finally netcat connects perfectly!
But now here is next problem: Netcat is DOS program with connection
and commands handled via keyboard - all commands to the QuoteTracker
server can be sent only from the keyboard and all responds from the
server go to the screen. But commands to the server need to be sent of
course by my fortran code and server responds have to be saved into
the file on harddrive or somehow into the readable by fortran code
memory buffer...
netcat works fine with redirected standard input or output or in a
pipe. In our application the windows machine created an ascii file
which was sent to the remote server via netcat, which returned the
results to be stored in another file, which was read by a windows
application. You could do this from within a fortran program with one
or more "call system()" statements.
But I can guess that the QuoteTracker server has its own protocol that
it wants you to observe, and you don't know what that protocol is, or
if you do, it requires a complicated handshake that netcat can't
simulate. No answer for that - but wouldn't that hamper any fortran
code that allowed you to do socket I/O?
Daniel Feenberg
Daniel Feenberg
OK, i have additional info which may clarify what is going on and what
is needed. May be also here are programmers who know how to connect C+
+ TCP/IP code to Fortran, or better to Windows GUI builder for Fortran
users called Clearwin. I can't but for those who know C++ and Fortran
that would not be too difficult i suspect
If from the language examples supplied in QuoteTracker website it is
not clear which part of the source is responsible for making TCP/IP
protocol connection here is another way: NETCAT for Windows. Thanks to
Daniel for providing this hint. You can download it from the net, it
has EXE and the source which is very small. Wikipedia has a link on
Netcat 1.1.1 NT http://en.wikipedia.org/wiki/Netcat
I succeeded to do all needed functions via NETCAT but all is done
manually. I type each command in DOS Prompt and get respond on screen
from the Quotetracker. This should be done via Clearwin and Fortran
text itself which will be doing that for you (i have written 100
source line example as i said earlier, let me know if you need it).
So to completely understand what is needed i describe the steps i am
doing manually now.
1) i start netcat in dos prompt
nc -v 127.0.0.1 16240
and get respond from the Quotetracker server:
OK <CONNECT><SERVERVERSION>1.10</SERVERVERSION><SERVERTIME>10/08/2009
17:01:32<SERVERTIME><EASTERNTIME>10/08/2009 20:01:38</
EASTERNTIME><CONNECT>
Now Netcat is connected to the server.
2) You HAVE TO login first typing
<LOGIN>
<AppName>Widget Trader Pro</AppName>
<AppVer>1.0.0</AppVer>
</LOGIN>{FF}
and get OK in respond.
3) Then the same way you can get quotes from the server
<L1QUOTES>
<ReqType>SUB</ReqType>
<Symbols>DELL,IBM,MSFT</Symbols>
<Symbols>AA,INTC</Symbols>
</L1QUOTES>{FF}
{FF} is char=255 Form Feed, the end of the line before you hit return.
You do that via keyboard keeping ALT DOWN and TYPING 255 in numeric
keypad
Done !
So, if anyone can take out the part of C++ code which connects code to
TCP/IP then everything else is clear: the Clearwin (or Winteracter
etc) will fill all requests just clicking one button like in my
example code or similar examples codes written in other languages by
other people, and get responds from server on its %cw screen (or/and
in the file like in READ_URL@ or internally in some memory buffer. i
do not know how TCP/IP protocol works, does it specify first before
upload the size of needed buffer? And i do not know how to make this
buffer available to Fortran)
I guess for C++/Delphi/C#/VB/Python Fortran programmers TCP/IP part
would not that hard. Only Fortran does not have this yet, but some day
it has to start expanding into the Web. Future Fortran programming is
inevitably on the net anyway so that your code will be residing on
some computer and you'll access it from your cell phone :)
Redirection will work in my case but it most probably was added to
your modified Netcat by C++ programmer. I do not see in help file
anything which describes that. Protocol of communication with
Quiotetracker is trivial and is in plain ASCII. You send requests in
XML -- it sends responds in similar XML. If my Fortran source would
send requests creating files on harddrive and Netcat would scan it
each 0.1 second or so, read it, and send to Quotetracker server and
get its respond and save respond in some file on harddrive which in
its turn Fortran will permanently scan too for differences in file
creating time and changes of content, it would be the not so elegant
and very temporal but still a solution
FYI, the "{FF}" above is hex FF, decimal 255,
*not* ASCII Form Feed. Form Feed is hex 0C,
decimal 12. Look at an ASCII table of characters
some time...
-Ken
Still looking for help with the solutions like calling Windows APIs
(WinSock or Wininet) from Fortran text instead of calling Netcat via
command shell. That will ensure one single connection and unlimited
usage in both directions. That is how all C, VB, Pascal, Perl & etcetc
are doing.
What, specifically? All one has to do to use the Win APIs is write the
interface blocks if the compiler of choice doesn't supply a module
pre-written.
Somewhat drudgery-laden, but straight-forward task.
--
Yeah. One that I've done in the past, as have plenty of others - nothing
special about what I did. In particular, nothing special enough to be
worth digging out and posting. It would take far more work to explain
the context of my code than it would contribute. It was getting close to
20 years ago now that I first did some of that code. It was on Unix
systems at first back then, but it wasn't particularly difficult to port
to Windows (and to have the Windows clients communicate with the Unix
servers). The stuff has been in daily production use since the mid 90's.
I haven't posted in this thread before because I couldn't imagine what
to say that wasn't obvious. One reads the documentation of the calls,
reads your compiler's documentation about interlanguage calling (or one
is lucky enough to have a compiler with f2003 C interop, in which case
you don't need as much compiler-specific documentation), and one does
it. I don't know of any special "tricks".
Understanding the many issues involved in network communication can be
quite complicated, but it mostly has little to do with languages (and
I'm not prepared to do a tutorial on those parts of it that I
understand).
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
One thing, though. On unix the socket numbers and file descriptors
use the same address space, where, last I knew, they didn't on
Windows. Some unix programs will use read() and write() with
tcp connections instead of send() and recv().
(snip)
-- glen
> Still looking for help with the solutions like calling Windows APIs
> (WinSock or Wininet) from Fortran text instead of calling Netcat via
> command shell.
Intel Visual Fortran does include modules for Winsock and Winsock2.
--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH
For email address, replace "invalid" with "com"
User communities for Intel Software Development Products
http://software.intel.com/en-us/forums/
Intel Software Development Products Support
http://software.intel.com/sites/support/
My Fortran blog
http://www.intel.com/software/drfortran
Don't have IVF though have somewhere DVF almost never used,
i use Silverfrost Fortran. If Intel has Fortran examples of using
Winsock's API
and may be declarations for this specific function that would help
shortening learning & debugging curve. I also hope may be somebody
know shortcuts using its .NET capabilities (so far these never
been for me useful, but who knows...).
The task of making streaming socket connection could be not that
easy.
Please do not take anyone this personally, but I found the
posts in this NG approx 5-7 years ago of DaveGemini
who was very keen to make similar but much simpler function of HTTP/
FTP read
(this is done with just one line in Silverfrost) to work with DVF
and nobody here was actually able to help for months.
> I found the
> posts in this NG approx 5-7 years ago of DaveGemini
> who was very keen to make similar but much simpler function of HTTP/
> FTP read...
> and nobody here was actually able to help for months.
Ah. A blast from the past. Just because Dave Frank/Gemini wasn't
sucessful in getting what he was looking for from here doesn't mean that
nobody was "able" to help him. Eventually, multiple people in the
newsgroup declined to read or respond to his postings or otherwise
assist him.
He had a tendency to ask for inputs, selectively pick data that could be
misinterpreted to support his predetermined answers, and then cite
people who had provided the data as though they supported him. He also
seemed sure that his own frankly naive putterings made him more of an
expert on numerical analysis than.... well... pretty much anyone else;
actually reading what other people had done in the field was apparently
below him.
As Greg Lindahl said (in Jan 2001):
>> But before you consider sending Dave results, remember that
>> he'll use them to make gross generalizations, so you're much
>> better off ignoring him.
By the way, yes I have specifically used winsock with CVF. I mentioned
before doing such network stuff on WIndows, but I just checked and found
that at least one version of it was specifically winsock and CVF.
[Snip...]
> naive putterings made him more of an expert on numerical analysis
FWIW, "Dave" also had a few clf psychotic episodes with me about Linux and
other FOSS as a "threat" to hell and half of Texas. And wasn't "Dave" also
a big fan of stock market "math analysis" voodoo? WOTTA MAROOON...
--
Regards, Weird (Harold Stevens) * IMPORTANT EMAIL INFO FOLLOWS *
Pardon any bogus email addresses (wookie) in place for spambots.
Really, it's (wyrd) at airmail, dotted with net. DO NOT SPAM IT.
I toss GoogleGroup (http://twovoyagers.com/improve-usenet.org/).
> In <1j8h4mf.1gmjp2t1a3c2leN%nos...@see.signature> Richard Maine:
>
> [Snip...]
>
> > naive putterings made him more of an expert on numerical analysis
>
> FWIW, "Dave" also had a few clf psychotic episodes with me about Linux and
> other FOSS as a "threat" to hell and half of Texas. And wasn't "Dave" also
> a big fan of stock market "math analysis" voodoo?
In a way, he was valuable as an object lesson on the value of the
Fortran standard. He had his favorite compiler, which isn't so unusual
in itself. But Dave would insist that his favorite compiler was the only
one that anyone could sanely use; no other choice was possible for
anyone. Those who made other choices were obviously guilty of all kinds
of imagined failings. This extended to people who used operating systems
or hardware that the compiler would not run on; those people clearly had
made simillarly wrong choices (per Harold's comments above).
Dave would regularly tell people that various Fortran codes conformed to
the Fortran standard. When it was pointed out that this wasn't so, Dave
would explain that whenever he said "standard", he was referring to
*THE* standard, by which he meant the one and only acceptable Fortran
compiler. Those documents published by national and international
standards organizations were irrelevant.
But what made it all such a good object lesson was that the one and only
acceptable Fortran compiler, which everyone must use now and forever,
changed multiple times. One year it would be one compiler, but the next
year it would be a different one (and the first one was no longer even
available). Then a few years later, it was yet another compiler that was
the one and only acceptable compiler now and forever. :-)
[Snip...]
> it would be one compiler, but the next year it would be a different one
I'd forgotten that little festish with "Dave" but it all comes back now. I
file it under "poetic justice" myself. :)