# Quantitative Finance in Julia

**URL:** <https://discourse.julialang.org/t/quantitative-finance-in-julia/119734>\
**Category:** Finance and Economics\
**Tags:** question\
**Created:** [September 23, 2024, 8:51am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734 "2024-09-23T08:51:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [September 23, 2024, 8:51am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/1 "2024-09-23T08:51:29Z")

</div>

Could we add in Market Data, also API from SWX / SIX or Marketscreener / Google etc?  
just in case something went wrong?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 23, 2024, 9:02am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/2 "2024-09-23T09:02:33Z")

</div>

Are you talking about the package [GitHub - JuliaQuant/MarketData.jl: Time series market data](https://github.com/JuliaQuant/MarketData.jl)?

If so it’s probably best to just ask in an issue there, or even make a PR to the package with a proposed implementation.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [September 23, 2024, 9:30am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/3 "2024-09-23T09:30:02Z")

</div>

See also [[ANN] Announcing YFinance.jl](https://discourse.julialang.org/t/ann-announcing-yfinance-jl/117962)

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [September 23, 2024, 9:52am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/4 "2024-09-23T09:52:54Z")

</div>

thanks for the rapid input and commentaries. 😀

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 3, 2024, 5:25am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/5 "2024-10-03T05:25:24Z")

</div>

By the Way i tried YFinance with currencies like “CHFMXN=X” and it works, but can provide us with an Example in the Documentation?

---

<div class="post-metadata">

**Author:** ![EOhneberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eohneberg/32/45704_2.png) [@EOhneberg](https://discourse.julialang.org/u/EOhneberg)\
**Post date:** [October 3, 2024, 7:02am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/6 "2024-10-03T07:02:26Z")

</div>

There is a Currency example in the readme on GitHub but I think not in the docs.

The function works the same for currencies as for stock prices which is why there is no specific example as of now. Happy to include one though.

If you let me know what you found difficult/ hard to figure out I will add a specific example to the docs.

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 3, 2024, 8:02am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/7 "2024-10-03T08:02:30Z")

</div>

what would be helpful or i tought is to  
do this code

begin  
CHFAUD = get\_prices(“CHFAUD=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFBRL = get\_prices(“CHFBRL=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFCAD = get\_prices(“CHFCAD=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFCNY = get\_prices(“CHFCNY=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFEUR = get\_prices(“CHFEUR=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFGBP = get\_prices(“CHFGBP=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFINR = get\_prices(“CHFINR=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFJPY = get\_prices(“CHFJPY=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFMXN = get\_prices(“CHFMXN=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFRUB = get\_prices(“CHFRUB=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFUSD = get\_prices(“CHFUSD=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
CHFZAR = get\_prices(“CHFZAR=X”,range=“1d”,interval=“1d”, startdt=“1900-01-01”,enddt=string(today())) |\> DataFrame  
end

in to a for loop i to A[“USD”…and so on] as struct or index variables for multiples entrances.

My problem now is that the variablenames are not build because of example CHF"USD".

M.f.G.Pascal

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 3, 2024, 8:15am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/8 "2024-10-03T08:15:31Z")

</div>

Not sure I understand the question, do you want do build a dictionary like

```julia
julia> using Dates, DataFrames, YFinance

julia> Dict("CHF$(x)" => DataFrame(get_prices("CHF$(x)=X", range = "1d", interval = "1d", startdt = today()-Day(5), enddt = today())) for x ∈ ["AUD", "BRL"])
Dict{String, DataFrame} with 2 entries:
  "CHFBRL" => 4×8 DataFrame…
  "CHFAUD" => 4×8 DataFrame…

julia> ans["CHFBRL"]
4×8 DataFrame
 Row │ ticker timestamp open high low close adjclose vol
     │ String DateTime Float64 Float64 Float64 Float64 Float64 Float64
─────┼──────────────────────────────────────────────────────────────────────────────────────
   1 │ CHFBRL=X 2024-09-29T23:00:00 6.43753 6.48242 6.40644 6.46093 6.46093 0.0
   2 │ CHFBRL=X 2024-09-30T23:00:00 6.4347 6.48683 6.40019 6.43414 6.43414 0.0
   3 │ CHFBRL=X 2024-10-01T23:00:00 6.42706 6.43625 6.36225 6.45249 6.45249 0.0
   4 │ CHFBRL=X 2024-10-03T06:56:00 6.4084 6.4084 6.378 6.378 6.378 0.0

```

?

---

<div class="post-metadata">

**Author:** ![EOhneberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eohneberg/32/45704_2.png) [@EOhneberg](https://discourse.julialang.org/u/EOhneberg)\
**Post date:** [October 3, 2024, 8:34am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/9 "2024-10-03T08:34:24Z")

</div>

Also not quite sure what you are trying to do. If you want to get all prices into one dataframe you can simply do this:

```julia
julia> using YFinance

julia> using DataFrames

julia> using Dates

julia> currencies = ["CHFAUD=X","CHFCAD=X","CHFCNY=X","CHFEUR=X","CHFGBP=X","CHFINR=X","CHFJPY=X","CHFMXN=X","CHFRUB=X","CHFUSD=X","CHFZAR=X"];

julia> CHF = vcat(DataFrame.(get_prices.(currencies,interval="1d", startdt="1900-01-01",enddt=string(today()),exchange_local_time=false))...)
54107×8 DataFrame
   Row │ ticker timestamp open high low close adjclose vol     
       │ String DateTime Float64 Float64 Float64 Float64 Float64 Float64
───────┼──────────────────────────────────────────────────────────────────────────────────────
     1 │ CHFAUD=X 2003-12-01T00:00:00 1.0712 1.073 1.0562 1.0584 1.0584 0.0
     2 │ CHFAUD=X 2003-12-02T00:00:00 1.0583 1.0673 1.0541 1.0595 1.0595 0.0
     3 │ CHFAUD=X 2003-12-03T00:00:00 1.0604 1.0637 1.0517 1.0546 1.0546 0.0
     4 │ CHFAUD=X 2003-12-04T00:00:00 1.0542 1.0586 1.0495 1.0534 1.0534 0.0
     5 │ CHFAUD=X 2003-12-05T00:00:00 1.0543 1.0671 1.0527 1.0665 1.0665 0.0
     6 │ CHFAUD=X 2003-12-08T00:00:00 1.0642 1.0675 1.0584 1.065 1.065 0.0
     7 │ CHFAUD=X 2003-12-09T00:00:00 1.0651 1.0715 1.0644 1.0684 1.0684 0.0
     8 │ CHFAUD=X 2003-12-10T00:00:00 1.0687 1.0712 1.0626 1.066 1.066 0.0
     9 │ CHFAUD=X 2003-12-11T00:00:00 1.0653 1.076 1.061 1.0642 1.0642 0.0
   ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
 54099 │ CHFZAR=X 2024-09-22T23:00:00 20.471 20.5293 20.3512 20.4367 20.4367 0.0
 54100 │ CHFZAR=X 2024-09-23T23:00:00 20.4697 20.4971 20.3528 20.4699 20.4699 0.0
 54101 │ CHFZAR=X 2024-09-24T23:00:00 20.4986 20.616 20.2021 20.5004 20.5004 0.0
 54102 │ CHFZAR=X 2024-09-25T23:00:00 20.292 20.3946 20.1327 20.2946 20.2946 0.0
 54103 │ CHFZAR=X 2024-09-26T23:00:00 20.306 20.3753 20.2547 20.3032 20.3032 0.0
 54104 │ CHFZAR=X 2024-09-29T23:00:00 20.3124 20.4423 20.2358 20.3166 20.3166 0.0
 54105 │ CHFZAR=X 2024-09-30T23:00:00 20.4396 20.6189 20.334 20.4404 20.4404 0.0
 54106 │ CHFZAR=X 2024-10-01T23:00:00 20.5511 20.6183 20.3668 20.5674 20.5674 0.0
 54107 │ CHFZAR=X 2024-10-03T08:28:18 20.4161 20.5034 20.2661 20.3526 20.3526 0.0
                                                                            54089 rows omitted

```

If you want to clean the tickers so they are valid symbols for column names you can do this:

```julia
julia> CHF.ticker = replace.(CHF.ticker,"=X"=>"");

```

Let’s say you want to have dates in the rows and each column being one close price you could do this:

```julia

julia> CHF_close = select(CHF,:ticker,:timestamp,:close);

julia> CHF_close = unstack(CHF_close,:ticker,:close);

julia> sort!(CHF_close, :timestamp);

julia> last(CHF_close,10)
10×12 DataFrame
 Row │ timestamp CHFAUD CHFCAD CHFCNY CHFEUR CHFGBP CHFINR CHFJPY CHFMXN CHFRUB CHFUSD CHFZAR       
     │ DateTime Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64? Float64?
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ 2024-09-25T23:00:00 1.72313 1.58484 8.26853 1.05607 0.88276 98.2386 170.078 23.0862 missing 1.17568 20.2946
   2 │ 2024-09-26T23:00:00 1.71409 1.59215 8.28133 1.05706 0.88094 98.706 171.397 23.1774 missing 1.1817 20.3032
   3 │ 2024-09-29T23:00:00 1.71791 1.60565 8.3323 1.06408 0.88809 99.4981 169.716 23.3335 missing 1.18977 20.3166
   4 │ 2024-09-30T23:00:00 1.71036 1.60006 8.301 1.06218 0.8843 99.0313 169.994 23.2609 missing 1.183 20.4404
   5 │ 2024-10-01T23:00:00 1.7164 1.59431 8.30585 1.06781 0.89007 99.0063 169.815 23.1884 missing 1.18156 20.5674
   6 │ 2024-10-03T08:25:57 missing 1.588 8.2447 missing missing missing missing missing 111.488 missing missing
   7 │ 2024-10-03T08:27:57 missing missing missing 1.0633 0.8946 missing missing missing missing missing missing
   8 │ 2024-10-03T08:28:18 1.71332 missing missing missing missing missing missing 22.8119 missing missing 20.3526
   9 │ 2024-10-03T08:28:34 missing missing missing missing missing 98.6262 missing missing missing missing missing
  10 │ 2024-10-03T08:28:43 missing missing missing missing missing missing 172.247 missing missing 1.17492 missing

```

Note here that the last few entries are double for different times of the day (this is unfortuantely a weird quirk of yahoo finance’s internal API and hard to deal with in the package itself). There is no close price yet for today is the problem really.

Edit: you can leave exchange\_local\_time=true but this will give you even more different values for today (oct 3rd) doesn’t impact other days though. In that case it will give you the last price for today it has for each currency pair - often this is at different times.

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 3, 2024, 10:22am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/10 "2024-10-03T10:22:06Z")

</div>

actuall i wanted more to have different matrices or dataframes for each currencies but all stuck into one could do it.

Thanks

---

<div class="post-metadata">

**Author:** ![EOhneberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eohneberg/32/45704_2.png) [@EOhneberg](https://discourse.julialang.org/u/EOhneberg)\
**Post date:** [October 3, 2024, 10:58am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/11 "2024-10-03T10:58:49Z")

</div>

Then @nilshg’s answer would be the one I guess. That one gives you a dictionary.

You can create all kinds of different structures. If you tell me exactly what you want the outer holding struct to be and what you want each Matrix/DataFrame to contain (variables) I can see if I cannot write you a quick function.

# Two examples:

## Vector of DataFrames:

```julia
julia> using YFinance, DataFrames, Dates

julia> currencies = ["CHFAUD=X","CHFCAD=X","CHFCNY=X","CHFEUR=X","CHFGBP=X","CHFINR=X","CHFJPY=X","CHFMXN=X","CHFRUB=X","CHFUSD=X","CHFZAR=X"];

julia> chf_vec = DataFrame.(get_prices.(currencies,interval="1d", startdt="1900-01-01",enddt=string(today()),exchange_local_time=true));

julia> typeof(chf_vec)
Vector{DataFrame} (alias for Array{DataFrame, 1})

julia> chf_vec[1]
5439×8 DataFrame
  Row │ ticker timestamp open high low close adjclose vol     
      │ String DateTime Float64 Float64 Float64 Float64 Float64 Float64
──────┼──────────────────────────────────────────────────────────────────────────────────────
    1 │ CHFAUD=X 2003-12-01T01:00:00 1.0712 1.073 1.0562 1.0584 1.0584 0.0
    2 │ CHFAUD=X 2003-12-02T01:00:00 1.0583 1.0673 1.0541 1.0595 1.0595 0.0
    3 │ CHFAUD=X 2003-12-03T01:00:00 1.0604 1.0637 1.0517 1.0546 1.0546 0.0
    4 │ CHFAUD=X 2003-12-04T01:00:00 1.0542 1.0586 1.0495 1.0534 1.0534 0.0
    5 │ CHFAUD=X 2003-12-05T01:00:00 1.0543 1.0671 1.0527 1.0665 1.0665 0.0
    6 │ CHFAUD=X 2003-12-08T01:00:00 1.0642 1.0675 1.0584 1.065 1.065 0.0
    7 │ CHFAUD=X 2003-12-09T01:00:00 1.0651 1.0715 1.0644 1.0684 1.0684 0.0
    8 │ CHFAUD=X 2003-12-10T01:00:00 1.0687 1.0712 1.0626 1.066 1.066 0.0
    9 │ CHFAUD=X 2003-12-11T01:00:00 1.0653 1.076 1.061 1.0642 1.0642 0.0
  ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
 5431 │ CHFAUD=X 2024-09-23T00:00:00 1.72515 1.72777 1.71733 1.72568 1.72568 0.0
 5432 │ CHFAUD=X 2024-09-24T00:00:00 1.72691 1.7294 1.71468 1.72664 1.72664 0.0
 5433 │ CHFAUD=X 2024-09-25T00:00:00 1.72043 1.72783 1.71028 1.71969 1.71969 0.0
 5434 │ CHFAUD=X 2024-09-26T00:00:00 1.72358 1.72358 1.70608 1.72313 1.72313 0.0
 5435 │ CHFAUD=X 2024-09-27T00:00:00 1.71475 1.72147 1.71086 1.71409 1.71409 0.0
 5436 │ CHFAUD=X 2024-09-30T00:00:00 1.71763 1.71963 1.70416 1.71791 1.71791 0.0
 5437 │ CHFAUD=X 2024-10-01T00:00:00 1.71042 1.72295 1.70242 1.71036 1.71036 0.0
 5438 │ CHFAUD=X 2024-10-02T00:00:00 1.71615 1.72038 1.703 1.7164 1.7164 0.0
 5439 │ CHFAUD=X 2024-10-03T11:51:21 1.7093 1.71782 1.70342 1.71696 1.71696 0.0
                                                                            5421 rows omitted

```

## NamedTuple:

Or a `NamedTuple` where the keys are the (clean) exchange rate names (e.g. CHFEUR) and the values are DataFrames:

```julia
julia> using YFinance, DataFrames, Dates

julia> currencies = ["CHFAUD=X","CHFCAD=X","CHFCNY=X","CHFEUR=X","CHFGBP=X","CHFINR=X","CHFJPY=X","CHFMXN=X","CHFRUB=X","CHFUSD=X","CHFZAR=X"];

julia> chf_nt = NamedTuple( ( Symbol(replace(c, "=X"=>"")), DataFrame(get_prices.(c,interval="1d", startdt=Date(1990),enddt=today()))) for c in currencies);

julia> typeof(chf_nt)
NamedTuple{(:CHFAUD, :CHFCAD, :CHFCNY, :CHFEUR, :CHFGBP, :CHFINR, :CHFJPY, :CHFMXN, :CHFRUB, :CHFUSD, :CHFZAR), NTuple{11, DataFrame}}

julia> chf_nt.CHFEUR
5102×8 DataFrame
  Row │ ticker timestamp open high low close adjclose vol     
      │ String DateTime Float64 Float64 Float64 Float64 Float64 Float64
──────┼──────────────────────────────────────────────────────────────────────────────────────
    1 │ CHFEUR=X 2005-03-16T00:00:00 0.64479 0.647 0.64466 0.64654 0.64654 0.0
    2 │ CHFEUR=X 2005-03-17T00:00:00 0.64654 0.64733 0.64549 0.64558 0.64558 0.0
    3 │ CHFEUR=X 2005-03-18T00:00:00 0.64566 0.64633 0.64425 0.64479 0.64479 0.0
    4 │ CHFEUR=X 2005-03-21T00:00:00 0.64487 0.64558 0.64371 0.64437 0.64437 0.0
    5 │ CHFEUR=X 2005-03-22T00:00:00 0.64441 0.64462 0.64247 0.64329 0.64329 0.0
    6 │ CHFEUR=X 2005-03-23T00:00:00 0.64321 0.64379 0.6423 0.64354 0.64354 0.0
    7 │ CHFEUR=X 2005-03-24T00:00:00 0.6435 0.64412 0.64267 0.64296 0.64296 0.0
    8 │ CHFEUR=X 2005-03-25T00:00:00 0.643 0.64367 0.64276 0.64284 0.64284 0.0
    9 │ CHFEUR=X 2005-03-27T23:00:00 0.64309 0.64429 0.64263 0.64408 0.64408 0.0
  ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
 5094 │ CHFEUR=X 2024-09-22T23:00:00 1.05281 1.0603 1.05219 1.05292 1.05292 0.0
 5095 │ CHFEUR=X 2024-09-23T23:00:00 1.06207 1.06351 1.05731 1.06197 1.06197 0.0
 5096 │ CHFEUR=X 2024-09-24T23:00:00 1.06173 1.06173 1.05172 1.06168 1.06168 0.0
 5097 │ CHFEUR=X 2024-09-25T23:00:00 1.05605 1.05921 1.0528 1.05607 1.05607 0.0
 5098 │ CHFEUR=X 2024-09-26T23:00:00 1.05714 1.06408 1.05494 1.05706 1.05706 0.0
 5099 │ CHFEUR=X 2024-09-29T23:00:00 1.06399 1.06579 1.05798 1.06408 1.06408 0.0
 5100 │ CHFEUR=X 2024-09-30T23:00:00 1.06215 1.07087 1.05988 1.06218 1.06218 0.0
 5101 │ CHFEUR=X 2024-10-01T23:00:00 1.06797 1.07022 1.06326 1.06781 1.06781 0.0
 5102 │ CHFEUR=X 2024-10-03T10:52:00 1.065 1.0669 1.061 1.0645 1.0645 0.0
                                                                            5084 rows omitted

```

Edit: Forgot to import packages and to define the currencies vector in the example.

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 4, 2024, 6:23am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/12 "2024-10-04T06:23:25Z")

</div>

In Scilab i have something like:

//Currencies CHF to…  
A=[“AUD”,“BRL”,“CAD”,“CNY”,“EUR”,“GBP”,“INR”,“JPY”,“MXN”,“USD”,“ZAR”];  
for i=1:size(A)(2);  
sleep(30,“s”);  
[B(A(i)),status(i)] =http\_get(“[https://www.alphavantage.co/query?function=FX\_DAILY&from\_symbol=CHF&to\_symbol=“+A(i)+”&outputsize=full&apikey=“+“Key”+”&datatype=csv",cert="none](https://www.alphavantage.co/query?function=FX_DAILY&from_symbol=CHF&to_symbol=%22+A(i)+%22&outputsize=full&apikey=%22+%22Key%22+%22&datatype=csv%22,cert=%22none)”);  
C(A(i))=strsplit(B(A(i)),ascii(13));  
a(i,:)=size(C(A(i)));  
for j=1:a(i);  
D(A(i))(j,:)=strsplit(C(A(i))(j),“,”);  
E(A(i))(j,:)=strtod(D(A(i))(j,5));  
end;  
b(i,:)=[min(strtod(D(A(i)))),max(strtod(D(A(i))))];  
end;  
c=(min(a(:,1))-1);

and it gives a struct like or depending on CSV or JSON someting more granular.

D [struct]

AUD: (4743×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] BRL: (2587×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] CAD: (5002×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] CNY: (4167×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] EUR: (4746×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] GBP: (5002×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] INR: (2587×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] JPY: (2611×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] MXN: (2587×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] USD: (2610×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""] ZAR: (2587×5) ["timestamp", "open", "high", "low", "close" ; ""+ascii(10)+"2024-10-0 … "", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+"", ""+ascii(10)+""]

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 4, 2024, 7:44am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/13 "2024-10-04T07:44:15Z")

</div>

Is that a question?

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 4, 2024, 7:52am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/14 "2024-10-04T07:52:20Z")

</div>

no, that is what im doing in SCILAB, i wanted to show a Picture, but i could not upload it. but the interesting part is the for…end cycles. but the vcat is also good. but now i’ am struggling to groupe the datas (Dataframe) into the tickers (done) and to give me for each ticker their mean, median, deviation, excess and kurtosis. afterward then also a correlation matrix or map.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 4, 2024, 8:08am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/15 "2024-10-04T08:08:41Z")

</div>

For this type of analysis you probably do just want to `vcat` the DataFrames together, and then use split-apply-combine techniques like

```julia
using StatsBase
combine(groupby(df, :ticker), :log_return .=> [mean, median, std, skewness, kurtosis])

```

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 4, 2024, 8:33am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/16 "2024-10-04T08:33:50Z")

</div>

In Pluto with Julia 1.10 i get this

ArgumentError: column name :log\_return not found in the data frame

1. **DataFrames** @_index.jl:413_ [inlined]
2. **DataFrames** @_index.jl:422_ [inlined]
3. **normalize\_selection** (::DataFrames.Index, ::Pair{\<:Union{AbstractString, Signed, Symbol, Unsigned}, \<:Union{Function, Type}}, ::Bool)@_selection.jl:488_
4. **\_combine\_prepare\_norm** (::DataFrames.GroupedDataFrame{DataFrames.DataFrame}, ::Vector{Any}, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool)@_splitapplycombine.jl:71_
5. **var"#\_combine\_prepare#711"** (::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::typeof(DataFrames.\_combine\_prepare), ::DataFrames.GroupedDataFrame{DataFrames.DataFrame}, ::Base.RefValue{Any})@_splitapplycombine.jl:52_
6. **\_combine\_prepare** @_splitapplycombine.jl:26_ [inlined]
7. **var"#combine#777"** (::Bool, ::Bool, ::Bool, ::Bool, ::typeof(DataFrames.combine), ::DataFrames.GroupedDataFrame{DataFrames.DataFrame}, ::Union{Regex, AbstractString, Function, Signed, Symbol, Unsigned, Pair, Type, DataAPI.All, DataAPI.Between, DataAPI.Cols, InvertedIndices.InvertedIndex, AbstractVecOrMat})@_splitapplycombine.jl:857_
8. **top-level scope** @_[Local: 1](http://localhost:1234/edit?id=bcd52fa0-822a-11ef-1aa5-0d4200066ddd#)_ [inlined]

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 4, 2024, 9:12am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/17 "2024-10-04T09:12:37Z")

</div>

Well I made up that column name, I assumed you’d be interested in the moments of the return distribution.

You can replace log\_return with a column that actually exists like close, or, maybe more usefully, create a log\_return column and then use that in the combine call.

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 4, 2024, 9:32am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/18 "2024-10-04T09:32:53Z")

</div>

ok, i will try

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 4, 2024, 9:40am UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/19 "2024-10-04T09:40:18Z")

</div>

That worked marvellous, thanks thats what i wanted.  
Its amazing. 🤩

M.f.G. Pascal

---

<div class="post-metadata">

**Author:** ![Pascal\_Buhler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pascal_buhler/32/45582_2.png) [@Pascal\_Buhler](https://discourse.julialang.org/u/Pascal_Buhler)\
**Post date:** [October 7, 2024, 12:09pm UTC](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734/20 "2024-10-07T12:09:21Z")

</div>

I wanted to make a correlation matrix with the datas as groups  
i tried  
combine(CHFadj, :adjclose .=\> [cor()])

wich gives me a summary, but not a correlation Matrix.  
Any Clue?  
from there i could take the heatmapfunction. but first the matrix?  
M.f.g. Pascal

[Next page](https://discourse.julialang.org/t/quantitative-finance-in-julia/119734.md?page=2)
