primitivefinance / excalibur Goto Github PK
View Code? Open in Web Editor NEWExcalibur
Excalibur
We should bring the agents into a struct Agent
instead of creating a vec in each simulation (e.g., steppers
in the dynamic_weights.rs
). This struct can have the builder design so agents can be easily added.
We should then pull out the loop used in this simulation since it is already generic. The run()
methods for the simulations should be changed to setup
and return an object that can be looped over.
Whenever the price of a pool changes, the arbitrageur agent uses some math to determine if they should trade in the pool. The math will compute the trade amounts to try and swap.
Allow the price changer to be generic over a type of price process.
Right now we are doing fees in terms of BPs and we cannot go smaller than one BP. Let's allow ourselves very small fees just so we can see what the right lower bound should be!
Right now the momentum and volatility targeting strategies only use a very basic heuristic for updating weights (namely change the weight by 0.2% over the course of one day depending on realized volatility and net returns, respectively.) These strategies should account for a. how far from the volatility target the current strategy is (in the case of vol targeting) and b. how negative or positive the net returns are for the period (in the case of momentum). If the we are far from the volatility target, weights should likely update by an amount > 0.2%, and vice versa. If net returns are strongly negative or strongly positive, the change should be > 0.2%, and vice versa.
Having seeds is excellent for replayability and debugging. But, if we want to most truly random simulations, we should have the ability to remove seeds. Why?
seed==2
for a GBM price path, then that path will only be scaled by drift/volatility but will qualitatively look the same.We should take extensive notes to document how the simulation was built.
Maybe we can make it in style of REVM docs that @0xJepsen wrote?
Maybe we start with a CLI and evolve into a more sophisticated UI
There are a collection of classic portfolio analysis techniques that we should integrate into our analyze toolkit
Is your feature request related to a problem? Please describe.
I will make arbitrageur
a trait so that we can have a consistent interface for any strategy we use. I will then bring in the RMM-01 strategies on top of the g3m.
Get a basic UI implemented for analysis that let's you pick a file to analyze and which events you want to take in.
Is your feature request related to a problem? Please describe.
Create a basic price changing agent hooked up to a liquid exchange. Can mimic the one used in portfolio_simulations
Describe the bug
add_liquidity
on the liquidity provider only works properly if the trajectory.initial_price is 1. Need to refactor the add_liquidity method to work with variable initial price.
The main simulation loop is responsible for:
If we use a default price process like GBM we pick static parameters.
We would like to have time dependent vol, or other dynamic parameters.
Short term: Use rustquant fork
Long term: Get it merged in
We can have the analyzer UI automatically read in the selected file once chosen. Then it can use the reader
module in analysis
to give a list of the events so they can be displayed and chosen from. Then the event selection should collect a set of vectors of those events.
Possibly to test it out, the next AnalyzerState
should display a scrollable list of these vectors and their values.
Config file needs to have all the levers we want to change to minimize the amount of recompiling we want to do.
Rough config:
We should generate some basic analysis for the volatility targeting strategy and visualize it.
The configs we use currently don't allow for an easy extension to having new agents or instantiating multiple copies of agents that perform slightly differently.
Also, it would be nice to have configs follow a more standard design pattern.
Meta issue of documentation for strategy prototyping
When we generate data from a large amount of simulations in parallel over sweeps, we need to organize their output in a usable way.
What data we want to end up with:
Notes:
Should be very easy to:
When we are running big simulations, if one environment has an error, everything halts. This SUCKS.
Let's do the following:
"gbm_drift=0_vol=0.1_trajectory=0"
.Right now we can ingest data from the JSON output into a nested mapping. Another feature we should add should allow for converting these events into the actual enum/structs that the bindings have. This should be pretty easy given that the bindings have both Serialize
and Deserialize
for all the structs/enum.
An agent must be responsible for updating the weights of the portfolio. This needs to emit an event in the contract and an updated price.
@Autoparallel Builds agent
@clemlak Adds event to smart contract + function for weight changes
New strategy prototyping.
Rather then computing a target vol, we would compute a notion of "momentum" and use it to describe the weight updates.
For example, if looking at an average price of an asset over time does it trend up or down -> positive / negative momentum.
What we could do is take the last 30 prices and compute a best fit line and draw correlation between slow and target weights. Would also benefit from time varying process parameters.
The types of plots we have set up in Python are a good start. We should rebuild them in Rust using the Plotters crate!
Document what we are doing, why we are doing. A place for math notes, mathematical descriptions of strategy. Almost like our quant manual for PIAB.
For example: Say we are doing our vol targeting strategfy and we want to analyse it. What kind of analysis should we do? -performance, risk, etc. We can put our results and configs in this.
Lets allow these to just be text fields in the UI?
We can type check these.
(Provide dump user bumper rails)
In order to provide sweeping parameter sets, we need to allow our config/settings/parameters to be more easily tunable for this. We should be able to pass either a fixed value or a range of values for relevant parameter sets.
Ship it with markdown. Maybe ad it to the Mdbook?
Right now we have a weight changer for vol targeting and momentum. I think it would be good to just make a weight changer trait that can be implemented for those different types of strategies (i.e., they just have a method like compute_new_weights
that can be implemented differently).
We can do the same for RMM parameters.
Then we can have a sim file for each strategy contract and the behavior of the parameters is just abstracted into a trait. We can decide which implementation we want to run for that sim in the config or something.
Reference codebase: https://github.com/squidowl/halloy/blob/main/src/main.rs
Here's a spec for an initial application delivered via ui/
:
This can be the start then we can work on features like modifying the config, modifying individual agents, running multiple sims, etc.
In order to use RMM effectively in simulations, we need the contract to implement the IStrategy
interface.
Now we should use this to be able to adjust the properties of (2D) plots
How does Shadow do this?
This could make our existing tools really powerful.
For development we can make whatever contracts we want.
@clemlak is working on these in box-contracts/
Rough api:
Note:
We need to be able to run simulations in parallel, so we should have some sort of way of batching simulations together to be run simultaneously.
Point to arbiter 0.6.0 feature branch
Asses viability of on and off chain fees models for Portfolio Protocol and/or generated Portfolio Strategies. Provide clear, quantitative examples of outcomes under different viable revenue models.
TBD
Should cover
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.