Exemplo n.º 1
0
        god['DER'].append(float(tempDER[-1]))
        god['SA'].append(float(tempSA[-1]))
        god['TM'].append(float(tempTM[-1]))
        god['IT'].append(float(tempIT[-1]))
        god_time.append(msg["news"]["time"])

    f = open('data.txt', 'w')
    f.write(str(buzz))
    f.write('\n')
    f.write(str(buzz_time))
    f.write('\n')
    f.write(str(assoc))
    f.write('\n')
    f.write(str(assoc_time))
    f.write('\n')
    f.write(str(alpha))
    f.write('\n')
    f.write(str(alpha_time))
    f.write('\n')
    f.write(str(god))
    f.write('\n')
    f.write(str(god_time))
    f.close()

    #from assignQValue.py
    estimate_distribution_mean()


#run tradersbot
t.onNews = news_Callback
t.run()
Exemplo 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()
Exemplo n.º 3
0
	newsBody = msg["news"]["body"]
	newsBody = str(newsBody).split(' ')
	vals = [float(item.replace(';','')) for item in newsBody if ';' in item]
	vals.append(float(newsBody[-1]))  
	news.append(vals)
	print 'Data ', news

	if len(news) >= 2:
		x = []
		d1 = np.array(news[-2])
		d0 = np.delete(np.array(news[-1]),[2])
		x = np.append(x, d0)
		x = np.append(x,d1)
		print 'Prediction: ', ridge.predict([x])[0]

t.onNews = updatePredict

def hi(msg,order):
	print "hey"

t.onAckRegister = hi
# ######################################################
# # each time AAPL trade happens for $x, make bid
# # and ask at $x-0.02, $x+0.02, respectively
# def marketMake(msg, order):
#     for trade in msg["trades"]:
#         if trade["ticker"] == 'AAPL':
#             px = trade["price"]
#             order.addBuy('AAPL', 10, px - 0.02)
#             order.addSell('AAPL', 10, px + 0.02)
Exemplo n.º 4
0
    news_items = news.split(';')
    news_items = [item.split() for item in news_items]
    names = [item[0] for item in news_items]
    numbers = [[float(item[4])] for item in news_items]
    reading = zip(names, numbers)
    reading = pd.DataFrame.from_items(reading)
    outcry_data = pd.concat([outcry_data, reading])
    model = smf.ols(
        formula='TAMIT ~ GDP + CPI + RS + HS + PPI + MTIS + U + MS + PI',
        data=outcry_data)
    res = model.fit()
    tamit_pred = res.predict(reading)
    logfile = open("outcry_log.txt", "a")
    logfile.write("Prediction " + str(pred_counter) + ": " + str(tamit_pred) +
                  "\n")
    logfile.close()
    pred_counter += 1


t.onNews = get_data

## onMarketUpdate

## onTraderUpdate

## onTrade

### RUN BOT

t.run()
Exemplo n.º 5
0
from tradersbot import TradersBot
'''t = TradersBot('mangocore.pw:10914', '*****@*****.**', 'never-open-students')'''
t = TradersBot('localhost', 'trader0', 'trader0')

def showNews(msg, order):
	a = msg['news']['body'].split()
	val = []
	for word in a:
		word = word.strip(';')
		try:
			num = float(word)
			val.append(num)
		except:
			continue
	print val
	
	idx = 

t.onNews = showNews

t.run()