Exemple #1
0
    def __init__(self, tickers=()):
        self._portfolio = {}

        self._transactions = slurp.transactions()

        portfolio_is_complete = False
        if bool(len(tickers) == 0):
            portfolio_is_complete = True
            tickers = tuple(api.symbols(remove='expired'))

        self._portfolio.update({
            ticker: stocks.Stock(self, ticker)
            for ticker in filter(api.whitelisted, tickers)
        })

        self._stocks = slurp.stocks(
            self._transactions,
            self._portfolio,
            portfolio_is_complete=portfolio_is_complete,
        )

        profile = api.rh.build_user_profile()
        self._equity = F(profile['equity'])
        self._extended_hours_equity = F(profile['extended_hours_equity'])
        self._cash = F(profile['cash'])
        self._dividends_total = F(profile['dividend_total'])
Exemple #2
0
 def _process(self, file):
     for line in file.readlines():
         line = line.strip('\r\n')
         items = line.split(',')
         print(items)
         code = items.pop(0)
         data = stocks.TradingData(items[0], float(items[1]), float(items[2]), float(items[3]), float(items[4]),
                                   int(items[5]))
         stock = stocks.Stock(code)
         stock.add_day_data(data)
         self._stocks.set_stock(code, stock)
Exemple #3
0
 def _process(self, file):
     data = file.readlines()
     group = len(data) // 6
     # sub the list about data read
     for x in range(group):
         open = x * 6
         end = open + 6
         temp = []
         code = '-1'
         for line in data[open:end]:
             line = line.strip('\r\n')
             items = line.split(':')
             code = items[0]
             temp.append(items[2])
         tradingData = stocks.TradingData(temp[0], float(temp[1]), float(temp[2]), float(temp[3]), float(temp[4]),
                                          int(temp[5]))
         stock = stocks.Stock(code)
         stock.add_day_data(tradingData)
         self._stocks.set_stock(code, stock)
Exemple #4
0
async def _stonks(ctx, ticket):
    await ctx.defer()
    stock = stocks.Stock(ticket)
    stock.fetch_data()
    out = stock.get_data()
    embedVar = discord.Embed(title="{} stocks".format(ticket),
                             description="stonks go stonks",
                             color=0x00ff00)
    embedVar.set_thumbnail(
        url=
        "https://i.kym-cdn.com/entries/icons/original/000/029/959/Screen_Shot_2019-06-05_at_1.26.32_PM.jpg"
    )
    for key in out:
        if key == "website":
            embedVar.add_field(name="{}:".format(key),
                               value="[here]({})".format(out[key]),
                               inline=False)
        else:
            embedVar.add_field(name="{}:".format(key),
                               value=out[key],
                               inline=False)

    await ctx.send(embed=embedVar)
Exemple #5
0
	#print(stock_name)
	stockdictionary[stock_name] = lineSplit
readFile.close()

#print(stockdictionary)
for key, value in stockdictionary.items():
    #print(value)
    value1 = value[1]
    valueList.append(int(value1))
    #print(value1)

#print(valueList)
# loop through the data and import the stocks class to find the data needed
for item in dataFile:
    if item['Symbol'] not in stockDict:
        newStock = stocks.Stock(item['Symbol'], item['Open'], item['High'], item['Low'], item['Volume'])
        #print(item['Symbol'] + "added")
        stockDict[item['Symbol']] = {'stocks': newStock}
        #print(stockDict)
    stockDict[item['Symbol']]['stocks'].addPrice(item['Close'], datetime.strptime(item['Date'], '%d-%b-%y'))
    # print (item['Symbol'], item['Close'])

#print(stockDict)
listStock =[]
#loop through the dictionary and append the values of the close price to a list
for item in stockDict:
    closes = stockDict[item]['stocks'].stockPriceList
    #print(closes)
    for i in closes:
        #print(i)
        if i == 65.08:
Exemple #6
0
def create_stocks(firm, face_value):
    amount_of_stocks = firm.book_value / face_value
    return stocks.Stock(firm.name, firm, face_value, amount_of_stocks)