Stephen Nimmo

Energy Trading, Risk Management and Software Development

Month: September 2012

Hibernate JPA Using Spring Data

Building some template code from the ground up. I have always been a big fan of the DAO crud template ( and have used it for years. But every year or so, I like to take a look around and see if there is something newer, better and something that will allow me to write/manage less code. I think I found it.

The basic concept of the Spring Data JPA implementation is to not have to create the implementation classes at all, which is awesome as with most projects I would end up with a bunch of empty implementation placeholders which actually do nothing except strongly type the interfaces. So let’s start from the JPA annotations.

An Object. DTO? Yeah. Domain object? Could be. You decide. To me, it’s a noun. Unless the underlying database is highly volatile, not owned by me or does not correlate to my object structures (star schema), I’ll use the Hibernate object through the layers.

public class User implements Serializable {

  private Long userUid;

  private String username;
  private String password;
  private String firstName;
  private String lastName;

...getters, setters, equals, hashcode, serial ignored for brevity sake


So there is our User. Notice the @Entity annotation for the class. We have a simple table with userUid as the PK, and 4 other columns. Very simple. Now on to the repository.

public interface UserRepository extends CrudRepository<User, Long> {


Yes. That’s all the code. It’s only an interface. Spring will weave these at runtime and generate implementations for them. Per Spring: “On container start we simply create a proxy instance for the interface which in turn is backed by an implementation of CrudRepository. So it’s only a proxy and some delegation.” How does it do that? You tell it where to look.

<jpa:repositories base-package="com.occupytheserver.demo.jpa.repository" />

Add to your spring xml file. This line traverses that package, looks for everything that extends those interfaces and creates implementations for them. What else do you need? Database connectivity, Hibernate and transaction plumbing.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${hibernate.connection.driver_class}" />
    <property name="url" value="${hibernate.connection.url}" />
    <property name="username" value="${hibernate.connection.username}" />
    <property name="password" value="${hibernate.connection.password}" />
    <property name="defaultAutoCommit" value="true" />

  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="${hibernate.connection.database}" />
        <property name="showSql" value="${hibernate.showSql}" />
        <property name="generateDdl" value="${hibernate.generateDdl}" />


  <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    <property name="jpaDialect">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

And that’s it. Love this implementation.

Dodd Frank Compliance: The Data Challenges of SDRs

As the final rule for market classification definition of the Dodd-Frank Act (DFA) was entered in the Federal Register on May 23, 2012, the triggers for many of the 60-90 day compliance periods are active. This publication has set many DFA initiatives into motion at many different swap market participants, most notably those with new swap data repository (SDR) offerings.

There is some standout language in the rules regarding SDR reporting in particular. As documented in Rule 17 CFR Part 45 Swap Data Recordkeeping and Reporting Requirements:

The NOPR would require SDRs to maintain data and transmit it to the Commission in the format required by the Commission. It would permit an SDR to allow those reporting data to it to use any data standard acceptable to the SDR, so long as the SDR remains able to provide data to the Commission in the Commission’s required format. (p 2139)

Here, the CFTC essentially gives permission to individual SDRs to collect the necessary data using any format they choose, so long as they would be able to provide the data the Commission needs. This means there will be no common protocol, formatting or key data values for transmitting trade data to SDRs, so key information, such as buyer, seller and even the product, may be different across all SDRs.

Many companies with SDR offerings have been publicizing the details of their services for quite some time; however, questions still remain about the entrance of new, potentially very influential players into the market.

What does this mean?

For those companies planning to use SDR extended services through existing client relationships, the changes may be limited to the addition of new DFA-related fields and some refinement of existing data types. Many end users and swap participants may choose to select a single SDR to route all their reporting data. By choosing a single SDR, they are essentially choosing a single protocol, transmission type and format, as well as a single map from their internal data representations of key fields to those values recognized by the specific SDR. These companies will choose the best SDR to fit their current practices, but it is important to note that they will be choosing from an incomplete list, since new SDRs are expected to debut soon.

However, there are companies that will be unable to isolate their SDR to a single vendor. For example, if a company is executing swaps on behalf of clients, its clients may request that the trade be sent to a specific SDR. For these types of companies, implementation now becomes a complicated transformation process based on the destination SDR. These companies will need to map their internal trade representations into what could be four to five different formats (XML, FIXML, FpML, etc.) and have the capabilities to transmit that data using many different ways (Web Services, FTP, sockets, etc.).

Combine this formatting and transmission issue with the possibility of having multiple internal trade capture systems, each with their own internal data representations, across multiple, independent divisions all pushing data to the SDRs, and you could end up with a mapping and translation nightmare.

In addition to the structure and data value mapping requirements, each SDR may also have their own workflow for how data is transmitted. These workflows will differ particularly due to the proliferation of combination messaging – sending a single message to handle both Real Time (RT) and Primary Economic Term (PET) requirements – which would also be SDR-dependent, both in format and workflow.

The world of Dodd-Frank is continually evolving, and companies must be ready to handle the changes fluidly. New SDRs mean new workflows, new data and new systems to maintain. This also means having both business and technical personnel well versed in not only the DFA rules, but also the slough of protocols, trade lifecycle changes and technologies required to implement effectively. As time goes on, we may see a smoothing of this information volatility as implementations go live and everyone involved begins to adjust to the new rules. It is clear that all swap market participants will face new challenges with multiple SDR interfaces and data protocols.


This post originally published:

Dodd Frank Compliance: How will the energy derivatives landscape change?

When the CFTC releases each new Dodd-Frank (DFA) rule, the agency starts with an overview describing the rule’s purpose. To paint the picture, here is a snippet of the CFTC’s overview summarizing the reasoning behind the DFA in its entirety:

“The legislation was enacted to reduce risk, increase transparency, and promote market integrity within the financial system by, among other things: (1) Providing for the registration and comprehensive regulation of swap dealers and major swap participants; (2) imposing clearing and trade execution requirements on standardized derivatives products; (3) creating robust recordkeeping and real-time reporting regimes; and (4) enhancing the Commission’s rulemaking and enforcement authorities with respect to, among others, all registered entities and intermediaries subject to the Commission’s oversight.”

While each of the CFTC’s four main DFA principles are important, the clearing and trade execution requirements on standardized derivatives products will be the biggest game-changer for all derivatives trading participants. While most energy market participants are trying to figure out how they will register with the CFTC, what an SDR is, or whether their current ETRM system is able to magically solve their Dodd-Frank problems, they may be ignoring the most important question.

How will our trading activity change after Dodd-Frank? This question may be difficult to answer completely.
We know the first general rule of Dodd-Frank is that swaps that can be cleared should be cleared. Where many swaps can be standardized, thus homogenized across platforms, swaps will move into a cleared model, transferring counterparty credit risk into the clearing houses. By moving the risk away from the counterparties involved in the transaction, this change will reduce the amount of systemic risk – and pain – that would occur if an entity files for bankruptcy.

But along with this benefit comes the cost of trading cleared versus uncleared transactions. For some trading activity, the additional costs of clearing the trade may make certain profitable trades unprofitable, reduce liquidity in the market, widening the bid/ask spread. For some entities, moving to a cleared model simply means a higher cost of doing business, and these additional costs will trickle down to the consumer or even create more uncertainty if margining becomes too expensive and the participant chooses to do nothing.

The second general rule of Dodd-Frank is that transactions that can be executed electronically should be executed electronically. This change is still blurry, as we have not yet seen the entrance of new swap execution facilities (SEFs). These new entities are designed to be electronic marketplaces for swaps, moving much of the bilateral swap trading activities into central locations for greater price transparency and access. Essentially, for certain swap trading venues with enough liquidity, the SEFs will be able to register as an execution facility for the product and begin to allow trade executions. These SEFs will play a critical role in swaps trading, where open interest, bid-ask spreads and volumes will add to pricing and transaction data quality.

Finally, another thing to keep in mind is if swaps can neither be cleared nor executed on a swap execution facility because a SEF or clearing house does not exist for that instrument, then the onus for margining and swap data repository (SDR) reporting is on the transaction participants themselves; thus, creating the large resource investment in Dodd-Frank compliance implementation. Whether a swaps end-user or swaps dealer, few appear ready for this paradigm shift in trading and regulatory reporting.

Ultimately, how will these changes affect energy market participants? Consider these changes on the horizon that will affect the ways companies engage in trading activities:

  1. Moving from credit-risk-heavy bilateral trading will cause additional capital requirements for organizations to meet margin requirements.
  2. Companies will need complex, near-real-time analytics and tools to evaluate and monitor counterparty margin requirements.
  3. Voice brokered financial swaps will move exclusively to SEFs.
  4. Proliferation of execution platforms will mean a need for additional electronic connectivity from market participants wanting to engage in certain trading activities.
  5. An explosion of market data from SEFs for price discovery, valuation and risk will prove valuable if managed effectively.
  6. Any trading activities which heavily utilized bilateral swap trading will need organizational review of how they should continue within the new market structure.

It is clear that the energy derivatives trading landscape will be drastically altered as Dodd-Frank continues to force more and more change across the industry. Anticipating these changes and making the right decisions and investments today will help energy market participants to prepare for a competitive tomorrow.

Originally published on Derivsource.

© 2017 Stephen Nimmo

Theme by Anders NorenUp ↑