Quantitative Finance in Julia

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

Are you talking about the package GitHub - JuliaQuant/MarketData.jl: Time series market data?

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.

See also [ANN] Announcing YFinance.jl

thanks for the rapid input and commentaries. :grinning:

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

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.

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

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

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

?

1 Like

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> 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> 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> 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.

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

Thanks

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> 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> 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.

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โ€);
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)+""]

Is that a question?

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.

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

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

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 [inlined]

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.

ok, i will try

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

M.f.G. Pascal

2 Likes

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