All Projects → Qluxzz → avanza

Qluxzz / avanza

Licence: MIT license
A Python library for the unofficial Avanza API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to avanza

fints-institute-db
Database of German Banks and their HBCI / FinTS endpoints
Stars: ✭ 28 (-48.15%)
Mutual labels:  finance, banking
mxfactorial
a payment application intended for deployment by the united states treasury
Stars: ✭ 36 (-33.33%)
Mutual labels:  finance, banking
awesome-open-finance
A curated list of open finance and open banking resources
Stars: ✭ 92 (+70.37%)
Mutual labels:  finance, banking
pyitau
Unofficial client to access your Itaú bank data
Stars: ✭ 28 (-48.15%)
Mutual labels:  finance, banking
cash
Home Bookkeeping on ExtJS 4, PHP 5, SQLite 3
Stars: ✭ 37 (-31.48%)
Mutual labels:  personal-finance, finance
open-psd2
An open source framework for using banking API's built for PSD2 regulation.
Stars: ✭ 20 (-62.96%)
Mutual labels:  finance, banking
bunq2ifttt
bunq2IFTTT creates a self-hosted interface between the bunq banking API and IFTTT.
Stars: ✭ 20 (-62.96%)
Mutual labels:  finance, banking
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-72.22%)
Mutual labels:  finance, banking
finatr
helping you analyze your future cash flows
Stars: ✭ 18 (-66.67%)
Mutual labels:  personal-finance, finance
ofxgo
Golang library for querying and parsing OFX
Stars: ✭ 96 (+77.78%)
Mutual labels:  finance, banking
Personal-Finance-Net-Worth-Tracker
Personal Finance (Net Worth Tracker) Wealth Management Spreadsheet
Stars: ✭ 31 (-42.59%)
Mutual labels:  personal-finance, finance
dimeshift-desktop
DimeShift desktop application
Stars: ✭ 14 (-74.07%)
Mutual labels:  personal-finance, finance
bankster
Money Creation Made Easy
Stars: ✭ 30 (-44.44%)
Mutual labels:  finance, banking
Loan-Web
ML-powered Loan-Marketer Customer Filtering Engine
Stars: ✭ 13 (-75.93%)
Mutual labels:  banking
AlphaBankUI-Android
Check out the new style for App Design aims for the Banking Applications...😉😀😁😎
Stars: ✭ 45 (-16.67%)
Mutual labels:  banking
scan
DeFi Scan, everything one-stop location for DeFi Blockchain. Powered by jellyfish & ocean network.
Stars: ✭ 31 (-42.59%)
Mutual labels:  finance
Mida
The open-source and cross-platform trading framework
Stars: ✭ 263 (+387.04%)
Mutual labels:  finance
hurtrade
An Open Source Forex Trading Platform
Stars: ✭ 22 (-59.26%)
Mutual labels:  finance
fhub
Python client for Finnhub API
Stars: ✭ 31 (-42.59%)
Mutual labels:  finance
budget-manager
Easy-to-use, lightweight and self-hosted solution to track your finances
Stars: ✭ 20 (-62.96%)
Mutual labels:  finance

Avanza

A Python library for the unofficial Avanza API. This library is based on the existing JavaScript library Avanza.

Please note that this is only a proof of concept, hence not meant to be used by anyone.

It might also be valuable to note that I am not affiliated with Avanza Bank AB in any way. The underlying API can be taken down or changed without warning at any point in time.

Installation

pip install avanza-api

Getting a TOTP Secret

NOTE: Since May 2018 two-factor authentication is required to log in.

Here are the steps to get your TOTP Secret:

  1. Go to Profil > Inställningar > Sajtinställningar > Inloggning och utloggning > Användarnamn > Tvåfaktorsinloggning and click "Återaktivera". (Only do this step if you have already set up two-factor auth.)
  2. Click "Aktivera" on the next screen.
  3. Select "Annan app för tvåfaktorsinloggning".
  4. Click "Kan du inte scanna QR-koden?" to reveal your TOTP Secret.
  5. Generate the TOTP code using the python code below and paste the TOTP code in the field below where you found the TOTP Secret.
  6. Done! From now on all you have to do is supply your secret in the constructor as in the examples below.

Generate TOTP code:

import hashlib
import pyotp
totp = pyotp.TOTP('MY_TOTP_SECRET', digest=hashlib.sha1)
print(totp.now())

Example

Authenticate and fetch account overview:

from avanza import Avanza
avanza = Avanza({
    'username': 'MY_USERNAME',
    'password': 'MY_PASSWORD',
    'totpSecret': 'MY_TOTP_SECRET'
})

overview = avanza.get_overview()

Get info about a certain account

from avanza import Avanza, TimePeriod

avanza = Avanza({
    'username': 'MY_USERNAME',
    'password': 'MY_PASSWORD',
    'totpSecret': 'MY_TOTP_SECRET'
})

report = avanza.get_insights_report(
    account_id='XXXXXXX',
    time_period=TimePeriod.ONE_WEEK
)

Place an order

from avanza import Avanza, OrderType

avanza = Avanza({
    'username': 'MY_USERNAME',
    'password': 'MY_PASSWORD',
    'totpSecret': 'MY_TOTP_SECRET'
})

result = avanza.place_order(
    account_id='XXXXXXX',
    order_book_id='XXXXXX',
    order_type=OrderType.BUY,
    price=13.37,
    valid_until=date.fromisoformat('2011-11-11'),
    volume=42
)

Subscribe to real time data

import asyncio
from avanza import Avanza, ChannelType

def callback(data):
    # Do something with the quotes data here
    print(data)

async def subscribe_to_channel(avanza: Avanza):
    await avanza.subscribe_to_id(
        ChannelType.QUOTES,
        "19002", # OMX Stockholm 30
        callback
    )

def main():
    avanza = Avanza({
        'username': 'MY_USERNAME',
        'password': 'MY_PASSWORD',
        'totpSecret': 'MY_TOTP_SECRET'
    })

    asyncio.get_event_loop().run_until_complete(
        subscribe_to_channel(avanza)
    )
    asyncio.get_event_loop().run_forever()

if __name__ == "__main__":
    main()

LICENSE

MIT license. See the LICENSE file for details.

RESPONSIBILITIES

The author of this software is not responsible for any indirect damages (foreseeable or unforeseeable), such as, if necessary, loss or alteration of or fraudulent access to data, accidental transmission of viruses or of any other harmful element, loss of profits or opportunities, the cost of replacement goods and services or the attitude and behavior of a third party.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].