Module Expr Str Import alias ImportFrom alias ImportFrom alias alias ImportFrom alias ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad TryExcept body Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num handlers ExceptHandler type TupleLoad NameLoad NameLoad body Raise NameLoad Str TryExcept body Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num handlers ExceptHandler type NameLoad body Raise NameLoad Str Delete AttributeDel NameLoad attr Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr Num Call NameLoad BinOpMult AttributeLoad NameLoad attr Num Num Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr Call NameLoad BinOpMult AttributeLoad NameLoad attr Num BinOpMult AttributeLoad NameLoad attr Num Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If BoolOpAnd CompareGt AttributeLoad NameLoad attr Num CompareGt AttributeLoad NameLoad attr Num body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad orelse If CompareLtE AttributeLoad NameLoad attr Num body Assign NameStore NameLoad orelse Assign NameStore NameLoad If NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr orelse Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr Return Dict Str Str Str NameLoad NameLoad NameLoad decorator_list decorator_list FunctionDef arguments args defaults body Expr Str Import alias Expr Call AttributeLoad NameLoad attr keyword UnaryOpUAdd AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A 
Module defining RandomFixedTraderHalves agent class.
 N/A random fms agents fms.utils BUY SELL fms.utils.exceptions MissingParameter RandomFixedTraderHalves N/A N/A agents Agent N/A N/A 
    Simulate an agent taking random decisions

    This agent subclass should have two keys in the
    args dict :
    - maxprice : maximum order price (float)
    - maxbuy : maximum quantity to buy (int)
    If any of those parameters is missing, a MissingParameter
    exception is raised.
    >>> from fms.agents import zerointelligencetrader
    >>> params = {'agents': [{'money':10000, 'stocks':200}]}
    >>> agent = zerointelligencetrader.ZeroIntelligenceTrader(params)
    Traceback (most recent call last):
        ...
    MissingParameter: maxprice
    >>> params = {'agents': [{'money':10000, 'stocks':200, 'args':[999]}]}
    >>> agent = zerointelligencetrader.ZeroIntelligenceTrader(params)
    Traceback (most recent call last):
        ...
    MissingParameter: maxbuy
    >>> params = {'agents': [{'money':10000, 'stocks':200, 'args':[999, 100]}]}
    >>> agent = zerointelligencetrader.ZeroIntelligenceTrader(params)
    >>> print agent.state()
    Agent ... - owns $10000.00 and    200 securities
    >>> print agent.maxprice
    999
    >>> print agent.maxbuy
    100

    The RandomFixedTraderHalves acts by returning a
    dict with (direction, price, quantity) keys.
    The 3 elements of the dict are randomly chosen,
    in uniform distributions. Price is chosen at the start.
    Buy price is in the lower half of 1 to max price.
    Sell price is in the upper half.
    >>> len(agent.act())
    3

    - direction is buy or sell
    - price is a %.2f float in [0.01,maxprice]
    - quantity is an int in :
      - if direction==BUY, [1,self.maxbuy]
      - if direction==SELL, [1,self.stocks]
    Thus, shortselling is not allowed.
     __init__ N/A N/A self params offset N/A 0 N/A N/A N/A N/A N/A agents Agent __init__ self params offset N/A N/A N/A N/A self maxprice N/A N/A self args N/A 0 N/A N/A N/A N/A AttributeError IndexError N/A N/A MissingParameter maxprice N/A N/A N/A N/A self maxbuy N/A N/A self args N/A 1 N/A N/A N/A IndexError N/A N/A MissingParameter maxbuy N/A N/A self args N/A N/A self buyprice N/A N/A N/A random randint 1 N/A int N/A N/A self maxprice 50 100.0 N/A N/A self sellprice N/A N/A N/A random randint N/A int N/A N/A self maxprice 50 N/A N/A self maxprice 100 100.0 N/A act N/A N/A self world market N/A None None N/A N/A 
        Return random order as a dict with keys in (direction, price, quantity).
        Price has already been chosen

        To avoid short selling as far as possible, if # of stocks
        is zero or negative, force BUY direction.
 
        To avoid levering up as far as possible, if money
        is zero or negative, force SELL.
         N/A N/A N/A N/A self stocks 0 N/A N/A self money 0 N/A N/A direction N/A N/A random choice N/A BUY SELL N/A N/A N/A N/A self stocks 0 N/A N/A direction BUY N/A N/A direction SELL N/A direction N/A N/A price N/A self sellprice N/A quantity N/A N/A random randint 1 N/A self stocks N/A N/A price N/A self buyprice N/A quantity N/A N/A random randint 1 N/A self maxbuy N/A N/A direction price quantity direction price quantity N/A N/A _test N/A N/A N/A N/A N/A 
    Run tests in docstrings
     N/A doctest N/A N/A N/A doctest testmod optionflags N/A N/A doctest ELLIPSIS N/A N/A N/A __name__ __main__ N/A N/A N/A _test