anonymous classes — usage

* Usage: GUI. Event handlers and listeners
* Usage: threads.
* Spring callbacks in templates
(See other posts on sample codes for both.)

anonymous static and non-static classes are routinely used inside static/non-static methods to create a thread and start it.

–> concurrency developers had better get thoroughly familiar with the basic rules of anon classes

career planning – next 5Y c2010

update… I feel if last job is a small no-name company (without a much higher salary), then it would affect my “image” for next job search.

See also post in 610610 http://tigertanbin610610.blogspot.com/2013/12/strategic-directions-2014.html
———–
Hi,

Over the next 5 years, though i want to stay in a big bank for many years, circumstances might force me to change job every 1-2 years. Aiming to grow stronger in 3 areas.

Brank) leadership job title in big banks — a door opener and a little halo. When job market declines, employers have too many candidates, they prefer known brands.

T) keep my technical skills relevant — I realize every time I change job, technical skill requirement is always (at least one of) the biggest factor. A lot of tech interviews and quizzes are non-trivial[1]. If we stop doing hands-on work with current technology, we will weaken and become obsolete.

F) mainstream financial domain knowledge esp. security trading. This would open up a lot of high-worth job opportunities. They are not open to me now due to my limited mainstream financial experience. Maybe i
don’t need such a job — i can read up and pretend to have, say, risk analytic experience?

For my next (2? 3?) job searches in the next 5 years, I’m unlikely to apply to PM or business analyst roles. Technical is my strength.

[1] Rarely do i get an easy tech interview on wall street.

lab49 iview

reentrant locks?

classloader hierarchy?

what's the challenge when notifyAll wakes up all the waiting threads?

why do we want to consider a synchronized block rather than a method?

why do we need primitive types when we have the wrapper classes?

synchronized static init block@@

I vaguely remember a static init block can have “synchronized”. I guess 2 threads might (in theory) run the block concurrently.

But each classloader (and all its ancestors) can only load a class once, so i guess the 2 threads will load the same class into separate class loaders that aren’t in parent-child@@

hidden this._target field in a delegate Instance

As stated else where on this blog, an “item” in a delegate inv list holds nothing but 2 pointer fields.
http://www.ikriv.com/en/prog/info/dotnet/Delegates.html sheds light on one of them —

Internally an “item” stores its target in a private field named _target.

Normally, public property Target just returns a value of _target. For static delegates though, _target contains a reference to the delegate instance itself. “Get” accessor of Target makes a quick check, and if _target references a delegate Instance (likely to be itself), returns null.

3 ways to instantiate the same c# delegate Type

In c++ or java, you can instantiate a class Animal many ways, like
Animal myCat; // exactly like declaring an int variable
Animal myCat(2); //age
Animal* myCat = new Animal(“kit”);

C# delegate is more complicated. http://www.yoda.arachsys.com/csharp/events.html has a concise list of about 5 different ways to Instantiate a delegate Type. Extremely insightful. Among other things, it reveals that in the instance method case the delegate Instance must “remember” the target

public delegate string FirstDelegate (int x); // type declaration.
 
// The following two creation expressions are equivalent,
// where InstanceMethod is an instance method in the class
// containing the creation expression (or a base class).
// The target is "this".
FirstDelegate d1 = new FirstDelegate(InstanceMethod);
FirstDelegate d2 = new FirstDelegate(this.InstanceMethod);

// Here we create a delegate instance referring to the same method
// as the first two examples, but with a different target.
FirstDelegate d3 = new FirstDelegate(anotherInstance.InstanceMethod);

// This delegate instance uses an instance method in a different class (and 
// obviously different target),
// specifying the target to call the method on
FirstDelegate d4 = new FirstDelegate(instanceOfOtherClass.OtherInstanceMethod);

// This delegate instance uses a static method in host class containing
// the creation expression (or a base class). Target is NULL for ALL static
FirstDelegate d5 = new FirstDelegate(StaticMethod);

// This delegate instance uses a static method in a different class
FirstDelegate d6 = new FirstDelegate(OtherClass.OtherStaticMethod);

how citi stays on top in munis

Other underwriters do try but can’t catch up with the leader.

–IPO market
When an underwriter gets a deal, they travel around the country to collect bids. Citi muni has a good distribution network (remember Global Transaction Service?) reaching out to hedge funds, pension funds, mutual funds etc.

citi often joins a syndicate to share the risk and share the profit. I guess the gorilla often influence the terms and enjoys the best margin.

muni issuers always call citi first – the market leader.

— secondary market
any muni salesforce need a lot of small “local” licenses to sell muni bonds in each local market. I guess it’s due to the tax implications. It takes a lot of effort to get those local licenses.

simplified ATM call/put valuation(mental arithmetic

Develop a mental valuation for ATM European call/put assuming 0 dividend/interest rate with 1 year TTL. (Note put and call have identical valuation in this context.)

if σai (annualized implied volatility) = 100%, then valuation/spot = 1/ =~ 0.4
if σai = 50%, then valuation/spot = 0.5 /   =~= 0.2. In other words, “leverage” is proportional to σai.

More generally, leverage is proportional to maturity-adjusted volatility. For example, 100 vol but 3 mth TTL, leverage is same as 50 vol 12 month.

Now the quick mental calc —
$1 spot = strike, 100% σai, 1 year, val = 0.4. This is the reference level.
50% σai, 1 year, val = reference * 50% = 0.2
100% σai, 3 month, val = reference * 3/12 = 0.2
80% σai, 3 month, val = reference * 0.8 * 3/12 = 0.16. (80% σai =~ 5% daily vol)

gamma measures non-linearity of curve – valuation-vs-spot

(Similar indications —
  risk-reversals quote measures skewness of smile curve
  strangle quote measures convexity of smile curve
)

Very roughly, gamma is an indication of the non-linearity of an instrument’s valuation wrt underlier price. All linear instruments have 0 gamma. Every security in the world including cash has non-zero delta. Zero delta is meaningless.

Sound bytes —

Short put/call have negative gamma.
Long put/call have positive gamma, i.e. at higher[1] spot, call delta gets more positive and put delta gets Less Negative.
* Further, at the same strike/TTL, call vs put share identical gamma. Reason is simple — their deltas in absolute terms add up to 100%

[1] let’s avoid “growing” or “increasing” as these words imply variation over time .

CMS garbabe collector "losing the race"

Apt metaphor — losing the race

Think of a hare (promotions) chasing the tortoise (CMS). If the promotion rate exceeds the “release rate” for too long, oldgen occupancy will grow too high. If it grows to 100% (catching up), then the CMS collector loses the race — a full STW collection is inevitable. You lose the benefit of the low-pause concurrent collector, and get the worst case scenario — longest pause.

By the way, The STW collection is a sliding compaction — see other posts in this blog.

As soon as the CMS notices the race is on (promotion rate, occupancy etc) it starts the collection cycle, hoping to keep ahead of the rival.

boost weak_ptr can access inner ptr only through a shared_ptr

Unlike shared_ptr, scoped_ptr and auto_ptr, a boost weak_ptr doesn’t overload operator-} and operator*. Ditto for std::weak_ptr.

There’s an important implication.[2]

“If I want to veto deletion of internal ptr, then I must join the club, i.e. the club must register me as –veto– member”.

As a passive observer, weak_ptr is helpless to prevent the internal pointer’s demise. There’s an important implication again [3].

[2] No direct means to get the raw pointer from a weak_ptr. You must create and go through a shared_ptr, either this->lock() or shared_ptr conversion ctor.  I feel a weak_ptr instance is an observer using a shared_ptr instance as a lens.

[3] User of weak_ptr can’t reliably use the referenced resource, since the resource could disappear any time.

Crucially, a std::weak_ptr can be empty, as explained on P96 [[std c++lib]]. We can detect weak_ptr emptiness when the inner ptr is deleted. In contrast, raw ptr doesn’t offer this feature — if the underlying heap object is reclaimed, the raw ptr becomes dangling and we have absolutely no way to detect that, according to my friend Paul M.

[13]pthreads dominates in linux #jvm

See also post on c^c++ threading libraries.

— (3.0 kernel, c2013) [[Linux system programming ]] P226 points out

  • “Pthreads remains the predominant threading solution for both C __and__ C++ on unix systems”
    • ** not just C
    • ** not just linux
    • ** “Even if you use a different threading solution, … most of them are built on top of Pthreads”
  • * in linux, pthreads is “provided by” glibc — the main C library — but is in a separate library libpthread (not “libpthreadS”)
  • * the linux pthreads implementation could create “thousands of threads in a single process without slowdown”
  • http://stackoverflow.com/questions/15367988/is-it-safe-to-mix-pthread-h-and-c11-standard-library-threading-features shows c++11 thread constructs use underlying thread support in the OS. On linux, the underlying is pthreads. 

swig vs javah, briefly

In the JNI world,

A “native method” (NM) is basically the skeleton one-liner method prototype in a *.java source file. Related to it …
a “native Function” (NF) is a special C function implemented using the JNI types (included from jni.h + jni_md.h) and conforming to JNI standard.

This native function is often a wrapper over an Existing Function (EF) written in unconstrained C and has the real business logic.

SWIG will wrap C++ EF, whereas javah command takes NM and creates C/C++ NF but in the form of a forward declaration (a.k.a. prototype). Based on that NF you then implement business logic.

Swig starts from C++ EF; javah start from NM.

Swig generates a lot of layers (the “entire stack”) — including pure C++ wrapper classes all the way to java proxy classes and anything (if any) in between. In contrast, javah generates just one of the layers (see above.)

allocator,less,vptr — (template|class|insance)-level

Case 1) First, let’s look at a similar situation — the vtbl is at the CLASS-level, not the instance-level. Each CLASS in the inheritance hierarchy has a vtbl, and each INSTANCE’s real-estate has 32-bit for a vptr seated to this vtbl.

Case 2) Let’s turn to allocators. Look at template declaration of vector.

Q: Why is allocator a template parameter and not a constructor parameter?
A:
* each concretized vector *class* probably has a pointer to an allocator — your custom allocator.
* each vector *instance* probably has fields for the size, the capacity etc. However, the allocator is shared by all the instances of the concrete class.

Q2: Can we make the allocator a static field?
A2: No. I feel allocator is “one allocator per template specialization”, but for a static field it’s “one object across ALL template specializationSSS”.

In this story we see various utility objects belonging to 3 levels of abstraction
* feature common for a generic, unconcretized template, across all concretized classes.
* feature unique to a particular concretized class
* feature unique to an instance of the class

The per-concretized-class level is the most abstract, so here’s another concrete example —
Case 3) The element comparison function is another “thing” at the class level. For a sorted map, each “concrete type-argument” (that you plug into the template) has its own comparator. (Java has a clean solution, but) In STL, a concrete comparator is supplied at the class level, and can’t be at the generic template level as a static field. When I concretize the map for Account objects, i choose a concrete comparator for my concretized class.

vptr is a const non-static field – (slicing, casting)

When you “cast” a c++ or java POINTER[1] up and down family tree, the vptr field of the pointee persistently points to the “most derived” vtbl. To fully appreciate the constness of the vptr, consider slicing —

Q: during slicing, how does vptr end up pointing to the base vtbl?
A: copy constructor of the base object will be used, which (blindly) initializes vptr with the base object’s vtbl.

Background — vtbl is an array of func pointers. One vtbl per CLASS, but —

Q: Is there any compiler where superclass’s and subclass’s vtbl share the same address?
A: Won’t work. When slicing, the trim-down object’s vptr must NOT point to original vtbl. Trim-down object can never access derived class methods.
A: but what if a subclass overrides no method? Probably will share the vtbl with super class?

vptr is like a non-static const field. In the non-slicing scenario, The magic of polymorphism depends on the “vptr still pointing to subclass vtbl even if object is accessed by a base ptr”.

A twist on the constness — After this->vptr is initialized in the base ctor, it gets reseated during subclass ctor. During destruction, this->vptr gets reseated during Base dtor. This knowledge is relevant only if base ctor/dtor calls virtual methods.

[1] nonref won’t work.

java reference-type volatile #partially constructed

Most volatile fields I know are primitive. What’s the usage of reference type volatiles? http://www.ibm.com/developerworks/java/library/j-jtp06197.html has several examples. One is on partial object.

“Without the theFlooble reference being volatile, the code in doWork() would be at risk for seeing a partially constructed Flooble as it dereferences the theFlooble reference.”

I think JVM guarantees to finish object instantiation and save the pointer in the volatile field in one atomic step, so another thread reading (dereferencing) this volatile reference will never see a partial object? Now I feel without volatile, reader can *see* stale image of an “under-construction” state of the object like a half-built mosque, even though by now the writer has finished construction on the heap.

Partial-object breaks double-check locking. See P 86 [[java threads]]. 2nd thread may see foo != null when the foo object is partially constructed.

4 ways to set jni search path

1) On all platforms, -Djava.library.path is all you need. But if you can’t modify the java command line, then there are a few alternatives

On *nix,
2) $LD_LIBRARY_PATH can include the directory of your libYourFile.so

On windows,
3a) if YourFile.dll is in the current directory, then it will be automatically  picked up

3b) otherwise, include its folder in %PATH%, which typically includes ….\bin folders and not …\lib, so be prepared

See P 17[[ JNI ]], which is on http://java.sun.com/docs/books/jni/html/start.html

workhorse methods of JTable + TableModel + TableColumnModel

Sooner or later you need to internalize these –

———–JT
set/getValueAt() — in both JT/TM, but different behavior

–editor/renderer
TableCellRenderer getCellRenderer(int row, int column)
int getEditingColumn/Row(void) — If nothing is being edited, returns -1
Component getEditorComponent(void) — If nothing is being edited, returns null

–related to table columns
getColumnCount() — JT/TCM identical, covering the View columns
TableColumnModel getColumnModel() — don’t use the createDefaultTableModel()

—less important ones
int getSelectedColumn/Row(void) Returns the index of the first selected column/row, -1 if no column is selected.
int[] getSelectedColumns/Rows() Returns the indices of all selected columns/rows.
convert[Column|Row]IndexToModel (int viewIndex)
convert[Column|Row]IndexToView (int modelIndex)

———–TM
getColumnCount() — different from the JT version. Covers the Model columns
set/getValueAt() — in both JT/TM, but different behavior
boolean isCellEditable(int, int)
addTableModelListener()

———–TCM
getColumn(int columnIndex)
getColumnCount() – JT/TCM identical
getColumnIndex(Object columnIdentifier)
removeColumn(TableColumn aColumn) — JT/TCM identical
moveColumn(int column, int targetColumn) — JT/TCM identical
addColumn(TableColumn aColumn) — JT/TCM similar

JComponent repaint(), validate(), pack(), realization and UI delegates

See below for other people’s definitions, but
– I think validation means a re-layout of children within a container pane. Required after changes therein. See javadoc.
– I think pack() compacts a container to the minimum size needed to display all children according to their preferred size. It has an important side effect of realizing the host JComponent.
– Repaint() is more common but underlying paint() operation is a low-level (more native), physical operation that takes care of the nitty gritty of displaying a jcomponent via its LAF UI delegate.
– I guess realization means isDisplayable? Note UI delegate objects are instantiated much earlier. [1]

[1] If you do a new JLabel() first thing in main(), and put a breakpoint on ComponentUI.java ctor, you will see that UI delegate objects are instantiated well before setVisible.

JComponent.paint(Graphic) is so sacred that it is EDT-only. Repaint() is usable from any thread, to schedule paint() on EDT.

“The validate method is used to cause a container to lay out its subcomponents again.” When changing container’s content, you have to call *both* (in either order)

* revalidate()
* repaint() to request a repaint for this container

“The following JComponent instance methods are safe to call from any thread: repaint(), revalidate(), and invalidate(). The repaint() and revalidate() methods queue requests for the event-dispatching thread to call paint() and validate(), respectively. The invalidate() method just marks the host component and all of its direct ancestors as requiring validation.”

Pack-and-show is a common idiom. JFrame.pack() is one of the birth methods whereby all child components become realized, whether hidden or visible. JFrame.show() and JFrame.setVisible() actually make them visible. These 2 methods are birth methods too as they makes subcomponents realized and visible. I think pain() is an underlying birth method but is invoked only from other birth methods.

http://java.sun.com/products/jfc/tsc/articles/painting/#background is a detailed article on painting

q[new]+dynamic_cast exceptions quick guide

Seldom asked in IV, but …

Tip — dynamic_cast and new() used to behave similarly, but nowadays new() fails differently by default.

Q0: Both new and dynamic_cast normally returns a …. Yes a …. p o i n t e r

Q1: Failed dynamic_cast<someType &> returns ….
Q2: Failed dynamic_cast<someType * > returns ….
Q3: Failed boost polymorphic_cast returns ….
Q5: Failed “new” returns … in the past?
Q6: Failed “new” returns … nowadays?
Q6b: how do you change that behavior?

A1: never returns! Bomb out with std::bad_cast. Reference can’t be null in c++.
A2: 0 ie null ptr
A3: same as A1 — consistent for both ref and ptr
A5: 0 ie null ptr
A6: never returns! Bomb out with std::bad_alloc
A6b: new (nothrow) …

synthetic put – in real world Put valuation

http://25yearsofprogramming.com/blog/20070412.htm says

To use the Black-Scholes formula for put options you must incorporate a routine to calculate the price of an equivalent “synthetic put”, which involves

    selling the stock short and buying a call option on it.

Because this can be less expensive than buying a put option, the prices of real puts are driven DOWN to the values of their equivalent synthetic puts. Without the synthetic put calculation, the Black-Scholes formula produces a higher theoretical valuation and makes all traded puts appear undervalued.

implicit interactions – casts && converters FROM nonref

Most casts operate on ref/ptr without creating objects[2], but most conversions happen on objects and nonref variables.Casting between unrelated ptr (or ref), where dynamic_cast and const_cast are irrelevant, is complicated and rare.

In this post, we focus on converting/casting FROM a nonref, either to a nonref or a pointer. dynamic_cast becomes irrelevant. Our tools are 1)static_cast 2)C-style cast, 3)implicit cast 4)explicit cvctor, 5)explicit OOC.

Conversions are notoriously implicit. One improvement is static_cast, which (still implicitly) invokes the conversion operations. Suppose we convert an object of Class S to an object of Class T. Either T has a cvctor (conversion ctor) or S has a OOC. I found some relevant coverage in the ARM —
static_cast can call OOC? yes
static_cast can call cvctor? yes. Also see http://www.cplusplus.com/doc/tutorial/typecasting/
static_cast can also call copy ctor – P70 effC++

assignment can call OOC? yes
assignment can call cvctor? probably yes to generate a temporary object

S s; T t;
t = s;

— nonref variable initialization by definition creates new objects
nonref variable initialization calls ooc? Y
nonref variable initialization calls cvctor? Y

pbclone implicitly calls ooc? Y
pbclone implicitly calls cvctor? Y

pbref calls ooc? illegal. won’t compile
pbref calls cvctor? illegal

Note in this more ugly cast expression, only OOC is usable:
MyClass::operator const char* () const{….}

[2] see post on casting-creating-new-pointer

double-checked locking and 3-step constructor re-ordering

I feel one reason why the DCL is broken relates to the 3-step process in “k = new Child()”. In c++, new (delete is similarly 2-stepper) is a 3-stepper — allocation + initialization + pointer assignment. JVM is written in c++, so probably same process —

1) allocate — new address for the new born Child
A) address saves to the 4-byte pointer k. Note the actual “store” operation (ie flush to main memory) may be delayed, but ironically not in this case — When you don’t want it delayed, it may; when you want it delayed it may not … Sigh.
B) initialize the memory cells of Child

Now the surprise — Steps A and B could be reordered by compiler. What if address assignment happens before initialization? Creator thread is in the critical section, between Steps A and B, but 2nd thread outside the critical section already sees A’s effect, believing the entire 3-stepper completed!

You may think Steps A and B are very very adjacent, but no no no. In a 128-processor machine with 100 threads on each, a lot of (mostly bad) things can happen when creator thread is pushed to end of the run queue.

poll^interrupt: 2ways to cancel threads]any lang

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#stop() officially recommends these 2 ways, echoed by [[java threads]]

“Many uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running. The target thread should check this variable regularly, and return from its run method in an orderly fashion if the variable indicates that it is to stop running. If the target thread waits for long periods (on a condition variable, for example), the interrupt method should be used to interrupt the wait.”

Unix signal is conceptually similar to interrupt.

 

verizon iview questions

Q: 5000 simultaneous requests? (Now i think fios sscfi need that capacity.)
A: on the IO side, consider NIO — multiplexing?
A: executor thread pool may help.
A: For request processing, use a queue at each interface, just like Zed.
A: According to Anthony, most trading systems are queue based.
A: how about Catcha.com? horizontal scaling. http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rprf_queuetip.html has pictures.
 
 
diff btw arraylist and vector

if 5 connections opened, how do u get them closed before garbage collection

if u need to read disk, how to ensure uniform seek time?

diff btw string and stringbuffer

reentrant means?

how does class loading work?

how do u implement lazy loading?

Runnable vs Thread?

business risks of a credit trading desk

See also CFA Reading 63

* credit default risk
* credit rating risk — credit rating of the issuer may drop, leading to a lower valuation
** if you short a bond but its credit rating improves, you short position devalues and you suffer an unrealized loss
* interest rate risk — rising IR hurting long positions; falling IR hurting short positions.
* volatility risk. I think if volatility decreases, option (call/put) valuation drops on your book.
* currency risk
* other market factors that lead to a deterioration in valuation. I feel interest rate and credit are the 2 root causes. Any other factors?

"this" as implicit arg to non-static c++ methods

Compiler adds an implicit param to each non-static method. Note in both java and c++, non-static method invocation absolutely[2] needs a receiving object ie the “this” pointer. C++ merely add that pointer as the implicit argument. In the example below, the object handle [3] is passed as argument to the method as if (suppose j1 is an instance of class J)

m(this, other_args) — binds to –> m(J*, other_params)

Runtime parameter passing mechanism includes an implicit pbref

J* this_ptr = & j1;

Since constness radiates left, a const j1 (RHS) requires the param (LHS) declared const. You can mark the method m() const. It’s interpreted as

m(J const *, other_params), so now the method call does a pbref

J const * this_ptr = & j1;

In conclusion —- you can use a non-const “handle”[3] to invoke a const method.

[2] There’s simply no exception. A non-static method invocation is a message, and needs an recipient object.
[3] handle can be a ptr, a reference, or a nonref variable

template struct J{
	J(T & rhs){}
	void m(T a) {
	  this->intVar = a; // legal when method is const but no one calls.
	}
	T intVar;
};
int main()
{
	int a=22;
	const J j1(a);
	j1.m(89);
	return 0;
}

2 ways to improve current income in your T-bond porfolio

Suppose your Treasury portfolio (safest investment) is yielding too low.

Technique level 1 — generally increases current income
* high yield bonds
** consider corporate instead of government bonds
* emerging market bonds, often denominated in USD, so if your PnL is in USD, then no fx risk. Soreign risk yes.
* callable bonds

Technique level 2 — often but not always increases current income
* foreign government bond with comparable liquidity and credit rating. Yield sometimes much higher, but with FX risk
* preferred stock of the same issuer
* longer-term bonds of the same issuer

hibernate m:1 LotException

       
           
       
       
       
      
       
       
        <many-to-one name="lotBean" column="LotId"
          insert=”false” update=”false”
          not-null=”false” not-found=”ignore”/> —–> ignore if a LotException object has a null lotBean or an invalid lotBean which doesn't exist in the lotBean table.
 
Also note LotId column in this table is mapped twice.

unlock@thread death

(See other posts about “consistency” issues due to the Release.)

Q: will the dead thread Hold or Release its locks?

* c++? — H. You need RAII. See posts on RAII
* For java sync-keyword — Release is guaranteed. See 2.2.1 [[Doug Lea]], P123 [[java threads]].
* For Lock.java, by default dead threads — Hold locks. see P123 [[java threads]]. Finally block is recommended.
* Thread.destroy()/suspend() + sync-keyword? — H, leading to deadlock
* Thread.stop() + sync-keyword? — R, leading to inconsistency
* What if i use Lock.java and Thread.stop()? My guess is — H

The give-and-take, the cost/benefit — Hold protects consistency but risks liveness; Release provides liveness but risks consistency.

group() – progressive match`]java

google iview 1st whiteboard cod` question
public class Main {
static final int size=20;
static Pattern p = Pattern.compile("[a-zA-Z]+");
static Matcher m;
static StringBuffer c; // candidate without extra space
static String good;
public static void main(String[] args) {
test("we all love apples more");
}
static void test(String s){
m = p.matcher(s);
c = new StringBuffer();
good="";
while(m.find()){
c.append(m.group());
if (c.length() >size) break;
good = c.toString();
c.append(" ");
}
System.out.println(good + "____");
System.out.println("12345678901234567890123");
}
}

long call butterfly – basics

* all-call — I don’t know other flies, but you can have an all-call fly or (equally popular) an all-put fly.
** in FXO, not so simple

* equidistant — among the 3 strikes.
** In FXO, equidistant in terms of delta. Eg 25 delta fly, where both “outside” options have delta values 0.25 away from the center

* size 1:2:1

* ATM – in the middle.

* wizard’s hat — the long call fly looks more like that than a butterfly.
Buy 1 ITM Call + Sell 2 ATM Call + Buy 1 OTM Call — long call butterfly — most common.
(sell the body buy the wings)

* less common in eqd — short call butterfly, short PUT butterfly, long PUT butterfly

Q: For a long call butterfly, the 4 premiums always add up to a net Cost. If underlier stays unchanged till expiry, is the payoff intuitive?
A: not intuitive. Only the low-strike long call makes money and more than covers your premium net cost. Other 3 expire worthless.

Actually the 2 “extreme” outcomes are more intuitive —
$ all 4 expires OTM — negative payoff == initial net cost
$ all 4 expires ITM — You pay initial premium, and leave the rest to clearinghouse, who gives the 2 lots you acquired (Wings) to your (Body) buyers.

In both cases there’s no more cash flow after the initial premium payment.

Q: How do you know if a butterfly strategy is long or short?
%%A: i don’t think you can know.

Q: in FXO, why is the standard strangle also called a fly?

WallSt infrastructure — security trading systems

XR,
(Another blog. No need to reply.)

A large part of the wall street core infrastructure is built around the (regulated) exchanges and (unregulated) ECN’s, and includes the major trading houses’ trading systems — front and back ends, equities, fixed income, currency and commodities, including risk. Developers in these systems are the backbone of wall street.

I feel less than 50% of my company’s technology staff are application developers. Among them, less than 50% develop apps for real time trading. The rest of the developers support reporting, end-of-day risk, post-trading (like my team), GL, compliance, surveillance, price and other data feeds into trading systems and data feeds out of trading systems, maintain accounts and other reference data, ….

Trading system developers are employed by brokerage houses (aka securities firms), hedge funds, mutual funds, prop traders, exchanges, and many boutique firms(?) On the other hand, retail banking, consumer banking, corporate banking (they all taking deposits and giving loans) and the advisory business of investment banks don’t have infrastructure to trade securities. I don’t think they have access to the security exchanges.The IPO, M&A, privatization… investment bankers do need some access to trading systems, as they issue securities.

Overall, how many percent of the financial IT people are in the “backbone”? I guess not more than 10%.