Profile Picture

Exchange-Traded Options programming

Posted By markETO Last Year
Message
QuestionMark Posted Wednesday January 13 2016
Hi guys,

I'd like to program options trading in RE.
I have old UNIX prompt C programming experience (and
MacPascal) but none of this Object Oriented / .NET so I
could use a little help.

I traversed the 'Trading Systems available for download'
at RE website but didn't find any that handled Exchange
Traded Options.

I need fragments of code which I can modify and insert
into my RE Trading System (where I handle the underlying
stock ticker). As the Trading System for each NewBar
iterates through each symbol (ticker) I would then call
appropriate procedures with their corresponding parameters
but the OO programming paradigm is tripping
me up. Even the terminology is confusing. That's why
I am looking for sample code.

Could someone show me some code examples to:
1.    Retrieve the Delta, Open Interest and Bid & Offer for
    an ATM Call option (nearest expiry)
    for the current symbol. For example, if the stock
    has just traded at 78.45 and has 50 cent strikes,
    then the At-The-Money Call will be the 78.50 strike.
    Actually don't worry too much about calculating the exact
    strike price (I'll do that), just show me how to call
    the function (with appropriate parameters) to
    retrieve the Delta, OI and Bid & Ask prices.

2.    Send a Limit Order to Buy (open a long position)
    at price XXX for the Option in 1. If there is a
    Time-In-Force parameter, make it Day-Only (Day order).

3.    Check the status of the order - Filled? Pending? Rejected?

4.    Send a Limit Order to Sell an option.

I assume all these code pieces could go inside
the "public override void NewBar()" procedure,
but if not, please clarify where. Also if one needs
to declare types / variables or allocate memory (new)
in the "public override void Startup()" section of code
please indicate that too.

Much Thanks in advance, Mark.

Posted Thursday January 28 2016
Hello there,

I am trying to get help with my options programming (this thread) and BillB in the Programming Forum
http://www.rightedgesystems.com/forums/4142/Welcome-to-the-Programming-Forum
said:

>billb
>Lead Developer
>Posted Wednesday December 26 2007
>
>We've opened this forum for the purpose of fielding programming / software development related questions.  We invite the community to jump in, but this will also be visited by the programmers here as well.
>
>We understand that not everyone using RightEdge is a programmer, so we welcome questions at all levels.

so hopefully someone reads this and is willing to respond. By reading thru the various RE forums it.s obvious that Daniel (dplaisted) is also very experienced (developer?). I hope that you are not all on a vacation or something. Or do I need to re-post my questions in some other forum?

Mark.
Posted Thursday January 28 2016
Hi Mark,
I'm just a fellow user, so I don't have any special inside knowledge of RightEdge, but I sense your frustration so I'm posting a quick response in the hope that it might be a little bit helpful.

1) In order to "retrieve" the Delta or OI for an options contract, you need to have a data source that publishes those.  Bid & Ask are commonly provided, but Delta and other options greeks will probably need to be handled differently.  Also, the way a datafeed provides updates is via "events" or "interrupts" or whatever you want to call them.  What I mean is, you don't request things and synchronously move to the next line of code once the data arrives.  Instead, you subscribe to a stream of events, and your code is "awakened" every time a new event arrives. So your code is being driven by the data, rather than the other way around.  More specifically, every time the best bid or offer changes, or every time a new trade is published by the exchange, a message is sent over the net by your datafeed, your code is awakened, and your logic needs to decide what to do.  I don't know if you can find a datafeed that publishes Delta and OI in such a way.  You could conceivably track OI yourself if you subscribe to a DMA datasource, but most independent traders are not in a position to undertake such a project.  You might be able get OI from the daily reports published by the exchange (depending on what instruments you are trading) but they don't publish them in realtime.  Regarding delta...  You can write your own code to compute delta using BSM or whatever model you prefer, but you'll need to track the underlying price as well (easy), and you'll also need to estimate implied volatility (more involved).  The latter should best be done by using quotes from the entire options chain for a given underlying, which adds to the fun.  

2, 3, 4) These are all very standard things to do, but again, it seems you are thinking of them in a synchronous way rather than an event-driven way.  Once you have subscribed to a symbol, you will receive events for that symbol.  Some of these will be market data events, while others will be broker events.  Broker events include order status updates (order received by broker, order rejected, order partially filled, order filled, order cancelation confirmed).  The workflow might look something like:
* When you receive a new price quote, update your estimates for options greeks, and test for entry/exit signals.  If your model tells you to buy/sell, enter a limit order and go back to sleep.
* If you're awakened by a broker event, check to see what kind it is (e.g. from my list above).  Handle each case accordingly.  (The devil lives in these details.)
This kind of programming can sometimes be easy (for a single-instrument system that only uses market orders) but more often it gets very tricky (for a multi-instrument system that uses limit orders).  You are building an event-driven state machine, and most people don't know how to do that. 

In summary, it sounds like you are trying to automate something that will require a great deal of skill, experience, and possibly investment.  I wish you the best of luck, and I hope this has been helpful. 


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems