def setUp(self): self.longMessage = True # Print complete error message on failure self.maxDiff = None # View the complete diff when there is a mismatch in a test self.interface = TransactionsInterface(environment=ENVIRONMENT) self.asset_manager_id = 1 self.assets_interface = AssetsInterface(environment=ENVIRONMENT) self.books_interface = BooksInterface(environment=ENVIRONMENT) self.asset = generate_asset(asset_manager_id=self.asset_manager_id, fungible=True) self.asset_book = generate_book(asset_manager_id=self.asset_manager_id) self.counterparty_book = generate_book(asset_manager_id=self.asset_manager_id) self.transaction1 = generate_transaction(asset_manager_id=self.asset_manager_id, asset_id=self.asset.asset_id, asset_book_id=self.asset_book.book_id, counterparty_book_id=self.counterparty_book.book_id, transaction_currency='USD', net_affecting_charges=True, charge_currency='USD') self.transaction2 = generate_transaction(asset_manager_id=self.asset_manager_id, asset_id=self.asset.asset_id, asset_book_id=self.asset_book.book_id, counterparty_book_id=self.counterparty_book.book_id, transaction_currency='USD', net_affecting_charges=True, charge_currency='USD') self.setup_cache() self.interface.new(self.transaction1) self.interface.new(self.transaction2) self.transaction_id1 = self.transaction1.transaction_id self.transaction_id2 = self.transaction2.transaction_id
def setUp(self): self.longMessage = True # Print complete error message on failure self.maxDiff = None # View the complete diff when there is a mismatch in a test self.interface = TransactionsInterface(environment=ENVIRONMENT) self.assets_interface = AssetsInterface(environment=ENVIRONMENT) self.books_interface = BooksInterface(environment=ENVIRONMENT) self.asset_manager_id = random.randint(1, 2**31 - 1) self.asset = generate_asset(asset_manager_id=self.asset_manager_id, fungible=True) self.trader_one_book = generate_book( asset_manager_id=self.asset_manager_id) self.trader_two_book = generate_book( asset_manager_id=self.asset_manager_id) self.wash_book = generate_book(asset_manager_id=self.asset_manager_id) self.setup_cache()
def setUp(self): self.longMessage = True # Print complete error message on failure self.maxDiff = None # View the complete diff when there is a mismatch in a test self.asset_manager_id = random.randint(1, 2**31 - 1) self.assets_interface = AssetsInterface(environment=ENVIRONMENT) self.books_interface = BooksInterface(environment=ENVIRONMENT) self.asset = generate_asset(asset_manager_id=self.asset_manager_id) self.asset_book = generate_book(asset_manager_id=self.asset_manager_id) self.counterparty_book = generate_book( asset_manager_id=self.asset_manager_id) self.transaction = generate_transaction( asset_manager_id=self.asset_manager_id, asset_id=self.asset.asset_id, asset_book_id=self.asset_book.book_id, counterparty_book_id=self.counterparty_book.book_id) self.transaction_id = self.transaction.transaction_id self.setup_cache()
def interface_direct_class(data_class): """help to direct to the correct interface interacting with DB by class name only""" if data_class in ASSET: interface = AssetsInterface() elif data_class in PARTY: interface = PartiesInterface() elif data_class in BOOK: interface = BooksInterface() elif data_class in CORPORATE_ACTION: interface = CorporateActionsInterface() elif data_class in MARKET_DATA: interface = MarketDataInterface() elif data_class in TRANSACTION: interface = TransactionsInterface() else: interface = AssetManagersInterface() return interface
def _import_book(asset_manager_id, rowdata): rowdata = {to_snake_case(key): value for key, value in rowdata.items()} if not rowdata.get('book_id'): return mapped_fields = [{ mapped_field: rowdata.pop(field) } for field, mapped_field in BOOK_FIELD_MAPPINGS.items()] [rowdata.update(field) for field in mapped_fields] book = Book(**rowdata) book_api = BooksInterface(environment=ENVIRONMENT) existing_book = book_api.search(asset_manager_id=asset_manager_id, book_ids=[book.book_id]) if not existing_book: book_api.new(book) else: book_api.amend(book) return book
from amaascore.assets.bond import BondGovernment from amaascore.assets.interface import AssetsInterface from amaascore.books.book import Book from amaascore.books.interface import BooksInterface from amaascore.core.reference import Reference from amaascore.parties.broker import Broker from amaascore.parties.company import Company from amaascore.parties.interface import PartiesInterface from amaascore.transactions.interface import TransactionsInterface from amaascore.transactions.transaction import Transaction logging.config.dictConfig(DEFAULT_LOGGING) # Create the interfaces assets_interface = AssetsInterface() books_interface = BooksInterface() parties_interface = PartiesInterface() transaction_interface = TransactionsInterface() def create_jgb(asset_manager_id): jgb_symbol = 'JB355' jgb_references = { 'ISIN': Reference(reference_value='JP1234567890'), 'Ticker': Reference(reference_value=jgb_symbol) } jgb = BondGovernment(asset_manager_id=asset_manager_id, asset_id=jgb_symbol, currency='JPY', references=jgb_references,
def setUpClass(cls): cls.books_interface = BooksInterface(environment=ENVIRONMENT) cls.asset_manager_id = random.randint(1, 2**31 - 1)
def setUpClass(cls): cls.books_interface = BooksInterface() cls.asset_manager_id = random.randint(1, 2**31 - 1)