Ejemplo n.º 1
0
 def __init__(self, eventData, context):
     self.logs = CRY2Logger()
     self.eventData = eventData
     self.eventTimer = None
     self.logs.InitLogging(self.eventData['name'], 'cyan')
     self.logs.info("Creating Periodic Event [{}]".format(self.eventData['name']))
     if self.eventData['runAtStart']:
         self.eventData['start'](self.eventData['end'], context)
     self.eventTimer = Timer(self.eventData['duration'], self.eventFired, [context]).start()
Ejemplo n.º 2
0
    def Connect(self, dataStore, cryptopiaGet):

        self.logs = CRY2Logger()
        self.logs.InitLogging('Sim-Wallet', 'yellow')
        self.logs.info("Starting Simulation Wallet")

        ######################################################################
        ##
        ## These should eventually turn into one mongodb
        ##

        self.mongoUserDataClient = MongoClient(<MONGODB_URI>)
        self.userDatabase = self.mongoUserDataClient['user']
        #self.userData = self.userDatabase.wallet.find_one({'email':userData['email']})
        self.dataStore = dataStore
        self.cGet = cryptopiaGet

        self.coinResultDB = self.mongoUserDataClient['cry2-market']
        self.coinResultSet = self.coinResultDB['cry2-5minute-epoch-v4']

        self.coinVolatility = 10
Ejemplo n.º 3
0
 def Init(self):
     self.logs = CRY2Logger()
     self.logs.InitLogging('DataTransform', 'green')
Ejemplo n.º 4
0
#!/bin/python3

import time
from common.cryptopiaget import CryptopiaGet
from common.datastore import DataStore
from common.logger import CRY2Logger
import tracemalloc

tracemalloc.start()
logs = CRY2Logger()
logs.InitLogging('Andromeda', 'cyan')
logs.info("Starting Andromeda")

dataStore = DataStore()
cGet = CryptopiaGet()

cGet.Init(dataStore)
dataStore.Connect({
    'Name': 'cry2-5minute-epoch-v4',
    'Epoch': 300,
}, cGet, 'server')

logs.info("Andromeda is running")

while (True):
    time.sleep(1)
Ejemplo n.º 5
0
    def Connect(self, collectionData, cGet, role):
        self.logs = CRY2Logger()
        self.logs.InitLogging('DataStore', 'cyan')

        self.cryptopiaGet = cGet
        self.mongoClient = MongoClient(<MONGODB_URI>)
        self.mongoDB = self.mongoClient['cry2-market']

        self.collectionData = self.mongoDB['CollectionData'].find_one({'Name': collectionData['Name']})
        if self.collectionData is None:
            self.collectionData = collectionData
            self.collectionData['startEpoch'] = self.GetCurrentEpochID()
            self.UpdateCollectionData()

        self.marketData = self.mongoDB[self.collectionData['Name']]
        self.marketData.create_index([("tradePair", pymongo.TEXT)])
        self.marketData.create_index([("epoch", pymongo.DESCENDING)])

        self.timeouts = {
            'Currencies': 86400,  # Time in seconds (24 hr)
            'TradePairs': 43200,  # Time in seconds (12 hr)
        }

        self.totalMarkets = ['BTC', 'NZDT', 'USDT', 'LTC', 'DOGE']
        self.closedMarkets=        ['NZDT', 'USDT', 'LTC', 'DOGE']

        self.Markets = {}
        self.lastMarketlock = threading.Lock()
        self.lastMarket = 0

        self.MarketOrderGroupLock = threading.Lock()
        self.MarketOrderGroups = []
        self.CurrentEpoch = 0

        #self.memoryLock = threading.Lock()
        #self.lastSnapshot = tracemalloc.take_snapshot()
        #self.currentSnapshot = {}

        self.events = [
        {
            'name': 'Get TradePairs',
            'duration': 86400, # Event timeout in seconds. Get next TradePairs once a day
            'start': self.StartMarketTradePair,
            'end': self.EndMarketTradePair,
            'runAtStart': True,
            'roles': ['client', 'server']
        },
        {
            'name': 'Get Currencies',
            'duration': 43200, # Event timeout in seconds. Get all currencies once every 12 hours
            'start': self.StartCurrencies,
            'end': self.EndCurrencies,
            'runAtStart': True,
            'roles': ['client', 'server']
        },
        {
            'name': 'Get Markets',
            'duration': self.collectionData['Epoch'], # Event timeout in seconds. Based on meta-data
            'start': self.StartGetMarket,
            'end': self.EndGetMarket,
            'runAtStart': True,
            'roles': ['server']
        },
        {
            'name': 'Get Mkt Hist Ord',
            'duration': 100, # Event timeout in seconds. This will be over-written when TradePairs are loaded
            'start': self.StartGetMarketHistoryOrders,
            'end': self.EndGetMarketHistoryOrders,
            'runAtStart': False,
            'roles': ['server']
        }
        ]

        self.eventTimer = PeriodicEventManager(self, role)
Ejemplo n.º 6
0
    def Connect(self, datastore, userData):
        self.logs = CRY2Logger()
        self.dataTransform = DataTransform()
        self.dataTransform.Init()
        self.logs.InitLogging('NeuralNetwork', 'purple')

        self.dataStore = datastore

        self.logs.info("Connected to User database")
        self.mongoClient = MongoClient(<MONGODB_URI>)
        self.mongoDB = self.mongoClient['cry2-market']
        self.marketData = self.mongoDB[self.dataStore.collectionData['Name']]
        self.marketData.create_index([("epoch", pymongo.DESCENDING)])

        self.userData = userData;

        self.trainingSessionID = 0
        self.evaluateIndex = 0

        self.logs.info("Starting new TensorFlow Session")
        self.sess = tf.Session()

        self.tfAskPrice = tf.placeholder("float")
        tf.summary.scalar('Ask_Price', self.tfAskPrice)
        self.tfBidPrice = tf.placeholder("float")
        tf.summary.scalar('Bid_Price', self.tfBidPrice)

        self.tfOpen = tf.placeholder("float")
        tf.summary.scalar('Open_Price', self.tfOpen)
        self.tfClose = tf.placeholder("float")
        tf.summary.scalar('Close_Price', self.tfClose)

        self.tfHigh = tf.placeholder("float")
        tf.summary.scalar('High_Price', self.tfHigh)
        self.tfLow = tf.placeholder("float")
        tf.summary.scalar('Low_Price', self.tfLow)

        self.tfChange = tf.placeholder("float")
        tf.summary.scalar('Pct_Change', self.tfChange)

        self.wx1 = tf.Variable(1.0, name="ask_weight")
        self.wx2 = tf.Variable(1.0, name="bid_weight")
        self.wx3 = tf.Variable(1.0, name="open_weight")
        self.wx4 = tf.Variable(1.0, name="close_weight")
        self.wx5 = tf.Variable(1.0, name="high_weight")
        self.wx6 = tf.Variable(1.0, name="low_weight")
        self.wx7 = tf.Variable(1.0, name="change_weight")

        self.coin_model = self.model(self.tfAskPrice, self.tfBidPrice, self.tfOpen, self.tfClose, self.tfHigh, self.tfLow, self.tfChange, self.wx1, self.wx2, self.wx3, self.wx4, self.wx5, self.wx6, self.wx7)
        tf.summary.scalar('coin_model', self.coin_model)

        self.targetChange = 0
        self.cost = tf.square(self.targetChange - self.coin_model) # use square error for cost function
        tf.summary.scalar('Cost', self.cost)

        self.train_op = tf.train.GradientDescentOptimizer(0.01).minimize(self.cost) # construct an optimizer to minimize cost and fit line to my data
        self.train_writer = tf.summary.FileWriter('./train', self.sess.graph)
        self.test_writer = tf.summary.FileWriter('./test')
        self.merged = tf.summary.merge_all()
        tf.global_variables_initializer().run(session=self.sess)
        self.events = [
        {
            'name': 'Retrain',
            'duration': 14400, # Add a training set every 4 hours
            'start': self.StartTraining,
            'end': self.EndTraining,
            'runAtStart': True,
            'roles': ['andromeda-v4']
        },
        {
            'name': 'Run Epoch',
            'duration': self.dataStore.collectionData['Epoch'], # Event timeout in seconds. Based on meta-data
            'start': self.StartRuns,
            'end': self.EndRuns,
            'runAtStart': True,
            'roles': ['andromeda-v4']
        }
        ]

        self.eventTimer = PeriodicEventManager(self, 'andromeda-v4')
Ejemplo n.º 7
0
 def Init(self, dataStoreObject):
     self.logs = CRY2Logger()
     self.logs.InitLogging('CryptopiaGet', 'cyan')
     self.dataStore = dataStoreObject