Esempio n. 1
0
def status(msg, order):
	global TMX
	global endTime
	totalDelta = 0.0
	totalVega = 0.0
	for key in msg['trader_state']['positions']:
		quant = msg['trader_state']['positions'][key]
		print key, quant
		try:
			K = int(key[1:-1])
		except:
			continue
		v = vols[K]
		if vols[K] == 0.0 or vols[K] == None:
			v = 20
		c = mibian.BS([TMX, K, 0.0, (endTime-time.time())/15.0], volatility = v)
		type = key[-1]
		if type == 'P':
			totalDelta += (c.putDelta)*quant
		else:
			totalDelta += (c.callDelta)*quant
		totalVega += c.vega*quant
	print 'Total delta: ' + str(totalDelta*100)
	print 'Total vega: ' + str(totalVega*100)

t.onMarketUpdate = upd
t.onTraderUpdate = status

t.run()
Esempio n. 2
0
        pending_orders.append(new_order)
    except:
        print('Unable to parse headline: Unknown error')


DEBUG = True
algo_bot = None
if len(sys.argv) >= 4:
    algo_bot = TradersBot(host=sys.argv[1],
                          id=sys.argv[2],
                          password=sys.argv[3])
    # DEBUG = False
    CANCEL_TRADES = False
else:
    algo_bot = TradersBot('127.0.0.1', 'trader0', 'trader0')
algo_bot.onAckRegister = onAckRegister
algo_bot.onMarketUpdate = onMarketUpdate
algo_bot.onTraderUpdate = onTraderUpdate
algo_bot.onTrade = onTrade
algo_bot.onAckModifyOrders = onAckModifyOrders
algo_bot.onNews = onNews

if not DEBUG:

    def f(*args):
        return None

    print = f

algo_bot.run()