GithubHelp home page GithubHelp logo

pjalzen / sensor.avanza_stock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from custom-components/sensor.avanza_stock

0.0 0.0 0.0 27 KB

Custom component to get stock data from Avanza for Home Assistant

License: MIT License

Python 100.00%

sensor.avanza_stock's Introduction

sensor.avanza_stock

GitHub Release GitHub Activity custom_updater License

Project Maintenance BuyMeCoffee

Custom component to get stock data from Avanza for Home Assistant.

Installation

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called avanza_stock.
  4. Download all the files from the custom_components/avanza_stock/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Add a sensor - platform: avanza_stock to your HA configuration.

Using your HA configuration directory (folder) as a starting point you should now also have this:

custom_components/avanza_stock/__init__.py
custom_components/avanza_stock/sensor.py
custom_components/avanza_stock/manifest.json

Configuration

key type description
platform (Required) string avanza_stock
stock (Required) number The stock id, see below how to find it.
name (Optional) string Custom name for the sensor. Default avanza_stock_{stock}.
shares (Optional) number The number of shares you own of this stock.
monitored_conditions (Optional) list Defines the attributes of the sensor, see below.

Monitored conditions

The following attributes are tracked by default

  • change
  • changePercent
  • name

Full list of available attributes.

  • change
  • changePercent
  • country
  • currency
  • description
  • directYield
  • dividends
  • flagCode
  • hasInvestmentFees
  • highestPrice
  • id
  • isin
  • lastPrice
  • lastPriceUpdated
  • loanFactor
  • lowestPrice
  • marketCapital
  • marketList
  • marketMakerExpected
  • marketPlace
  • marketTrades
  • morningStarFactSheetUrl
  • name
  • numberOfOwners
  • orderDepthReceivedTime
  • priceAtStartOfYear
  • priceEarningsRatio
  • priceFiveYearsAgo
  • priceOneMonthAgo
  • priceOneWeekAgo
  • priceOneYearAgo
  • priceSixMonthsAgo
  • priceThreeMonthsAgo
  • priceThreeYearsAgo
  • pushPermitted
  • quoteUpdated
  • sector
  • shortSellable
  • superLoan
  • tickerSymbol
  • totalNumberOfShares
  • totalValueTraded
  • totalVolumeTraded
  • tradable
  • volatility

Finding stock id

Got to Avanza and search for the stock you want to track. In the resulting url there is a number, this is the stock id needed for the configuration. Even though it is a Swedish bank it is possible to find stocks from the following countries:

  • Sweden
  • USA
  • Denmark
  • Norway
  • Finland
  • Canada
  • Belgium
  • France
  • Italy
  • Netherlands
  • Portugal
  • Germany

Example

Configuration with default settings:

sensor:
  - platform: avanza_stock
    stock: 5361

Configuration with custom settings:

sensor:
  - platform: avanza_stock
    name: Avanza Bank Holding
    stock: 5361
    monitored_conditions:
      - totalVolumeTraded
      - totalValueTraded

Usage

Automation to send summary after stock market closes on workdays using telegram:

# Telegram Stock Summary
- alias: 'Telegram Stock Summary'
  initial_state: true

  trigger:
    - platform: time
      at: '18:00:00'

  condition:
    condition: state
    entity_id: binary_sensor.workday
    state: 'on'

  action:
    - service: notify.telegram
      data:
        message: '
<b>Stock Summary {{ states.sensor.date.state }}</b>
<code>
{{ states.sensor.avanza_stock_5361.attributes.name }} : {{ states.sensor.avanza_stock_5361.attributes.changePercent }}
</code>
'

Note: This automation could be further improved by looping over all sensors and checking if their entity_id starts with sensor.avanza_stock_ and then extract the information.

Changelog

  • 1.0.0 - Add number of shares as optional configuration
  • 0.0.10 - Clean up monitored conditions
  • 0.0.9 - Compare payment date with todays date, ignore time
  • 0.0.8 - Ignore dividend if amount is zero, add resources.json and manfiest.json
  • 0.0.7 - Changed to async setup
  • 0.0.6 - Make sure dividend payment date has not passed
  • 0.0.5 - Add dividends information
  • 0.0.4 - Add companny information (description, marketCapital, sector, totalNumberOfShares)
  • 0.0.3 - Add key ratios (directYield, priceEarningsRatio, volatility)
  • 0.0.2 - Configure monitored conditions
  • 0.0.1 - Initial version

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.