def sample_prices(self, ev, d = 1): """ Samples the prices for each of the events' outcomes. Returns a dict with tuples with the current/buy/sell price. """ # get the supply and the current risk supply = MarketBalance.for_event(ev) current_risk = self.log_cost(supply.values()) prices = {} # loop over each outcome (variable) for (out, amount) in supply.items(): supply[out] -= d buy = self.log_cost(supply.values()) - current_risk supply[out] += 2 * d sell = self.log_cost(supply.values()) - current_risk supply[out] -= d current = self.current_price(supply.values(), amount) prices[out] = (current, buy, sell) assert supply[out] == amount return prices
def eval_cost(self, ev, ps): "Evaluates the cost of accepting the given order represented as a list of positions. " # eval current risk for the maker supply = MarketBalance.for_event(ev) current_risk = self.log_cost(supply.values()) # get the supply after completing the trade for p in ps: assert (p.outcome in supply) supply[p.outcome] += p.amount # and eval the new risk with it new_risk = self.log_cost(supply.values()) # cost is the change in risk return new_risk - current_risk