Whole thing consists from several parts:
- faststock.py, strats.py, safeacc.py - parts of stock exchange model. They stand for trade simulation
- rust_client - wrapper of Solana's RPC client & Python interface generated by pyo3 Rust crate for stock model to track transactions on Solana's blockchain
- client.py - Python RPC client wrapper with SolanaPy python package, just a python implementation of rust_client (it was created to study API)
- sender, setter, messenger - on-chain programs, that are to be deployed on a localnet Solana's blockchain
Ready-to-use docker image:
https://hub.docker.com/r/vadimpy/solexample
First terminal (run localnet Solana blockchain):
$ solana-test-validator -r
Second terminal (listen its logs):
$ solana logs
Third terminal (deploy on-chain programs and run exmaples notebook):
$ cd solanastocksim/stock_backend
$ ./deploy.sh
$ jupyter-notebook
Run example.ipynb cell-by-cell
Be careful! Recommended system requirements for Solana's localnet are 24 logical CPUs and 64GB of memory
$ cd solanastocksim/stock_frontend/rust_client
$ cargo +nightly build --target-dir ../build
$ cd solanastocksim/stock_backend
$ cargo +nightly build-bpf --bpf-out-dir build
Configure paths in solanastocksim/cfg.yml
(for Docker it is already configured)
Run Jupyter notebook
sudo docker run --name vadimpy/solexample -it -p 8888:8888 -a stdin -a stdout -i -t vadimpy/solexample:latest /bin/bash
cd solanastocksim
jupyter notebook --ip 0.0.0.0 --allow-root