Skip to content
This repository was archived by the owner on Sep 6, 2019. It is now read-only.

Commit bc5027c

Browse files
Add currencies
1 parent 0b60b96 commit bc5027c

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

src/Ito.jl

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ include("maths/statistics.jl")
88
include("maths/integration.jl")
99
include("ts/term_structure.jl")
1010
include("process/process.jl")
11+
include("currencies/currency.jl")
1112

1213
end

src/currencies/currency.jl

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
immutable Currency
2+
name::String
3+
code::String
4+
numeric::Int
5+
symbol::String
6+
fractionSymbol::String
7+
fractionsPerUnit::Int
8+
rounding::Function
9+
formatString::String
10+
end
11+
12+
13+
# Data from http://fx.sauder.ubc.ca/currency_table.html
14+
# and http://www.thefinancials.com/vortex/CurrencyFormats.html
15+
16+
list_currencies=[
17+
18+
# Africa
19+
("South-African rand", "ZAR", 710, "R", "", 100, identity, "%3% %1\$.2f"),
20+
21+
# America
22+
("Argentinian peso", "ARS", 32, "", "", 100, identity, "%2% %1\$.2f"),
23+
("Brazilian real", "BRL", 986, "R\$", "", 100, identity, "%3% %1\$.2f"),
24+
("Canadian dollar", "CAD", 124, "Can\$", "", 100, identity, "%3% %1\$.2f"),
25+
("Chilean peso", "CLP", 152, "Ch\$", "", 100, identity, "%3% %1\$.0f"),
26+
("Colombian peso", "COP", 170, "Col\$", "", 100, identity, "%3% %1\$.2f"),
27+
("Mexican peso", "MXN", 484, "Mex\$", "", 100, identity, "%3% %1\$.2f"),
28+
("Peruvian nuevo sol", "PEN", 604, "S/.", "", 100, identity, "%3% %1\$.2f"),
29+
("Peruvian inti", "PEI", 998, "I/.", "", 100, identity, "%3% %1\$.2f"),
30+
("Peruvian sol", "PEH", 999, "S./", "", 100, identity, "%3% %1\$.2f"),
31+
("Trinidad & Tobago dollar", "TTD", 780, "TTD\$", "", 100, identity, "%3% %1\$.2f"),
32+
("U.S. dollar", "USD", 840, "\$", "¢", 100, identity, "%3% %1\$.2f"),
33+
("Venezuelan bolivar", "VEB", 862, "Bs", "", 100, identity, "%3% %1\$.2f"),
34+
35+
# Asia
36+
("Bangladesh taka", "BDT", 50, "Bt", "", 100, identity, "%3% %1\$.2f"),
37+
("Chinese yuan", "CNY", 156, "Y", "", 100, identity, "%3% %1\$.2f"),
38+
("Hong Kong dollar", "HKD", 344, "HK\$", "", 100, identity, "%3% %1\$.2f"),
39+
("Israeli shekel", "ILS", 376, "NIS", "", 100, identity, "%1\$.2f %3%"),
40+
("Indian rupee", "INR", 356, "Rs", "", 100, identity, "%3% %1\$.2f"),
41+
("Iraqi dinar", "IQD", 368, "ID", "", 1000, identity, "%2% %1\$.3f"),
42+
("Iranian rial", "IRR", 364, "Rls", "", 1, identity, "%3% %1\$.2f"),
43+
("Japanese yen", "JPY", 392, "¥", "", 100, identity, "%3% %1\$.0f"),
44+
("South-Korean won", "KRW", 410, "W", "", 100, identity, "%3% %1\$.0f"),
45+
("Kuwaiti dinar", "KWD", 414, "KD", "", 1000, identity, "%3% %1\$.3f"),
46+
("Nepal rupee", "NPR", 524, "NRs", "", 100, identity, "%3% %1\$.2f"),
47+
("Pakistani rupee", "PKR", 586, "Rs", "", 100, identity, "%3% %1\$.2f"),
48+
("Saudi riyal", "SAR", 682, "SRls", "", 100, identity, "%3% %1\$.2f"),
49+
("Singapore dollar", "SGD", 702, "S\$", "", 100, identity, "%3% %1\$.2f"),
50+
("Thai baht", "THB", 764, "Bht", "", 100, identity, "%1\$.2f %3%"),
51+
("Taiwan dollar", "TWD", 901, "NT\$", "", 100, identity, "%3% %1\$.2f"),
52+
53+
# Europe
54+
("Bulgarian lev", "BGL", 100, "lv", "", 100, identity, "%1\$.2f %3%"),
55+
("Belarussian ruble", "BYR", 974, "BR", "", 1, identity, "%2% %1\$.0f"),
56+
("Swiss franc", "CHF", 756, "SwF", "", 100, identity, "%3% %1\$.2f"),
57+
("Czech koruna", "CZK", 203, "Kc", "", 100, identity, "%1\$.2f %3%"),
58+
("Danish krone", "DKK", 208, "Dkr", "", 100, identity, "%3% %1\$.2f"),
59+
("European Euro", "EUR", 978, "", "", 100, x->round(x,2), "%2% %1\$.2f"),
60+
("British pound sterling", "GBP", 826, "£", "p", 100, identity, "%3% %1\$.2f"),
61+
("Hungarian forint", "HUF", 348, "Ft", "", 1, identity, "%1\$.0f %3%"),
62+
("Iceland krona", "ISK", 352, "IKr", "", 100, identity, "%1\$.2f %3%"),
63+
("Lithuanian litas", "LTL", 440, "Lt", "", 100, identity, "%1\$.2f %3%"),
64+
("Norwegian krone", "NOK", 578, "NKr", "", 100, identity, "%3% %1\$.2f"),
65+
("Polish zloty", "PLN", 985, "zl", "", 100, identity, "%1\$.2f %3%"),
66+
("Romanian leu", "ROL", 642, "L", "", 100, identity, "%1\$.2f %3%"),
67+
("Romanian new leu", "RON", 946, "L", "", 100, identity, "%1\$.2f %3%"),
68+
("Swedish krona", "SEK", 752, "kr", "", 100, identity, "%1\$.2f %3%"),
69+
("Turkish lira", "TRL", 792, "TL", "", 100, identity, "%1\$.0f %3%"),
70+
("New Turkish lira", "TRY", 949, "YTL", "", 100, identity, "%1\$.2f %3%"),
71+
72+
# Europe deprecated
73+
("Austrian shilling", "ATS", 40, "", "", 100, identity, "%2% %1\$.2f"),
74+
("Belgian franc", "BEF", 56, "", "", 1, identity, "%2% %1\$.0f"),
75+
("Cyprus pound", "CYP", 196, "£", "", 100, identity, "%3% %1\$.2f"),
76+
("Deutsche mark", "DEM", 276, "DM", "", 100, identity, "%1\$.2f %3%"),
77+
("Estonian kroon", "EEK", 233, "KR", "", 100, identity, "%1\$.2f %2%"),
78+
("Spanish peseta", "ESP", 724, "Pta", "", 100, identity, "%1\$.0f %3%"),
79+
("Finnish markka", "FIM", 246, "mk", "", 100, identity, "%1\$.2f %3%"),
80+
("French franc", "FRF", 250, "", "", 100, identity, "%1\$.2f %2%"),
81+
("Greek drachma", "GRD", 300, "", "", 100, identity, "%1\$.2f %2%"),
82+
("Irish punt", "IEP", 372, "", "", 100, identity, "%2% %1\$.2f"),
83+
("Italian lira", "ITL", 380, "L", "", 1, identity, "%3% %1\$.0f"),
84+
("Luxembourg franc", "LUF", 442, "F", "", 100, identity, "%1\$.0f %3%"),
85+
("Latvian lat", "LVL", 428, "Ls", "", 100, identity, "%3% %1\$.2f"),
86+
("Maltese lira", "MTL", 470, "Lm", "", 100, identity, "%3% %1\$.2f"),
87+
("Dutch guilder", "NLG", 528, "f", "", 100, identity, "%3% %1\$.2f"),
88+
("Portuguese escudo", "PTE", 620, "Esc", "", 100, identity, "%1\$.0f %3%"),
89+
("Slovenian tolar", "SIT", 705, "SlT", "", 100, identity, "%1\$.2f %3%"),
90+
("Slovak koruna", "SKK", 703, "Sk", "", 100, identity, "%1\$.2f %3%"),
91+
92+
# Oceania
93+
("Australian dollar", "AUD", 36, "A\$", "", 100, identity, "%3% %1\$.2f"),
94+
("New Zealand dollar", "NZD", 554, "NZ\$", "", 100, identity, "%3% %1\$.2f")
95+
]
96+
97+
list_deprecated=[
98+
"ATS"=>"EUR",
99+
"BEF"=>"EUR",
100+
"CYP"=>"EUR",
101+
"DEM"=>"EUR",
102+
"EEK"=>"EUR",
103+
"ESP"=>"EUR",
104+
"FIM"=>"EUR",
105+
"FRF"=>"EUR",
106+
"GRD"=>"EUR",
107+
"IEP"=>"EUR",
108+
"ITL"=>"EUR",
109+
"LUF"=>"EUR",
110+
"LVL"=>"EUR",
111+
"MTL"=>"EUR",
112+
"NLG"=>"EUR",
113+
"PTE"=>"EUR",
114+
"SIT"=>"EUR",
115+
"SKK"=>"EUR"
116+
]
117+
118+
# Codegen function
119+
for currency in list_currencies
120+
@eval ($(symbol("$(currency[2])"*"Currency")))()=Currency(($currency)...)
121+
end
122+
123+
import Base.show
124+
show(io::IO, curr::Currency)=print(io, "$(curr.code)")

0 commit comments

Comments
 (0)