tarkah / tickrs

Realtime ticker data in your terminal 📈
MIT License
1.17k stars 58 forks source link

Display option & stock currency instead of assuming USD #6

Closed MabezDev closed 3 years ago

MabezDev commented 3 years ago

Awesome project, I was actually planning on embarking on a similar, but you have basically implemented what I had in mind!

Coming from the UK, some stocks and options I view are not USD, this PR fixes that by:

Before: image

After: image

tarkah commented 3 years ago

Hey, thanks for the PR! Can you give me a few examples to check out? I noticed in the options quote section, there is currency and financialCurrency and I just want to double check we are using the right one.

MabezDev commented 3 years ago

Ticker: LLOY.L, Lloyds bank, currency is GBp (penny, not pound see : https://en.wikipedia.org/wiki/Penny_sterling)

Yahoo query response:

{
  "optionChain": {
    "result": [
      {
        "underlyingSymbol": "LLOY.L",
        "expirationDates": [],
        "strikes": [],
        "hasMiniOptions": false,
        "quote": {
          "language": "en-US",
          "region": "US",
          "quoteType": "EQUITY",
          "quoteSourceName": "Delayed Quote",
          "triggerable": false,
          "currency": "GBp",
          "firstTradeDateMilliseconds": 820137600000,
          "priceHint": 2,
          "marketState": "CLOSED",
          "exchange": "LSE",
          "shortName": "LLOYDS BANKING GROUP PLC ORD 10",
          "longName": "Lloyds Banking Group plc",
          "messageBoardId": "finmb_670064",
          "exchangeTimezoneName": "Europe/London",
          "exchangeTimezoneShortName": "BST",
          "gmtOffSetMilliseconds": 3600000,
          "market": "gb_market",
          "esgPopulated": false,
          "regularMarketChange": -0.034999847,
          "regularMarketChangePercent": -0.12439967,
          "regularMarketTime": 1598024157,
          "regularMarketPrice": 28.1,
          "regularMarketDayHigh": 28.35,
          "regularMarketDayRange": "27.72 - 28.35",
          "regularMarketDayLow": 27.72,
          "regularMarketVolume": 111207306,
          "regularMarketPreviousClose": 28.135,
          "bid": 28.055,
          "ask": 28.065,
          "bidSize": 0,
          "askSize": 0,
          "fullExchangeName": "LSE",
          "financialCurrency": "GBP",
          "regularMarketOpen": 28.21,
          "averageDailyVolume3Month": 250381814,
          "averageDailyVolume10Day": 116946786,
          "fiftyTwoWeekLowChange": 2.6669998,
          "fiftyTwoWeekLowChangePercent": 0.10486375,
          "fiftyTwoWeekRange": "25.433 - 73.66",
          "fiftyTwoWeekHighChange": -45.560005,
          "fiftyTwoWeekHighChangePercent": -0.6185176,
          "fiftyTwoWeekLow": 25.433,
          "fiftyTwoWeekHigh": 73.66,
          "earningsTimestamp": 1596099600,
          "earningsTimestampStart": 1596099600,
          "earningsTimestampEnd": 1596099600,
          "trailingAnnualDividendRate": 0,
          "trailingPE": 70.25,
          "trailingAnnualDividendYield": 0,
          "epsTrailingTwelveMonths": 0.4,
          "epsForward": 7.79,
          "sharesOutstanding": 70774398976,
          "bookValue": 1.084,
          "fiftyDayAverage": 29.270735,
          "fiftyDayAverageChange": -1.1707344,
          "fiftyDayAverageChangePercent": -0.039996754,
          "twoHundredDayAverage": 35.11067,
          "twoHundredDayAverageChange": -7.010668,
          "twoHundredDayAverageChangePercent": -0.19967344,
          "marketCap": 19887607808,
          "forwardPE": 0.036071885,
          "priceToBook": 25.92251,
          "sourceInterval": 15,
          "exchangeDataDelayedBy": 20,
          "tradeable": false,
          "symbol": "LLOY.L"
        },
        "options": [
          {}
        ]
      }
    ],
    "error": null
  }
}

It seems currency is the correct field, as it correctly specifies GBp not GBP. If I was to guess, financialCurrency is the regions (US, GB etc) primary currency, but I'm not certain of that.

As most US stocks are traded in USD, both currency and finacialCurrency are the same

MabezDev commented 3 years ago

A second look this morning, it seems the currency is cut off in the option list. Any recommendations on formatting it to fit, or is it not required? Given that the currency is specified in the window above?

tarkah commented 3 years ago

So check out this response:

https://query1.finance.yahoo.com/v10/finance/quoteSummary/LLOY.L?modules=price

It includes the currency symbol, which I definitely prefer since it takes up a lot less space. That way, we can keep the formatting all the same. I'm grabbing this response inside the stock widget, we just need to pass this currency symbol to the options widget when we create it inside the stock widget.

tarkah commented 3 years ago

Hmm that symbol seems innacurate tho since it's for a "pound"

tarkah commented 3 years ago

So I guess GBp is how stocks are commonly traded? Maybe it's best to have the explicit 3 letter currency code.

Instead of having that code on every row in the options pane, maybe we can specify it just on the strike price up top. And then just on current price in the stock widget?

tarkah commented 3 years ago

Ok, I rebased and added a couple changes. I don't think we need currency at the options list level, just showing for the selected option. Here is how it looks:

Screenshot from 2020-08-22 10-35-06 Screenshot from 2020-08-22 10-35-31

tarkah commented 3 years ago

I've left currency on just the strike price for the options pane. It seems redundant otherwise and I prefer this look. What do you think?

Screenshot from 2020-08-22 10-39-09

MabezDev commented 3 years ago

So I guess GBp is how stocks are commonly traded? Maybe it's best to have the explicit 3 letter currency code.

Indeed, I think it's correct to use the three digit currency code.

I've left currency on just the strike price for the options pane. It seems redundant otherwise and I prefer this look. What do you think?

I agree, we really only need to display it in one place, it can be inferred everywhere else.

I am happy with the way it looks, will definitely help me out come Monday :D.

tarkah commented 3 years ago

Awesome! I'll get this merged and released later today. Thanks for your help.