Skip to content

Error when two bids submitted that cannot be settled #25

Description

@20robin06
  • pymarket version: 0.7.6
  • Python version: 3.9
  • Operating System: windows 10

Description

When two bids are submitted that cannot be settled I receive an error:

i.e.:

r = np.random.RandomState(1234)
mar = pm.Market()

mar.accept_bid(1, 5, 4, True, 0)
mar.accept_bid(1, 5, 5, True, 0)

mar.accept_bid(1, 6, 6, False, 0)
mar.accept_bid(1, 6, 7, False, 0))

What I Did

The command I ran:

bids = mar.bm.get_df()
transactions, extras = mar.run('p2p')
stats = mar.statistics()

The error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-128-a1f818cf5b34> in <module>
      1 bids = mar.bm.get_df()
----> 2 transactions, extras = mar.run('uniform')

c:\projects\colombiadata\venv\lib\site-packages\pymarket\market.py in run(self, algo, *args, **kwargs)
    150         df = self.bm.get_df()
    151         mec = MECHANISM[algo](df, *args, **kwargs)
--> 152         transactions, extra = mec.run()
    153         self.transactions = transactions
    154         self.extra = extra

c:\projects\colombiadata\venv\lib\site-packages\pymarket\mechanisms\mechanism.py in run(self)
    170     def run(self):
    171         """Runs the mechanisms"""
--> 172         trans, extra = self._run()
    173         trans = self._cleanup(trans)
    174         return trans, extra

c:\projects\colombiadata\venv\lib\site-packages\pymarket\mechanisms\mechanism.py in _run(self)
    133         N = bids.shape[0]
    134         if (bids.loc[bids['buying']].shape[0] not in [0, N]):
--> 135             trans, extra = self.algo(self.bids, *self.args, **self.kwargs)
    136             return trans, extra
    137         else:

<ipython-input-125-14a8cb0a7b32> in uniform_price_mechanism(bids)
     16 
     17     ## Filter only the trading bids.
---> 18     buying_bids = buying_bids.iloc[: b_ + 1, :]
     19     selling_bids = selling_bids.iloc[: s_ + 1, :]
     20 

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions