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 Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore BinOpDiv Call NameLoad BinOpMult BinOpMult Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore BinOpAdd AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Num Assign NameStore Num If NameLoad body Assign NameStore BinOpDiv Call NameLoad Call NameLoad NameLoad Call NameLoad NameLoad orelse Assign NameStore BinOpDiv Call AttributeLoad NameLoad attr Num BinOpMult AttributeLoad NameLoad attr Num Num If AttributeLoad NameLoad attr body Assign NameStore BinOpDiv Call NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore BinOpDiv Call NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr If NameLoad body Assign NameStore BinOpDiv Call NameLoad Call NameLoad NameLoad Call NameLoad NameLoad orelse Assign NameStore BinOpDiv Call AttributeLoad NameLoad attr Num BinOpMult AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd BinOpMult NameLoad Call NameLoad AttributeLoad NameLoad attr BinOpMult NameLoad BinOpSub Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr TryExcept body Assign NameStore BinOpDiv Call NameLoad BinOpMult BinOpDiv NameLoad Call NameLoad AttributeLoad NameLoad attr Num Num handlers ExceptHandler type NameLoad body Assign NameStore BinOpDiv Call AttributeLoad NameLoad attr Num BinOpMult AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd BinOpMult NameLoad Call NameLoad AttributeLoad NameLoad attr BinOpMult NameLoad BinOpSub Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr TryExcept body Assign NameStore BinOpDiv Call NameLoad BinOpMult BinOpDiv NameLoad Call NameLoad AttributeLoad NameLoad attr Num Num handlers ExceptHandler type NameLoad body Assign NameStore BinOpDiv Call AttributeLoad NameLoad attr Num BinOpMult AttributeLoad NameLoad attr Num Num Assign NameStore AttributeLoad NameLoad attr If CompareEq NameLoad Num body Assign NameStore Num Assign NameStore Call NameLoad BinOpDiv AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad Assign NameStore BinOpAdd BinOpSub AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad BinOpMult BinOpAdd AttributeLoad NameLoad attr NameLoad NameLoad If CompareGt NameLoad NameLoad body Assign NameStore NameLoad Assign NameStore BinOpAdd NameLoad NameLoad Assign NameStore NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Assign NameStore NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return Dict Str Str Str NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str If NameLoad body AugAssignSub AttributeStore NameLoad attr NameLoad AugAssignAdd AttributeStore NameLoad attr BinOpMult NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse AugAssignAdd AttributeStore NameLoad attr NameLoad AugAssignSub AttributeStore NameLoad attr BinOpMult NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr 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 AvgBuySellTraderD agent class.
 N/A random fms agents fms.utils BUY SELL fms.utils.exceptions MissingParameter AvgBuySellTraderD 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 AvgBuySellTraderD acts by returning a
    dict with (direction, price, quantity) keys.
    The 3 elements of the dict are randomly chosen,
    in uniform distributions at first. Leverage discouraged.
    As the agent acquires more information it will pick
    buy or sell based on relative attractiveness measured
    by wealth plus stock.
    Trader also defects by a random amount.
    >>> 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 sellhist N/A list N/A N/A self buyhist N/A list N/A N/A self buybids N/A list N/A N/A self sellbids N/A list N/A act N/A N/A self world market N/A None None N/A N/A 
        Return order as a dict with keys in (direction, price, quantity).
        Until trader gets data, use random prices.
        Evaluates attractiveness of buy vs sell.
        Buys or sells as much as it can.
        Pick price based on average of bids and successful bids,
        weighted more heavily to successes depending on number of
        successes (buy or sell depending on choice).

        Avoid short selling and levering up (borrowing).
         N/A shift N/A N/A int N/A N/A N/A N/A random random N/A self maxprice 10 100.0 N/A successes N/A N/A self sellhist N/A self buyhist N/A bids N/A N/A self sellbids N/A self buybids N/A sellprice 0 N/A buyprice 0 N/A successes N/A N/A stockprice N/A N/A float N/A sum successes N/A len successes N/A N/A stockprice N/A N/A N/A random randint 1 N/A N/A self maxprice 100 100.0 N/A N/A self sellhist N/A N/A sellprice N/A N/A float N/A sum N/A self sellhist N/A len N/A self sellhist N/A N/A self buyhist N/A N/A buyprice N/A N/A float N/A sum N/A self buyhist N/A len N/A self buyhist N/A bids N/A N/A bidprice N/A N/A float N/A sum bids N/A len bids N/A N/A bidprice N/A N/A N/A random randint 1 N/A N/A self maxprice 100 100.0 N/A sellprice N/A N/A sellprice N/A len N/A self sellhist N/A bidprice N/A N/A len N/A self sellbids N/A len N/A self sellhist N/A N/A N/A sellprice N/A N/A int N/A N/A sellprice N/A len N/A self sellbids 100 100.0 N/A N/A N/A ZeroDivisionError N/A N/A sellprice N/A N/A N/A random randint 1 N/A N/A self maxprice 100 100.0 N/A buyprice N/A N/A buyprice N/A len N/A self buyhist N/A bidprice N/A N/A len N/A self buybids N/A len N/A self buyhist N/A N/A N/A buyprice N/A N/A int N/A N/A buyprice N/A len N/A self buybids 100 100.0 N/A N/A N/A ZeroDivisionError N/A N/A buyprice N/A N/A N/A random randint 1 N/A N/A self maxprice 100 100.0 N/A sellquant N/A self stocks N/A N/A buyprice 0 N/A N/A buyprice 0.01 N/A buyquant N/A int N/A N/A self money buyprice N/A sellwealth N/A N/A self money N/A sellquant sellprice N/A buywealth N/A N/A N/A self money N/A buyquant buyprice N/A N/A N/A self stocks buyquant stockprice N/A N/A sellwealth buywealth N/A N/A direction SELL N/A price N/A sellprice shift N/A quantity sellquant N/A N/A N/A N/A self sellbids append price N/A N/A direction BUY N/A price N/A buyprice shift N/A quantity buyquant N/A N/A N/A N/A self buybids append price N/A N/A direction price quantity direction price quantity N/A record N/A N/A self direction price quantity N/A N/A N/A 
        Record transaction
         N/A direction N/A N/A N/A self stocks quantity N/A N/A self money N/A quantity price N/A N/A N/A N/A self sellhist append price N/A N/A N/A self stocks quantity N/A N/A self money N/A quantity price N/A N/A N/A N/A self buyhist append price 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