class LoggerTestCase(unittest.TestCase): def setUp(self): self.logger = Logger(0, "Test", "H4") def testInit(self): self.assertEqual(self.logger.info, "INFO") def testWriteInfo(self): self.logger.log_info("TestComponent", "TetMessage")
def testGetCandle(self): logger = Logger(0, "EUR_USD", 30) stream = Stream(logger) candle = stream.get_candle() self.assertIsNotNone(candle) self.assertIsNotNone(candle.open)
def getModel(self, dir=1): atr_len = 14 ma_len = 20 now = str( datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.000000000Z")) candles = [Candle(now, 20000, 20000, 20000 + dir, 20000 + dir, 10)] while len(candles) < max(atr_len, ma_len) + 1: candles.append( Candle(now, candles[-1].open + (5 * dir), candles[-1].high + (5 * dir), candles[-1].low + (5 * dir), candles[-1].close + (5 * dir), candles[-1].volume)) logger = Logger(0, "TST_SYM", 30) return Model(0, '0', logger, candles, atr_len, ma_len)
def setUp(self): now = str( datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.000000000Z")) candle = Candle(now, 200, 200, 100, 150, 100) self.state = State(candle, 5, 100) self.distance = 1 self.tp = 2 self.sl = 2 self.trl = 2 self.min_seq = 3 self.use_mac = True logger = Logger(0, "TST_SYM", 30) self.intelligence = Intelligence(0, 0, logger, self.distance, self.tp, self.sl, self.trl, self.min_seq, self.use_mac)
parser.add_argument("instrument") parser.add_argument("granularity", type=int) args = parser.parse_args() """ Parse args """ implementation = args.implementation instrument = args.instrument granularity = args.granularity """ Create logger and lists of components """ logger = Logger(implementation, instrument, granularity) stream = config.get_stream(logger) candles = stream.get_candles(config.get_max_model_param(implementation) + 1) models = config.get_models(logger, candles) intelligences = config.get_intelligences(logger) brokers = config.get_brokers(logger) """ Functions """ def name(): return "Main %d" % implementation """
def testGetCandles(self): logger = Logger(0, "EUR_USD", 30) stream = Stream(logger) candles = stream.get_candles(10) self.assertEqual(len(candles), 10)
def setUp(self): self.logger = Logger(0, "Test", "H4")
def testPlaceOrder(self): logger = Logger(0, "EUR_USD", 30) broker = Broker(0, logger, 0.025, '101-004-4759925-003') order = Order("Unit test", 1, 1.0020, 0, 1, 1) self.assertTrue(broker.input(order))
def testPlaceNoOpenOrder(self): logger = Logger(0, "EUR_USD", 30) broker = Broker(0, logger, 0.025, '101-004-4759925-003') order = Order("Unit test", None, None, None, None, None) self.assertFalse(broker.input(order))
import py.config as config from py.logger import Logger from py.stream import Stream logger = Logger(0, "EUR_USD", 30) candles = Stream(logger).get_candles(30) config.get_models(logger, candles) config.get_intelligences(logger) config.get_brokers(logger) print(config.get_account(logger))
import time from sys import argv from py.logger import Logger, logType from py.configReader import Reader from py.check import Check from py.argParser import passArgs if __name__ == "__main__": noLog = passArgs(argv) logger = Logger(noLog) reader = Reader(logger) checker = Check(logger, reader) try: checkTime = int(reader.readConfig()["checktime"]) except: logger.log( "Parsing Error from Checktime, please look at the Configfile", logType.error) quit() while (True): checker.checkIP() time.sleep(checkTime)