Type | Description | |||
Query as String | A string expression that indicates the query being sent to a FXP server. | |||
String | A string expression that indicates the server's response. |
Here's the description for the FXP protocol.
The server listens for connections to TCP port 5 0 1 1. This port number has not been allocated by any official body, and is subject to change.
A client creates a connection to the server, and sends one or more requests over the connection. Each request is answered by an individual response from the server over the same connection. Requests are always answered in sequence. The connection may be broken by either the client or the server. Responses that are lost due to a broken connection are not re-transmitted.
Requests and responses are transmitted using the ASCII character set. Each request consists of a number of lines of text, followed by a single blank line. Each response consists of a number of lines of header text, followed by a single blank line, optionally followed by a number of lines of data, followed by a single blank line. All lines of text (including blank lines) are terminated by the two character sequence <carriage return> <line feed>. This retains compatibility with the telnet protocol, and telnet can be used to send fxp requests to a server.
The protocol is case insensitive, and requests and responses may be sent in either upper or lower case.
fxp/1.1The protocol version line is followed by one or more request specification lines, in any order. Each request specification line consists of a tag, followed by a single colon character, followed by a single space character, followed by a value. A specific tag may only be used once per request. Values revert to their default values after each request.
Query: currenciesThe Query line is optional, and specifies the type of FXP query. The value must be one of quote or currencies. A query type of quote is used to obtain information about the conversion rate between two currencies. A query type of currencies is used to obtain currency symbol codes and currency names. The default value is quote.
Quotecurrency: CADIf the query type is quote, then the Quotecurrency line is required, and specifies the currency that the client wants to know the price of. The value can be any valid 3 letter ISO or O A N D A currency code.
If the query type is currencies, then the Quotecurrency line is optional. If present, it specifies the currency symbol that the client wants to know the name of.
Quotecurrency: {CHF 125.75}Optionally, the Quotecurrency line may be given with a value consisting of a left curly brace character, followed by a 3 letter currency code, followed by a single space character, followed by a floating point number, followed by a right curly brace character. This variant allows the client to specify the amount of the currency to be converted. The default amount is 1.0 units of the currency.
Basecurrency: USDThe Basecurrency line is optional, and is used to specify the currency units used in the response. The value can be any valid 3 letter ISO or O A N D A currency code. The default Basecurrency is USD.
Date: Mon, 02 Jun 1997 13:37:56 GMTThe Date line is optional, and is used to specify the date and time to be used when retrieving the conversion rate information. The value of the date tag must be in the form specified in RFC 822, as modified by RFC 1123. The default Date value is the current date and time.
Timeincrement: 86400The Timeincrement line is optional, and specifies the number of seconds between adjacent conversion results. The value must be a positive integer. The default Timeincrement value is 60 seconds.
Nprices: 12The Nprices line is optional, and specifies the number of conversion results required. The value must be a positive integer. If the Nprices value is greater than 1, the specified number of conversions will be performed. The date and time of the first conversion will be given by the Date line. This date and time will be incremented for each subsequent conversion by the amount given on the Timeincrement line. The default Nprices value is 1.
Queryid: 129The Queryid line is optional. The value of the Queryid tag must be a single token with no embedded space or tab characters. There must be no more than 80 characters in the value. If a Queryid line is present in a request, a Queryid line with the same tag will be included in the response to that request.
Quoteperiod: spotThe Quoteperiod line is optional. It specifies the time period used to collect the data used in the response. A value of day asks for the statistics that best summarize the entire day's prices for the Quotecurrency. A value of spot asks for the statistics that best describe the prices at the specified date and time. The default Quoteperiod value is day.
Quotetype: bid ask max_bidThe Quotetype line is optional. The value of the tag is a non-empty list of tokens, separated by single space characters. The legal tokens are:
bid | the median price offered by people willing to buy the Quotecurrency |
ask | the median price desired by people willing to sell the Quotecurrency |
min_bid | the minimum bid price |
min_ask | the minimum ask price |
max_bid | the maximum bid price |
max_ask | the maximum ask price |
fractile_low_bid | the price that 75% of the buyers are willing to pay |
fractile_low_ask | the price that 25% of the sellers are willing to accept |
fractile_high_bid | the price that 25% of the buyers are willing to pay |
fractile_high_ask | the price that 75% of the sellers are willing to accept |
num_ticks | the total number of price quotations seen during the Quoteperiod |
date | the date of the data used in composing the response |
The default Quotetype value is bid.
fxp/1.1 200 okThe first digit of each response code specifies the class of the response. Response codes starting with 2 specify a successful response, and such responses are followed by lines of data. Response codes starting with 4 indicate an illegal query. Response codes starting with 5 indicate a server error.
Response code | Possible user text explanations |
---|---|
200 | response ok |
400 | bad request |
404 | not found |
500 | server internal error |
501 | not implemented |
503 | unavailable |
505 | version unsupported |
The response code line is followed by zero or more response header lines, in any order. Each response header line consists of a tag, followed by a single colon character, followed by a single space character, followed by a value. A specific tag will only be used once per response.
Content-lines: 1If the response code started with a 2, the response headers will be followed by lines of data. The Content-lines value will be present, and will specify how many lines of data will follow.
Queryid: 129The Queryid line will be present if it was successfully recognized in the request, regardless of the value of the response code. The value of the Queryid will be equal to the value given in the request.
The request headers will be terminated by a single blank line. If the Content-lines header was present the blank line will be followed by the given number of lines of data, terminated by another blank line.
If the query type was quote, each line of data will contain one value for each token given in the Quotetype line. The values will be separated by single space characters. If the Quotetype token was date, the value will be a date string given in the standard date format specified in RFC 822, as modified by RFC 1123. For all other tokens, if the server can answer the query, the value will be a single floating point number such as:
1.2645If the server can not answer the query, the value will be the token:
nafor "not available".
If the query type was currencies, each line of data will start with a three letter ISO (or O A N D A) currency symbol, followed by a single space character, followed by the name of the currency in English. If the quotecurrency was specified in the request, the response will contain a single line containing the symbol and name of that currency. If the quotecurrency was not specified, the response will contain multiple lines, one for each of the possible currencies.
http://www.O A N D A.com/products/fxp/protocol.html