Skip to content

Instantly share code, notes, and snippets.

View jmmshn's full-sized avatar

Jimmy Shen jmmshn

  • LLNL
  • Livermore
View GitHub Profile
@jmmshn
jmmshn / update_fw_structure_charge.py
Created May 5, 2023 22:17
[update fireworks database] check the structure charge and update the charge #fireworks
for doc in FW_STORE.query({
"spec._tasks.0.job.function_args.0.charge": {"$exists": 1},
"spec._tasks.0.job.function.@bound.write_additional_data.info:json": {"$exists": 1},
# "fw_id" : {"$gt" : 1000}
}
):
chg_structure = doc["spec"]["_tasks"][0]["job"]["function_args"][0]["charge"]
chg_defect = doc["spec"]["_tasks"][0]["job"]["function"]["@bound"]["write_additional_data"]["info:json"]["charge_state"]
if chg_structure != chg_defect:
print('messed', doc["fw_id"])
@jmmshn
jmmshn / monty_decoder.py
Created March 17, 2023 17:43
[Monty Decoder] #serialization #monty
from monty.json import MontyDecoder
def mdecode(d):
return MontyDecoder().process_decoded(d)
@jmmshn
jmmshn / dextra_orderbook_3node_good_guess.jl
Last active October 17, 2022 16:51
dextra_orderbook_3node_good_guess
model, bought, sold, price = construct_model(total_trade_volume, orderbook)
@constraint(model, price[1] == 1)
@constraint(model, price[2] <= 1330.0)
@constraint(model, price[2] >= 1390.0)
@constraint(model, price[3] <= 19420.0)
@constraint(model, price[3] >= 19380.0)
optimize!(model)
summarize(orderbook, bought, sold, price)
o1 = LimitBuyOrder(1, 2, 1000, 1/1328)
o2 = LimitBuyOrder(3, 1, 0.1, 19400)
o3 = LimitBuyOrder(2, 3, 2, 1328/19400)
orderbook = OrderBook([o1, o2, o3], ["DAI", "ETH", "BTC"])
@jmmshn
jmmshn / dextra_orderbook_3node_bad_guess.jl
Created October 17, 2022 07:21
dextra_orderbook_3node_bad_guess
model, bought, sold, price = construct_model(total_trade_volume, orderbook)
@constraint(model, price[1] == 1)
optimize!(model)
summarize(orderbook, bought, sold, price)
@jmmshn
jmmshn / dextra_orderbook_2node_stable.jl
Created October 17, 2022 06:33
dextra_orderbook_2node_stable
model, bought, sold, price = construct_model(total_trade_volume, orderbook)
@constraint(model, price[1] == 1)
optimize!(model)
summarize(orderbook, bought, sold, price)
@jmmshn
jmmshn / dextra_orderbook_2node_inf.jl
Last active October 17, 2022 06:18
dextra_orderbook_2node_inf
model, bought, sold, price = construct_model(total_trade_volume, orderbook)
optimize!(model)
summarize(orderbook, bought, sold, price)
@jmmshn
jmmshn / 2node_orderbook.jl
Last active October 17, 2022 06:17
DEXTRA_2node_orderbook
order1 = LimitBuyOrder(2, 1, 1, 1328.0)
order2 = LimitSellOrder(1, 2, 0.5, 0.00075)
orderbook = OrderBook([order1, order2], ["DAI", "ETH"])
approx_prices = [1.0, 1328.0]
get_graph(
orderbook,
approx_prices;
min_val=1000,
max_val=2000,
)
@jmmshn
jmmshn / limitbuyorder_216.jl
Created October 16, 2022 05:47
limitbuyorder_216
LimitBuyOrder(2, 1, 6, 7.5E-4)
@jmmshn
jmmshn / load_dextra.jl
Created October 16, 2022 05:46
Load DEXtra
# Load the package
using DEXTra
@doc LimitBuyOrder