forked from swapniljariwala/nsepy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
71 lines (53 loc) · 1.8 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 19:33:20 2015
@author: SW274998
"""
from nsepy.archives import get_price_history, get_price_list, str_to_date
from nsepy.archives import ThreadReturns, get_price_history_small
from nsepy.archives import __get_symbol_count
from nsepy import derivatives as ddt, indices
import datetime
from datetime import date
import time
from multiprocessing.pool import ThreadPool
import threading
import pandas as pd
import numpy as np
import matplotlib as plt
from bs4 import BeautifulSoup
from matplotlib.pyplot import subplots, draw
from matplotlib.finance import candlestick
if __name__ == '__main__':
proxies = {'http':'proxy1.wipro.com:8080'}
s = time.clock()
kwarg1 = {'index' : 'CNX Nifty', 'start' : date(2015,9,1), 'end' : date(2015,9,24), 'proxies' : proxies}
kwarg2 = {'stock' : 'WIPRO', 'start' : date(2015,9,1), 'end' : date(2015,9,24), 'proxies' : proxies}
t1 = ThreadReturns(target = indices.archives.get_price_history,
kwargs = kwarg1)
t2 = ThreadReturns(target = get_price_history,
kwargs = kwarg2)
t3 = ThreadReturns(target = indices.archives.get_pe_history, kwargs = kwarg1)
t1.start()
t2.start()
t3.start()
t1.join()
t2.join()
t3.join()
e = time.clock()
print (e - s)
ind = indices.archives.get_price_history(**kwarg1)
#lt = get_price_history(**kwarg2)
ind = t1.result
lt = t2.result
pe = t3.result
'''
lt['index'] = ltni.index
lt.drop_duplicates(subset='index', take_last=True, inplace=True)
del lt['index']
'''
lt['NIFTY'] = ind['Close']
lt['P/E'] = pe['P/E']
data = lt
ax = subplots()
candlestick(ax,data['Open'],data['High'],data['Low'],data['Close'])