ui export
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
version: "3.5"
|
||||
|
||||
services:
|
||||
|
||||
postgres:
|
||||
image: postgres:10
|
||||
volumes:
|
||||
- "./metabase_data:/var/lib/postgresql/data"
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_DB: metabase
|
||||
POSTGRES_USER: metabase_usr
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
|
||||
metabase:
|
||||
depends_on:
|
||||
- postgres
|
||||
image: metabase/metabase
|
||||
ports:
|
||||
- "3000:3000"
|
||||
restart: always
|
||||
environment:
|
||||
MB_ENCRYPTION_SECRET_KEY: ${MB}
|
||||
MB_DB_TYPE: postgres
|
||||
MB_DB_DBNAME: metabase
|
||||
MB_DB_PORT: 5432
|
||||
MB_DB_USER: metabase_usr
|
||||
MB_DB_PASS: ${POSTGRES_PASSWORD}
|
||||
MB_DB_HOST: postgres
|
||||
|
||||
mongo:
|
||||
image: mongo
|
||||
restart: always
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: econ
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: econ
|
||||
ports:
|
||||
- '27017:27017'
|
||||
volumes:
|
||||
- ./econ_data:/data/db
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from pymongo import MongoClient
|
||||
cmt="current_market_trades"
|
||||
cma="current_market_asks"
|
||||
cmb="current_market_bids"
|
||||
|
||||
class MongoExporter():
|
||||
|
||||
def __init__(self,conn_string,db,econ) -> None:
|
||||
|
||||
# Provide the mongodb atlas url to connect python to mongodb using pymongo
|
||||
|
||||
|
||||
# Create a connection using MongoClient. You can import MongoClient or use pymongo.MongoClient
|
||||
client = MongoClient(conn_string)
|
||||
|
||||
# Create the database for our example (we will use the same database throughout the tutorial
|
||||
self.client=client[db]
|
||||
self.econ=econ
|
||||
|
||||
def reset_market(self):
|
||||
"""Resets the current market data in the analytics stack"""
|
||||
c=self.client
|
||||
c[cmt].drop()
|
||||
c[cma].drop()
|
||||
c[cmb].drop()
|
||||
|
||||
def submit_full_market(self):
|
||||
c=self.client
|
||||
market=self.econ.get_component("ContinuousDoubleAuction")
|
||||
self.reset_market()
|
||||
|
||||
for i in range(len(market.executed_trades)):
|
||||
step=market.executed_trades[i]
|
||||
if len(step)>0:
|
||||
for transaction in step:
|
||||
transaction["step"]=i
|
||||
c[cmt].insert_one(transaction)
|
||||
c[cma].insert_many(market.asks)
|
||||
c[cmb].insert_many(market.bids)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# This is added so that many files can reuse the function get_database()
|
||||
Reference in New Issue
Block a user