This solution connects to a decentralized exchange https://mango.markets over Solana Blockchain and streams real-time information on Solana perpetual futures into Google Spanner. We use the data to train the model in Vertex AI notebook using Nvidia CUDA 11 capable graphic card to predict the price-delta of the asset with variable time horizon.
Google cloud platform real-time training/inference architecture
gcloud spanner instances create defi --config=regional-us-central1 \
--description="Defi Futures stream" --nodes=1
git clone https://github.com/galic1987/spanner-nvidia-vertex-inference-demo
cd spanner-nvidia-vertex-inference-demo
!pip install -r requirements.txt
Run 1_create_database_and_table.ipynb notebook.
Waiting for operation to complete...
Created database futuresfunding on instance defi
Open shell
conda create -n python39 python=3.9.2
conda activate python39
cd spanner-nvidia-vertex-inference-demo
pip install -r requirements-connector.txt
python 2_connector_stream.py
Inserted instance data.{'DATA_KEY': '83bfca51-7f81-43e1-9240-dad2df820d47', 'FUNDING': Decimal('-0.000017749'), 'OPEN_INTEREST': Decimal('370173.500000000'), 'ORACLE_PRICE': Decimal('40.735000000'), 'MID_PRICE': Decimal('40.735000000'), 'LONG_FUNDING': Decimal('148554.672244567'), 'SHORT_FUNDING': Decimal('148554.672244567'), 'APR': Decimal('-0.155484342'), 'APY': Decimal('-0.144000701'), 'SPREAD': Decimal('0.010000000'), 'SYMBOL': 'SOL-PERP', 'OBSERVATION_TIME': 'spanner.commit_timestamp()'}
Run 3_spanner_gpu_train_inference.ipynb notebook.