예제 #1
0
#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
예제 #2
0
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"
예제 #3
0
#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
예제 #4
0
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"
예제 #5
0
파일: testBot.py 프로젝트: J-N/StockMarket
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):
예제 #6
0
import sys
import random

sys.path.append('../')

from traderbot import TraderBot

robot = TraderBot(555555)

stockArray = robot.getSymbols()

startingPrice = -1

buy(robot.accountID, 'StockA', 1)
예제 #7
0
import sys
import random

sys.path.append('../')

from traderbot import TraderBot

robot = TraderBot(555555)

stockArray = robot.getSymbols()

startingPrice = -1

buy(robot.accountID,'StockA',1)
예제 #8
0
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):