[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/biz/ - Business & Finance


View post   

File: 13 KB, 196x257, PYFI.jpg [View same] [iqdb] [saucenao] [google]
12289809 No.12289809 [Reply] [Original]

I built a few python scripts to find undervalued companies. Anyone else use python to automate big data pulls?

>> No.12289829

any tips how to use python in crypto

>> No.12289842
File: 170 KB, 361x240, cowsSacred.png [View same] [iqdb] [saucenao] [google]
12289842

>>12289809
This is cool as hell OP is based

>> No.12289856

>>12289809
what libraries did you use?

>> No.12289933

>>12289809
kek, actually got that book for Christmas. Have it in front of me now

>> No.12290023

>>12289809

Where'd you get your data from? Bloomberg?

>> No.12290045

where to start if i want to learn python?

>> No.12290056

>>12290045
Do you have any experience with programming at all?

>> No.12290061

>>12289829
>>12289842
>>12289856

I haven't done anything with python for crypto. Just pulled all companies in the NYSE and NASDAQ.

I used pandas, numby and a couple others. if you want i can post the scripts.

>> No.12290064

>>12290061
Please do.

>> No.12290068

>>12290056
nope, just VBA (kek)

>> No.12290098

>>12290023
I pulled all the companies for NASDAQ/NYSE from. http://www.eoddata.com/symbols.aspx

The financial ratios are pulled from http://financials.morningstar.com/ (this is where the Earnings Per Share data is pulled)

https://www.zacks.com/stocks is used to pull the close price.

I know other sites can be accessed for data. this is what I have been using.

>> No.12290117

>>12290068
lmao, well when I was learning the three most helpful things I found were:

1. I started with Python: Crash Course by Eric Matthes to get the basics down
2. tutorialspoint.com for their Python 3 tutorial to get some of the nuisances and deeper features
3. and I used hackerrank.com to practice on their challenges

Use google to find the answers for smaller questions that you're not sure about (i.e. they're asking for a two decimal answer and you need to turn your float into a number with two decimals after the point).

>> No.12290124

>>12290117
thanks man

>> No.12290131

>>12290064
So I found a great course that gave me my start with this, it was on the pirate bay. search GET RICH SLOW - Step by step value investing with Python.

it has the videos, python scripts and excel spread sheet formals to complete the process of doing the data pulls and then using excel to get the valuations of the companies.

>> No.12290191
File: 495 KB, 2010x1612, Market Cap Pull.png [View same] [iqdb] [saucenao] [google]
12290191

>>12290064
If your using Mac you may need to change the format of the file path but this script will pull the market caps for all companies in your excel file(all companies in the NYSE/NASDAQ or what ever exchange you want)

Sorry for the image but not enough room to paste it.

>> No.12290209

>>12289809
Could ya post em that’s be cool im learning python rn, first anguage

>> No.12290216
File: 27 KB, 500x374, 1544960788943.jpg [View same] [iqdb] [saucenao] [google]
12290216

>>12290191
hey Zack

>> No.12290285

This one pulls all the EPS data for companies in your excel file. These pulls can take a few hours but if your high speed you can learn how to setup an amazon virtual machine with AWS ECU2 to let it run with your python programs with using your own computers resources.

Here is the Part 1 so you can copy pasta it.

# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup
import urllib2
import numpy as np
import pandas as pd
import csv
from os import chdir
from time import time
from time import sleep

#------------------function to open the webpage-----------------
def GetData(ticker,findf):
#test to see if excahnge works "NYS" vs "NAS"-----------------------------
istst = (r'http://financials.morningstar.com/ajax/ReportProcess4CSV.html?'+
r'&t=XNYS:' + ticker + r'&region=usa&culture=en-US&cur=&reportType=is'+
r'&period=12&dataType=A&order=asc&columnYear=5&curYearPart=1st5year&'+
r'rounding=3&view=raw&r=519204&denominatorView=raw&number=3')
header = {'User-Agent': 'Mozilla/5.0'} #Needed to prevent 403 error on Wikipedia
req = urllib2.Request(istst,headers=header)
page = urllib2.urlopen(req)
soup = BeautifulSoup(page, "lxml")
if len(soup) == 0:
ex = "NAS"
else:
ex = "NYS"
#assign the tickers
finwiki = (r'http://financials.morningstar.com/finan/ajax/exportKR2CSV.html?'+
r'&callback=?&t=X'+ex+r':'+ticker+r'&region=usa&culture=en-US&cur=&order=asc')
#links = [iswiki,bswiki,cfwiki,finwiki] #putting it all in a list
links = [finwiki] #putting it all in a list
#-----------------the rest of the code----------------
header = {'User-Agent': 'Mozilla/5.0'} #Needed to prevent 403 error on Wikipedia
req = urllib2.Request(links[0],headers=header)
page = urllib2.urlopen(req)
soup = BeautifulSoup(page, "lxml")
#---------------End of Part 1----------------

>> No.12290304

Part 2 of the EPS Scraper...remember to paste them all into your own Python editor.

#------------------returned the I&E----------
dat = soup.get_text() #pulls out just the text from the csv
#just do a text thing
#so create a file?
target = open('test01.csv', 'w')
target.write(dat)
target.close()
#can use skip rows?
#---------------

#read it in as a dataframe? skip the first row
df = pd.read_csv("test01.csv",header = 2,index_col=False) #, index_col=False
df.index = df['Unnamed: 0']
df = df.drop(['Unnamed: 0'], axis = 1)
df.index.names = ['Desc'] #rename the index
#print(isdf)
#to return the lines that I need
dfeps = df.loc[['Earnings Per Share USD']].copy() #,'Return on Assets %'
#so the technique to change the name is to add a column
dfeps['name'] = ticker
dfeps.index = dfeps['name']
del dfeps['name']
#change the name of the colums to last years, to make it consistant?
#then can do valuation in excel...no need to pull in price at each period
################now combine the two df's###############
if j==0:
findf = dfeps
else:
findf = findf.append(dfeps) #the merged BS/IS
return findf
#---------------End of Part 2------------

>> No.12290374

https://github.com/wilsonfreitas/awesome-quant

is a really good resource, I would bookmark it.

>> No.12290408
File: 42 KB, 399x357, 16545631763675698165656145612316768623415615656656546105321565252342.jpg [View same] [iqdb] [saucenao] [google]
12290408

>>12290374

>> No.12290549
File: 52 KB, 782x528, 1341268934615.jpg [View same] [iqdb] [saucenao] [google]
12290549

>>12289809
>>12289933
>>12290061

OP, take this image into heart. You can do literally anything with Python that you would do regularly. However, if you're new to business, you should learn more about business before trying to jump into programming. Figure out what you want to do.

That being said, learning Python is probably one of the best career moves. Best of luck.

>> No.12290587
File: 292 KB, 1084x1346, Undervaluation List.png [View same] [iqdb] [saucenao] [google]
12290587

There are a few others sripts that pull data like the last two years of the close price, the stock price when the earnings where reported and one the creates charts. Using all the big data scaped by the programs I can use excel to create the Discounted Cash Flow model and apply to all the stocks. the ultimate product is a list of companies showing what their value should be based on the past 5 years of earning and prices and what they are currently trading at. If the stock is currently trading below its valuation then its undervalued and can be analyzed further. if its trading over its price its overvalued and can be targeted for shorts.
This is more that goes into it like current market cycles and other factors affecting the company.
Investors Business Daily is a great way to narrow down the list of undervalued companies to give you the best of the best.

>> No.12290592

>>12290549
Thank You! We never stop learning.

>> No.12290656
File: 6 KB, 226x223, VERY slow in the head.png [View same] [iqdb] [saucenao] [google]
12290656

>>12289809
I have that book lying around somewhere but never really got the chance to open it--I'm a Swift/Object-C applecuck XCode brainlet so I have to ask: where does one even write Python scripts, particularly for finance? I did the codecademy courses for it some years back and quite liked it, though courses like that never really tell you where to go after or give you proper tutorials for IDEs

>> No.12290749

>>12290656
https://www.anaconda.com/download/#macos

This is the editor I use, you want to use the spider editor found in the application.

>> No.12290769

>>12290656
sublime

>> No.12290836
File: 940 KB, 2876x1755, Screen Shot 2018-12-30 at 10.50.51 PM.png [View same] [iqdb] [saucenao] [google]
12290836

this one has been running for about 7 hours and still has about 2 more...

>> No.12291144

Fascinating thread. Sure would love to automate some of these tasks but never managed to get past the basics in programming. Every course and book goes from fully internal to suddenly pulling into from other areas without explaining how to actually do that.

>> No.12291146

>>12290285
>knows python
>doesnt know pastebin
bruh

>> No.12291177

>>12289809

Why not just use a stock screener like investing.com? I mean, I like python, but what do you intend to do? Algorithmic trading?

>> No.12291361

>>12291146
You are too smart for me,
https://pastebin.com/Jni3vDMY Market Cap Pull
https://pastebin.com/7NtV0GaN EPS Scraper
https://pastebin.com/6eFyPhTn Price at EPS
https://pastebin.com/jUYDjGMj Price history current and two years prior
https://pastebin.com/v0TE8jXL

here is everything i'm using.

>> No.12291372

>>12290098

Could use Bloomberg to keep active tabs on a watchlist generated the night or week before.

500,000 queries a day iirc to Bloomberg on the free API.

>> No.12291375

Whats the best language for trading bots?

>> No.12291414

Awesome thread, good work OP.

>> No.12291430

>>12291177
I want more options to manipulate the data so I pull big amounts of stock data for information like prices over multiple years, cash flow amounts, balance statement information, etc. That is not commonly found on free services.

Then I use valuation models not available on free services. If you can find a site that use discount cash flow method to calculate valuations for any stock on any exchange I will use it.

>> No.12291455

>>12291375
I hear Python is one of the more popular websites. I would check out this site to learn more about algorithmic trading: https://www.quantopian.com
also Think or Swim platform I think is okay but I you may need to do some research.

>> No.12291471

>>12291372
I need to come on here more often, that sounds like common sense as a source to pull from.

>> No.12292495

>>12291414
agreed, I wish more posts on this board were of this quality

>> No.12292528

>feel really comfortable with python, enough to write what everybody here has posted on my own
>literally 0 knowledge how to spot undervalued companies or investment opportunities looking at data
Crossed the ocean and drowned in the puddle lads

>> No.12292541
File: 25 KB, 600x484, 1546149910263.jpg [View same] [iqdb] [saucenao] [google]
12292541

>>12292495
>>12291375
>>12290587
Complete brainlet shit head here. Can anyone here tell me what this is and how i can join this? Im a business student with alot of free time and this looks interesting. Never did programming or wizardry ever in my life. The most I did was if logic gates for a theme park during high school computer class. Where do I start? And any material would be appreciated. Thank frens

>> No.12292583

>>12292541
I'm brainlet-tier right along with you fren, and programming for finance is definitely interesting and potentially profitable. In programming there exist different languages with different strengths and weaknesses, though Python is especially renowned for its applications in science and big data (in this case finance). A great starting point to programming in general is Codecademy, they have a free Python course last I checked that is totally in-browser. The learning curve in programming IMO is not at the beginner or advanced level but rather at the intermediate level--you get the basics of a language but don't really know where to go on your own. With this, I would also like more frens to expand upon this subject

>> No.12292586

>>12292528
make me a bot like this

https://www.youtube.com/watch?v=ng_Rz6VoYu4

>> No.12292620

Also, since this is a based Python thread, is there any real merit to sticking with Python 2? Or is the community all about Python 3 full steam ahead?

>> No.12292624

>>12292583
Thanks fren I'll look intk that

>> No.12292674

>>12292586
Dont know what hes talking about except the trailing sell
But it seems doable
Where should I start to expand my knowledge to this kind of stuff from "buy low sell high lol"?

>> No.12292675

>>12289829
PyAlgoTrade

>> No.12292727

How much time to learn python without programing experience?
Im very depressed in my work, i need to move, i can study for 4 years with my saves.

>> No.12292743

>>12292620
Python 3

>> No.12292765
File: 90 KB, 563x517, 1546041604682.jpg [View same] [iqdb] [saucenao] [google]
12292765

>>12290191
Not many people know this.
But THIS is how you properly share code. As a screenshot in 4chan.

Only other viable way is making a photograph of a printed out page and sending it via postcard.

>> No.12293589

Thx for all the tips guis!
Can't all those things be done with java/Scala as well? Too much code?

>> No.12293737

I made my own algo trading platform and front-end in Node.js, which has been blazing fast and highly flexible for my high-frequency needs so far.
Brokers trading and live/historic data sourcing and high precision paper order execution simulation (can simulate same-price L2 queue, and partial fills) for any exchange I care to implement (I've provided impl's for Binance and Bitstamp so far).
You write a strategy script in javascript in your browser, submit it to the engine which sandboxes your script in a VM, runs it for however long you want, live or paper trading, and you can see all the stuff it's doing. Running a few low volume strat's on there for the past couple months - pretty comfy.
Node.js has been great t b h, and making the web front-end for it was easier as a result.

>> No.12293751

>>12292765
kek, was thinking the same

> what is pastebin

>> No.12293755

Where to cop good models?

>> No.12293760

>>12290836

> bare except
absolutely disgusting

>> No.12293785

I use ruby, mainly to help calculate my taxes though.

>> No.12293812

>>12289809
Used it for automatic SEC filing notifications.
Also automated my front end web job and haven't told my boss. Pretty cozy.

>> No.12293841

>>12292727
half a year with good books/tutorials ( at leisurely pace even )

>> No.12293846

>>12290045
Took me about a year, but I started with PRAW and Reddit bots.
Just Google PRAW in 5 minutes Reddit or something.
From there, you can cut your teeth on a few more bots. I had a few with custom dictionaries and would reply to comments, then tell them to fuck off or give praise if they responded to my comment. Basically have fun trolling. Then read Automate the Boring Stuff.
There's no panacea, no magic book. Use your knowledge and come up with needs that fit your life and learn how fulfill them with Python via Google and cussing.

>> No.12293861

>>12293841
Implying though that the local market will actually give a damn.

I've been trying to move from front end to Jr back end for the past year and can't catch anybody's eye. I'm in a hick town though, so ymmv

>> No.12294083

>>12292541
Here are some good basics:
https://www.scipy-lectures.org/index.html
Most important is trail and error, learn by exploration.