sbenthall / SHARKFin

Simulating Heterogeneous Agents with Finance
6 stars 5 forks source link

Set up and run a ggshark simulation #200

Closed mesalas closed 1 year ago

mesalas commented 1 year ago

@gms158 and @wjt5121 Lets see if we can get a ggshark type of simulation going

There are three aims in this task:

1 Modify scripts and automated infrastructure to run a ggshark simulation 2 test that we can actually run a ggshark simulation combining ammps and sharkfin 3 test if the included change to the closing sequence in ammps fixes the type 3 errors

Once we can confirm 1 and 2 you can run 10 simulations with different seeds to test if we get the type 3 error where ammps finishes before it receives the shutdown signal from SHARKFin.

Edit: I see that I still hit the type 3 error. so I will have to get back on that

You will need new ammps binaries that can be found in the ggshark branch of the ammps_sharkfin_container repository.

The procedure is similar to what we have done previously so I think it will be compatible with all your scripting with a few changes to the command line arguments.

One simulation contains three components that share a rabbitMQ queue and a random seed. These are labeled [rabbitMQ queue] and [random seed] below.

Im assuming a rabbitMQ server to be available at [rabbitMQ host].

1

Generate an ammps config file using ammps_config_generator this will output [ammps_config].xlsx python gg_shark_config.py --seed [random seed] --name [ammps_config].xlsx --days 240 The python script can be found in the ggshark branch of ammps_config_generator

2

Start ammps:

dotnet amm.engine.dll RunConfFromFile [ammps_config].xlsx working --instruments ABC:NYSE:0.01:0.01,ABC:CITADEL:0.001:0.001 --number 0 --rabbitMQ-host [rabbitMQ host] --rabbitMQ-queue [rabbitMQ queue] --t False

This is similar but with the instruments option now specifying the "ABC" stock being traded at NYSE and at citadel.

3

Start SHARKFin

python run_any_simulation.py testoutput --tag tag --seed [random seed] --popn 25 --quarters 4 --runs 60 --attention 0.05 --dphm 1500 --market ClientRPCMarket --dividend_growth_rate 1.000628 --dividend_std 0.011988 --queue [rabbitMQ queue] --rhost [rabbitMQ host]

wjt5121 commented 1 year ago

@mesalas I've made the changes to the automation but running in to issue switch branches and when running the sim.

  1. I'm receiving this message when I attempt to checkout the ggshark branch.
error: Your local changes to the following files would be overwritten by checkout:
    baseconfiguration/base_agent_configuration.py
Please commit your changes or stash them before you switch branches.
Aborting

I'm unsure why it would be reporting local changes as I am attempting the checkout command immediately following cloning the repo. However, as indicated if I run the a 'git stash', then the checkout is successful.

  1. Once in the ggshark branch I see a file called "make_ggshark_config.py" not 'gg_shark_config.py" as stated above which I would assume this is a just a typo.

  2. With the branching resolved I can execute an experiment the and the ammps configuration files are created Started with the following arguments: --seed 23932 --name test_conf64.xlsx --days 480 --out-dir /usr/simulation/

However the simulations hang during launch, with ammps producing the with the following error.

Connecting to external SHARKFin market on 20.230.0.191 using queue ggshark3rd64
The given key 'valuationStd' was not present in the dictionary.
System.Collections.Generic.KeyNotFoundException: The given key 'valuationStd' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at amm.engine.com.agents.instutitonal.dividendInstitution_ExternalConfig..ctor(String matchingMarketName, Int64 matchingMarketId, List`1 subcriberIDs, Dictionary`2 externalConfig) in /Users/trz909/dev/amm.engine/amm.engine/amm.engine/com/agents/instutitonal/DividendInstitution_ExternalConfig.cs:line 46
   at amm.engine.com.agents.helpers.AgentGenerators.MakeDividendLongShortInstitutions(AMEngine engine, MarketEngineConfig mec, Int32 simId, List`1 uniqueIds, Dictionary`2 dividendLongShortInstitutions, List`1 dividendLongShortInstConfigurations) in /Users/trz909/dev/amm.engine/amm.engine/amm.engine/com/agents/helpers/AgentGenerators.cs:line 367
   at amm.engine.com.simulations.RunConfFromFile.RunSimulations() in /Users/trz909/dev/amm.engine/amm.engine/amm.engine/com/simulations/RunConfFromFile.cs:line 287
Simulations Didn't Finish OK for RunConfFromFile /usr/simulation/test_conf64.xlsx /shared/home/ammpssharkfin/output/ammps_test_ggshark3rd64out
System.Exception: Simulations Didn't Finish OK for RunConfFromFile /usr/simulation/test_conf64.xlsx /shared/home/ammpssharkfin/output/ammps_test_ggshark3rd64out
   at amm.engine.com.main.Runner.<>c.<Main>b__2_0(Options o) in /Users/trz909/dev/amm.engine/amm.engine/amm.engine/com/main/Runner.cs:line 105
   at amm.engine.com.main.Runner.Main(String[] args) in /Users/trz909/dev/amm.engine/amm.engine/amm.engine/com/main/Runner.cs:line 46
Connected and awaiting RPC requests

Here is what is in the error log from sharkFin GPFRaw = 0.979148 GPFNrm = 0.988336 GPFAggLivPrb = 0.974215 Thorn = APF = 0.979148 PermGroFacAdj = 0.990704 uInvEpShkuInv = 0.977122 VAF = 0.874979 WRPF = 0.537284 DiscFacGPFNrmMax = 0.954376 DiscFacGPFAggLivPrbMax = 1.005063

sbenthall commented 1 year ago

@mesalas What's up with the valuationStd error?

mesalas commented 1 year ago

Im not sure why you get the error with local changes. There shouldn't be any when you pull the repository and check out a branch?

The other error shows up because the dividend institution agents are are expecting a column called "valuationStd" in the configuration file (test_conf64.xlsx), when they are initialized. The problem is that they shouldn't, because thats was only used in the old pricing logic, before switching to Lucas asset pricing.

I can't reproduce the error with the binaries that are in the ggshark branch of the ammps_sharkfin_container repository, but if I use the ones in master I can reproduce the error.

I need to implement the new pricing function, but then I will put everything into master

mesalas commented 1 year ago

Hi @wjt5121 and @gms158. We are going to us ammps only for this simulation.

We will need updated the binaries for ammps in the main branch of the ammps_sharkfin_container project https://github.com/mesalas/ammps_sharkfin_container/tree/master/container_contents/ammps_bin and make_ggshark_config.py in the main branch of the ammps_config_generator project.

The sequence is the same as before, but without using rabbitMQ and SHARKFIn:

first make an ammps config python make_ggshark_config.py --seed [random seed] --name [ammps_config].xlsx --days 240 --market_fraction [x]

Then run ammps with the generated config: dotnet amm.engine.dll RunConfFromFile [ammps_config].xlsx working --instruments ABC:NYSE:0.01:0.01,ABC:CITADEL:0.001:0.001 --number [n] -s true

n is the simulation number. Initially we just want to test this with the parameter x = 0.5

Once we have verified that works

we want to do multiple runs with different random seeds where the x parameter is [0,0.25,0.5,0.75,1.0]