Exemplo n.º 1
0
def initiateSellingSequenceNOW():
    data = jhelp.readData('data.json')
    array = getInput(data)
    while (array[1] == 0):
        array = getInput(data)
    tick = array[0]
    shares = array[1]

    numberOfSharesForStock = 0
    for ob in data:
        if (ob['tick'] == tick):
            numberOfSharesForStock += int(ob['shares'])

    if (shares > numberOfSharesForStock):
        print "You are trying to sell more shares than you have!"
    else:
        if (shares == numberOfSharesForStock):
            sellAllTheShares(tick, shares, data)
        else:
            sellSomeShares(tick, shares, data)
Exemplo n.º 2
0
def initiateSellingSequenceNOW():
	data = jhelp.readData('data.json')
	array = getInput(data)
	while(array[1] == 0):
		array = getInput(data)
	tick = array[0]
	shares = array[1]

	numberOfSharesForStock = 0
	for ob in data:
		if(ob['tick'] == tick):
			numberOfSharesForStock += int(ob['shares'])

	if(shares > numberOfSharesForStock):
		print "You are trying to sell more shares than you have!"
	else:
		if(shares == numberOfSharesForStock):
			sellAllTheShares(tick,shares,data)
		else:
			sellSomeShares(tick,shares,data)
Exemplo n.º 3
0
# =============================================================
import ystockquote
import time
import json
import sys
from Helper import helperMethods
from Helper import jhelp
from Helper import juser
# =============================================================

data = jhelp.readData('data.json')
jhelp.closeUpPlease('data.json')

# tick': u'WFM', u'name': u'Whole Foods Market', u'shares': u'260', u'bought': u'54.55'
# through code, entered 	ob['bookval'] = bookval
# ob['currentPrice'] = price
# ob['marketval'] = marketval
# ob['percentgain'] = percentGain(bookval,marketval)


def printAllTheStocks(data, totalBook, totalMarket):
    for ob in data:
        name = str(ob['name'])
        bought = float(ob['bought'])
        price = ob['currentPrice']
        marketval = ob['marketval']
        bookval = ob['bookval']
        perGain = ob['percentgain']
        totalB = float(totalBook)
        totalM = float(totalMarket)
        helperMethods.printHeader(name, bought, price)
Exemplo n.º 4
0
# =============================================================
import ystockquote
import time
import json
import sys
from Helper import helperMethods
from Helper import jhelp
from Helper import juser
# =============================================================

data = jhelp.readData('data.json')
jhelp.closeUpPlease('data.json')

# tick': u'WFM', u'name': u'Whole Foods Market', u'shares': u'260', u'bought': u'54.55'
# through code, entered 	ob['bookval'] = bookval
	# ob['currentPrice'] = price
	# ob['marketval'] = marketval
	# ob['percentgain'] = percentGain(bookval,marketval)

def printAllTheStocks(data,totalBook,totalMarket):
	for ob in data:
		name = str(ob['name'])
		bought = float(ob['bought'])
		price = ob['currentPrice']
		marketval = ob['marketval']
		bookval = ob['bookval']
		perGain = ob['percentgain']
		totalB = float(totalBook)
		totalM = float(totalMarket)
		helperMethods.printHeader(name,bought,price)
		helperMethods.printPercentOfBook(totalB,bookval,totalM,marketval)