Exemple #1
0
def caifuziyou(stocklist):
    days0to15_data = bt.get_stock_data(bt.get_data(20), bt.get_data(0),
                                       *stocklist)
    days0to180_data = bt.get_stock_data(bt.get_data(180), bt.get_data(30),
                                        *stocklist)
    kelly_data = {}
    for i in days0to15_data:
        try:
            x1 = days0to15_data[i]['Adj Close'].tolist()[-1]
            x2 = max(days0to180_data[i]['Adj Close'].tolist())
            if x2 / x1 >= 2: kelly_data[i] = x1 / x2
        except:
            pass

    return kelly_data
    def get_rjump(self, z=None, shell=None):
        if all_or_none(z, shell):
            z = self.z
            shell = self.shell

        rjump = {'K': get_data(z, 'rjump1'),
                 'L1': 1.17,
                 'L2': 1.39,
                 'L3': get_data(z, 'rjump4'),
                 'M1': 1.16,
                 'M2': 1.207,
                 'M3': 1.158,
                 'M4': 1.895,
                 'M5': 1.895,
                 'N': 2.0}
        return rjump[shell]
Exemple #3
0
def caifuziyou(stocklist):
    days0to100_data = bt.get_stock_data(bt.get_data(100), bt.get_data(0),
                                        *stocklist)
    days0to5_data = bt.get_stock_data(bt.get_data(5), bt.get_data(0),
                                      *stocklist)
    days0to15_data = bt.get_stock_data(bt.get_data(15), bt.get_data(0),
                                       *stocklist)
    days0to30_data = bt.get_stock_data(bt.get_data(30), bt.get_data(0),
                                       *stocklist)
    kelly_data = {}
    probability_rate = np.array([0.3, 0.3, 0.5, 0.8])
    for i in days0to100_data:
        try:
            '''
            get p
            '''
            days0to100_data[i]["daily"] = days0to100_data[i][
                'Adj Close'].pct_change()
            days = 10
            dt = 1.0000 / days
            mu = days0to100_data[i]["daily"].mean()
            sigma = days0to100_data[i]["daily"].std()
            startprice = days0to100_data[i]['Adj Close'].tolist()[-1]
            temp1, temp2, temp3, temp4 = 0.0, 0.0, 0.0, 0.0
            bsum = 0
            for j in range(1000):
                pricelist = bt.perdict10days(startprice,
                                             mu,
                                             dt,
                                             sigma,
                                             days=10)
                if bt.incornot(list(pricelist)) >= 0.03:
                    temp1 += 1
                    bsum += bt.incornot(list(pricelist))
            b = bsum / temp1
            temp1 = float(temp1) / 1000
            if bt.incornot(days0to5_data[i]['Adj Close'].tolist()) > 0.03:
                temp2 = 1
            if bt.incornot(days0to15_data[i]['Adj Close'].tolist()) > 0.06:
                temp3 = 1
            if bt.incornot(days0to30_data[i]['Adj Close'].tolist()) > 0.07:
                temp4 = 1
            p = sum(probability_rate * np.array([temp1, temp2, temp3, temp4
                                                 ])) / sum(probability_rate)
            kelly_data[i] = [i, startprice, p, b * 9]
        except:
            pass
    l = []
    for i in kelly_data:
        kelly_data[i].append(
            bt.kelly_caculation(kelly_data[i][-2], kelly_data[i][-1]))
        l.append(kelly_data[i])
    l.sort(key=lambda x: x[-3], reverse=True)
    return l
    def get_effyld(self, el=None, exciter='e'):
        """EFFective Fluorescence YieLD for all lines.
        3/91 r.a. waldo
        NEED TO FIND REFS FOR THIS
        """
        # need to check this xray may actually be accelerating voltage...?
        # var was xenergy in RAW code
        if el is None:
            el = self
        # Coster-Kronig Coefficients
        ck12 = get_data(el.z, 'c12')
        ck13 = get_data(el.z, 'c13')
        ck23 = get_data(el.z, 'c23')

        if el.shell[0] != 'L':
            effyld = el.omega
        elif el.shell[0] == 'L':
            rj1 = self.get_rjump(el.z, 'L1')
            rj2 = self.get_rjump(el.z, 'L2')
            rj3 = self.get_rjump(el.z, 'L3')
            l1 = get_data(el.z, 'Lb3')
            l2 = get_data(el.z, 'Lb1')
            l3 = get_data(el.z, 'La1')
            if el.shell == 'L1':
                effyld = el.omega
            elif el.shell == 'L2':
                if el.xray < l1 and el.xray > l2:
                    effyld = el.omega
                elif el.xray > l1:
                    el1 = el
                    el1.shell = 'L2'  # 3
                    omegaL2 = self.get_omega(el1)
                    if exciter == 'e':
                        effyld = omegaL2*(1.0 + ck12)
                    else:
                        effyld = omegaL2*(1.0 + ck12*(rj1 - 1.0) *
                                          rj2/(rj2 - 1.0))
            elif el.shell == 'L3':
                if el.xray < l2 and el.xray > l3:
                    effyld = el.omega
                elif el.xray < l1 and el.xray > l2:
                    effyld = el.omega*(1.0 + ck23*(rj2 - 1.0) *
                                       rj3/(rj3 - 1.0))
                elif el.xray > l1:
                    if exciter[0] == 'e':
                        effyld = el.omega*(1.0 + 0.5*ck13 +
                                           0.5*(1.0 + ck12)*ck23)
                else:
                    effyld = el.omega*(
                            1.0 +
                            ck13*(rj1 - 1.0)*rj2*rj3/(rj3 - 1.0) +
                            ck23*(rj2 - 1.0)*rj3/(rj3 - 1.0) +
                            ck12*(rj1 - 1.0)*rj2*rj3/(rj3 - 1.0))
        elif el.shell[0] == 'N':
            effyld = 0.0

        return effyld
    def user_input(self, volt):

        z, name = get_options('Please enter Element Symbol:',
                              'els', count=True)
        # make sure the selected line is valid
        while True:
            line = get_options('Please enter Element X-Ray Line '
                               '(Ka, Lg2, etc.):', 'lines')
            xray = get_data(z, line)
            if xray > 0:
                break
            user_alert('Invalid line for this element; try again:')
        opt = self.get_opt()
        if volt is None:
            volt = get_nums('Accelerating voltage for this element?:',
                            50, 0)
        return name, line, z, volt, opt
    def get_omega(self, z=None, shell=None):
        """Fluorescence Yields"""
        if all_or_none(z, shell):
            z = self.z
            shell = self.shell

        omega = 0.0
        if shell == 'K':  # Bambynek etal., Rev. Mod. Physics. 1972 pg 757
            # Could updat to Bambynek 1984
            d = (0.015 + 0.0327*z - 0.64e-6*z**3)**4
            omega = d/(1.0 + d)
        elif shell == 'M4' or shell == 'M5':  # ???? REF??
            omega = 0.68e-9*(z - 13)**4
        elif shell == 'N1':  # ??? Ref??
            omega = 1.0e-9*(z - 13)**4
        elif shell == 'M2' or shell == 'M3' or shell[0] == 'N':  # 5
            omega = 0.0
        else:  # Krause, J. Phys. Chem. Ref. Data Vol. 8, No. 2, 1979, p. 307.
            if shell == 'M1':
                shell = 'L3'
            shell = shell.lower()
            omega = get_data(z, shell)
        return omega
Exemple #7
0
import seaborn as sns
import basictools as bt
import stockplay as sp
import csv
sns.set(style="whitegrid")
capset = set()
with open('gt10blist') as f:
    for i in f.readlines():
        if "-" not in i and "." not in i:
            capset.add(i.replace("\n", ""))
l = sp.caifuziyou(list(capset))
filename_tod = "ND" + bt.get_data(0) + ".csv"
filename_yes = "ND" + bt.get_data(1) + ".csv"
set_tod = set([])
set_yes = set([])
with open(filename_tod, 'w') as fd:
    for t in l:
        if t[-1] != 0:
            set_tod.add(t[0])
            writer = csv.writer(fd)
            writer.writerow(t)
with open(filename_yes) as fd:
    for i in fd.readlines():
        if len(i) > 10:
            set_yes.add(i.replace("\n", "").split(",")[0])
temp1 = []
for i in l:
    if i[0] not in set_yes and i[0] in set_tod:
        temp1.append([i[0], i[1], i[2]])
temp1.sort(key=lambda x: x[-1], reverse=True)
for i in temp1:
Exemple #8
0
     "*****@*****.**"
 ]
 url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
 content = pd.read_html(url)
 stocklist = content[0]['Symbol'].tolist()
 print('sp500 index data got')
 cur_date = str(datetime.date.today())
 if not stocklist: exit()
 print("starting polling date from yahoo")
 earningdate = bt.get_next_event(*stocklist)
 msg = ""
 print("finding the delta less then 10days")
 for i in earningdate:
     if 0 < bt.get_date_delta(earningdate[i], cur_date) <= 10:
         msg += i + ","
 str1 = "caifu" + bt.get_data(0) + ".csv"
 list1 = msg[:-1].split(",")
 print list1
 l = sp.caifuziyou(list1)
 with open(str1, 'a') as fd:
     for t in l:
         if t[-1] != 0:
             writer = csv.writer(fd)
             writer.writerow([bt.get_date_delta(earningdate[i], cur_date)] +
                             t)
 l = op.caifuziyou(list1)
 with open(str1, 'a') as fd:
     for t in l:
         if t[-1] != 0:
             writer = csv.writer(fd)
             writer.writerow([bt.get_date_delta(earningdate[i], cur_date)] +
Exemple #9
0
import copy
import csv
parent_list = ["Gavin", "Owen", "Chao", "Maggie", "Vivian", "Nina"]
child_list = ["Angelina", "Audrey", "Nora", "Ethan", "Edwin", "Annie"]
arrange_list = []
n = 0
while (n <= 9):
    temp = copy.deepcopy(child_list)
    for i in range(len(parent_list)):
        index_k = random.randint(0, len(temp) - 1)
        loop = 0
        while (i == child_list.index(temp[index_k])):
            index_k = random.randint(0, len(temp) - 1)
            loop += 1
            if loop == 5: break
        if loop == 5:
            for _ in range(1, len(parent_list)):
                arrange_list.pop()
        else:
            arrange_list.append(
                (parent_list[i], temp[index_k], str(bt.get_data(-4 - n * 7)),
                 "Week " + str(n + 11)))
            temp.pop(index_k)
    if loop == 5: pass
    else: n += 1
with open("arrangement.csv", 'a') as fd:
    for t in arrange_list:
        print t
        writer = csv.writer(fd)
        writer.writerow(list(t))
Exemple #10
0
 content = pd.read_html(url)
 stocklist = content[0]['Symbol'].tolist()
 with open('/var/www/html/2.html', 'w') as file:
     file.write('<html> \n')
     file.write('    <head> \n')
     file.write('        <title>Stock Data</title> \n')
     file.write('    </head> \n')
     file.write('    <body> \n')
     for i in stocklist:
         file.write('        <H1> ' + i + ' </H1> \n')
         file.write("        <img alt='no image1' src='" + i +
                    "10days.png'></img> \n")
     file.write('    </body> \n')
     file.write('<html> \n')
 while (1):
     data1 = bt.get_stock_data(bt.get_data(95), bt.get_data(1), *stocklist)
     for i in data1:
         data1[i]["daily"] = data1[i]['Adj Close'].pct_change()
         days = 10
         dt = 1.0000 / days
         mu = data1[i]["daily"].mean()
         sigma = data1[i]["daily"].std()
         if data1[i]['Adj Close'].tolist() != []:
             startprice = data1[i]['Adj Close'].tolist()[-1]
         else:
             startprice = 0 - 100.00
         for j in range(100):
             plt.plot(bt.perdict10days(startprice, mu, dt, sigma, days=10))
         str1 = "/var/www/html/" + i + "10days.png"
         print(str1)
         plt.savefig(str1)
Exemple #11
0
import yfinance as yf
import os
import time
sns.set(style="whitegrid")
if __name__ == "__main__":
    url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
    content = pd.read_html(url)
    stocklist = content[0]['Symbol'].tolist()
    with open('/var/www/html/2.html', 'w') as file:
        file.write('<html> \n')
        file.write('    <head> \n')
        file.write('        <title>Stock Data</title> \n')
        file.write('    </head> \n')
        file.write('    <body> \n')
        for i in stocklist:
            file.write('        <H1> ' + i + " " + bt.get_data(0) +
                       ' </H1> \n')
            file.write("        <img alt='no image1' src='" + i +
                       "10days.png'></img> \n")
        file.write('    </body> \n')
        file.write('<html> \n')
    while (1):
        try:
            data1 = bt.get_stock_data(bt.get_data(95), bt.get_data(1),
                                      *stocklist)
            for i in data1:
                data1[i]["daily"] = data1[i]['Adj Close'].pct_change()
                days = 10
                dt = 1.0000 / days
                mu = data1[i]["daily"].mean()
                sigma = data1[i]["daily"].std()
Exemple #12
0
def caifuziyou(stocklist):
    earningdate = bt.get_next_event(*stocklist)
    latest_option_date = {}
    optiondata_call = {}
    optiondata_put = {}
    for i in earningdate:
        temp = yf.Ticker(i)
        if temp.options:
            for j in sorted(temp.options):
                if 3 < bt.get_date_delta(j, earningdate[i]) < 35:
                    latest_option_date[i] = j
                    break
            if i in latest_option_date:
                optiondata_call[i] = temp.option_chain(
                    latest_option_date[i]).calls
                optiondata_put[i] = temp.option_chain(
                    latest_option_date[i]).puts
        else:
            pass
    '''
    check the stock flipping  more than 2%
    '''
    days0to100_data = bt.get_stock_data(bt.get_data(100), bt.get_data(0),
                                        *stocklist)
    days0to30_data = bt.get_stock_data(bt.get_data(20), bt.get_data(0),
                                       *stocklist)
    days30to60_data = bt.get_stock_data(bt.get_data(90), bt.get_data(0),
                                        *stocklist)
    days60to90_data = bt.get_stock_data(bt.get_data(180), bt.get_data(91),
                                        *stocklist)
    kelly_data = {}
    probability_rate = np.array([0.2, 0.2, 1, 0.2])
    for i in latest_option_date:
        '''
        get p
        '''
        days0to100_data[i]["daily"] = days0to100_data[i][
            'Adj Close'].pct_change()
        days = 10
        dt = 1.0000 / days
        mu = days0to100_data[i]["daily"].mean()
        sigma = days0to100_data[i]["daily"].std()
        startprice = days0to100_data[i]['Adj Close'].tolist()[-1]
        temp1, temp2, temp3, temp4 = 0.0, 0.0, 0.0, 0.0
        for j in range(1000):
            pricelist = bt.perdict10days(startprice, mu, dt, sigma, days=10)
            if bt.incornot(list(pricelist)) > 0.02: temp1 += 1
        temp1 = float(temp1) / 1000
        if bt.incornot(days0to30_data[i]['Adj Close'].tolist()) > 0.03:
            temp2 = 1
        if bt.incornot(days30to60_data[i]['Adj Close'].tolist()) > 0.1:
            temp3 = 1
        if bt.incornot(days60to90_data[i]['Adj Close'].tolist()) > 0.1:
            temp4 = 1
        p = sum(probability_rate *
                np.array([temp1, temp2, temp3, temp4])) / sum(probability_rate)
        if p >= 0.6: corp = "call"
        elif p <= 0.2: corp = "put"
        else: corp = "hold"
        if corp == "call": kelly_data[i] = [corp, i, latest_option_date[i], p]
        elif corp == "put" and 1 - p > 0.6:
            kelly_data[i] = [corp, i, latest_option_date[i], 1 - p]
        else:
            kelly_data[i] = [corp, i, -1, -1]
        '''
        get b
        '''
        strikelist_call = optiondata_call[i]["strike"].tolist()
        strikelist_put = optiondata_put[i]["strike"].tolist()
        target = bt.closestprice(strikelist_call, startprice)
        if optiondata_call[i].loc[lambda df: df['strike'] == target][[
                "bid", "ask"
        ]].sum(axis=1).tolist() != []:
            option_call_price = optiondata_call[i].loc[
                lambda df: df['strike'] == target][["bid", "ask"]].sum(
                    axis=1).tolist()[0] / 2
        else:
            option_call_price = 1000
        if optiondata_put[i].loc[lambda df: df['strike'] == target][[
                "bid", "ask"
        ]].sum(axis=1).tolist() != []:
            option_put_price = optiondata_put[i].loc[
                lambda df: df['strike'] == target][["bid", "ask"]].sum(
                    axis=1).tolist()[0] / 2
        else:
            option_put_price = 1000
        if option_call_price == 0 or not option_call_price:
            option_call_price = 1000
        if option_put_price == 0 or not option_put_price:
            option_put_price = 1000
        b_call = (startprice * 0.03 - 0) / option_call_price
        b_put = (startprice * 0.02 - 0) / option_put_price
        if kelly_data[i][0] == "call":
            kelly_data[i].append(b_call)
            kelly_data[i].append(option_call_price)
            kelly_data[i].append(target)
        if kelly_data[i][0] == "put":
            kelly_data[i].append(b_put)
            kelly_data[i].append(option_put_price)
            kelly_data[i].append(target)
    for i in kelly_data:
        if kelly_data[i][0] != "hold":
            kelly_data[i].append(
                bt.kelly_caculation(kelly_data[i][-4], kelly_data[i][-3]))
        else:
            kelly_data[i] = []
    l = []
    for i in kelly_data:
        if kelly_data[i] == [] or kelly_data[i][-1] == 0: continue
        l.append(kelly_data[i])
    l.sort(key=lambda x: x[-5], reverse=True)
    return l
Exemple #13
0
def Mac(el1, el2):
    """Calculation of Mass the Absorption Coefficient of an impinging X-Ray
    from el1 on el2.
    This calc needs to be checked.  See above refs"""

    if  el1.z == 5 and el2.z == 40:
        """ B xray interacting with Zr ???  weird"""
        xmu = 8270.0
        iflag = 2
    ie = ""
    cutoff = 0
    xray = el1.xray
    z = el2.z
    mass = el2.mass
    # calculate 'c' parameter
    if xray > get_data(z, 'K'):
        if z < 6:
            c = -2.87536e-4 + 1.808599e-3 * z
        else:
            c = (5.253e-3 +
                 1.33257e-3 * z +
                 -7.5937e-5 * z**2 +
                 1.69357e-6 * z**3 +
                 -1.3975e-8 * z**4)
    elif xray < get_data(z, 'L3'):
        c = (-9.24e-5 +
             1.41478e-4 * z +
             -5.24999e-6 * z**2 +
             9.85296e-8 * z**3 +
             -9.07306e-10 * z**4 +
             3.19254e-12 * z**5)
        if xray > get_data(z, 'L1'):
            c = c
        elif xray > get_data(z, 'L2'):
            c = c * 0.858
        else:
            c = c*(0.8933 - z*8.29e-3 + z**2*6.38e-5)
    elif xray > get_data(z, 'M1'):
        if z < 30:
            c = (1.889757e-2 +
                 -1.8517159e-3 * z +
                 6.9602789e-5 * z**2 +
                 -1.1641145e-6 * z**3 +
                 7.2773258e-9 * z**4)
        else:
            c = (3.0039e-3 +
                 -1.73663566e-4 * z +
                 4.0424792e-6 * z**2 +
                 -4.0585911e-8 * z**3 +
                 1.497763e-10 * z**4)
    elif xray > get_data(z, 'M5'):
        c1 = (7.7708e-5 +
              -7.83544e-6 * z +
              2.209365e-7 * z**2 +
              -1.29086e-9 * z**3)
        c2 = (1.406 +
              0.0162 * z +
              -6.561e-4 * z**2 +
              4.865e-6 * z**3)
        c3 = (0.584 +
              0.01955 * z +
              -1.285e-4 * z**2)
        c4 = (1.082 +
              1.366e-3 * z)
        c5 = (1.6442 +
              -0.0480 * z +
              4.0664e-4 * z**2)
        if xray > get_data(z, 'M2'):
            c = c1*c2*c3
        elif xray > get_data(z, 'M3'):
            c = c1*c2*c4
        elif xray > get_data(z, 'M4'):
            c = c1*c2*0.95
        else:  # M5
            ie = 'M5'
            c = c1*c2*c5
    else:
        c = 1.08*(4.3156e-3 +
                  -1.4653e-4 * z +
                  1.707073e-6 * z**2 +
                  -6.69827e-9 * z**3)
        if xray < get_data(z, 'N1'):
            cutoff = ((0.252*z - 31.1812)*z + 1042.)/1000.0
            ie = 'N1'

#      calculate 'n' parameter
    if xray > get_data(z, 'K'):
        if z < 6:
            n = (3.34745 +
                 0.02652873 * z +
                 -0.01273815 * z**2)
        else:
            n = (3.112 +
                 -0.0121 * z)
    elif xray > get_data(z, 'L3'):
        n = (2.7575 +
             1.889e-3 * z +
             -4.982e-5 * z**2)
    elif xray > get_data(z, 'M1'):
        n = (0.5385 +
             0.084597 * z +
             -1.08246e-3 * z**2 +
             4.4509e-6 * z**3)
    elif xray > get_data(z, 'M5'):
        n = 3.0 - 0.004*z
    else:
        n = 0.3736 + 0.02401*z

#      calculate 'a' parameter
    if xray > get_data(z, 'K'):
        if z < 6:
            a = (24.4545 +
                 155.6055 * z +
                 -14.15422 * z**2)
        else:
            a = (47.0 * z +
                 6.52 * z**2 +
                 -0.152624 * z**3)
    elif xray > get_data(z, 'L3'):
        a = (17.8096 * z +
             0.067429 * z**2 +
             0.01253775 * z**3 +
             -1.16286e-4 * z**4)
    elif xray > get_data(z, 'M1'):
        a = (10.2575657 * z +
             -0.822863477 * z**2 +
             2.63199611e-2 * z**3 +
             -1.8641019e-4 * z**4)
    elif xray > get_data(z, 'M5'):
        a = (4.62 * z +
             -0.04 * z**2)
    else:
        a = (19.64 * z +
             -0.61239 * z**2 +
             5.39309e-3 * z**3)

#      calculate 'b' parameter
    if xray > get_data(z, 'K'):
        if z < 6:
            b = -103. + 18.2*z
        else:
            b = 0.
    elif xray > get_data(z, 'L3'):
        b = 0.
    elif xray > get_data(z, 'M1'):
        if z < 61:
            b = (5.654 * z +
                 -0.536839169 * z**2 +
                 0.018972278 * z**3 +
                 -1.683474e-4 * z**4)
        else:
            b = (-1232.4022 * z +
                 51.114164 * z**2 +
                 -0.699473097 * z**3 +
                 3.1779619e-3 * z**4)
    elif xray > get_data(z, 'M5'):
        b = (2.51 +
             (-0.052) * z +
             3.78e-4 * z**2) * get_data(z, 'M4') * 1000.
    else:
        b = -113. + 4.5*z

    if xray > get_data(z, 'N1'):
        qq = (-xray*1000.+b)/a
        if qq > 88.:
            qq = 88.
        elif qq < -88.:
            qq = -88.

        xmu = c * z**4 / mass * ((12.397 / xray)**n) * (1. - np.exp(qq))
        if xmu < 0.0:
            mess = '!!!   negative  mac    !!!'
    else:
        xmu = (((12.397 / xray)**n) * c * z**4 / mass * (xray - cutoff) /
               (1.08 * get_data(z, 'N1')))
    if xray < 1.1 * cutoff:
        mess = '!!!  Ec<1.1xcutoff     !!!'
    elif xray - cutoff < 0.02 and xray - cutoff > -0.005:
        mess = '!!!  close to edge     !!!'
    else:
        mess = 'Good!!'
    if ie == 'M5':
        mess += '!!!M4>Ec>M5 edge & Zab<70!!!'
        if el2.mass >= 70:
            mess = 'Good!!'
    if ie == 'N1':
        mess += '!!!  Ec below M5 edge  !!!'
    if xmu < 0.0 and ie == 'N1':
        mess = '!!!neg. mac & Ec<M5edge!!!'
    user_alert(mess + '\nemiter=%s %s; absorber=%s; mu=%.4g'
               % (el1.name, el1.line, el2.name, xmu))

    if xmu <= 0.0:
        xmu1 = xmu
        xmu = get_nums('MAC is negative; Enter a value for this MAC :')
        user_alert('emiter=%s %s; absorber=%s;'
                   'mu changed from %.4g to %.4g'
                   % (el1.name, el1.line, el2.name, xmu1, xmu))
    return xmu
Exemple #14
0
        stocklist.append(i.replace("\n", ""))
print stocklist
if __name__ == "__main__":
    with open('/var/www/html/nsdq.html', 'w') as file:
        file.write('<html> \n')
        file.write('    <head> \n')
        file.write('        <title> NYSE Stock Data</title> \n')
        file.write('    </head> \n')
        file.write('    <body> \n')
        for i in stocklist:
            file.write('        <H1> ' + i + ' </H1> \n')
            file.write("        <img alt='no image1' src='" + i +
                       ".png'></img> \n")
        file.write('    </body> \n')
        file.write('<html> \n')
    while (1):

        data1 = bt.get_stock_data(bt.get_data(365), bt.get_data(0), *stocklist)
        for i in stocklist:
            try:
                data1[i].plot(subplots=False, figsize=(10, 4))
                str1 = "/var/www/html/" + i + ".png"
                plt.savefig(str1)
                plt.clf()
                plt.cla()
                plt.close()
            except:
                plt.clf()
                plt.cla()
                plt.close()
        time.sleep(86400)
Exemple #15
0
sns.set(style="whitegrid")
import stockplay as sp
import pandas as pd
import csv




str1='JWN ,NTAP ,SNPS ,CPRT ,TJX ,COST ,MDT ,LB ,PGR ,A ,KEYS ,HRL ,ROST ,NVDA ,ADSK ,HPE ,PVH ,BBY ,TTWO ,DG ,DE ,INTU ,ULTA ,DLTR ,RCL ,HPQ ,ADI ,AZO ,DXC '
list1=str1.replace(",","").split(" ")
l=op.caifuziyou(list1)
with open(r'ymh1.csv','a') as fd:
    for t in l:
        if t[-1]!=0:
            writer=csv.writer(fd)
            writer.writerow([bt.get_data(0)]+t)

l=sp.caifuziyou(list1)
with open(r'ymh1.csv','a') as fd:
    for t in l:
        if t[-1]!=0:
            writer=csv.writer(fd)
            writer.writerow([bt.get_data(0)]+t)

'''
url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
content = pd.read_html(url)
stocklist = content[0]['Symbol'].tolist()
=======
str1="CPB 17 ,JWN 11 ,NTAP 10 ,SNPS 3 ,CPRT 3 ,TJX 4 ,COST 11 ,MDT 4 ,LB 3 ,PGR 3 ,A 4 ,KEYS 9 ,HRL 4 ,ROST 4 ,KSS 2 ,NVDA 4 ,ADSK 10 ,HPE 4 ,PVH 10 ,BBY 4 ,TTWO 3 ,DG 11 ,DE 5 ,AAP 2 ,INTU 4 ,GPS 11 ,ULTA 11 ,DLTR 11 ,LOW 3 ,HPQ 10 ,TIF 16 ,WMT 2 ,HD 2 ,ADI 3 ,AZO 9 ,DXC 11 ,"
l1=[]
Exemple #16
0
import seaborn as sns
import pandas as pd

import basictools as bt
import stockplay as sp
import csv

sns.set(style="whitegrid")
url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
content = pd.read_html(url)
stocklist = content[0]['Symbol'].tolist()+['pdd',"sqqq","tqqq","pltr","qqq","vldr"]
l=sp.caifuziyou(stocklist)
filename_tod=bt.get_data(0)+".csv"
filename_yes=bt.get_data(1)+".csv"
set_tod=set([])
set_yes=set([])
with open(filename_tod, 'w') as fd:
    for t in l:
        if t[-1] != 0 :
            set_tod.add(t[0])
            writer = csv.writer(fd)
            writer.writerow(t)
with open(filename_yes) as fd:
    for i in fd.readlines():
        if len(i) > 10:
            set_yes.add(i.replace("\n", "").split(",")[0])
temp1=[]
for i in l:
    if i[0] not in set_yes and i[0] in set_tod:
        temp1.append([i[0],i[1],i[2]])