#!/usr/bin/perl ############################################################################# # # fxtp_commands.cgi -- FXTP command API documentation. # # $License: # # Copyright (C) Kenneth A. Kittlitz, All Rights Reserved. # # Unless explicitly acquired and licensed from Licensor under a # separate arrangement, the contents of this file are subject to the # Idea Futures Public License ("IFPL") Version 1.0, or subsequent # versions as allowed by the IFPL, and You may not copy or use this file # in either source code or executable form, except in compliance with the # terms and conditions of the IFPL. # # The IFPL V1.0 is identical to the Reciprocal Public License V1.1 as # published at , with the # following two changes to term 13.8: # # [start of changes] # Change 1) Replace: # "This License shall be governed by Colorado law provisions..." # with: # "This License shall be governed by Alberta law provisions...". # # Change 2) Replace: # "You further agree that Adams County, Colorado USA is proper venue..." # with: # "You further agree that Alberta, Canada is proper venue...". # [end of changes] # # All software distributed under the License is provided strictly on # an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR # IMPLIED, AND KENNETH A. KITTLITZ HEREBY DISCLAIMS ALL SUCH # WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT, # OR NON-INFRINGEMENT. See the License for specific language # governing rights and limitations under the License. # # :License$ # ############################################################################# use strict; use CGI; require "Common.pl"; my (@content,$data); my $query = new CGI; print $query->header; my $title = "FXTP Command Set"; my $header = "FXTP Commands"; $data = <
  • FXTP Commands
  • COPYRIGHT: this document may be freely redistributed in its entirety, including this copyright notice. Redistribution of parts of this document requires the consent of the editor, Ken Kittlitz (kittlitz AT ideosphere DOT com). All other rights reserved.

    FXTP Command Set

    Introduction

    This document describes the Foresight Exchange Transport Protocol (FXTP) command set. FXTP is the protocol by which clients (web, telnet email, etc.) communicate with the FXTP server. The FXTP Overview describes the overall server structure and rationale behind FXTP; complete documentation on how to play the Foresight Exchange is also available.

    Overview of Usage

    Connecting to the FXTP Server

    To use the Foresight Exchange, you send FXTP commands to the server via one of several ways:

    This document focuses on the connection and telnet/email servers.

    Basic Command Structure

    FXTP commands are all of the form:

    name argument1,argument2,...
    

    where name is the name of command and argument1, argument2 etc. are its arguments. All "raw" FXTP commands as supported by the connection server are terminated by a newline character (ASCII value 10); that is, no command can span multiple lines. The telnet and email servers allow more humane ways of entering some commands.

    An example of an FXTP command is:

    claim_info Foobar,short,judge

    which would return the short description and the judge of claim "Foobar". Exactly how the information is returned depends on the server being used.

    FXTP Servers

    FXTP servers allow you to send FXTP commands to the main database server. Other than the webface, which takes care of the FXTP commands for you, you have the choice of sending/receiving raw FXTP commands via the connection server, or formatted commands via the telnet or email servers.

    Connection Server

    The connection server runs on port 7001 of ideosphere.com It accepts "raw" FXTP commands, meaning that each command is terminated by a new-line, and returns raw output. The format of the output varies from command to command, however:

    Note that each line of output is terminated by a newline character (ASCII value 10), not by a carriage return/newline combination.

    For example, sending the FXTP command:

    claim_info Foobar short,date_due

    to the connection server might result in output like:

    200 command OK, output follows...
    This is the short description of claim "Foobar"...
    1995/01/01
    .
    

    In other words, the claim status is the first line of output, the short description of the claim is returned as the second line, the claim's due date returned as the third line, and the terminating '.' as the third line.

    To exit a connection server session, send the command bye.

    The connection server is designed for use by programs such as automated agents and Java applets.

    Telnet Server

    The telnet server runs on port 7002 of ideosphere.com, and is designed to be used by people rather than programs. Like the connection server, it accepts FXTP commands as input; most are simple enough to be specified on one line, but it supports extensions for more complex commands, including alternate syntax, shortcuts, and. formatting of command output so that it is easier to interpret: for successful commands, the status line is not returned; for all command the terminating '.' line is stripped. Each line of output is terminated by a carriage return/newline pair (ASCII 10 + ASCII 12).You can identify the end of a command's output because the server displays the following prompt when it is ready to receive more input:

    FXTP-telnet:

    To exit a telnet server session, enter the command bye.

    Email Server

    The email server is available at fx\@ideosphere.com, and is designed to be used by people rather than programs (though nothing prevents you from writing a program that uses it). Like the connection server, it accepts FXTP commands as input; most are simple enough to be specified on one line, but for more complex commands it supports extensions such as alternate syntax, shortcuts and formatting of command output so that it is easier to interpret.. For all command output, the server strips off the terminating '.'; in its response message, it indicates which output is associated with which command request.

    If the server was unable to recognise any commands in the message, it will return the output for the help command.

    Telnet and Email Server Extensions

    Because the telnet and email servers are designed primarily for use by people rather than programs, they use some variations on the raw FXTP syntax. These fall into three categories: shortcuts, alternate syntax and output formatting.

    Shortcuts

    The only shortcut currently supported is login, which has the following syntax:

    login uid,password

    When this command is entered (either in a telnet server session, or as a line in a message to the mail server), subsequent commands that require a uid and/or a password can be typed in abbreviated form. For example, the person with uid 107 and password 'haha' would normally place orders command like this:

    orders 107,haha,new Foobar B10\@30

    But using the login shortcut, he/she can send commands like:

    login 107,haha

    orders ,,new Foobar B10\@30

    Note that the commas that delimit the uid and password fields still have to be included. So, for example, the shortcut for the same user's account command:

    account 107,-1

    would be:

    account ,-1

    Commands that can be abbreviated using the login shortcut are: account, approve, claim, orders, set_email, profile, set_password, set_profile and user_info

    Alternate Syntax

    For ease of use, the telnet and email servers use alternate syntax for the following commands: claim.

    Output Formatting

    For ease of use, the telnet and email servers format the raw output of the following commands: account, claim, claim_info.

    Types of Commands

    FXTP commands can be broken down into several categories (some commands appear in more than category).

    Registration/Administration Commands

    The following commands are used to create or maintain your FX registration:

    Trading Commands

    The major trading commands are:

    User Information Commnands

    Commands that return information about users are:

    Claim Information/Editing Commands

    Commands that create, modify, or return information about a claim are:

    Additionally, help is available for the regular expression syntax used to specify claims.

    Miscellaneous Commands

    Command Descriptions

    This section describes the FXTP commands in detail; commands are listed alphabetically.

    Account

    Retrieves a user's portfolio, as specified by a profile key or keyword (both are values that selects a set of claims).

    Syntax

    account uid,<profile_key | keyword>
    

    Returns

    The system time, user's nym, cash, networth and score. For each keyword selected, the keyword name. For each claim associated with the keyword, the claim symbol, user's holdings (0 if none), bid/ask/last price (on one line, separated by tabs), short description and user's booked orders (blank line if none).

    The connection server returns the information one item per line; the telnet and email servers format the output.

    Connection Server Example

    account 107,-1
    200 command OK, output follows...
    1996/09/24 14:19:52
    Killer
     883.01
     972.31
    0.972
    Category: Booked Orders
    \$vIF
    1
    68      70      70
    Real \$ Ver. of IF (<1.1.2000)
    50Y\@53,100N\@10
    BBQT
    0
    81      90      90
    U.S. Abandons Net Censorship
    50N\@5                 
    .
    
    
    

    Activate

    Activates a newly-registered account.

    Syntax

         activate email,password
    

    where:

    Returns

    The uid for your account. This information is also emailed to you.

    Connection Server Example

    activate ken\@ideosphere.com,f2jK1v
    200 command OK, output follows...
    uid=107
    .
    

    Approve

    Allows a player who has been asked to be the judge of a proposed to agree to this role and, implicitly, approve the claim's wording, due date, etc. Once a new claim has been approved and passed the mandatory waiting period, it becomes active for trading.

    Syntax

         approve uid, password, claim
    

    where:

    Returns

    English sentence denoting success or failure of operation.

    Connection Server Example

    approve 107,haha,Foobar
    200 command OK, output follows...
    Claim 'Foobar' changed to APPROVED state.
    .
    

    Bye

    Terminates a telnet server or connection server session.

    Syntax

         bye
    

    Connection Server Example

    bye
    205 over and out
    Connection closed by foreign host.   
    
    

    Change_claim_state

    Allows the judge of an active claim to close it (render judgement).

    Syntax

         change_claim_state password, claim, YES_payout
    

    where:

    Returns

    English sentence denoting success or failure of operation.

    Connection Server Example

    change_claim_state haha,Foobar,0
    200 command OK, output follows...
    Claim 'Foobar' changed to state RETIRED.
    .
    
    

    Claim

    Creates a new claim or edits an existing claim. To create a claim, you must have at least $50 in your account.

    Syntax

         claim uid, password, symbol, short, long, judge, due,
               newsgroup, scaled, keyword, keyword,...
    

    where:

    When creating a claim, optional fields (see usage), can be omitted (though you still need to include all commas).

    Usage

    Not all arguments need to be given. If creating a new claim, arguments not given are set to appropriate default values. If editing an existing claim, empty arguments do not affect existing claim values. To reset a claim value to its default, pass in 'none' for it.

    When creating a new claim, the following fields are mandatory:

    When editing an existing claim, the following rules apply:

    Alternate Syntax

    The raw FXTP syntax of claim (as supported by the connection server) is not human-friendly. The telnet and email servers use an alternate syntax of the form:

         claim uid,password
         tag: value
         tag: value
         end
    

    where:

    Optional fields may be omitted. Note that the long description may span multiple lines.

    Telnet/Email Server Example

    The following would create claim "Foobar" (assuming a claim with that symbol doesn't already exist).

    claim 107,haha
    symbol: Foobar
    short: This is the Foobar claim
    long: This is the long
    description of the Foobar claim.
    judge: 110
    due:  1995/01/01
    keywords: News:World News
    News:US News
    end
    

    Claim_info

    Returns information about the specified claim symbol regular expression.

    Syntax

         claim_info (claim_regexp),attribute,attribute...]
    

    where legal attributes are: short, judge, date_created, date_due, date_closed, long, bid, ask, last, owner, newsgroup, scaled, price, book, status, keywords.

    Returns

    Attribute values are returned in the order the attributes were specified; each value is terminated by a newline character. Note that some attributes may not have values (e.g., "date_closed" for active claims). In such case, only a newline character is returned..

    The telnet and email server split output lines at about 70 characters.

    Connection Server Example

    claim_info BC96,short,keywords,book
    200 command OK, output follows...
    Clinton re-elected in 96
    Politics:US Politics
    79 BC96 100\@89,157 BC96 65\@89,128 BC96 58\@89,286 BC96 
    1\@89,199 BC96 106\@88,162 BC96 100\@88,157 BC96 79\@86
    79 BC96 100N\@9,116 BC96 10N\@9,199 BC96 99N\@8
    .
    

    Claim_list

    Returns the symbols of claims having the keywords specified by a regular expression

    Syntax

         claim_list keyword_regexp
    

    where:

    Returns

    The symbols of the claims that are associated with the keyword(s). Each symbol is terminated by a newline character.

    Connection Server Example (Extract)

    claim_list News
    200 command OK, output follows...
    Cuba
    SGAJ
    seal
    IrWh
    16Jn
    DKfg
    OJvn
    .
    

    Help

    Returns help information about the specified topic.

    Syntax

         help topic
    

    where:

    Topics include individual FXTP commands and information on FXTP servers, regular expressions etc. "help topics" returns a list of available topics.

    List_claims

    Returns all claim symbols.

    Syntax

         list_claims
    

    Returns

    All claim symbols, including those of proposed or retired claims, each terminated by a newline.

    List_keywords

    Returns all valid keywords (claim categories).

    Syntax

         list_keywords
    

    Returns

    All possible claim keywords, each terminated by a newline..

    List_uids

    Returns the UIDs of all FX users..

    Syntax

         list_uids
    

    Returns

    All FX user UIDs, each terminated by a newline..

    Login

    Registers player's UID and/or password with an email or telnet server session.

    Note: this is a telnet/email server extension, not a true FXTP command.

    Syntax

         login [uid],[password]
    

    Usage

    Once the login command has been used, FXTP commands that require the player's uid and/or password may be abbreviated by leaving out those field values. The commas that delimit the fields must still be included however..

    Telnet/Email Server Example (Extract)

    orders 107,haha,new Foobar S5\@40

    login 107,haha
    orders ,,del Foobar S5\@40
    

    Orders

    Places, modifies or deletes claim coupon orders.

    Syntax

         orders uid,password,order,[order,]...
    

    where each "order" is of the form:

         <new|del|inc|dec> claim [B|S]quantity\@price
    

    and:

    Usage

    The new specifier adds a new order to the book. An error is returned if you already have an order at the same price.

    The del specifier deletes an existing order. An error is returned if you do not have such an order on the book.

    The inc specifier increments the existing order at the specified price by the specified quantity. An error is returned if you do not have an existing order at the specified price.

    The dec specifier decrements the existing order at the specified price by the specified quantity. An error is returned if you do not have an existing order at the specified price.

    Returns

    English sentences describing the success or failure of the order(s). If successful, the orders may be added to the book or cause transactions to occur (if they match existing orders of the opposite type).

    Connection Server Example

    orders 107,haha,new FooBar B10\@20
    200 command OK, output follows...
    order 'new FooBar 10\@20' added to book.
    .
    

    Plot

    Plots the price of a claim over a specified time period.

    Syntax

         plot claim,[start_date],[end_date],<GIF|ASCII>
    

    where:

    Returns

    If an ASCII plot was requested, it will be returned in the output. If a GIF plot was requested, a URL will be returned.

    Connection Server Example

    plot Foobar,,,GIF
    200 command OK, output follows...
    http://www.ideosphere.com/ideosphere/fx/plot/foobar.gif
    .
    

    Profile

    Returns a specified user profile.

    Syntax

         profile uid,profile_key
    

    where:

    Returns

    The associated profile.

    Connection Server Example

    profile 107,1
    200 command OK, output follows...
    K+Arts & Entertainment:Entertainment Technology K+Arts & Entertainment:Movies
    

    .

    Register

    Registers a new user.

    Syntax

         register email,nym,privacy
    

    where:

    Returns

    If the email address appears valid, and neither the email address nor nym is in use by another player, an email message is sent containing an initial password. The password can then be used to activate the account.

    Connection Server Example

    register ken\@ideosphere.com,Killer,0
    200 command OK, output follows...
    Password has been sent to ken\@ideosphere.com by email.
    

    .

    Resend_id

    Mails the FX UID and password associated with the specified email address to that email address. This is useful for people who have forgotten their passwords..

    Syntax

         resend_id email
    

    where:

    Returns

    If the email address is associated with an FX account, the UID and password will be mailed to the address.

    Set_email

    Changes the email address of a registered user.

    Syntax

         set_email uid,password,new_email
    where:
    

    Set_password

    Changes the password of a registered user.

    Syntax

         set_password uid,old_password,new_password
    

    Set_profile

    Sets the specified user profile.

    Syntax

         set_profile uid,password,profile_key,profile
    

    where:

    Returns

    The associated profile.

    Note: profile 0 can also be set, but represents the player's timezeone offset from GMT. As such, its value is numeric rather than a category string.

    Connection Server Example

    set_profile 107,password,1,K+News:World News
    200 command OK, output follows...
    Profile 1 set for user 107.
    

    .

    Ticker

    Returns most recent ticker entries for the specified user or claim for the specified number of days.

    Syntax

         ticker uid,claim[,days]
    

    where:

    Returns

    Ticker lines of the form:

         claim quantity price date/time pairs people buyer seller
    

    where:

    All items are separated by tab characters.

    Connection Server Example

    The following would retrieve the ticker entries for claim "BC96" that have occurred within the last day:

    ticker ,BC96,1
    200 command OK, output follows...
    BC96  100  88  1996/09/25 14:04:36  5034  51  162  305
    BC96  106  88  1996/09/25 14:04:36  5034  51  199  305
    BC96  1  89  1996/09/25 14:02:53  5034  52  286  305
    .
    

    Time

    Returns the current FX server time (GMT).

    Syntax

         time
    

    Returns

    The FX server time (GMT), in format YYYY/MM/DD HH:MM:SS

    User_info

    Returns information about the specified user

    Syntax

         user_info uid,attribute,attribute...]
    
    

    where legal attributes are: nym, email, privacy, cash, networth, score, fees_in, fees_out, holdings, book, gid, allowance, date_signup, date_last_on

    Returns

    Attribute values are returned in the order the attributes were specified; each value is terminated by a newline character. Note that some attributes may not have values; in such case, only a newline character is returned..

    Connection Server Example

    user_info 107,email,cash,score,holdings
    200 command OK, output follows...
    Ken\@lucifer.com
     883.01
    0.963
    \$vIF:1  Immo:50 Cuba:50 Ches:20 BC96:-100       APPL:10 TWAC:50
    .
    

    Volume

    Returns the number of coupons traded within the most recent N days, where N is specified by the command argument. Trading volume is summarised by claim.

    Syntax

         volume [days]
    

    where:

    Returns

    For each claim that had activity during the requested time period, its symbol and number of coupons traded, separated by a space character and terminated by a newline character.

    Connection Server Example

    volume 1
    200 command OK, output follows...
    TWAC 343
    BC96 531
    Ms.P 81
    CLan 133
    Cash 50
    Ches 66
    DLan 1
    .
    

    Other Topics

    Keywords

    Keywords (also knows as categories) are used to categorise FX claims. Each keyword describes a category (e.g., "Science & Technology:Space", "News:World News"), and each claim is associated with one or more keywords. Classifying claims by keywords helps users zero in on the types of claims that interest them; in particular, they can set up profiles containing specific keywords.

    Commands that use or manipulate keywords are:

    Profiles

    Profiles allow users to select claims or categories of claims that they are interested in. Once defined, a profile can be used with the account command.

    Profiles are specified by numeric keys; the following keys are supported:

    User-Defined Profiles

    Profile keys 1 through 5 may be defined by the user via the set_profile command, which takes a key as its first argument and a value as its second argument. Profile values consist of tab-separated items of the form:

         K+keyword
         K-keyword
         C+claim
         C-claim
    

    where:

    Any number of such items can be specified in a profile.

    Regular Expressions

    Certain FXTP commands take Perl regular expressions for one or more of their arguments. A complete discussion of such expressions is beyond the scope of this document, but some of their features are:

    Claim symbols or keywords containing characters such as '*' or '^' must be handled carefully. For example, since claim_info takes a regular expression as its first argument, special characters in claim symbols such as "\$vIF" must be protected with '\' characters:

         claim_info \\\$vIF,short
    

    Commands that use regular expressions are:

    This page is maintained by Ken Kittlitz (kittlitz AT ideosphere DOT com). Last modified on 11/09/2003.

    EOT push(@content,$data); &showHtml(8,$title,$header,undef,undef,@content);