Closed Kyjaque closed 10 months ago
strategy.py -- check line 62
Minimum code to run sims and display results:
some predefined constants used # basic vars used to create market base_pair, quote_pair = "USTC/BUSD", "USDT/BUSD" liquidity_usd = 1000000 ust_start_price = 0.1 binance_swap_fee = 0.12 / 100
run sim for each of the price functions and display results for sim in sims: # we do a deep copy to start each simulation with original market state # use_market = copy.deepcopy(mkt) base = MarketQuote(base_pair, ust_start_price) quote = MarketQuote(quote_pair, 1) mkt = new_market(liquidity_usd, quote, base, binance_swap_fee)
# run first with buybacks use_args = copy.deepcopy(div_protocol_args) use_args["do_buybacks"] = True amm = ConstantProductEngine(mkt) div_strategy = DivStrategy(amm, use_args) # instantiate div strategy class simul = peg_simulation(sims[sim], div_strategy, use_args, "avg") # run the simulation, returned are trades with all data
# now run without buybacks, this is optional, if you want to overlay in1 chart ust price with and without buybacks use_args = copy.deepcopy(div_protocol_args) use_args["do_buybacks"] = False amm = ConstantProductEngine(mkt) div_strategy = DivStrategy(amm, use_args) simul_nobuyback = peg_simulation(sims[sim], div_strategy, use_args, "avg")
# add no buyback price to the simulation simul["breakdown"]["mkt_price_nbb"] = simul_nobuyback["breakdown"].mkt_price
simul["sim_name"] = sim # display results show(new_simulation_figure(mkt, simul))
calc_taxes, args of price and volume, returns the taxed amount in USDT based on current peg time_peg_increase is moving the peg in time steps avg_price_peg_increase is moving the peg price wise execute_div executes a trade, args are market price, TradeOrder, datetime of the trade, flag if it is a buyback
closing cause of future code reset from faffy
Use run.py, to run the simulations, it is outside of main directory, it should open browser windows with charts
adding/fixing: