Coder Social home page Coder Social logo

hussain-alsalman / tasi Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 2.0 877 KB

The tasi package for R is designed to assist the quantitative trader to extract Saudi stock market historical prices and financial statements.

Home Page: https://www.arabiananalyst.com/2021/11/29/tasi-2-0/

License: GNU General Public License v3.0

R 100.00%
stock

tasi's People

Contributors

actions-user avatar hussain-alsalman avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

tasi's Issues

Adjusting prices to dividends

There is a small issue with the add_adj_price() function. Currently it request dividends history for specified company based on the specified period window (start and end dates) which is what you would expect. The issue is that the server uses these dates to filter data returned using the announcement dates of the dividends and not the distribution dates which can lead to filtering out necessary data. below is an example

let's say company A has announced their dividends distribution on 9th of April and the actual distribution happened on the 30th of same month. if you use get_company_records() function with period from 10th of April till 10th of May, the add_adj_price() function will not capture the distributed dividends that was announced on the 9th despite the fact that the actual distribution happened within the period. Subsequently, the resulting adjusted prices will be inaccurate.

As you can see, this is a server-side limitation but I would rather to work around this limitation. Feel free to take a shot at it and would like to know your thoughts as well.

Data Extraction Error

Hi,

I am facing data extraction error.
Can you please check the issue here.

Performance of Saudi Aramco company stock

comp_df <- get_company_records("2022-07-01","2022-12-17",company_symbol = 2222, use_cache = FALSE)
Error in rjson::fromJSON(file = parseURL(0, startDate, endDate, type = type, :
not all data was parsed (0 chars were parsed out of a total of 708542 chars)

traceback()
4: stop(sprintf("not all data was parsed (%d chars were parsed out of a total of %d chars)",
size, nchar(json_str, type = "bytes")))
3: rjson::fromJSON(file = parseURL(0, startDate, endDate, type = type,
comSymbol = company_symbol, adjustment = adjustPeriod))
2: request_data(startDate = start_date, endDate = end_date, type = "company",
company_symbol = company_symbol, adjustPeriod = FALSE)
1: get_company_records("2022-07-01", "2022-12-17", company_symbol = 2222,
use_cache = FALSE)

the link doesn't work anymore

df_supplement <- rjson::fromJSON(file = "https://www.saudiexchange.sa/wps/portal/saudiexchange/ourmarkets/main-market-watch/!ut/p/z1/04_Sj9CPykssy0xPLMnMz0vMAfIjo8ziTR3NDIw8LAz8LVxcnA0C3bwtPLwM_I0MzMz1w1EVGAQHmAIVBPga-xgEGbgbmOlHEaPfAAdwNCCsPwpNia-7mUGgn2Ogv5G5qYFBsBG6AixOBCvA44bg1Dz9gtzQCIPMgHQAsqCDtA!!/p0/IZ7_5A602H80OOMQC0604RU6VD10H0=CZ6_5A602H80O8DDC0QFK8HJ0O2067=NJgetMainNomucMarketDetails=/",simplify = FALSE)

fin_parsURL() is broken

The current fin_parsURL() function is not parsing correct links to the financial statements page of the specified company. Right now, It returns financial statement for one specific company regardless of specified company symbol. I have not yet decided on the best way to fix it. All links look unique for each listed company which makes parameterization an issue.

There are two workaround I can think of to resolve this issue.

  • Store all unique links in a list and parse links in lookup manner.
    • Disadvantage: to include new companies package need to be updated and re-installed.
  • Initiate web drive at request time to navigate the website to the financial statements table.
    • Disadvantage: requests will be extremely slow, I expect 10-30s per request.

I am open for new idea. let me know

`get_daily_market_stats()` does not parse strings with percentages

The function currently produce a column full with NA for change percentage.

        open   high    low  close percent_change volume_traded value_traded no_of_trades   market_cap
 [1,]  85.10  86.00  84.80  85.10             NA         46193    3932553.1          429 1.276500e+09
 [2,]  30.00  30.00  29.90  29.95             NA       3742149  112103632.8         8620 7.247900e+12
 [3,]   7.37   7.41   7.30   7.37             NA       1005537    7376901.4         1604 1.231527e+10
 [4,] 153.80 154.00 152.40 153.00             NA        151731   23206653.8         1195 1.361700e+10

percentages column needs to be handled separately

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.