Add better currency support in checking/saving accounts
lasconic opened this issue · comments
Currently, when we create an account we use the following:
https://github.com/lasconic/finary/blob/0097c080a6da0f181594a05cc3407e298d0c93c9/finary_api/holdings_accounts.py#L30
"currency" : {"code": "EUR"}
It works (even with "USD" for example) but the Web UI currently uses:
"currency" : {"id": 1}
where id is the id of the currency as returned by the currency API.
We need to provide a way to search a currency by code, get the ID and use it. The command line should get an argument with a code (and we do the lookup) or an id (and we check if it's a numeric value ?).
[...]/currencies?type=fiat
we get the following, so we can make something similar to the place id look up from real estates i guess
{
"result": [
{
"id": 28,
"name": "United States Dollar",
"code": "USD",
"symbol": "$",
"correlation_id": "6246d8632a89de8c1452c688",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/United States Dollar USD.png"
},
{
"id": 12,
"name": "Indonesian Rupiah",
"code": "IDR",
"symbol": "Rp",
"correlation_id": "6246d8432a89de8c1452c633",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Indonesian Rupiah IDR.png"
},
{
"id": 33,
"name": "Malaysian Ringgit",
"code": "MYR",
"symbol": "RM",
"correlation_id": "6246d8512a89de8c1452c658",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Malaysian Ringgit MYR.png"
},
{
"id": 182,
"name": "Argentine Peso",
"code": "ARS",
"symbol": "AR$",
"correlation_id": "6246d82e2a89de8c1452c5fc",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Argentine Peso ARS.png"
},
{
"id": 23,
"name": "Turkish Lira",
"code": "TRY",
"symbol": "TL",
"correlation_id": "6246d8612a89de8c1452c682",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Turkish Lira TRY.png"
},
{
"id": 25,
"name": "Norwegian Krone",
"code": "NOK",
"symbol": "Nkr",
"correlation_id": "6246d8532a89de8c1452c65d",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Norwegian Krone NOK.png"
},
{
"id": 32,
"name": "South Korean Won",
"code": "KRW",
"symbol": "₩",
"correlation_id": "6246d8492a89de8c1452c642",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/South Korean Won KRW.png"
},
{
"id": 123353,
"name": "Iraqi Dinar",
"code": "IQD",
"symbol": "IQD",
"correlation_id": "6246d8452a89de8c1452c637",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Iraqi Dinar IQD.png"
},
{
"id": 10954,
"name": "Moroccan Dirham",
"code": "MAD",
"symbol": "MAD",
"correlation_id": "6246d84d2a89de8c1452c64c",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Moroccan Dirham MAD.png"
},
{
"id": 8,
"name": "Czech Republic Koruna",
"code": "CZK",
"symbol": "Kč",
"correlation_id": "6246d83a2a89de8c1452c61a",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Czech Republic Koruna CZK.png"
},
{
"id": 24,
"name": "Chinese Yuan",
"code": "CNY",
"symbol": "CN¥",
"correlation_id": "6246d8382a89de8c1452c614",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Chinese Yuan CNY.png"
},
{
"id": 13,
"name": "Indian Rupee",
"code": "INR",
"symbol": "Rs",
"correlation_id": "6246d8442a89de8c1452c636",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Indian Rupee INR.png"
},
{
"id": 27,
"name": "South African Rand",
"code": "ZAR",
"symbol": "R",
"correlation_id": "6246d8692a89de8c1452c699",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/South African Rand ZAR.png"
},
{
"id": 183,
"name": "New Taiwan Dollar",
"code": "TWD",
"symbol": "NT$",
"correlation_id": "6246d8612a89de8c1452c684",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/New Taiwan Dollar TWD.png"
},
{
"id": 103791,
"name": "Saudi Riyal",
"code": "SAR",
"symbol": "SR",
"correlation_id": "6246d8592a89de8c1452c66d",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Saudi Riyal SAR.png"
},
{
"id": 10,
"name": "Romanian Leu",
"code": "RON",
"symbol": "RON",
"correlation_id": "6246d8572a89de8c1452c669",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/default.png"
},
{
"id": 7,
"name": "Hungarian Forint",
"code": "HUF",
"symbol": "Ft",
"correlation_id": "6246d8432a89de8c1452c632",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Hungarian Forint HUF.png"
},
{
"id": 17,
"name": "Japanese Yen",
"code": "JPY",
"symbol": "¥",
"correlation_id": "6246d8472a89de8c1452c63c",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Japanese Yen JPY.png"
},
{
"id": 18,
"name": "Thai Baht",
"code": "THB",
"symbol": "฿",
"correlation_id": "6246d85f2a89de8c1452c67d",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Thai Baht THB.png"
},
{
"id": 15,
"name": "Russian Ruble",
"code": "RUB",
"symbol": "RUB",
"correlation_id": "6246d8582a89de8c1452c66b",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Russian Ruble RUB.png"
},
{
"id": 16,
"name": "Croatian Kuna",
"code": "HRK",
"symbol": "kn",
"correlation_id": "6246d8422a89de8c1452c630",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Croatian Kuna HRK.png"
},
{
"id": 9,
"name": "Australian Dollar",
"code": "AUD",
"symbol": "AU$",
"correlation_id": "621d77aff35fc3b829a2f3f9",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Australian Dollar AUD.png"
},
{
"id": 6,
"name": "Danish Krone",
"code": "DKK",
"symbol": "Dkr",
"correlation_id": "6246d83b2a89de8c1452c61c",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Danish Krone DKK.png"
},
{
"id": 31,
"name": "British Pound Sterling",
"code": "GBP",
"symbol": "£",
"correlation_id": "6246d83e2a89de8c1452c625",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/British Pound Sterling GBP.png"
},
{
"id": 3,
"name": "Hong Kong Dollar",
"code": "HKD",
"symbol": "HK$",
"correlation_id": "6246d8412a89de8c1452c62e",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Hong Kong Dollar HKD.png"
},
{
"id": 21,
"name": "Polish Zloty",
"code": "PLN",
"symbol": "zł",
"correlation_id": "6246d8562a89de8c1452c666",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Polish Zloty PLN.png"
},
{
"id": 22,
"name": "Bulgarian Lev",
"code": "BGN",
"symbol": "BGN",
"correlation_id": "6246d8312a89de8c1452c602",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Bulgarian Lev BGN.png"
},
{
"id": 14,
"name": "Brazilian Real",
"code": "BRL",
"symbol": "R$",
"correlation_id": "6246d8332a89de8c1452c608",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Brazilian Real BRL.png"
},
{
"id": 11,
"name": "Swedish Krona",
"code": "SEK",
"symbol": "Skr",
"correlation_id": "6246d85a2a89de8c1452c671",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Swedish Krona SEK.png"
},
{
"id": 104661,
"name": "United Arab Emirates Dirham",
"code": "AED",
"symbol": "AED",
"correlation_id": "6246d82c2a89de8c1452c5f6",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/United Arab Emirates Dirham AED.png"
},
{
"id": 2,
"name": "Canadian Dollar",
"code": "CAD",
"symbol": "CA$",
"correlation_id": "6246d8362a89de8c1452c60e",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Canadian Dollar CAD.png"
},
{
"id": 5,
"name": "Philippine Peso",
"code": "PHP",
"symbol": "₱",
"correlation_id": "6246d8562a89de8c1452c664",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Philippine Peso PHP.png"
},
{
"id": 4,
"name": "Icelandic Króna",
"code": "ISK",
"symbol": "Ikr",
"correlation_id": "6246d8452a89de8c1452c638",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Icelandic Króna ISK.png"
},
{
"id": 29,
"name": "Mexican Peso",
"code": "MXN",
"symbol": "MX$",
"correlation_id": "6246d8512a89de8c1452c657",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Mexican Peso MXN.png"
},
{
"id": 30,
"name": "Israeli New Sheqel",
"code": "ILS",
"symbol": "₪",
"correlation_id": "6246d8442a89de8c1452c634",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Israeli New Sheqel ILS.png"
},
{
"id": 1,
"name": "Euro",
"code": "EUR",
"symbol": "€",
"correlation_id": "6246d83d2a89de8c1452c622",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Euro EUR.png"
},
{
"id": 20,
"name": "Singapore Dollar",
"code": "SGD",
"symbol": "S$",
"correlation_id": "6246d85b2a89de8c1452c672",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Singapore Dollar SGD.png"
},
{
"id": 6439,
"name": "CFP Franc",
"code": "XPF",
"symbol": null,
"correlation_id": "6246d8682a89de8c1452c696",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/default.png"
},
{
"id": 19,
"name": "Swiss Franc",
"code": "CHF",
"symbol": "CHF",
"correlation_id": "6246d8362a89de8c1452c610",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/Swiss Franc CHF.png"
},
{
"id": 26,
"name": "New Zealand Dollar",
"code": "NZD",
"symbol": "NZ$",
"correlation_id": "6246d8542a89de8c1452c65f",
"logo_url": "https://cdn.finary.com/000terminal/currencies/logos/New Zealand Dollar NZD.png"
}
],
"message": "OK",
"error": null
}
Might off-subject but do you if finary handle internaly exchange rate?
I mean if we have multiple currencies how does it report while sum up the portfolio value to unique currency?
Last time I checked, in 2022, it was messy. They did have an internal exchange rate at the time of insertion but you couldn't add one yourself. Meaning if I have euros, and I buy today Google shares in USD, and enter them in FInary in two months, there was no way to do it well.
Ok because it looks (not sure it was already the case in 2022) there is one currency for the transaction itself and one for the display. I was hoping their where showing the converted amount on the fly instead of calculating it at the time of insertion.
I did raise the question, let's see :): https://community.finary.com/t/gestion-des-taux-de-changes-sur-finary-a-laffichage/9971