#buys it immediately #sells it at a random price # import sys import random # sys.path.insert(0, '../') from traderbot import TraderBot #riskFactor represents how risky the bot is in general #it affects both how much money it's willing to wager, and how long it'll wait #before giving up riskFactor = 0.65 #fraction of original price riskFactorMultiplier = 3 robot = TraderBot() stockArray = robot.getSymbols() startingPrice = -1 while (True): #checks if portfolio is empty portfolio = robot.getPortfolio() currentlyOwnedStock = "" stockQuantity = -1 empty = True for stock in stockArray: if portfolio[stock] != 0: empty=False
import random # I'll need to change this to incorporate from traderbot import TraderBot robot = TraderBot() stockArray = robot.getSymbols() # initial loop for ticker in stockArray: portfolio = robot.getPortfolio() if portfolio[ticker] != 0: # selling distribution: # 25 percent at market price # 10 percent at 10 percent above market price # 10 percent at 10 percent below market price # 5 percent at 5 percent below market price marketFraction = 0.25 aboveMarket = 0.10 tenBelowMarket = 0.10 fiveBelowMarket = 0.05 price = robot.getPrice(ticker) result = robot.ask((int)(portfolio[ticker] * marketFraction), price, ticker) if result == "Accepted": print "trade accepted"
#picks a random stock #buys it immediately #sells it at a random price # import sys import random # sys.path.insert(0, '../') from traderbot import TraderBot #riskFactor represents how risky the bot is in general #it affects both how much money it's willing to wager, and how long it'll wait #before giving up riskFactor = 0.99 #fraction of original price riskFactorMultiplier = 3 robot = TraderBot() stockArray = robot.getSymbols() startingPrice = -1 while (True): #checks if portfolio is empty portfolio = robot.getPortfolio() currentlyOwnedStock = "" stockQuantity = -1 empty = True for stock in stockArray: if portfolio[stock] != 0: empty = False
import random #I'll need to change this to incorporate from traderbot import TraderBot robot = TraderBot() stockArray = robot.getSymbols() #initial loop for ticker in stockArray: portfolio = robot.getPortfolio() if (portfolio[ticker] != 0): #selling distribution: #25 percent at market price #10 percent at 10 percent above market price #10 percent at 10 percent below market price #5 percent at 5 percent below market price marketFraction = 0.25 aboveMarket = 0.10 tenBelowMarket = 0.10 fiveBelowMarket = 0.05 price = robot.getPrice(ticker) result = robot.ask((int)(portfolio[ticker] * marketFraction), price, ticker) if result == 'Accepted': print "trade accepted"
import sys sys.path.insert(0, '../') import random from traderbot import TraderBot robot = TraderBot() stockArray = robot.getSymbols() print "Stock Array", stockArray size = len(stockArray) print "Array Size", size randomStockIdx = random.randint(0, size - 1) randomStock = stockArray[randomStockIdx] print "random stock ticker:", randomStock price = robot.getPrice(randomStock) print "stock price:", price money = robot.getFunds() maxShares = 100 confirmation = robot.buy(randomStock, maxShares) if (confirmation == 1):
import sys import random sys.path.append('../') from traderbot import TraderBot robot = TraderBot(555555) stockArray = robot.getSymbols() startingPrice = -1 buy(robot.accountID, 'StockA', 1)
import sys import random sys.path.append('../') from traderbot import TraderBot robot = TraderBot(555555) stockArray = robot.getSymbols() startingPrice = -1 buy(robot.accountID,'StockA',1)