def main(): customer1 = Customer("John Wick", "Makedonias 3") customer1.place_order(Order("20201215", Payment(100000))) customer1.place_order(Order("20201216", Payment(250000))) customer2 = Customer("Nemo", "MC Wallaby 42") customer2.place_order( Order("20201205", Credit(34235, "2349673", "20221010"))) customer2.place_order( Order("20201205", Credit(5436, "2349673", "20221010"))) customer3 = Customer("John Snow", "The Wall") customer3.place_order(Order("20201203", Payment(4234))) customer3.place_order(Order("20203905", Credit(5436, "746853", "20221111"))) customer3.place_order( Order("20203905", Check(654735, "555555", "20210203"))) print(customer1) print("") print(customer2) print("") print(customer3)
def main(): item1=Item(1,'beer', 10.00) item2=Item(2,'chips', 3.00) item3=Item(3,'salsa', 2.00) inventory=Inventory() inventory.addItem(item1) inventory.addItem(item2) inventory.addItem(item3) orderitem1=OrderItem(inventory.getItemByNumber(1),1) orderitem2=OrderItem(inventory.getItemByNumber(2),3) orderitem3=OrderItem(inventory.getItemByNumber(3),2) order = Order() order.addOrderItems(orderitem1) order.addOrderItems(orderitem2) order.addOrderItems(orderitem3) payment =order.calcTotal() print(payment)
def test_order_is_filled_if_enough_in_warehouse(self): # Create the Order as usual order = Order(TALISKER, 50) # Create the mock warehouse object in record mode mocker = mox.Mox() warehouse = mocker.CreateMockAnything() # Record the sequence of actions expected from the Order object warehouse.get_inventory(TALISKER).AndReturn(50) warehouse.remove(TALISKER, 50) # Put all mock objects in replay mode mocker.ReplayAll() # Exercise the Order object order.fill(warehouse) # Verify that the order is filled and that the warehouse saw # the correct behavior self.assertTrue(order.is_filled()) mocker.VerifyAll()
def clip_orders(self, orders, desired_volume): # given an array of bid or ask orders, # and a desired volume, resize the orders so that # the total volume == desired_volume #total_volume = lambda arr : sum([a.v for a in arr]) # volume = total_volume(orders) # original volume, in units base i = 1 while total_base_volume(orders[:i]) < desired_volume: i += 1 if i > len(orders): # not enough orders in the orderbook! break # more than likely, adding on the last order tacked on a bit of overshoot. # the remainder MUST be spanned by last order (i.e. cannot be in the second # to last otherwise we would have caught it) if desired_volume is None: wtf = 1 remainder = total_base_volume(orders[:i]) - desired_volume last_order = orders[i - 1] orders[i - 1] = Order(last_order.p, last_order.v - remainder) return orders[:i]
def test_repr(self): self.x = Order(1) lines = [] lines.append("Order") lines.append("id: 1") lines.append("status: selection") lines.append("Burger: ()") lines.append("Wrap: ()") lines.append("Sides: ()") lines.append("Drinks: ()") lines.append("Price: $0.00") assert str(self.x) == '\n'.join(lines) side1 = item.initialise_sides(dict())[0] side1.stock = 10000 self.x.set_sides([side1]) lines[5] = "Sides: {}".format(tuple([side1])) lines[7] = "Price: ${:.2f}".format(side1.price) assert str(self.x) == '\n'.join(lines)
def test_group_orders_of_same_price_and_type(self): self.live_orders_board.register( Order('my-user-id', 20, Decimal(27.2), OrderType.BUY)) self.live_orders_board.register( Order('my-user-id', 30, Decimal(27.2), OrderType.BUY)) self.live_orders_board.register( Order('my-user-id', 20, Decimal(27.9), OrderType.BUY)) self.live_orders_board.register( Order('my-user-id', 20, Decimal(27.2), OrderType.SELL)) self.live_orders_board.register( Order('my-user-id', 30, Decimal(27.2), OrderType.SELL)) self.live_orders_board.register( Order('my-user-id', 20, Decimal(27.9), OrderType.SELL)) self.assertEqual( SummaryInfo('BUY: 20 kg for £27.90', 'BUY: 50 kg for £27.20', 'SELL: 50 kg for £27.20', 'SELL: 20 kg for £27.90'), self.live_orders_board.summary())
def test_broker_LONG_manage_active_positions(): # FIRST ITERATION next(broker.market_data.tick) order_date = pd.to_datetime("2010-01-01") order_1 = Order( order_id=1, ticker="AAPL", amount=2, date=order_date, signal=Signal.from_nothing(), stop_loss=-0.1, # Triggered take_profit= 0.399999, # Can get 0.399999999 when working with these number, so to make this trigger timeout=pd.to_datetime("2010-01-06")) orders_event = Event(event_type="ORDERS", data=[order_1], date=order_date) broker.process_orders(portfolio, orders_event) end_date = pd.to_datetime("2010-01-04") broker.handle_dividends(portfolio) # LATTER ITERATIONS while broker.market_data.cur_date < end_date: market_data_event = next(broker.market_data.tick) margin_acc_update_event = broker.manage_active_trades(portfolio) if margin_acc_update_event != None: portfolio.handle_margin_account_update(margin_acc_update_event) broker.handle_dividends(portfolio) closed_trade = broker.blotter.closed_trades[0] assert closed_trade.close_date == pd.to_datetime("2010-01-03") assert closed_trade.close_price == pytest.approx( 10 * 1.399999 - 3) # 3 in dividends, makes the 0.4 take_profit barrier trigger assert closed_trade.dividends_per_share == 3 assert closed_trade.total_dividends == 6
def main(): """ Turn on the FinanceServer - fetch data from the FinanceServer - parse out each order as an Order object - add these Orders to the OrderBook using the values in Action - for each added order, decide to trade indicated by signal """ strategy_choice = sys.argv[1] books = {} client = FinanceClient(host_ip, server_port) ordermanager = OrderManager() if strategy_choice == 'Vanilla': strategy = Vanilla() elif strategy_choice == 'Strawberry': strategy = Strawberry() else: print('strategies available: Vanilla or Strawberry') print(strategy.name, strategy.description) for line in client.fetch(): try: order = Order(line) book = books.get(order.symbol) if book is None: book = books[order.symbol] = OrderBook(order.symbol) if order.action == 'A': book.add(order) elif order.action == 'M': book.modify(order) bid, offer = book.display_book(output=True) ordermanager.signal(bid, offer, strategy.execute) except Exception as e: print(e) pass
def addOrder(args): """ Adds an Order along with its Recipe to an OrderList. """ orderListName = args[0] plantName = args[1] orderId = args[2] orderDeadline = args[3] plant = Plant.fromXmlFile(plantFileExists(plantName)) order = Order(id=int(orderId), deadline=int(orderDeadline)) recipe = Recipe() for m in plant.machines: print "Time for", m.name + ":", time = int(input()) recipe[m.name] = time order.recipe = recipe orderListFilename = orderListExists(orderListName) orderList = OrderList.fromXmlFile(orderListFilename) orderList.addOrder(order) orderList.toXmlFile(orderListFilename)
def test_when_apis_are_down_order_price_is_zero( self, shipping_price, product_price, ): discount = Decimal('0.6') uri = re.compile(r'http://127.0.0.1:8000/*') httpretty.register_uri( httpretty.GET, uri, body=response_factory(403), ) httpretty.register_uri( httpretty.GET, uri, body=response_factory(403), ) expected_price = Decimal('0') result = Order(discount).get_order_price() assert result == expected_price
def _update_execution(self, execution, a): runtime = self._determine_runtime(self.actionState.getT()) orderbookState = self.orderbook.getState(self.orderbookIndex) if runtime <= 0.0 or a is None: price = None ot = OrderType.MARKET else: price = execution.getOrderbookState().getPriceAtLevel(self.side, a) ot = OrderType.LIMIT order = Order( orderType=ot, orderSide=self.side, cty=self.actionState.getI(), price=price ) execution.setRuntime(runtime) execution.setState(self.actionState) execution.setOrder(order) execution.setOrderbookState(orderbookState) execution.setOrderbookIndex(self.orderbookIndex) return execution
def generate_orders_from_signals(self, portfolio, signals_event: Event): orders = [] signals = signals_event.data for signal in signals: cur_date = portfolio.market_data.cur_date try: ticker_data = portfolio.market_data.current_for_ticker( signal.ticker) except MarketDataNotAvailableError as e: Logger.logr.warning( "Failed to generate order from signal because market data was not available for ticker {} in {}" .format(signal.ticker, cur_date)) continue max_dollar_size = self.max_position_size_percentage * portfolio.calculate_portfolio_value( ) max_nr_stocks_of_ticker = math.floor(max_dollar_size / ticker_data["open"]) amount = math.floor(signal.direction * signal.certainty * max_nr_stocks_of_ticker) if amount < 0: print("amount: ", amount) if amount == 0: continue take_profit = signal.ewmstd * signal.ptSl[0] stop_loss = signal.ewmstd * signal.ptSl[1] timeout = cur_date + relativedelta(months=1) orders.append(Order(order_id=self.get_order_id(), ticker=signal.ticker, amount=amount, date=portfolio.market_data.cur_date, signal=signal, \ stop_loss=stop_loss , take_profit=take_profit, timeout=timeout)) return Event(event_type="ORDERS", data=orders, date=signals_event.date)
def check_event(update: Update, _: CallbackContext) -> None: try: msg = update._effective_message user = msg.from_user if not user.is_bot: order = Order(msg).get_answer() type = order.get('type') if type == 'audio': update.message.reply_audio( audio=open(order.get('send'), 'rb'), reply_to_message_id=order.get('msg_id')) elif type == 'photo': update.message.reply_photo( photo=open(order.get('send'), 'rb'), reply_to_message_id=order.get('msg_id')) elif type == 'text': update.message.reply_text( order.get('send'), parse_mode=order.get('parse'), reply_to_message_id=order.get('msg_id')) except Exception as e: print(e)
def order(self, customer, orders : []): book_list = [] for order in orders: # Author if hasattr(order, 'surname'): # searching most recent release among all publishers publishers = Publisher.enlist() # all existing publishers most_recent = [] for p in publishers: books = p.booksByAuthor(order) if books: most_recent.append(books[0]) # the most recent book: book = list(sorted(most_recent, key=lambda x: x.uptime()))[0] book = Book.reprice(book, self.get_real_price(book)) book_list.append(book) else: # Book: book_list.append(Book.reprice(order, self.get_real_price(order))) order = Order(self, customer, book_list) # if the orders are processed simultaneously & automatically if self.AUTO_BUY: if not order: # order cannot be executed # and books need to be printed and delivered # self.orders is a queue for those orders. self.orders.append(order) else: # Buy it! # Order is executed order.execute() return order
def test_default_burger_no_stock(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) orig_white_bun = inventory_fixture["white"] = 0 orig_beef = inventory_fixture["beef"] orig_cheese = inventory_fixture["cheese"] orig_tortilla = inventory_fixture["tortilla"] orig_tuna = inventory_fixture["tuna"] orig_lettuce = inventory_fixture["lettuce"] orig_onion = inventory_fixture["onion"] orig_tomato = inventory_fixture["tomato"] orig_avocado = inventory_fixture["avocado"] try: def_burg1 = order1.Create_Item("Default Burger") except ItemError as err: assert(err.message == "Not enough white buns in stock.") else: assert(False) assert(order1.Calculate_Cost() == 0) assert(inventory_fixture["white"] == (orig_white_bun)) assert(inventory_fixture["beef"] == (orig_beef)) assert(inventory_fixture["cheese"] == (orig_cheese)) assert(inventory_fixture["tortilla"] == (orig_tortilla)) assert(inventory_fixture["tuna"] == (orig_tuna)) assert(inventory_fixture["lettuce"] == (orig_lettuce)) assert(inventory_fixture["onion"] == (orig_onion)) assert(inventory_fixture["tomato"] == (orig_tomato)) assert(inventory_fixture["avocado"] == (orig_avocado)) assert(order1.ID == None) assert(order1.Status == None)
def createAction(self, level, state, orderbookIndex=None, force_execution=False): # Determines whether to run and force execution of given t, or if # segmentation of t into multiple runtimes is allowed. if force_execution: runtime = state.getT() ot = OrderType.LIMIT_T_MARKET else: runtime = self.determineRuntime(state.getT()) ot = OrderType.LIMIT if orderbookIndex is None: orderbookState, orderbookIndex = self.getRandomOrderbookState() else: orderbookState = self.orderbook.getState(orderbookIndex) if runtime <= 0.0 or level is None: price = None ot = OrderType.MARKET else: price = orderbookState.getPriceAtLevel(self.side, level) order = Order(orderType=ot, orderSide=self.side, cty=state.getI(), price=price) action = Action(a=level, runtime=runtime) action.setState(state) action.setOrder(order) action.setOrderbookState(orderbookState) action.setOrderbookIndex(orderbookIndex) action.setReferencePrice(orderbookState.getBestAsk()) return action
def _create_execution(self, a): runtime = self._determine_runtime(self.actionState.getT()) orderbookState = self.orderbook.getState(self.orderbookIndex) if runtime <= 0.0 or a is None: price = None ot = OrderType.MARKET else: price = orderbookState.getPriceAtLevel(self.side, a) ot = OrderType.LIMIT order = Order( orderType=ot, orderSide=self.side, cty=self.actionState.getI(), price=price ) execution = Action(a=a, runtime=runtime) execution.setState(self.actionState) execution.setOrder(order) execution.setOrderbookState(orderbookState) execution.setOrderbookIndex(self.orderbookIndex) execution.setReferencePrice(orderbookState.getBestAsk()) return execution
def insert_menu(): print "\n1. 'products'\n2. 'orders'\n3. Back" while True: key = raw_input("Select table: ") if key == '1': name = raw_input('Enter product name: ') while True: try: price = int(raw_input('Enter product price: ')) except ValueError: print 'Wrong Answer. Please Try Again!' else: products.add(Product(products.last, name, price)) return elif key == '2': while True: try: oid = int(raw_input('Enter oid: ')) except ValueError: print 'Wrong Answer. Please Try Again!' else: break while True: try: pid = int(raw_input("Enter pid: ")) except ValueError: print 'Wrong Answer. Please Try Again!' else: if not products.exists(pid): print "Product with pid={} doesn't exist!".format(pid) return orders.add(Order(oid, pid)) return elif key == '3': return print 'Wrong Answer. Please Try Again!'
def create_bid_order(self, price, quantity, timeout): """ Create a bid order (buy order) :param price: The price for the order :param quantity: The quantity of the order :param timeout: The timeout of the order, when does the order need to be timed out :type price: Price :type quantity: Quantity :type timeout: Timeout :return: The order that is created :rtype: Order """ assert isinstance(price, Price), type(price) assert isinstance(quantity, Quantity), type(quantity) assert isinstance(timeout, Timeout), type(timeout) order = Order(self.order_repository.next_identity(), price, quantity, timeout, Timestamp.now(), False) self.order_repository.add(order) self._logger.info("Bid order created with id: " + str(order.order_id)) return order
def test_input_generation_randomly(dest, due, start): # 탁자 1, 2, 3 의 선호도는 각각 6:3:1 # 책상 1, 2, 3 의 선호도는 각각 5:4:1 itemset = [] tableR = random.random() if tableR > 0.6: itemset = itemset + test_input_dependency_generation('table_1', 0.7) elif tableR > 0.1: itemset = itemset + test_input_dependency_generation('table_2', 0.7) else: itemset = itemset + test_input_dependency_generation('table_3', 0.7) deskR = random.random() if deskR > 0.5: itemset = itemset + test_input_dependency_generation('desk_1', 0.3) elif deskR > 0.1: itemset = itemset + test_input_dependency_generation('desk_2', 0.3) else: itemset = itemset + test_input_dependency_generation('desk_3', 0.3) chairR = random.random() if chairR > 0.8: itemset = itemset + test_input_dependency_generation('chair_1', 0.5) chairR = random.random() if chairR > 0.8: itemset = itemset + test_input_dependency_generation('chair_2', 0.5) chairR = random.random() if chairR > 0.8: itemset = itemset + test_input_dependency_generation('chair_3', 0.5) return Order(itemset, dest, due, start)
def push(self, event): orders = [] price = event.price[3] self.prices.append(price) if len(self.prices) > 0: rsi = self._calculate_rsi() if rsi >= self.OVERBOUGHT: if self.signal == 1: orders.append(Order(event.instrument, -1, 0)) orders.append(Order(event.instrument, -1, 0)) if self.signal == 0: orders.append(Order(event.instrument, -1, 0)) self.signal = -1 elif rsi <= self.OVERSOLD: if self.signal == -1: orders.append(Order(event.instrument, 1, 0)) orders.append(Order(event.instrument, 1, 0)) if self.signal == 0: orders.append(Order(event.instrument, 1, 0)) self.signal = 1 return orders
def push(self, event): orders = [] if event.type == Event.TRADE: price = event.price self.prices.append(price) rsi = self._calculate_rsi() if len(self.prices) >= self.sizeq: maq = sum(self.prices[-self.sizeq:]) / self.sizeq if len(self.prices) == self.sizes: mas = sum(self.prices) / self.sizes macd = maq - mas self.lmacd.append(macd) if len(self.lmacd) >= self.sizemamacd: mamacd = sum( self.lmacd[-self.sizemamacd:]) / self.sizemamacd if macd > mamacd and rsi < self.OVERSOLD: if self.state == 0: if self.signal == -1: orders.append(Order(event.instrument, 100, 0)) orders.append(Order(event.instrument, 100, 0)) if self.signal == 0: orders.append(Order(event.instrument, 100, 0)) self.signal = 1 self.state = 1 elif macd < mamacd or rsi > self.OVERBOUGHT: if self.state == 1: if self.signal == 1: orders.append(Order(event.instrument, -100, 0)) orders.append(Order(event.instrument, -100, 0)) if self.signal == 0: orders.append(Order(event.instrument, -100, 0)) self.signal = -1 self.state = 0 del self.prices[0] return orders
for z in range(0, random.randint(2, 4)): product = random.choice(product_list) if len(s_list) != 0: while True: counter = 0 for sale in s_list: if sale.product.get_id() == product.get_id(): product = random.choice(product_list) else: counter += 1 if counter == len(s_list): break s = Sale(sale_id, product, random.randint(1, 5), ts) sale_id += 1 sale_list.append(s) s_list.append(s) for sale in s_list: total += float(sale.sub_total) o = Order(order_id, s_list, str(round(total, 2)), user, ts) ran_status = random.randint(1, 3) if ran_status == 1: o.mark_shipped() elif ran_status == 2: o.mark_shipped() o.mark_complete() order_id += 1 order_list.append(o) dat_loader.write_data("Sales", sale_list) dat_loader.write_data("Orders", order_list)
lines = i.readlines() order_strings = order_strings_from_lines(lines) orders = [] for order in order_strings: customer = Customer(customer_email_from_order(order), customer_first_name(order), customer_last_name(order), customer_newsletter_subscription(order)) billing_address = address_from_order(order, "Billing address:\n") delivery_address = address_from_order(order, "Delivery address:\n\n") order_model = Order( delivery_handling(order), order.splitlines()[1], mputils.text_for_identifier("Transaction ID:", order), billing_address, delivery_address, customer) book_orders = book_orders_from_lines(mputils.order_lines(order), order_model) order_model.book_orders = book_orders orders.append(order_model) customer_file = filename_with_suffix(out_file, "customer") with open(customer_file, 'w', newline='') as customer_csvfile: csvwriter = csv.writer(customer_csvfile, quoting=csv.QUOTE_MINIMAL) for order in orders: customer = order.customer csvwriter.writerow([ customer.email, customer.first_name, customer.last_name, customer.newsletter_subscription, order.transaction_id,
# https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file # https://techtutorialsx.com/2017/01/07/flask-parsing-json-data/ from flask import Flask, request, render_template from flask_ask import Ask, statement, question, session, context import json from order import Order import re import datetime app = Flask(__name__) ask = Ask(app, "/") curOrder = Order() cfaimg = 'https://i.imgur.com/NXnRoK5.png' red = 'https://imgur.com/e25PRAg.png' @app.route('/') def homepage(): return "hi" @ask.launch def start_skill(): curOrder.resetDict() print "started skill" message = "What would you like?" welcome_title = "Welcome" welcome_message = render_template('welcome') out = question(welcome_message).standard_card(title='Welcome', text='Testing') textContent = {'primaryText': {'text': message, 'type': 'RichText'}}
def maintain_equity(symbol_ticker, desired_portion, tolerance): """ Maintains equity of stocks you own to a certain percentage. Args: symbol_ticker: str of the symbol desired_portion: Decimal value of the fraction you want your portfolio to be of this stock tolerance: Decimal value of the tolerance you can respect with your desired portion Returns: list of Orders that are suggested to maintain the desired_portion """ my_portfolio = Portfolio() available_funds = my_portfolio.excess_margin() invested_funds = my_portfolio.value(Portfolio.ValueType.MARKET_VALUE) equity_instrument = Instrument(Instrument.Type.STOCK, symbol_ticker) current_positions = my_portfolio.positions() available_quantity = 0.0 quantity_equity = 0.0 weights = [] symbol_quantity = 0 symbol_value = 0.0 for position in current_positions: check_instrument = Instrument(Instrument.Type.STOCK, position['symbol']) if position['symbol'] == symbol_ticker: symbol_quantity, symbol_value = my_portfolio.share_info( check_instrument) continue quantity, value = my_portfolio.share_info(check_instrument) heapq.heappush(weights, [-value, quantity, position['symbol']]) weight = (symbol_quantity * symbol_value) / invested_funds difference = desired_portion - weight needed_shares_to_buy = 0 needed_shares_to_sell = 0 reallocated_funds = invested_funds * difference if difference > 0: trade = Order.Type.BUY needed_shares_to_buy = (reallocated_funds) // symbol_value elif difference < 0: trade = Order.Type.SELL reallocated_funds = reallocated_funds * -1 needed_shares_to_sell == (reallocated_funds) // symbol_value else: return return_orders = [] if trade == Order.Type.SELL: sell_order = Order(equity_instrument, trade, needed_shares_to_sell, Order.TimeInForce.GFD) return_orders += [sell_order] trade = Order.Type.BUY else: buy_order = Order(equity_instrument, trade, needed_shares_to_buy, Order.TimeInForce.GFD) return_orders += [buy_order] trade = Order.Type.SELL lower_bound = reallocated_funds - (reallocated_funds * tolerance) upper_bound = reallocated_funds + (reallocated_funds * tolerance) total_spent = 0 while not (within_bounds(lower_bound, upper_bound, total_spent)): try: [value, quantity, ticker] = weights.pop() shares_needed = int((reallocated_funds - total_spent) / value) instrument_trade = Instrument(Instrument.Type.STOCK, ticker) if shares_needed >= quantity: add_to_order = Order(instrument_trade, trade, quantity, Order.TimeInForce.GFD) total_spent += quantity * value else: add_to_order = Order(instrument_trade, trade, quantity - shares_needed, Order.TimeInForce.GFD) total_spent += (quantity - shares_needed) * value return_orders += [add_to_order] except: break print("Suggested Order List:") for order in return_orders: print(str(order)) print("\n##########################################\n") return return_orders
#2308 박교령 #이 프로젝트의 이름은 'Personal computer Custom'입니다. #간단히 설명하자면, 각자 컴퓨터를 주문할 때 원하는 부품들을 따로 따로 # 교체가 가능한 조립주문 프로그램입니다. #실행파일입니다 from order import Order o = Order() #Order함수 넣어주기 o.show_kinds() #order클래스에 있는 show_kinds()실행
#main.py from order import Order from file_manager import FileManager file_manager = FileManager("history.bin") #history 있으면 내역 보여주자 history = [] try: data = file_manager.load() #[Drink객체, Drink객체] sum = 0 for h in history: print(h) sum += h.price print("여태껏 아마스빈에 퍼부은 내돈 :" + str(sum) + "원") except FileNotFoundError: print("내역이 없습니다.") print("-----------------------------------------------------------------") o = Order() o.order_drink() #history에 저장하자 file_manager.save(history + o.order_menu)
from flask import render_template, url_for, abort, request, redirect from fieldCheck import validNewIngredientCheck, IngredientFieldError, FieldTypeError from ingredient import Ingredient from SystemManager import app, systemShutdown from order import Order from sides import Side from Sundaes import Dessert from run import GourmetBurgers import copy newOrder = Order() orderSubmit = Order() @app.route('/404') @app.errorhandler(404) def page_note_found(e=None): return render_template('404.html'), 404 @app.route("/") def index(): return render_template("index.html") @app.route("/orderConfirmation/<orderID>") def orderConfirmation(orderID): return render_template('confirmation.html', orderID=orderID) # CODE FOR CUSTOMER INTERFACE
from order import Order from shipper import Shipper from shipping_cost import ShippingCost # Test Fedex shipping order = Order(Shipper.fedex) cost_calculator = ShippingCost() cost = cost_calculator.shipping_cost(order) assert cost == 3.0 # Test UPC shipping order = Order(Shipper.upc) cost_calculator = ShippingCost() cost = cost_calculator.shipping_cost(order) assert cost == 4.0 # Test Postal shipping order = Order(Shipper.postal) cost_calculator = ShippingCost() cost = cost_calculator.shipping_cost(order) assert cost == 5.0