Skip to content

Commit

Permalink
Merge pull request #273 from sbenthall/i272
Browse files Browse the repository at this point in the history
pass `runs` parameter as days per quarter and no default for days per quater
  • Loading branch information
sbenthall authored Feb 6, 2024
2 parents b9eeabb + 9a3220b commit b649e20
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions sharkfin/markets/ammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self,
seed=None,
queue_name='',
host='localhost',
dividend_growth_rate = 1.000628,
dividend_std = 0.011988,
dividend_growth_rate = 1.000203,
dividend_std = 0.011983,
price_to_dividend_ratio = 60 / 0.05,
rng = None,
macro_price_field = None,
Expand Down
2 changes: 1 addition & 1 deletion sharkfin/tests/test_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_stopped_market(self):
dividend_growth_rate = 1.000628
dividend_std = 0.011988

pdr = price_dividend_ratio_random_walk(0.95, 5, dividend_growth_rate, dividend_std)
pdr = price_dividend_ratio_random_walk(0.95, 5, dividend_growth_rate, dividend_std, 90)

market = MockMarket(
dividend_growth_rate = 1.000628,
Expand Down
2 changes: 1 addition & 1 deletion sharkfin/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def combine_lognormal_rates(ror1, std1, ror2, std2):


def price_dividend_ratio_random_walk(
DiscFac, CRRA, dividend_growth_rate, dividend_std, days_per_quarter=90
DiscFac, CRRA, dividend_growth_rate, dividend_std, days_per_quarter
):
## From Equation 30 from the C. Carroll Lucas asset pricing notes:
## http://www.econ2.jhu.edu/people/ccarroll/public/lecturenotes/AssetPricing/LucasAssetPrice.pdf
Expand Down
31 changes: 17 additions & 14 deletions simulate/run_any_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def default(self, obj):
# General simulation arguments
parser.add_argument("-d", "--seed", help="random seed", default=0)
parser.add_argument("--quarters", help="number of quarters", default=2)
parser.add_argument("--runs", help="runs per simulation", default=60)
parser.add_argument("--days", help="days per quarter", default=60)

# Population parameters
parser.add_argument(
Expand Down Expand Up @@ -93,17 +93,17 @@ def default(self, obj):
parser.add_argument(
"--pop_CRRA",
help="Mean population CRRA. Used for MockMarket and LUCAS0 population.",
default="3",
default="5",
)
parser.add_argument(
"--pop_DiscFac",
help="Mean population CRRA. Used for MockMarket and LUCAS0 population.",
default="0.99",
default="0.90",
)
parser.add_argument(
"--pop_aNrmInitMean",
help="Log of initial mean asset levels for LUCAS0 population.",
default="6",
default="0.5",
)

parser.add_argument(
Expand Down Expand Up @@ -169,7 +169,7 @@ def run_attention_simulation(
agent_parameters,
a=None,
q=None,
r=1,
r=1, ############ALERT##########################
market=None,
fm=None,
dphm=1500,
Expand All @@ -193,7 +193,7 @@ def run_attention_simulation(
fm,
a=a,
q=q,
r=r,
r=r, ############ALERT##########################
market=market,
rng=rng,
seed=seed,
Expand All @@ -210,7 +210,7 @@ def run_chum_simulation(
agent_parameters,
a=None,
q=None,
r=1,
r=1, ############ALERT##########################
fm=None,
market=None,
dphm=1500,
Expand All @@ -224,7 +224,7 @@ def run_chum_simulation(
SequentialPortfolioConsumerType, agent_parameters, dphm=dphm, rng=rng
)

sim = CalibrationSimulation(a=a, q=q, r=r, market=market)
sim = CalibrationSimulation(a=a, q=q, r=r, market=market) ############ALERT##########################

sim.simulate(burn_in=pad, buy_sell_shock=(buy, sell))

Expand All @@ -250,11 +250,12 @@ def env_param(name, default):
seed = int(args.seed)
popn = int(args.popn)
quarters = int(args.quarters)
runs = int(args.runs)
days_per_quarter = int(args.days)
runs = days_per_quarter # variable runs per quarter is an artifact of an earlier version
# and should be deprecated

# General market arguments
market_class_name = str(args.market)

population_name = str(args.population)
pop_CRRA = float(args.pop_CRRA)
pop_DiscFac = float(args.pop_DiscFac)
Expand Down Expand Up @@ -301,7 +302,7 @@ def env_param(name, default):
seed,
popn,
quarters,
runs,
days_per_quarter,
market_class_name,
expectations_class_name,
population_name,
Expand Down Expand Up @@ -334,7 +335,7 @@ def env_param(name, default):
"dividend_std": dividend_std,
"rng": rng,
"price_to_dividend_ratio": price_dividend_ratio_random_walk(
pop_DiscFac, pop_CRRA, dividend_growth_rate, dividend_std
pop_DiscFac, pop_CRRA, dividend_growth_rate, dividend_std, days_per_quarter
),
}

Expand Down Expand Up @@ -384,7 +385,8 @@ def env_param(name, default):
parameter_dict,
a=attention,
q=quarters,
r=runs,
# days_per_quarter is current hard-coded at 60.
r=runs, #############ALERT###########################
market=market,
fm=expectations_class,
dphm=dphm,
Expand All @@ -403,7 +405,8 @@ def env_param(name, default):
parameter_dict,
a=attention,
q=quarters,
r=runs,
# days_per_quarter is current hard-coded at 60.
r=runs, #############ALERT###########################
market=market,
dphm=dphm,
buy=buysize,
Expand Down

0 comments on commit b649e20

Please sign in to comment.