vadimpy / solanastocksim

Fun stock simulator integrated with Solana blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

solanastocksim

Fun stock simulator integrated with Solana blockchain

Structure

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

Run

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

Build

Build client:

$ cd solanastocksim/stock_frontend/rust_client
$ cargo +nightly build --target-dir ../build

Build on-chain programs:

$ cd solanastocksim/stock_backend
$ cargo +nightly build-bpf --bpf-out-dir build

Configure paths in solanastocksim/cfg.yml (for Docker it is already configured)

Docker commands:

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

About

Fun stock simulator integrated with Solana blockchain


Languages

Language:Jupyter Notebook 50.9%Language:Rust 26.4%Language:Python 22.4%Language:Shell 0.3%