Coder Social home page Coder Social logo

finviz's Introduction

Hi there 👋

I mainly work in Go and Python, with a major focus on the fintech/trading niche.

I'm looking to work on some innovative ideas around the intersection of old and new tech as it applies to the end user.

website linkedin

finviz's People

Contributors

d3an avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

finviz's Issues

slice bounds out of range

Hey, I'm getting this error lately, when calling symbol LABU:getQts, err = client.GetQuotes(symbols).
image

It's not caught by err. Is it possible to fix it? 🙏

GetQuotes not working

Hey there, thanks for the great api.

I'd like to get e.g. a particular's ticker Current Ratio. Based on the screener example on your home page, If I do e.g.

client := quote.New(nil)
stocks, err := client.GetQuotes([]string{"AAPL", "TSLA"})

all parameters/columns yield no information, please see the pic:

2021-12-27_10-35

Am I doing sth wrong? Any suggestion appreciated 👍

Add data cleaning for dataframes

Dataframes are currently returned in the format they were created in. That means that a column that should be in percent is actually represented in string format (i.e. "+35.79%" vs. 0.3579) Create cleaning functions that "type casts" data into the proper format for further analysis.

Add breadth-first iteration to Bulk Tickers View

Add breadth-first iteration to the Bulk Tickers views (510 & 520) to preserve order. The tickers in these views are sorted in a horizontal fashion, but are structured (HTML) vertically. i.e. You have an array of td elements (columns) and within each element is an array of tr elements (tickers). Implement a method to output a dataframe of tickers (and data) in the correct order specified.

Swap async with synchronous request approach

The async approach to screener/quote downloads may result in a temporary/permanent service block. Switch to a strict synchronous approach to better avoid Cloudflare roadblocks.

Update user agents

Finviz/Cloudflare may have blocked some of the user agents generated for requests. Update the user agent library for more modern options. Blocked user agents result in HTTP status code 403 and Cloudflare "error code: 1010".

Consider conducting research on which user agents have been compromised (1423 options).

Add go-vcr package for scraper testing

Add go-vcr package. This package is likely based on the pyvcr package for Python. Its incredibly useful for testing, permitting the avoidance of writing custom patch and mock objects.

Add support for multi-page screens

Currently, the maximum number of securities returned in a screen is 20 (free version). Write a function that allows for multiple pages of screen results to be downloaded. Consider running a recursive operation on the existence of the next button at the bottom of the page.

Allow the default 20 number of rows to be modified by users. Finviz Elite allows this number to be varied up to 100 rows. If it's too much of a hassle, don't bother.

Status code 429

Recently, I am getting code error 429 often. I have not got it for last 8 months with the same code.

Has FinViz put some limit on requests? Has anyone getting the same error? Thanks..

image

Create ScreenInputReader function/interface for json

  1. Create a ScreenInputReader function that would consume a JSON object (marshalled/unmarshalled?) or maybe a byte array and extract a ScreenInput object from the input.
  2. Consider refactoring screener.go into a better designed approach. Use interfaces where necessary.

This is good functionality to add and may help with writing Python bindings later on.

Refactor exported Quote methods

  • Separate GetQuoteData into GetFullQuoteData and GetBasicQuoteData. The difference is that GetFullQuoteData also returns the special sections (Analyst Recommendations, News, Insider Trading, Description, Chart) in its DataFrame.
  • Add specific methods for each special quote section, i.e. GetInsiderTrading, GetNews, GetAnalystRecommendations, GetDescription, GetChart.

General Abstractions

Evaluate whether certain components should be abstracted, i.e., Client, the backoff procedure, and/or the general request procedure.

Create Python bindings

Using gopy, figure out if it's possible to export this library as a Python package, especially as to whether or not PyPI will support it.

There are two primary FinViz packages for Python, finviz and finvizfinance. Both are decently maintained, but still have a lot of room for improvement. If this package can support all features included in the forementioned packages, improve on outstanding issues, and include even more features (AND documentation), Python developers may begin to use this package instead.

Refactor filter code

The code for filters.go is over 3000 lines. There's a lot of repetition, which can probably be refactored.

There has to be a way to refactor the implementation to be simpler. Although the lack of generics prevents a generalization of types, there has to be a better object-oriented (or composition) way to reduce the complexity of the codebase. Figure it out and clean up the code.

Improve Filter Value Lookups

The FilterValueLookup covers all 70 filter types and their corresponding values. The dictionary needs to be fixed up so that each value perfectly mirrors that provided on the site. Once this step is completed, shortcuts should be added as well. Consider the Market Cap filter. A possible shortcut for Mega ($200bln and more) could just be mega.

As a bonus task, consider adding support for approximate string matching. Take a look at the Levenshtein distance metric and see how others have implemented this technique in their projects.

Add support for different chart timeframes

Free

  • Technical: Daily
  • Line: Daily, Weekly, Monthly
  • Candle: Daily, Weekly, Monthly

Elite

  • Technical: Daily
  • Line: 1min, 5min, Daily, Weekly, Monthly
  • Candle: 5min, 15min, 30min, Daily, Weekly, Monthly

Refactor screener helper methods

  • Several of the screener helper methods could be tightened.
    • Replace single statement type switches with declarations.
    • Clean up if statements where possible.
    • Limit use of interfaces when abstractions are not necessary.

URL Generation bug (two question marks)

Fix the url generation bug in which two question marks appear in the final result instead of one. This doesn't affect functionality, but may stand out among FinViz's other requests.

Add unit tests

Every good package has unit tests. Write a few, get the coverage stamp on the README, and maybe find a couple bugs along the way. Having good test coverage is a great way to make sure new code won't break the system on a refactoring or new feature.

The testing package is probably all that's needed, but it's probably a good idea to patch the requests and use mocks where necessary. Take a look at a few of the other go testing packages and see if they're necessary.

  • Add unit testing
    • filter_test.go
      • Multiple values for unsupported filter
      • Multiple values for supported filter
      • Single value for filter
      • No values for filter
    • screener_test.go
      • GenerateURL
        • all inputs (valid)
        • duplicate filters
    • views_test.go
      • Scrape

EDIT: Added the coverage badge. Currently using the testing, govcr, and testify packages to write unit tests.

Add url scraping subcommand to CLI

Create a subcommand that accepts a FinViz url as input and returns a DataFrame (or exports to a file) the resulting scrape of that url. If the FinViz app detailed in the url is not supported, print an informative error message.

Examples:

$ finviz urlscraper https://finviz.com/quote.ashx?t=AAPL
OR 
$ finviz usr https://finviz.com/screener.ashx?v=111&f=exch_nasd&ft=4
OR (unsupported app)
$ finviz usr https://finviz.com/groups.ashx?g=industry&sg=consumerdefensive&v=210&o=name
[ERROR] Groups app not supported.

Add support for non-default views (except charts view)

FinViz offers several views for viewing screen results. Each view is labelled with a unique ID.
The following views exist:

  • Overview (110)
  • Valuation (120)
  • Ownership (130)
  • Performance (140)
  • Custom (150)
  • Financial (160)
  • Technical (170)
  • Charts (210)
  • Basic (310)
  • News (320)
  • Description (330)
  • Snapshot (340)
  • TA (350)
  • Tickers (410)
  • Bulk Tickers (Change Only) (510)
  • Bulk Tickers (Full with Relative Volume) (520)
    Add support for these views (except charts view)

Add descriptions to filters

Add descriptions to filters (or in some lookup) so that CLI users can get better understanding on different filter types.

Clean up wiki

  • add a custom sidebar to improve readability
  • update code examples
  • figure out how to add metadata to wiki for better SEO (GitHub allows search of wikis)

Add properties to filters

Add properties to filters, i.e. whether or not they support multiple or custom values (custom values is looking ahead to elite support)

Output data to csv and json

Add functionality to support the output of screener results to a csv or json. Also support the creation of external file results for csv or json.

Restructure code using more OOP

Restructure the existing codebase to support more inherited methods/classes. This extends into supporting other FinViz apps such as News.

Create a partially abstract base class View and interface ViewInterface:

type View struct {}

type ViewInterface interface {
    GenerateURL() string
    Scrape(document *goquery.Document) ([][]string, error)
}

Each app should have a derived object that inherits the predefined interface methods, such as for News:

type NewsView struct {
    finviz.View
}

Going deeper, an app should derive its actual views from the app view base class, ex:

type SourceNewsView struct {
    NewsView
}

This restructuring should help greatly with view URL generation as derived objects can call parent methods, thus generating the URL in a step by step basis: ('https://finviz.com' OR 'https://elite.finviz.com') + '/news.ashx' + '?v=2'.

Additionally, this restructuring will help clean up the file structure of the codebase and make it more presentable and less daunting on GitHub.

Add support for Quote app

FinViz also has quote pages for its tickers (quote.ashx). Given a list of tickers, create a function that completes a download and scrape using goroutines for concurrency and efficiency. Add a CLI subcommand for this as well.

$ finviz quote aapl,goog,amzn,tsla

Add support for News page

FinViz has a News page. Add support for it. Create a new subcommand for the CLI to facilitate this as well.

There are only two views. So, two scraping functions are required (probably).

Set CLI export flag to be either (csv|json)

Other CLI libraries, specifically argparse and click for Python, support arguments that must be one of a few given options. Figure out if Cobra supports this, and if it does then implement it. If Cobra does not support it, submit a PR to Cobra to fix it.

Create full PrintDataFrame function

The Gota library has a print() method for dataframes, but the method is private. As such, each call to print a dataframe results in a shortened screen printing. Create a custom PrintDataFrame function to override these actions and allow the dataframe (regardless of size) to print to screen.

Change JSON output format to have ticker primary keys

Ex.

[
  {
    "A": {
      "Avg Volume": "1.47M",
      "Change": "0.00%",
      "No.": 1,
      "Perf Half": "28.54%",
      "Perf Month": "6.04%",
      "Perf Quart": "13.47%",
      "Perf Week": "4.12%",
      "Perf YTD": "21.23%",
      "Perf Year": "45.95%",
      "Price": 103.42,
      "Recom": "2.40",
      "Rel Volume": 0.97,
      "Ticker": "A",
      "Volatility M": "1.80%",
      "Volatility W": "1.82%",
      "Volume": 0
    },
    "AA": {
      "Avg Volume": "7.33M",
      "Change": "0.00%",
      "No.": 2,
      "Perf Half": "23.38%",
      "Perf Month": "7.32%",
      "Perf Quart": "26.03%",
      "Perf Week": "-2.65%",
      "Perf YTD": "-31.80%",
      "Perf Year": "-19.75%",
      "Price": 14.67,
      "Recom": "2.70",
      "Rel Volume": 0.77,
      "Ticker": "AA",
      "Volatility M": "4.72%",
      "Volatility W": "4.12%",
      "Volume": 0
    }
  }
]

instead of

[
  {
    "Avg Volume": "1.47M",
    "Change": "0.00%",
    "No.": 1,
    "Perf Half": "28.54%",
    "Perf Month": "6.04%",
    "Perf Quart": "13.47%",
    "Perf Week": "4.12%",
    "Perf YTD": "21.23%",
    "Perf Year": "45.95%",
    "Price": 103.42,
    "Recom": "2.40",
    "Rel Volume": 0.97,
    "Ticker": "A",
    "Volatility M": "1.80%",
    "Volatility W": "1.82%",
    "Volume": 0
  },
  {
    "Avg Volume": "7.33M",
    "Change": "0.00%",
    "No.": 2,
    "Perf Half": "23.38%",
    "Perf Month": "7.32%",
    "Perf Quart": "26.03%",
    "Perf Week": "-2.65%",
    "Perf YTD": "-31.80%",
    "Perf Year": "-19.75%",
    "Price": 14.67,
    "Recom": "2.70",
    "Rel Volume": 0.77,
    "Ticker": "AA",
    "Volatility M": "4.72%",
    "Volatility W": "4.12%",
    "Volume": 0
  }
]

Switch out gocyclo for gocognit

Both gocyclo and gocognit calculate code complexities, but according to popular review, gocognit uses better logic (ex. switch statement with 18 branches is +1 in gocognit and +19 in gocyclo) and makes more reasonable estimates. As a bonus, gocognit has been updated more recently than gocyclo.

Add CLI Finviz commands

Create a base command finviz and add subcommands as functionality increases.
Create a screener subcommand to run screens against Finviz.
Create a help sub-subcommand for screener to help with displaying valid options.

Examples:

$ finviz screener -s TopGainers -o -ChangeFromOpen -f Industry:gold,airlines  Price:PriceOver1
# Same as running the RunScreen function and printing the dataframe to screen
$ finviz screener help
# Returns general help for all options (basically lists possible values and syntax)
$ finviz screener help signal filter:industry,sector
# Returns general help for signal and filter, along with specific help for industry, sector filters

Panic if ticker not available

I am requesting quotes client.GetQuotes([]symbols) for a bunch of tickers and get panic if a ticker is not available in FinViz, e.g. ticker SHAC is not.. 
error received while scraping quote for 'SHAC': error getting url: 'https://finviz.com/quote.ashx?t=SHAC&ty=c&p=d&b=1', status code: '404'
I could catch the error, remove the ticker and pull again, but that could be much overhead, specially from FinViz point of view. Could this be fixed internally so the program does not panic but throws warning instead that a ticker is not available?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.