def getScrList():
    UniqueScript = "select distinct Script_Name from Bse_Results order by Script_Name"
    db = DB_Operation(UniqueScript)
    DbScrList = list(db.db_select())
    ScrList = []
    for x in DbScrList:
        ScrList.append(x[0])
    return (ScrList)
def ScrScan():
    ScrQuery = """
    select  Script_Name, convert(date,[Quarter],104)[Qtr] ,Net_Profit, Other_Income, Total_Income,
round((Net_Profit/Total_Income)*100,2) Proft_age from Bse_Results 
where Total_Income >0 and Script_Name = '{}'
order by Script_Name,[Quarter]
"""
    ScrList = getScrList()
    for i in ScrList:
        ScrQueryExe = ScrQuery.format(i)
        db = DB_Operation(ScrQueryExe)
        row = DataFrame(db.db_select(),
                        columns=[
                            'ScrName', 'Quarter', 'Net_Profit', 'Other_Income',
                            'Total_Income', 'ProfitAge'
                        ])
        rowFour = (row.tail(4))
        NetProfit = rowFour['Net_Profit'].real
        print(rowFour)
Пример #3
0
from Algo_classes import DB_Operation
from Algo_classes import Stock_Info
import os

st_Pick_path = 'c:\\vishal\\Stock_pickup.txt'
f_status = os.path.exists(st_Pick_path)

if f_status == False:
    st_pick_file = open(st_Pick_path, 'w')
    st_pick_file.write(
        'Scriptname,Change,Recovered,Std_Div_Val,Last_close,comments\n')
else:
    st_pick_file = open(st_Pick_path, 'a')

SI = Stock_Info()
DB = DB_Operation('EXEC     [dbo].[Alog_List_Stock]')
row = DB.db_select()
up_stock_cnt = 0
dw_Stock_cnt = 0
for x in row:
    str_script_name = str(x[0])
    stk_Pattern = DB_Operation("EXEC     [dbo].[Alog_Patterns] @Coname = '" +
                               str_script_name + "'")
    stk_Row = stk_Pattern.db_select()
    st_H_Dt = str(stk_Row[2][8])
    st_L_Dt = str(stk_Row[3][8])
    st_L_cls = float(stk_Row[3][4])
    end_cls = float(stk_Row[1][4])
    end_Dt = str(stk_Row[1][8])
    Hi_cls = float(stk_Row[2][4])
    days_Diff = SI.date_Diff(st_H_Dt, st_L_Dt)
Пример #4
0
@author: khoday
'''

from Algo_classes import DB_Operation

#
#
# conn = pymssql.connect(user='******',password='******',host='.\\SQLEXPRESS', database='StockQuote',port='1433')
# cur =conn.cursor()
# ls_script=cur.execute(Script_list_Sql)
# for x in ls_script:
#     print (x)
sql_list_script = "select Script_Name from NSE_EOD where Trnx_date in(select MAX(trnx_Date) from NSE_EOD)"
sql_Prom_holding = (
    "select * from Share_Pattern where Script_Name ='{}' order by [Quarter]")
DB = DB_Operation(sql_list_script)
All_script = DB.db_select()
Promo_holding = []
Co_name = []
for x in All_script:
    print(x[0])
    #     sql_Prom_holding_exe= sql_Prom_holding +(x[0])+"' order by [Quarter]"
    print(sql_Prom_holding_exe.format(x[0]))
    DB1 = DB_Operation(sql_Prom_holding_exe.format(x[0]))
    Rows = DB1.db_select()
    for y in Rows:
        #         print (y[0],y[1],y[2],y[3])
        Promo_holding.append(y[2])

    print(Promo_holding)
    if len(Promo_holding) > 1:
                del_page = str(row['% Dly Qt to Traded Qty']).strip()
                if del_Qty == '-':
                    del_Qty = trd_Qty

                if del_page == '-':
                    del_page = 100
                specul = int(trd_Qty) - int(del_Qty)

                if ser == 'EQ' or ser == 'BE':
                    sql_Stock_del_ins = (
                        "EXEC    [dbo].[Stock_del_Insert] @Script = '%s',@Series = '%s',@Trd_qty = %s,@Spec = %s,@Del_Qty = %s,@NoOf_Trd = '%s',@Del_PAge =%s,@Trn_dt = '%s'"
                    ) % (script_name, ser, trd_Qty, specul, del_Qty, no_of_trd,
                         del_page, trnx_dt)
                    try:
                        db_inst = DB_Operation(sql_Stock_del_ins)
                        db_inst.Insert_data()
                        print(script_name +
                              ' inserted successfully for trade on ' +
                              trnx_dt + '!!!')

                    except:
                        continue
            try:
                csv_File.close()
                shutil.move(f_full_Path, f_Path + '\\' + 'Completed')
                sleep(1)
            except:
                os.remove(f_full_Path)
    except:
Пример #6
0
'''
Created on Aug 13, 2018

@author: khoday
'''

from Algo_classes import DB_Operation


sql ='select * from ListOfScrips'

DB = DB_Operation(sql)
all_row =DB.db_select()
for x  in all_row:
    print (x[1])
    
print ('done')
Пример #7
0
def DB_select(sql_query):
    DB = DB_Operation(sql_query)
    scr =DB.db_select()
    return tuple(scr)