Beispiel #1
0
 def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Setup ML model
     '''
     self.models_per_product = self.load_models_from_filesystem()
     self.last_learning = datetime.datetime.now()
     trigger_learning(self.merchant_token, self.merchant_id,
                      settings['kafka_reverse_proxy_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
 def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Internal state handling
     '''
     self.execQueue = []
     '''
         Information store
     '''
     self.products = {}
     self.offers = {}
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
Beispiel #3
0
 def __initialize(self):
     merchant_token = self.__get_merchant_token()
     self.settings["merchant_token"] = merchant_token
     self.settings["merchant_id"] = MerchantBaseLogic.calculate_id(
         merchant_token)
     self.settings[
         "marketplace_url"] = MerchantBaseLogic.get_marketplace_url()
     self.settings["producer_url"] = MerchantBaseLogic.get_producer_url()
     self.settings[
         "kafka_reverse_proxy_url"] = MerchantBaseLogic.get_kafka_reverse_proxy_url(
         )
     self.settings["debug"] = True
     self.settings["max_amount_of_offers"] = 10
     self.settings["shipping"] = 2
     self.settings["primeShipping"] = 1
     self.settings["max_req_per_sec"] = 10.0
     self.settings["learning_interval"] = 2.0
     self.settings["data_file"] = None
     self.settings["underprice"] = 0.2
     self.settings["initialProducts"] = 5
     self.settings["min_marketsituations"] = 50
     self.settings[
         "market_situation_csv_path"] = '../data/marketSituation.csv'
     self.settings["buy_offer_csv_path"] = '../data/buyOffer.csv'
     self.settings[
         "initial_merchant_id"] = 'DaywOe3qbtT3C8wBBSV+zBOH55DVz40L6PH1/1p9xCM='
     self.settings["testing_set_csv_path"] = '../data/marketSituation.csv'
     self.settings["output_file"] = '../tmp/out.txt'
     return self
Beispiel #4
0
    def __init__(self, settings, api: ApiAbstraction = None):
        MerchantBaseLogic.__init__(self)

        self.settings = settings
        '''
            Internal state handling
        '''
        self.execQueue = []
        '''
            Information store
        '''
        self.products = {}
        self.offers = {}
        '''
            Predefined API token
        '''
        self.merchant_id = settings["merchant_id"]
        self.merchant_token = settings["merchant_token"]
        '''
            Setup API
        '''
        if api is None:
            self.api = Api(self.merchant_token,
                           self.settings["marketplace_url"],
                           self.settings["producer_url"])
        else:
            self.api = api
Beispiel #5
0
 def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
 def update_settings(self, new_settings):
     MerchantBaseLogic.update_settings(self, new_settings)
     self.update_api_endpoints()
     return self.settings
import argparse
import sys

sys.path.append('./')
sys.path.append('../')
from merchant_sdk import MerchantBaseLogic, MerchantServer
from merchant_sdk.api import PricewarsRequester, MarketplaceApi, ProducerApi
from merchant_sdk.models import Offer
'''
    Template for Ruby deployment to insert defined tokens
'''
merchant_token = "{{API_TOKEN}}"
#merchant_token = 't3LvIwV9wN3pWMBdvysjtoR3zWEV1JLtMgpedLnaiqQFEbs9alsUaLXarl6s5RmQ'

settings = {
    'merchant_id': MerchantBaseLogic.calculate_id(merchant_token),
    'marketplace_url': MerchantBaseLogic.get_marketplace_url(),
    'producer_url': MerchantBaseLogic.get_producer_url(),
    'priceDecrease': 1,
    'intervalMin': 1.0,
    'intervalMax': 1.0,
    'initialProducts': 3,
    'minPriceMargin': 16,
    'maxPriceMargin': 32,
    'shipping': 5,
    'primeShipping': 1,
    'max_req_per_sec': 10,
    'underprice': 0.01,
    'globalProfitMarginForFixPrice': 10
}
Beispiel #8
0
 def with_merchant_token(self, merchant_token: str):
     if merchant_token:
         self.settings["merchant_token"] = merchant_token
         self.settings["merchant_id"] = MerchantBaseLogic.calculate_id(
             merchant_token)
     return self