Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackplot #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nse.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def runner(ticker):

def threader(q):
while True:
ticker = q.get()
ticker = q.get(timeout= 12)
print("Ticker {}".format(ticker))
runner(ticker)
q.task_done()
Expand Down
122 changes: 122 additions & 0 deletions report
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
Run at 2020-06-09 12:15:20.664564
Time taken: 160 sec
Could not fetch 35 scripts

Run at 2020-06-09 12:18:31.073331
Time taken: 157 sec
Could not fetch 25 scripts

Run at 2020-06-09 12:21:38.939781
Time taken: 157 sec
Could not fetch 30 scripts

Run at 2020-06-09 12:24:46.897072
Time taken: 156 sec
Could not fetch 29 scripts

Run at 2020-06-09 12:27:53.026439
Time taken: 182 sec
Could not fetch 49 scripts

Run at 2020-06-09 12:31:25.339519
Time taken: 152 sec
Could not fetch 23 scripts

Run at 2020-06-09 12:34:27.501356
Time taken: 168 sec
Could not fetch 35 scripts

Run at 2020-06-09 12:37:46.262105
Time taken: 167 sec
Could not fetch 33 scripts

Run at 2020-06-09 12:41:03.833007
Run at 2020-06-09 13:40:24.687193
Time taken: 197 sec
Could not fetch 126 scripts

Run at 2020-06-09 13:44:12.358284
Time taken: 199 sec
Could not fetch 116 scripts

Run at 2020-06-09 13:48:01.424822
Time taken: 179 sec
Could not fetch 105 scripts

Run at 2020-06-09 13:51:31.075624
Time taken: 208 sec
Could not fetch 91 scripts

Run at 2020-06-09 13:55:29.608030
Time taken: 209 sec
Could not fetch 114 scripts

Run at 2020-06-09 13:59:29.068990
Time taken: 232 sec
Could not fetch 212 scripts

Run at 2020-06-09 14:03:51.459592
Time taken: 195 sec
Could not fetch 121 scripts

Run at 2020-06-09 14:07:36.793795
Time taken: 207 sec
Could not fetch 120 scripts

Run at 2020-06-09 14:11:34.392382
Time taken: 180 sec
Could not fetch 650 scripts

Run at 2020-06-09 14:15:05.032219
Time taken: 207 sec
Could not fetch 128 scripts

Run at 2020-06-09 14:19:02.676415
Time taken: 199 sec
Could not fetch 127 scripts

Run at 2020-06-09 14:22:51.983409
Time taken: 237 sec
Could not fetch 162 scripts

Run at 2020-06-09 14:27:19.551565
Time taken: 269 sec
Could not fetch 137 scripts

Run at 2020-06-09 14:32:18.686275
Time taken: 192 sec
Could not fetch 23 scripts

Run at 2020-06-09 14:36:00.768084
Time taken: 186 sec
Could not fetch 14 scripts

Run at 2020-06-09 14:39:37.386701
Time taken: 170 sec
Could not fetch 20 scripts

Run at 2020-06-09 15:10:20.977627
Time taken: 177 sec
Could not fetch 27 scripts

Run at 2020-06-09 15:13:48.945508
Time taken: 197 sec
Could not fetch 26 scripts

Run at 2020-06-09 15:17:36.251554
Time taken: 202 sec
Could not fetch 40 scripts

Run at 2020-06-09 15:21:28.633489
Time taken: 196 sec
Could not fetch 38 scripts

Run at 2020-06-09 15:25:15.508481
Time taken: 203 sec
Could not fetch 24 scripts

Run at 2020-06-09 15:29:08.997536
Time taken: 206 sec
Could not fetch 36 scripts

Run at 2020-06-09 15:33:05.081513
Binary file added rvnl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from utils import combiner

script_names = "data/stock"
volume_path = "historical_data/buyer_seller_volume"
intraday_path = "historical_data/intraday"
with open(script_names, "r") as f:
data = f.read()
t_list = data.split("\n")


combiner(volume_path, t_list)
combiner(intraday_path,t_list)
1 change: 1 addition & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ def combiner(filepath,file_names):

with open(filepath+"/"+ticker, 'w') as fw:
fw.write(str(final))

57 changes: 57 additions & 0 deletions visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import matplotlib.pyplot as plt
from matplotlib.ticker import (AutoMinorLocator, MultipleLocator)
import numpy as np
import matplotlib.ticker as ticker

import ast
def fname(a):
path= "historical_data/intraday/" + a
path2="historical_data/buyer_seller_volume/" + a
with open (path2,"r") as f2:
data2= f2.read()
g2= ast.literal_eval(data2)
f2.close()
with open(path,"r") as f:
data =f.read()
g= ast.literal_eval(data)
f.close()

date=[]
lpt=[]
vol=[]
for key in g:
date.append(key)
k=key
for key in g[k]:
if key== "ltp":
lpt.append(g[k][key])
for key in g2[k]:
if key== 'deliveryToTradedQuantity':
vol.append(g2[k][key])

fig,axs= plt.subplots(2 ,figsize=(50,10))
axs[0].plot(date,vol)
axs[1].plot(date,lpt)

for i in range(len(axs)):
# Change major ticks to show every 20.
axs[i].xaxis.set_major_locator(MultipleLocator(5))
if (i != 0):
axs[i].yaxis.set_major_locator(MultipleLocator(5))
# Change minor ticks to show every 5. (20/4 = 5)
axs[i].xaxis.set_minor_locator(AutoMinorLocator(4))
axs[i].yaxis.set_minor_locator(AutoMinorLocator(4))
# if (i != 0):
# axs[i].autoscale()
axs[0].yaxis.set_ticks(np.arange(0, 100, 10))
fig.autofmt_xdate(rotation=90)
plt.grid(b=True)
plt.gca().invert_yaxis()
plt.savefig('rvnl.png')
# plt.show()
#print("date = {}".format(date))
#print("ltp values = {}".format(lpt))
#print("volume values = {}".format(vol))

a= str(input("enter the file name to visualize data : "))
fname(a)