Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[support] py-stocks-api

Featured Replies


PY-Stocks

A minimal stocks API wrapper of Yfinance.

 

Source: https://github.com/patrickstigler/py-stocks

Build: https://hub.docker.com/r/patrickstigler/py-stocks-api

 

Endpoints

Download

The /download/:symbol/:startDate/:endDate endpoint takes a symbol and a start and end date

Params:

interval default 1d

Example command

curl localhost:8000/download/AAPL/2021-08-01/2021-08-03 | jq

JSON Response

{"schema": {"fields":[{"name":"Date","type":"datetime"},{"name":"Open","type":"number"}, {"name":"High","type":"number"},{"name":"Low","type":"number"},{"name":"Close","type":"number"}, {"name":"Adj Close","type":"number"},{"name":"Volume","type":"integer"}],"primaryKey":["Date"],"pandas_version":"0.20.0"}, "data":[{"Date":"2019-12-31T00:00:00.000Z","Open":289.9299926758,"High":293.6799926758,"Low":289.5199890137,"Close":293.6499938965,"Adj Close":289.8670349121,"Volume":25247625}]}

History

The /history/:symbol/ endpoint takes a symbol

Params:

will download all available data about the symbol

Example command

curl localhost:8000/history/AAPL/ | jq

JSON Response

{"schema":{"fields":[{"name":"Date","type":"datetime"},{"name":"Open","type":"number"},{"name":"High","type":"number"},{"name":"Low","type":"number"},{"name":"Close","type":"number"},{"name":"Volume","type":"integer"},{"name":"Dividends","type":"number"},{"name":"Stock Splits","type":"number"}],"primaryKey":["Date"],"pandas_version":"0.20.0"},"data":[{"Date":"1980-12-12T00:00:00.000Z","Open":0.4784811735,"High":0.4805576009,"Low":0.4784811735,"Close":0.4784811735,"Volume":117258400,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-15T00:00:00.000Z","Open":0.4535170794,"High":0.4555935627,"Low":0.4535170794,"Close":0.4535170794,"Volume":43971200,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-16T00:00:00.000Z","Open":0.4202322364,"High":0.4223087202,"Low":0.4202322364,"Close":0.4202322364,"Volume":26432000,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-17T00:00:00.000Z","Open":0.4306303263,"High":0.4327067819,"Low":0.4306303263,"Close":0.4306303263,"Volume":21610400,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-18T00:00:00.000Z","Open":0.4431188107,"High":0.4451952656,"Low":0.4431188107,"Close":0.4431188107,"Volume":18362400,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-19T00:00:00.000Z","Open":0.4701594412,"High":0.4722368129,"Low":0.4701594412,"Close":0.4701594412,"Volume":12157600,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-22T00:00:00.000Z","Open":0.4930462837,"High":0.4951236558,"Low":0.4930462837,"Close":0.4930462837,"Volume":9340800,"Dividends":0.0,"Stock Splits":0.0},{"Date":"1980-12-23T00:00:00.000Z","Open":0.5138424039,"High":0.5159197751,"Low":0.5138424039,"Close":0.5138424039,"Volume":11737600,"Dividends":0.0,"Stock Splits":0.0},{"Date":"2021-12-10T00:00:00.000Z","Open":175.2050018311,"High":177.5680999756,"Low":174.6999969482,"Close":177.4848022461,"Volume":61115558,"Dividends":0.0,"Stock Splits":0.0}]}

Info

The /info/:symbol endpoint takes a symbol and return company information and the current price.

Example command:

curl localhost:8000/info/AAPL | jq

JSON Response:

{ "52WeekChange": 0.18871057, "SandP52WeekChange": 0.2816925, "address1": "One Apple Park Way", "algorithm": null, "annualHoldingsTurnover": null, "annualReportExpenseRatio": null, "ask": 0, "askSize": 1800, "averageDailyVolume10Day": 70456128, "averageVolume": 77309822, "averageVolume10days": 70456128, "beta": 1.202797, "beta3Year": null, "bid": 0, "bidSize": 1200, "bookValue": 3.882, "category": null, "circulatingSupply": null, "city": "Cupertino", "companyOfficers": [], "country": "United States", "currency": "USD", "currentPrice": 147.54, "currentRatio": 1.062, "dateShortInterest": 1628812800, "dayHigh": 149.12, "dayLow": 147.51, "debtToEquity": 210.782, "dividendRate": 0.88, "dividendYield": 0.006, "earningsGrowth": 1, "earningsQuarterlyGrowth": 0.932, "ebitda": 110934999040, "ebitdaMargins": 0.31955, "enterpriseToEbitda": 22.65, "enterpriseToRevenue": 7.238, "enterpriseValue": 2512655745024, "exDividendDate": 1628208000, "exchange": "NMS", "exchangeTimezoneName": "America/New_York", "exchangeTimezoneShortName": "EDT", "expireDate": null, "fiftyDayAverage": 146.94086, "fiftyTwoWeekHigh": 151.68, "fiftyTwoWeekLow": 103.1, "financialCurrency": "USD", "fiveYearAverageReturn": null, "fiveYearAvgDividendYield": 1.29, "floatShares": 16513305231, "forwardEps": 5.67, "forwardPE": 26.021162, "freeCashflow": 80625876992, "fromCurrency": null, "fullTimeEmployees": 147000, "fundFamily": null, "fundInceptionDate": null, "gmtOffSetMilliseconds": "-14400000", "grossMargins": 0.41005, "grossProfits": 104956000000, "heldPercentInsiders": 0.00071000005, "heldPercentInstitutions": 0.58426, "impliedSharesOutstanding": null, "industry": "Consumer Electronics", "isEsgPopulated": false, "lastCapGain": null, "lastDividendDate": null, "lastDividendValue": null, "lastFiscalYearEnd": 1601078400, "lastMarket": null, "lastSplitDate": null, "lastSplitFactor": null, "legalType": null, "logo_url": "https://logo.clearbit.com/apple.com", "longBusinessSummary": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. It also sells various related services. The company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, HomePod, iPod touch, and other Apple-branded and third-party accessories. It also provides AppleCare support services; cloud services store services; and operates various platforms, including the App Store, that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. In addition, the company offers various services, such as Apple Arcade, a game subscription service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It sells and delivers third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was founded in 1977 and is headquartered in Cupertino, California.", "longName": "Apple Inc.", "market": "us_market", "marketCap": 2438865616896, "maxAge": 1, "maxSupply": null, "messageBoardId": "finmb_24937", "morningStarOverallRating": null, "morningStarRiskRating": null, "mostRecentQuarter": 1624665600, "navPrice": null, "netIncomeToCommon": 86801997824, "nextFiscalYearEnd": 1664150400, "numberOfAnalystOpinions": 41, "open": 148.35, "openInterest": null, "operatingCashflow": 104414003200, "operatingMargins": 0.28788, "payoutRatio": 0.16309999, "pegRatio": 1.34, "phone": "408-996-1010", "previousClose": 148.36, "priceHint": 2, "priceToBook": 38.00618, "priceToSalesTrailing12Months": 7.025293, "profitMargins": 0.25004, "quickRatio": 0.887, "quoteType": "EQUITY", "recommendationKey": "buy", "recommendationMean": 2, "regularMarketDayHigh": 149.12, "regularMarketDayLow": 147.51, "regularMarketOpen": 148.35, "regularMarketPreviousClose": 148.36, "regularMarketPrice": 147.54, "regularMarketVolume": 48597195, "returnOnAssets": 0.19302, "returnOnEquity": 1.27125, "revenueGrowth": 0.364, "revenuePerShare": 20.61, "revenueQuarterlyGrowth": null, "sector": "Technology", "sharesOutstanding": 16530199552, "sharesPercentSharesOut": 0.0056, "sharesShort": 93105968, "sharesShortPreviousMonthDate": 1626307200, "sharesShortPriorMonth": 96355309, "shortName": "Apple Inc.", "shortPercentOfFloat": 0.0056, "shortRatio": 1.19, "startDate": null, "state": "CA", "strikePrice": null, "symbol": "AAPL", "targetHighPrice": 190, "targetLowPrice": 132, "targetMeanPrice": 165.87, "targetMedianPrice": 168, "threeYearAverageReturn": null, "toCurrency": null, "totalAssets": null, "totalCash": 61696000000, "totalCashPerShare": 3.732, "totalDebt": 135491002368, "totalRevenue": 347155005440, "tradeable": false, "trailingAnnualDividendRate": 0.835, "trailingAnnualDividendYield": 0.0056282016, "trailingEps": 5.108, "trailingPE": 28.884104, "twoHundredDayAverage": 133.05403, "volume": 48597195, "volume24Hr": null, "volumeAllCurrencies": null, "website": "http://www.apple.com", "yield": null, "ytdReturn": null, "zip": "95014" }

 

Edited by patrickstigler
fixed link - fork to my repo

  • 1 month later...
On 10/19/2021 at 4:33 PM, patrickstigler said:

Source https://github.55860.com/pinkahd/py-stocks

Hey @patrickstigler, what's up with this?  Sent you a PM

  • Author

Good question, it was linked in his repo. I gonna update it.

@Squid

  • Author

For the wrong links in the description. TBH I don't know how this happend. I must have copied it.

 

Now I fixed it. 

 

  • Created a fork of the repo
  • read the code
  • updated this post
  • updated the App xml
  • updated the image for the container 
  • 2 years later...

Hi this is exactly what I am after.

 

Few questions on the current state:

1. I started with testing 'history' and the result worked:

 

curl 192.168.1.2:8787/history/AAPL | jq
...
{
      "Date": "2024-10-15T00:00:00.000Z",
      "Open": 233.6100006104,
      "High": 237.4900054932,
      "Low": 232.3699951172,
      "Close": 233.8500061035,
      "Volume": 64707600,
      "Dividends": 0,
      "Stock Splits": 0
    },
    {
      "Date": "2024-10-16T00:00:00.000Z",
      "Open": 231.6199951172,
      "High": 232.1199951172,
      "Low": 229.8500061035,
      "Close": 231.7799987793,
      "Volume": 32657566,
      "Dividends": 0,
      "Stock Splits": 0
    }
  ]
}

 

2. I then tested the /info/ section as this is where I currently need a value from:

root@Jarvis:~# curl 192.168.1.2:8787/info/AAPL | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    64  100    64    0     0     12      0  0:00:05  0:00:05 --:--:--    15
{
  "logo_url": "",
  "preMarketPrice": null,
  "regularMarketPrice": null
}

 

Looks broken: I do not get any info data back as you can see above.

 

Also, is it possible to make it query an individual value from /info/ ?

IE. 

curl ... /info/volume/APPL

curl ... /info/dayHigh/APPL

 

I want to be able to get a single value back from the call (parameterized as input).

I could then call from excel and get the single value back for example (vs an array of stuff)...

A few tweaks and this would be awesome!

Thanks!

 

 

 

 

Edited by dk4dk4

  • 3 months later...

Hi bro,

 

Is this still active? I do not get any data back:
Testing asset: S&P (Symbol: SPX) on 2024-05-08...
Fetching stock info...
{'logo_url': '', 'preMarketPrice': None, 'regularMarketPrice': None}
Fetching historical data...
{'schema': {'fields': [{'name': 'Date', 'type': 'string'}, {'name': 'Open', 'type': 'number'}, {'name': 'High', 'type': 'number'}, {'name': 'Low', 'type': 'number'}, {'name': 'Close', 'type': 'number'}, {'name': 'Adj Close', 'type': 'number'}, {'name': 'Volume', 'type': 'number'}], 'primaryKey': ['Date'], 'pandas_version': '1.4.0'}, 'data': []}
--------------------------------------------------

 curl http://1.1.1.1:4404/download/AAPL/2021-08-01/2021-08-03 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
curl: (52) Empty reply from server
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.