pickassets
.
![]() |
![]() |
---|---|
![]() |
![]() |
You can install the package by running the following command in the Julia REPL:
using Pkg
Pkg.add(url="github.com/shayandavoodii/PickAssets.jl.git")
pickassets
. The function takes the following arguments:
- An object of type
Method
. This object specifies the method used to pick the assets. The available methods are:HighVolume
: Picks the assets with the highest average volume during the specified time span.HighVolatility
: Picks the assets with the highest average volatility during the specified time span.RandomWise
: Picksm
assets randomly from the passed Vector of assets.MarketCap
: Picks the assets with the highest current market capitalization.
- A Vector of assets. This Vector should contain the names of the assets that you would like to create the dataset from.
The HighVolume
and HighVolatility
methods take the following additional arguments in order to specify the time span:
val
: The values you intend to use for creating the dataset. I.e., the close price values of the assets (for theHighVolatility
method), and the volume values of the assets (for theHighVolume
method).dates
: The dates corresponding to the values passed in theval
argument.partition
: The partition method used to partition the data. As of now, theDateBased
andValueBased
methods are available which can be used inYearly
,Monthly
, orSeasonally
spans. TheDateBased
method partitions the data based on the dates passed in thedates
argument, while theValueBased
method partitions the data based on the values passed in theval
argument. For example, if you pass theYearly
span to theDateBased
method, the data will be partitioned into yearly spans based on the dates passed in thedates
argument. TheValueBased
method will partition the data into yearly spans based on the value passed to the time span. For example, if you pass theYearly(252)
span to theValueBased
method, the data will be partitioned into yearly spans each containing 252 values.
pickassets
function to create datasets from a universe of assets based on the various configurations:
using PickAssets, Dates
# A Matrix of close price values of the assets of size (n, m)
# where n is the number of assets and m idicates the number of days.
close_prices = rand(10, 1000)
# A Vector of dates corresponding to the close price values
dates = [Date(2021, 1, 1) + Day(i) for i in 1:1000]
# A Vector of asset names
assets = ["Asset$i" for i=1:10]
# Dataset1: Picks the assets with the highest average volume in yearly time span based on the dates:
dataset1 = pickassets(HighVolume(close_prices, dates, DateBased(Yearly())), assets)
# Dataset2: Picks the assets with the highest average volume in yearly time span based on the values:
dataset2 = pickassets(HighVolume(close_prices, dates, ValueBased(Yearly(252))), assets)
# Dataset3: Picks the assets with the highest average volatility in monthly time span based on the dates:
dataset3 = pickassets(HighVolatility(close_prices, dates, DateBased(Monthly())), assets)
# Dataset4: Picks the assets with the highest average volatility in monthly time span based on the values:
dataset4 = pickassets(HighVolatility(close_prices, dates, ValueBased(Monthly(21))), assets)
# Dataset5: Picks 5 assets randomly from the universe of assets:
dataset5 = pickassets(RandomWise(5), assets)
# Dataset6: Picks the first 3 assets with the highest market capitalization:
using YFinance
assets = tickers = ["CSCO", "RY", "SHOP", "TD", "ENB", "BN"]
dataset6 = pickassets(MarketCap(3), assets)
After retrieving the superior tickers in terms of the specified method, one can use the following field of the returned PickedAssets
object to construct the dataset:
# For the first dataset, `dataset1`:
close_prices[dataset1.idx, :]
pickassets
function is an object of type PickedAssets
which contains the following fields:
mean
: The mean of the performed method onval
. I.e., the overal average of volatility (for theHighVolatility
method) or volume (for theHighVolume
method) over all partitions. The picked assets have definitely higher values than themean
.sup
: The Vector of superior tickers.idx
: The Vector of indexes of the superior tickers in the original Vector of assets. This can help you to find the superior tickers in the original Vector of assets.res
: ADict
of the superior tickers and their corresponding values. This provides an overview of all tickers and their corresponding values.
dataset1.mean
# 0.49894928681020795
dataset1.sup
# 4-element Vector{String}:
# "Asset2"
# "Asset4"
# "Asset10"
# "Asset1"
dataset1.idx
# 4-element Vector{Int64}:
# 1
# 2
# 4
# 10
dataset1.res
# Dict{String, Float64} with 10 entries:
# "Asset8" => 0.481928
# "Asset7" => 0.498171
# "Asset2" => 0.508003
# "Asset5" => 0.497606
# "Asset6" => 0.492131
# "Asset4" => 0.507848
# "Asset9" => 0.495822
# "Asset10" => 0.50147
# "Asset3" => 0.491802
# "Asset1" => 0.514713