Morgan Stanley HFT Overhaul

TheTradeNews.com reports that Morgan Stanley’s HFT software re-write is promising:

“This is the first time we’ve done a full re-write of our equity trading infrastructure – it’s brand new software running on brand new hardware, and we’ve specifically brought in expertise from low latency trading firms to achieve this”

Leave a comment

Filed under Finance, Programming

Clean Code cheat sheet

This Clean Code cheat sheet was posted on LinkedIn. I’m guessing it’s a summary of “Clean Code” by Robert Martin.

Leave a comment

Filed under Programming

Book Review: The Governor’s Wife, Mark Gimenez

GovernorsWife

Initially, I was concerned that this book was going to be a bit dull – it starts with a lot of scene setting about American politics and there’s much coverage of the history/geography of the border with Mexico. Having read the book, I totally forgive the author for spending the time to introduce the reader to these matters – it brings realism to the motivations and main characters: the Governor, the Mexican doctor and the bandit (El Diablo). Interesting that the title is The Governor’s Wife – she’s the focal point of the plot, but not necessarily involved in much of the story line.

It’s a terrific book. The action sequence at the end that brings together the three male protaganists is on a par with Lee Child’s Jack Reacher series, yet his handling of the journey taken by the Governor and his change of outlook is sensitively written. He gives great colour to even minor roles – if a film is made of this book, I bet many stars will covet the role of the political advisor to the Governor.

Definitely worth reading – I’m looking forward to another by Mark Gimenez.

FiveStars

Leave a comment

Filed under Book Review

Herb Sutter GotW91: Smart Pointer parameters

Herb Sutter’s guidelines on passing smart pointers as parameters include the following:

  • Copying smart pointers incurs two performance hits:
    • Cost of increment and decrement on the internally synchronised reference count
    • Scalability woes due to cache contention on the shared reference count
  • Passing a shared_ptr by value implies taking shared ownership. A copy is needed anyway, so incurring copying cost is fine.
  • Don’t use a const smart_ptr& parameter because it exposes the function to the caller’s lifetime management policy. Use a Widget* instead.

Guideline: Don’t pass a smart pointer as a function parameter unless you want to use or manipulate the smart pointer itself, such as to share or transfer ownership.

Guideline: Prefer passing objects by value, *, or &, not by smart pointer.

Leave a comment

Filed under C++, Programming

Herb Sutter GotW89: Smart Pointers

Herb Sutter’s GotW89 Smart Pointers post includes good reasons to use make_shared/make_unique instead of naked new. Avoiding memory fragmentation is one of those:

Separate allocation

auto sp1 = shared_ptr<Widget>{ new widget{} };
auto sp2 = sp1;

Separate allocation

Single allocation
If you use make_shared to allocate the object and the shared_ptr all in one go, then the implementation can fold them together in a single allocation.

auto sp1 = make_shared<Widget>();
auto sp2 = sp1;

Single allocation

Leave a comment

Filed under C++, Programming

Fake Tweet causes Dow Jones to drop 1%

TheTradeNew.com reports on a mini-crash last month:

Shortly after 1pm on Tuesday 23 April, a tweet from the verified Twitter account of US newswire Associated Press stated explosions at the White House had injured President Obama. Within minutes, the markets had bottomed out, with the Dow Jones Industrial Average sliding 145 points, or 1%, before rebalancing pre-drop, four minutes later.

These days, even Tweets and blog posts may be polled for market sensitive content in order to inform trading strategies:

Automated news reading services scan web-based news sources and social media for breaking news relevant to markets and specific securities. This can be fed via an application program interface (API), to a trading algorithm, which may act as a circuit breaker to stop trading or accelerate participation in a certain stock depending on the news.

Leave a comment

Filed under Finance

decltype and declval

Good examples of decltype and declval posted on reddit and TheNewCpp.com.

Leave a comment

Filed under C++, Programming

How to choose whether to pass by const-reference or by value

There was a post on the ISOCpp blog last week about passing by const-reference or by value. The full StackOverflow post is Why do we copy then move? and another related post asks Are the days of passing by const ref over?.

First, as my friend and colleague Andy Sawyer pointed out in a conversation, taking a parameter by value leaks implementation detail out of the function so he recommends passing by const reference unless there’s a good reason not to.

Second, whilst passing by value presents the opportunity for the callee to store data using move semantics, the callee has to invoke that explicitly by calling std::move:


#include <string>
#include <iostream>

class A
{
public:
 A( const std::string& s ) :
 str_( s )
 {
   std::cout << "A: s='" << s << "', str_='" << str_ << "'\n";
 }
private:
 std::string str_;
};

class B
{
public:
 B( std::string s ) :
 str_( s )
 {
   std::cout << "B: s='" << s << "', str_='" << str_ << "'\n";
 }
private:
 std::string str_;
};

class C
{
public:
 C( std::string s ) :
 str_( std::move(s) )
 {
std::cout << "C: s='" << s << "', str_='" << str_ << "'\n";
 }
private:
 std::string str_;
};


int _tmain(int argc, _TCHAR* argv[])
{
 A a( "ConstReference" ); // Constructor(char*) then CopyConstructor
 B b( "PassByValue" ); // Constructor(char*) then CopyConstructor
 C c( "PassByValueAndMove" );// Constructor(char*) then MoveConstructor

return 0;
}

PassByValueAndMove

2 Comments

Filed under C++, C++ Code, Programming

Herb Sutter GotW6: Const and Mutable

This item covers ground Herb already presented in this video. He recommends that const member functions must be one of:

  • truly physically/bitwise const with respect to this object
  • internally synchronized so that if it does perform any actual writes to the object’s data, that data is correctly protected with a mutex or equivalent (or if appropriate are atomic) so that any possible concurrent non-const accesses by multiple callers can’t tell the difference.

Similarly, he asserts that the guidelines taught for C++98, that const means logically const but you had a free rein with internal data, is no longer true for C++11 with its memory model and thread safety specification.

This implies stricter best practice on use of mutable member variables. Any time you need to mutate data in a const member function, you should protect it with a synchronisation object to ensure thread safety.

Leave a comment

Filed under C++, Programming

Book Review: Persuader, Lee Child

Persuader, Lee ChildThe first Jack Reacher thriller I read was One Shot. It came free with a copy of the London Evening Standard. That’s when the Standard cost 50p, before it became a free paper. On the back of that, I went on to read all the Jack Reacher stories – and One Shot wasn’t even the best. The best stories are those in which he gets members from his team of Special Investigators back together.

Persuader is one of the stories in which Reacher hooks up with a team – in this case, some government agents. Reacher gets a second chance to take revenge on an old adversary, whilst helping the agents to crack a gang of suspected smugglers.

Why is Reacher such a compelling character? He’s incredibly violent yet he’s smart too – like a cross between Jean Claude van Damme and Sherlock Holmes. He shuns convention – no fixed abode, he wanders wherever fate takes him, without any care for material goods (except the ever-present folding toothbrush). He stays true to his own code of Justice. Once committed to a cause, he never backs off. Men respect him, women flock to him. What’s not to like?!

Four stars

Leave a comment

Filed under Book Review