Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8944891
Clean out django-fett branch
harshak913 Aug 18, 2020
0df09d7
Add Heroku-optimized files
harshak913 Aug 18, 2020
e8d1751
Configure postgres for heroku deployment
harshak913 Aug 19, 2020
6a7c100
Models created
harshak913 Aug 20, 2020
3cf3014
encoding for models
harshak913 Aug 20, 2020
3bae66e
Final models created for heroku db
harshak913 Aug 20, 2020
d8f5a4f
Search bar Companies
inquinate26 Aug 21, 2020
118596a
Search Bar
inquinate26 Aug 21, 2020
db68b70
Autocomplete Done
inquinate26 Aug 21, 2020
ffa7853
Naming Fix
inquinate26 Aug 21, 2020
e185cfa
comments
inquinate26 Aug 21, 2020
3a8ab97
Year Padding and Cleanup for Slider
inquinate26 Aug 23, 2020
ad4db58
Further Data Cleanup
inquinate26 Aug 23, 2020
0b5af17
Standardization Update for Django
inquinate26 Nov 15, 2020
7762e4d
Further Standardization and cleaning
inquinate26 Nov 15, 2020
9dc5a1e
Another Standard Update
inquinate26 Nov 16, 2020
5f129b6
Standardization Ordering and Standardization Update Program
inquinate26 Nov 18, 2020
8553ca3
Ordering
inquinate26 Nov 18, 2020
79a24c6
Number and Centering
inquinate26 Nov 20, 2020
8a1d779
added workspace file
harshak913 Nov 23, 2020
9078087
YFDescription Update
inquinate26 Dec 8, 2020
2f60e09
Merge branch 'django-fett' of https://github.com/harshak913/Project-A…
inquinate26 Dec 8, 2020
e208b85
Organization for Algo and Old Django
inquinate26 Dec 8, 2020
792f153
description insertion v1
harshak913 Dec 8, 2020
45018d7
Merge branch 'django-fett' of https://github.com/harshak913/Project-A…
harshak913 Dec 8, 2020
1c0b2b8
description insert v2
harshak913 Dec 8, 2020
f52ac33
description insert v3
harshak913 Dec 8, 2020
634b664
description insert v3
harshak913 Dec 8, 2020
7a54de7
description insert v4
harshak913 Dec 9, 2020
e883fc2
Other updates
inquinate26 Dec 9, 2020
99ec723
Merge branch 'django-fett' of https://github.com/harshak913/Project-A…
inquinate26 Dec 9, 2020
4637149
added print statement to DB insert
harshak913 Dec 9, 2020
0ff81b6
Merge branch 'django-fett' of https://github.com/harshak913/Project-A…
harshak913 Dec 9, 2020
a8e0df1
Mockup Files
inquinate26 Dec 12, 2020
9d2d249
Display changes
inquinate26 Dec 25, 2020
248b492
Updates tp information, base, and views. Standard Match P = Primary
inquinate26 Dec 29, 2020
5d79bc5
Added new items to avoid list for compounding
inquinate26 Jan 5, 2021
0a0d5fe
base.html changes to display
inquinate26 Jan 5, 2021
da02a87
update to some items
inquinate26 Jan 11, 2021
62ac1d0
dict_print and standard match rerun
inquinate26 Jan 12, 2021
c9c71ca
Views update. Removed several line items
inquinate26 Jan 13, 2021
b97c2bd
Year updates & small stuff
inquinate26 Jan 24, 2021
c24358b
Rerun with update years
inquinate26 Feb 1, 2021
b8ed8f6
Updates to standard match to improve unit conv and quarter match
inquinate26 Feb 14, 2021
d8527af
Further improvements
inquinate26 Feb 15, 2021
728a966
Quarter match test changes to see which ones have no proper months
inquinate26 Feb 15, 2021
ffbb5e3
Updates to display and tables
inquinate26 Feb 21, 2021
4287b0c
big updates to allow for nonstop running of quarter and standardization
inquinate26 Mar 6, 2021
0592aae
Big quarter updates
inquinate26 Mar 7, 2021
eee0672
Updates for quarter display and processing
inquinate26 Mar 13, 2021
617db0b
cors_origin allowed
inquinate26 Apr 7, 2021
f77255c
ArtRss for news scraping
inquinate26 May 1, 2021
d87c0d9
Search by ticker on line 24
inquinate26 May 18, 2021
d3ee9b0
Article Updates
inquinate26 Jun 9, 2021
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
Binary file removed .env
Binary file not shown.
Binary file modified .gitignore
Binary file not shown.
5 changes: 5 additions & 0 deletions .slugignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Heres a comment
*.psd
*.pdf
/test
/spec
79 changes: 79 additions & 0 deletions Algo/ArtRss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import feedparser
import psycopg2
import re

connection = psycopg2.connect(host="ec2-34-197-188-147.compute-1.amazonaws.com", dbname="d7p3fuehaleleo", user="snbetggfklcniv", password="7798f45239eda70f8278ce3c05dc632ad57b97957b601681a3c516f37153403a")
connection.autocommit = True
cursor = connection.cursor()

#company specific news------------->
scrape_query = "select * from company;"
cursor.execute(scrape_query)
entries = cursor.fetchall()

for entry in entries:
if entry[0] != 0:
ticker = entry[1]
#name = re.sub(r'\W+', '', entry[2])
cik = entry[0]
#if cik == 315189:
# breakOff = True
#print(name)
#newsQ = "https://news.google.com/rss/search?q="+name+"ticker&hl=en-US&gl=US&ceid=US%3Aen"
newsQ = "https://news.google.com/rss/search?q="+ticker+"-ticker&hl=en-US&gl=US&ceid=US%3Aen"
NewsFeed = feedparser.parse(newsQ) #company specific
#print(NewsFeed)
i=0
for item in NewsFeed['entries']:
if i < 50:
title =item['title'].replace("'", "‘")
link = item['link'].replace("'", "‘")
date_published = item['published']
source = item['source']['title'].replace("'", "‘")
i+=1
sql_statement = "INSERT INTO news (cik, title, link, date_published, source) VALUES('%s', '%s', '%s', '%s', '%s')"%(cik, title, link, date_published, source)
print(sql_statement)
#cursor.execute(sql_statement)

#print(i)
allCats = [
#Business News ------------------------>DONE
{'NewsFeed': "https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGx6TVdZU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen" #general business news
,'cik': 0},

#US News-------------------------->DONE
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqIggKIhxDQkFTRHdvSkwyMHZNRGxqTjNjd0VnSmxiaWdBUAE?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 1},

#World News----------------------->
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGx1YlY4U0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 2},

#Technology News------------------>
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGRqTVhZU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 3},

#Entertainment News--------------->
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNREpxYW5RU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 4},

#Science News------------------------->
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRFp0Y1RjU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 5},

#Health News---------------------->
{'NewsFeed': 'https://news.google.com/rss/topics/CAAqIQgKIhtDQkFTRGdvSUwyMHZNR3QwTlRFU0FtVnVLQUFQAQ?hl=en-US&gl=US&ceid=US%3Aen'
,'cik': 6},
]

for cats in allCats:
NewsFeed = feedparser.parse(cats['NewsFeed'])
cik = cats['cik']
for item in NewsFeed['entries']:
title =item['title'].replace("'", "‘")
link = item['link']
date_published = item['published']
source = item['source']['title'].replace("'", "‘")
sql_statement = "INSERT INTO news (cik, title, link, date_published, source) VALUES('%s', '%s', '%s', '%s', '%s')"%(cik, title, link, date_published, source)
print(sql_statement)
#cursor.execute(sql_statement)
219 changes: 219 additions & 0 deletions Algo/Standard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore.js">
</script>
</head>
<body>

<p>Standardized Display</p>

<p id="demo"></p>


<script type="text/javascript">

/*
var data = [
{ year__year: "2016", standard_name: "Net Income", report_period: "2016-02-26", value: "5" },
{ year__year: "2016", standard_name: "Net Income", report_period: "2018-02-26", value: "6" },
{ year__year: "2018", standard_name: "Net Income", report_period: "2018-02-26", value: "10" },
{ year__year: "2018", standard_name: "Operating Cash", report_period: "2019-02-26", value: "15" },
{ year__year: "2018", standard_name: "Operating Cash", report_period: "2020-02-26", value: "16" },
{ year__year: "2019", standard_name: "Operating Cash", report_period: "2018-02-26", value: "15" },
{ year__year: "2019", standard_name: "Operating Cash", report_period: "2019-02-26", value: "20" },
{ year__year: "2019", standard_name: "Gross Margin", report_period: "2018-02-26", value: "25" },
{ year__year: "2020", standard_name: "Gross Margin", report_period: "2020-02-26", value: "33" },
{ year__year: "2020", standard_name: "Gross Margin", report_period: "2021-02-26", value: "34" },
{ year__year: "2020", standard_name: "Gross Margin", report_period: "2022-02-26", values: "35" },
];
*/

var data = [
{ year__year: "2016", quarter: 'Q1',standard_name: "Net Income", report_period: "2018-02-26", value: "6" },
{ year__year: "2016", quarter: 'Q3',standard_name: "Net Income", report_period: "2018-02-26", value: "6" },
{ year__year: "2018", quarter: 'Q2',standard_name: "Net Income", report_period: "2018-02-26", value: "10" },
{ year__year: "2018", quarter: 'Q1',standard_name: "Operating Cash", report_period: "2019-02-26", value: "15" },
{ year__year: "2018", quarter: 'Q1',standard_name: "Operating Cash", report_period: "2020-02-26", value: "16" },
{ year__year: "2019", quarter: 'Q1',standard_name: "Operating Cash", report_period: "2018-02-26", value: "15" },
{ year__year: "2019", quarter: 'Q1',standard_name: "Operating Cash", report_period: "2019-02-26", value: "20" },
{ year__year: "2019", quarter: 'Q1',standard_name: "Gross Margin", report_period: "2018-02-26", value: "25" },
{ year__year: "2020", quarter: 'Q1',standard_name: "Gross Margin", report_period: "2020-02-26", value: "33" },
{ year__year: "2020", quarter: 'Q2',standard_name: "Gross Margin", report_period: "2021-02-26", value: "34" },
{ year__year: "2020", quarter: 'Q3',standard_name: "Gross Margin", report_period: "2022-02-26", values: "35" },
];

//this will decide if we got to use the additional quarter processing code
var quarterCheck = true;

//Generate all numbers between the two years
function getAllNumbersBetween(x, y) {
var b = 0
var numbers = [];
// Set a temporary variable i to start at value x.
// As long as the value of i is less than the value y, increment it.
// The loop will end when i is equal to y.
for (var i = x; i <= y; i++) {
z = {}
z['id'] = b;
z['year'] = String(i);
numbers.push(z);
b++
}
return numbers;
}

//groupby function that allows me to group by multiple keys
function groupBy(array , f )
{
var groups = {};
array.forEach( function( o )
{
var group = JSON.stringify( f(o) );
groups[group] = groups[group] || [];
groups[group].push( o );
});
return Object.keys(groups).map( function( group )
{
return groups[group];
})
}

//get min and max years for filling in the blanks.
var min_year = new Number(Math.min.apply(null, data.map(function(e) {
return new Number(e.year__year);
})));

var max_year = new Number(Math.max.apply(null, data.map(function(e) {
return new Number(e.year__year);
})));

console.log(min_year)
console.log(max_year)

//get all the numbers between the two
years = getAllNumbersBetween(min_year, max_year);

console.log(years)


quarterYears = []
//quarter year display additional processing
if ( quarterCheck ){
for ( q=0; q<data.length; q++ ){
data[q]['year__year'] = data[q]['year__year'] + ' ' + data[q]['quarter']
}
quarters = ['Q1', 'Q2', 'Q3', 'Q4'];
console.log('We are looking at quarters baby');
var id = 0;
for ( i=0; i<years.length; i++ ){
var currYear = years[i].year;
for ( j=0; j<quarters.length; j++ ){
var temp = {};
temp['year'] = years[i].year + ' ' +quarters[j];
temp['id'] = id;
id++
quarterYears.push(temp);
}
}
years = quarterYears
}

console.log(quarterYears)
console.log(data)


//group the pulled items together by standard name and years
var newarray = groupBy(data, function(item)
{
return [item.standard_name, item.year__year];
});

//print to see if groupBy worked
console.log(newarray)

//create empty array to insert singular cleaned latest years for line items
var singular_years = [];

//Process the data and get the year with the most recent report time
for ( i=0; i<newarray.length; i++ ){
//get the latest date
var latest_date = new Date(Math.max.apply(null, newarray[i].map(function(e) {
return new Date(e.report_period);
})));

console.log('Latest Date: ' + latest_date)

for ( j=0; j<newarray[i].length; j++ ){
//see if the item within array of array is the obj with the latest filing
if (newarray[i][j].report_period === latest_date.toISOString().substring(0, 10)) {
//if it is insert it into singular_years
console.log('Latest report period for ' + newarray[i][j].standard_name + " " + newarray[i][j].year__year + " " + newarray[i][j].report_period)
const target = {};
const returnedTarget = Object.assign(target, newarray[i][j]);
singular_years.push(returnedTarget);
}
}
}

//singular years is the complete list
console.log(singular_years)

var cleaned_years = groupBy(singular_years, function(item)
{
return [item.standard_name];
});

console.log(cleaned_years)
finList = [...singular_years];

for ( i=0; i<cleaned_years.length; i++ ){
//create copy of years to see which years will need to be filtered out
yearCopy1 = [...years];
for ( j=0; j<cleaned_years[i].length; j++ ){
var currentYear = String(cleaned_years[i][j].year__year)
console.log(cleaned_years[i][j].standard_name + currentYear)
//filter out the obj with that year from yearCopy1
yearCopy1 = yearCopy1.filter(function( obj ) {
return obj.year !== currentYear;
});
}
const template = Object.assign({}, cleaned_years[i][0]);
template['value'] = '-'
template['report_period'] = '-'
console.log(template)
console.log(yearCopy1)
for ( k=0; k<yearCopy1.length; k++ ) {
var newTemp = Object.assign({}, template);
newTemp['id'] = yearCopy1[k].id;
newTemp['year__year'] = yearCopy1[k].year;
finList.push(newTemp);
}
}

for ( k=0; k<finList.length; k++ ) {
finList[k]['year__year'] = String(finList[k]['year__year']);
var matchYear = years.find(obj => {return obj.year === finList[k].year__year})
finList[k]['id'] = matchYear['id']
}

console.log(finList)

finList.sort(function(a, b) {
return a.id - b.id;
});

var cleaned_years = groupBy(finList, function(item)
{
return [item.standard_name];
});

console.log(cleaned_years)



</script>

</body>
</html>
Loading