Пример #1
0
def get_equity_price(symbol):
    scrip_id = symbol.upper()
    n = Nse()
    data = n.get_scrip_data(scrip_id)
    price, lastUpdateTime = n.get_data_for_key(data, 'lastPrice')
    print("Current LTP for {} is {} at time {} ".format(
        scrip_id, price, lastUpdateTime))
Пример #2
0
def get_open_price_equity(symbol):
    scrip_id = symbol.upper()
    n = Nse()
    data = n.get_scrip_data(scrip_id)
    price, lastUpdateTime = n.get_data_for_key(data, 'open')
    print("Open Price for {} is {} at time {} ".format(scrip_id, price,
                                                       lastUpdateTime))
Пример #3
0
    #     for j in range(i,len(mn)):
    #         x = mn[i][0],mn[j][0]
    #         y = mn[i][1],mn[j][1];
    #         c+=1
    #         print(c)
    #         plt.plot(x,y)

    plt.xlabel("date")
    plt.ylabel("price")
    plt.title(STOCK)
    plt.xticks(x, rotation='vertical')
    # Pad margins so that markers don't get clipped by the axes
    plt.margins(0.2)
    plt.show()
    plt.plot(maxdate, maxY)
    df.plot(x='CH_TIMESTAMP', y='CH_CLOSING_PRICE')


db = Nse()
fno = nse.Nse()
fno_lot = fno.get_fno_lot_sizes(as_json=False)
fno_list = list(fno_lot.keys())

global df, historic_data, x, y, mapping, mn, mx, maxY, minY, mindate, maxdate, closingPrice, STOCK
for stk in fno_list:
    try:
        print("processing ... " + stk)
        getMaxMin(stk, True)
    except:
        print(stk)
Пример #4
0
from nse import Nse
import time
from nsetools import nse

db = Nse()
fno = nse.Nse()

lis = fno.get_fno_lot_sizes(as_json=False)

fno_lot = dict(lis)
keys = list(fno_lot.keys())
print(keys)
for key in keys[10:]:
    try:
        price = db.live(key)['lastPrice']
        if price * lis[key] > 200000 and price * lis[key] < 500000:
            print(key.ljust(20),
                  str(lis[key]).ljust(20),
                  str(price).ljust(20), "{:,}".format(price * lis[key]))
    except:
        pass
        # time.sleep(1)
# print(data)
Пример #5
0
from nse import Nse

db = Nse()

data = db.live("HDFCBANK")   
print(data)

#Load OIL Brand Data.
data = db.load('HDFCBANK')
#Bar Grap Of Data
Hdata = db.history("HDFCBANK","05-10-2020",'15-10-2020')
print(Hdata)
Пример #6
0
def is_market_open():

    n = Nse()
    market_status = n.get_market_status()
    print("Market is {} currently ".format(market_status))
Пример #7
0
def get_day_high_low(symbol):
    scrip_id = symbol.upper()
    n = Nse()
    data = n.get_scrip_data(scrip_id)
    low, high = n.get_day_high_low(data)
    print(" Days Low is {} and Days High is {} ".format(low, high))
Пример #8
0

def changeLastRunDate(lastRunDate):
    fh = open("lastRundate.txt", "w")
    fh.write(lastRunDate)
    fh.close()


def getLastRunDate():
    filename = 'lastRundate.txt'
    fh = open(filename, "r")
    return fh.read()


if __name__ == '__main__':
    nse = Nse()
    count = 0
    lastRunDate = getLastRunDate()
    while (count <= 10000):
        time.sleep(20)
        if count == 0:
            nse.download_bhavcopy(lastRunDate)
            print('lastRunDate is', lastRunDate)
        else:
            previousDate = getPreviousDate(lastRunDate)
            nse.download_bhavcopy(previousDate)
            lastRunDate = previousDate
            print('lastRunDate is', lastRunDate)
        count = count + 1
        changeLastRunDate(lastRunDate)
Пример #9
0
import logging
import json
import re
import six
import time
from nse import Nse
from datetime import datetime, timedelta
from dateutil import parser
from utils import js_adaptor, byte_adaptor

log = logging.getLogger('nse')
logging.basicConfig(level=logging.DEBUG)


def isHoliday(date):
    return date.isoweekday() > 5


def getPreviousDay():
    currentDay = datetime.now().date()
    previousDay = currentDay - timedelta(days=1)
    return previousDay.strftime('%dth %b %Y')


if __name__ == '__main__':
    nse = Nse()
    count = 0
    yesterday = getPreviousDay()
    print('lastRunDate is', yesterday)
    nse.download_bhavcopy(yesterday)