def testExchangeSubmitLimitOrderPartialFill(): (symbol, testExchange, testExchangeParticipant1, testExchangeParticipant2 ) = TestExchange.testExchangeCreateTestSetup() # Setup test orders in the order book testOrder = order.Order( "AA", trade.TradeActions.Buy, order.OrderTypes.Limit, 10, 100, 0, testExchangeParticipant1.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) testOrder = order.Order( "AA", trade.TradeActions.Buy, order.OrderTypes.Limit, 9, 100, 0, testExchangeParticipant2.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) testOrder = order.Order( "AA", trade.TradeActions.Sell, order.OrderTypes.Limit, 11, 100, 0, testExchangeParticipant2.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) # Check full fill of limit order against book testOrder = order.Order( "AA", trade.TradeActions.Sell, order.OrderTypes.Limit, 9, 175, 0, testExchangeParticipant2.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) topOfBookQuote = testExchange.orderBook.getTopOfBook() testComparisonQuote = quote.Quote(symbol, 9, 11, 25, 100) assert (topOfBookQuote == testComparisonQuote) # Check partial fill of limit order against book testOrder = order.Order( "AA", trade.TradeActions.Sell, order.OrderTypes.Limit, 9, 50, 0, testExchangeParticipant2.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) topOfBookQuote = testExchange.orderBook.getTopOfBook() testComparisonQuote = quote.Quote(symbol, None, 9, 0, 25) assert (topOfBookQuote == testComparisonQuote) print "Test Completed Succesfully"
def testExchangeCancelOrder(): (symbol, testExchange, testExchangeParticipant1, testExchangeParticipant2 ) = TestExchange.testExchangeCreateTestSetup() testOrder = order.Order( symbol, trade.TradeActions.Buy, order.OrderTypes.Limit, 10, 100, 0, testExchangeParticipant1.getAccount().getAccountId()) result = testExchange.submitOrder(testOrder) assert (result[0] == True) topOfBookQuote = testExchange.orderBook.getTopOfBook() testComparisonQuote = quote.Quote(symbol, 10, None, 100, 0) assert (topOfBookQuote == testComparisonQuote) testExchange.cancelOrder(1) topOfBookQuote = testExchange.orderBook.getTopOfBook() testComparisonQuote = quote.Quote(symbol, None, None, 0, 0) assert (topOfBookQuote == testComparisonQuote) print "Test Completed Succesfully"
level=logging.DEBUG) logging.info('Verbose ĺogging enabled') cfg = ConfigParser() cfg.read('env.cfg') BANNED_CHANNELS = ast.literal_eval(cfg['TELEGRAM']['banned_channels']) initdb.initdb() rir = rips.Rips() vit = teekkari.Teekkari() vai = valitsin.Valitsin() opi = oppija.Oppija() tag = tagaaja.Tagaaja() quo = quote.Quote() tir = tirsk.Tirsk() mc = mainari.Mainari(cfg['MINECRAFT']['server'], cfg['MINECRAFT']['game_ops'], cfg['MINECRAFT']['server_admins'], cfg['MINECRAFT'].getboolean('use_ip'), cfg['MINECRAFT'].getboolean('use_hostname')) km = kilometri.Kilometri() objects = [rir, vit, vai, tir, opi, km, quo, mc, tag] def allMessages(update: Update, context: CallbackContext): for obj in objects: obj.messageHandler(update, context)