Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to draw a graph by using stock prices in APPLE or SAMSUNG data in CVS file by using Python language.SAMSUNG and APPLE data saved in separate files in same folder.

Desired interface like this Desired Interface If user select Samsung or APPLE in check box.(Only one can select at a time and draw,If I select Apple then Samsung is disabled)Then draw a graph between Date vs Open and Close by selected types from getting suitable CVS file in that folder.In here I give sample data set of apple.csv,it look likes as follows and Samsung data set also like this;
Name,Date,Open,High,Low,Close,Volume
AAPL,02 Jan 2017,115.82,115.82,115.82,115.82,0
AAPL,03 Jan 2017,115.8,116.33,114.76,116.15,28781800
AAPL,04 Jan 2017,115.85,116.51,115.75,116.02,21118100
AAPL,05 Jan 2017,115.92,116.86,115.81,116.61,22193500

I am newer to this language So anyone,please give any guidance to do this task.So please If anyone can give to correct guidance path to do this,it will great help for me.

What I have tried:

Code is that I have tried:(But this is not correct because I want to selected column to draw Date vs. Open and Close and I want to ignore first row because column header.So please edit my code)

import  matplotlib.pyplot as plt
import  csv
dateOfx=[]
open_price_y1=[]
close_price_y2=[]

with open('E:\\Project\Data set\\apple.csv','r') as csvfile:
    plots =csv.reader(csvfile,delimiter=',')
    for column in plots:
        dateOfx.append(int(column[1]))
        open_price_y1.append(int(column[2]))
        close_price_y2.append(int(column[4]))

plt.plot(dateOfx,open_price_y1,close_price_y2 ,label='Loaded from file!')
plt.xlabel('Date')
plt.ylabel('Open')
plt.ylabel('Close')

plt.title('Share Market Price')
plt.legend()
plt.show()
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900