Você está na página 1de 71

X_TRADERAPITipsandTricks

AcoursebyTradingTechnologies

IntendedAudience
PriorDevelopmentExperiencewithC++,C#, orVisualBasic FamiliarwithXTAPI FamiliarwithTradingApplicationlogic ThisisnotanIntroduction!

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
3

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

XTAPIOverview
XTAPIisacollectionofobjectsandinterfaces thatprovideaccesstotheTTenvironment throughcustomapplications. XTAPIobjectsproviderealtimeaccessto
MarketandImpliedPrices,includingDepth Send,Modify,andCancelOrders RiskAdministrationandBackOfficetasks MarketBrowsingandContractSpecifications ReceiveandprocessFillrecords

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

XTAPIOverview
XTAPIusesMicrosoftsCOMtechnology AnyCOMenabledlanguagecanbeusedto developXTAPIapplications
Examples:C++,VisualBasic

.Netlanguagesarecompatiblebutnotnative
Examples:C#,VisualBasic.Net

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
6

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

XTAPIisSTA
XTAPIisaSingleThreadedApartment(STA)model. IfyouareabletodevelopyourapplicationwiththeSTAmodel, youshould.BecauseXTAPIisSTA,youwillnotpayany marshallingorthreadcontextswitchingpenalties. TTdoesnotrecommendtheMultiThreadedApartment(MTA) Modelbecauseyourapplicationwillincurthreadcontext switchingwitheachmethodcalltoXTAPI.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

AvoidingtheCOMBarrier
MTA Application

COM

Athreadcontextswitchwill occurwheneveramethodor propertyofXTAPIiscalled fromyourMTAapplication.

STA XTAPI

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

MultiThreadedApplications
TodevelopamultithreadedXTAPIapplication,youshould stillselecttheSTAmodel.Createasinglethreadthatwillact astheentrypointtoXTAPI,andhaveallotherthreadsin yourapplicationaccessXTAPIthroughthissinglethread

UserWorker Thread XTAPI XTAPIAccess Thread UserWorker Thread UserWorker Thread


Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

GetProperties
TheGet()methodcausestoXTAPIallocateaVARIANT andreturnittoyourapplicationforextraction.

1 3 4 2

4VARIANTShave beencreated!

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

10

AvoidingtheCOMBarrier
Tooptimizeyourcode,condensethenumberof VARIANTobjectsthatneedtobecreated Optimally,wewouldneedonlyasingleVARIANT objecttobecreated,witheachofourdata memberscontainedwithinit

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

11

CompoundGetProperties
Thisoptimizationisaccomplishedby usingCompoundGetProperties CompoundGetPropertiesrequestmultiple XTAPIpropertieswithinasinglemethodcall. ThiseliminatestheneedforXTAPIto repeatedlyallocateindividualVARIANT objects

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

12

Example:CompoundGetProperties

AsingleVARIANTiscreatedtoholdallofthe propertyvalues.Dataextractionintotypedvalues occursinnativecode.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

13

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
14

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

Ticks!=Points!=X_TRADERDisplay
XTAPIprovidesspecificdatatypesformany propertiesthatallowyoutorequestvaluesin differentformats.
PriceFormats X_TRADERStringFormat Ticks Currency Delta Data Types Integer Decimal String

LetXTAPIhandlethedataconversions.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

15

BadExample
ThefollowingcodesnippetshowstheextractionoftheBestBidvalue inX_TRADERstringformat,andthenconvertsthatpricetoaTick Value.

Thisrequirestheusertoaddtheirowndataconversioncode

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

16

UseXTAPItodoyourdataconversion

SpecifiesTicks Format

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

17

UsingTicksisrecommended
XTAPInativelyworkswithpricesinTicks Modifyingyourapplicationtousetickprices willeliminatetheneedtoconvertdatatoand fromdifferentformatsbothinyour applicationaswellasinXTAPI

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

18

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
19

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

InsideMarketvs DepthUpdates
TosubscribeforInsideMarketupdates:OnNotifyUpdate

TosubscribeforDepthupdates:OnNotifyDepthUpdate

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

20

Depth+InsideMarket
Amarketdepthupdatewillincludeanyinsidemarketupdates

OnNotifyUpdate

OnNotifyDepthUpdate

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

21

Depthvs.InsideMarketExample
Assumeyouarewritinganautomated MarketMakingapplication.
PeryourMarketMakingagreementwiththe Exchange,yourquotingordersmustbewithin2 levelsoftheInsideMarket WhentheInsideMarketmoves,youmay wantto requoteyourorder.Thedecisionisbasedon liquidity
Ifthereissufficientliquidity,youcanquoteatthe InsideMarket Ifthereisnot,youwanttoquoteupto2levelsaway,in anattempttoavoidgettingfilled

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

22

Depthvs IMExample
Basedontheapplicationrequirements,you needonlytotakeanactioniftheInside Marketvalueschange ThereforeyoucansubscribetoInsideMarket changesandonlyrequestDepthwhenneeded Thiswillresultinfewereventcallbacks, increasingapplicationperformance

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

23

Depthvs IMExample
SummaryofApplicationLogic
TheapplicationsubscribestotheOnNotifyUpdate eventinorder toreceiveanotificationwhentheInsideMarket valueschange WhentheInsideMarketchanges,theOnNotifyUpdate eventwill befired.Withinyoureventhandlermethod,requestMarket Depth Basedonthemarketmakingstrategy,orderswillbeplacedin themarket:
IfElseif Level 0quantity>=50 Level 0+Level1>=50 Neither oftheabovearetrue Then. PlaceorderatLevel0 PlaceorderatLevel1 PlaceorderatLevel2

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

24

Depthvs IMExample
Thiswillresultin significantlyfewer callbacks.Italsoonly givesyouadepth snapshotwhenthere hasbeenachangeto theInsideMarket, eliminating superfluous notificationsof outsidequoting,and improvingtheoverall efficiencyofthe application

3PriceLevels oneitherside oftheMarket


Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

25

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
26

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

FilterUpdatesforthevaluesyouwant
WhenusinganInstrumentNotify(TTInstrNotify)objecttoreceive eventcallbacks,youwillreceivetheeventwhenany oftheinstrumentsproperties change Asanoptimization,youcansetaNotifyFilterthatwillonlyfiretheeventcallbacks whenthespecifiedpropertieschange ThisisaccomplishedbyusingtheUpdateFilter property

NowonlychangestotheLastTraded Price,theBestBid,ortheBestAsk willresultintheeventbeingfired.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

27

BacktotheDepthvs IMExample
OurMarketMakingexamplecanbefurther optimized.Currentlywearereceivingthe OnNotifyUpdate eventwhenany oftheInside Marketvalueschange(Price,Quantity,High,Settle, etc) BysettingaNotifyFilter,wecanlimittheevent callbackstofireonly whentheInsideMarketPrice changes,ignoringanyotherupdates

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

28

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
29

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

RapidFillDelivery
WhenRapidFillDeliveryis OFF (Default)
Exchange

OrderServer

FillServer

XTAPI

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

30

RapidFillDelivery
WhenRapidFillDeliveryisON
Exchange

OrderServer

FillServer

XTAPIacceptsthefirst fillitreceives

XTAPI

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

31

RapidFillDeliveryCaveats
XTAPIs OrderSetslistentoFillnotificationsfromtheOrderServer, regardlessoftheRapidFillDeliverysetting.Thiscanleadtoinflight issues. Forexample,assumeyouhaveRapidFillDeliverysettoTRUE,andyou haveasingleOrderSetcontainingtwoworkingorders. YourapplicationreceivesaFullFillRecordfromtheFillServer.Inyour eventhandlermethod,youqueryforthenumberoforderscontained withintheOrderSet. TheOrderSet(may)reportbackthatitcontains2 orders.Thisseemslike anerrorbecauseyourFullyFilledordershouldnolongerexist.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

32

RapidFillDeliveryCaveats
Itsnotanerror. TheOrderSetwilleventuallycorrectitself when theOrderServerprocessestheFillRecordandsends thenotificationtoyourapplication.Thisinflight issuemustbeconsideredwhendecidingwhetherto utilizeRapidFillDelivery.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

33

RapidFillDeliveryCaveats
Thesepropertieswillnotbeavailablefromthe FillRecordwhenRapidFillDeliveryisON:

Ex:OrderNo OrderNo FillKey

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

34

BrokerTec must useRapidFillDelivery


OnBrokerTec,duringtheWorkupPhase,theexchangewill notsendaFillNotificationuntiltheWorkupPhaseiscomplete. TheFillrecordsareheldattheFillServer.Togetaroundthis, turnonRapidFillDelivery,whichwillforcetheFillReceiptstobe sentfromtheOrderServer.

Youwillnotreceivefillnotificationsuntilafterthe WorkupPhaseisoverunless youenable RapidFill Delivery.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

35

RapidFillDeliveryUsageGuidelines
In General
TurnRFDOn if TurnRFDOff if Responding toFills(e.g. Accurate OrderBook hedgingaspread)istheprime managementistheprime functionofyourapplication functionofyourapplication

Thedeterminationofwhethertoenable ordisable RapidFillDeliveryshouldbebasedonthe requirementsoftheapplication.Thereisnosimple YesorNoanswer.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

36

RapidFillDelivery
Now that the costs and benefits of Rapid Fill Delivery are clear, if you decide to enable them in your application, here is how:

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

37

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
38

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

UseXTAPIproperties
Manyuserstrytotrackmarketandorder statusvaluesthemselves. XTAPIdoesitforyou. ThefollowingslidesillustrateseveralOrderSet propertiesthatwillprovideaccurateposition information.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

39

UseXTAPIproperties BuyPosition
NetPos Currentnetpositionbasedonfills BuyPos Quantityboughtbasedonfills
Example: Youhaveasinglebuyorderinthemarketwithanorderquantityof12. Youreceiveapartialfillof8fortheorder OrderSet.NetPos is8 OrderSet.BuyPos is8 OrderSet.SellPos is0

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

40

UseXTAPIproperties SellPosition
NetPos Currentnetpositionbasedonfills SellPos Quantitysoldbasedonfills
Example: Youhaveasinglesellorderinthemarketwithanorderquantityof18. Youreceiveapartialfillof11fortheorder OrderSet.NetPos is11 OrderSet.BuyPos is0 OrderSet.SellPos is11

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

41

CombinedPositionExample
Example: Yousubmitasinglebuyorderwithanorderquantityof12. Youreceiveapartialfillof8fortheorder Yousubmitasinglesellorderwithanorderquantityof18. Youreceiveapartialfillof11fortheorder

OrderSet.NetPos is3 OrderSet.BuyPos is8 OrderSet.SellPos is11

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

42

OrderSet:BuyCnt /SellCnt
BuyCnt returnsthenumberofindividualbuyorders SellCnt returnsthenumberofindividualsellorders
Example: Therearethreebuyordersinthemarket, withorderquantitiesof5,12,and17 Therearetwosellordersinthemarket, withorderquantitiesof2and8 OrderSet.BuyCnt =3 OrderSet.SellCnt =2

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

43

OrderSet:BuyWrk /SellWrk
BuyWrk returnstheaggregatequantityofbuyorders SellWrk returnstheaggregatequantityofsellorders
Example: Therearethreebuyordersinthemarket, withorderquantitiesof5,12,and17 Therearetwosellordersinthemarket, withorderquantitiesof2and8 OrderSet.BuyWrk =34 OrderSet.SellWrk =10

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

44

AverageCostofBuys/Sells
This slide assumes that your Order Set contains orders and fills for a single Instrument

AverageCostofBuys(inTicks)=BuyTicks /BuyPos AverageCostofSells(inTicks)=SellTicks /SellPos


Todeterminetheaveragecostofyourbuyorders containedwithinthisOrderSet,divideOrderSet.BuyTicks byOrderSet.BuyPos Todeterminetheaveragecostofyoursellorders containedwithinthisOrderSet,divideOrderSet.SellTicks byOrderSet.SellPos

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

45

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
46

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

ImpliedPriceEngine
Bydefault,XTAPIhastheImplieds EngineturnedOFF Bydefault,RTDhastheImplieds EngineON ToturnXTAPIs ImpliedEngineON, theInstrumentobjects CalculateTTImplieds propertyshould besettoTRUE(1)

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

47

Exchangevs TTImplieds
XTAPIs ImpliedEnginewillcalculateimpliedprices formarketswhentheExchangedoesnot disseminateitsownimpliedprices. TurningtheImpliedEngineON orOFF willnotaffect Exchangedisseminatedimplieds prices,onlyXTAPI generatedimplieds.
Certainexchanges(e.g.LIFFE)disseminatetheirownImplied prices.Inthiscase,turningtheXTAPIImpliedEngineON/OFF hasnoimpact.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

48

ImpliedDepth?
TheXTAPIImpliedEnginedoesnotcalculate ImpliedDepth. IftheExchangedisseminatesImpliedDepth, XTAPIwilldeliverthisdatatoyou. NotethatX_TRADERdoesnotdisplayImplied Depth.TheonlywaytoreceiveExchange disseminatedImpliedDepth,inTT,isthrough XTAPI.
49

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

DirectversusImpliedPriceFields
ToviewDirectPricesonly: Ask BidQty Bid AskQty

ToviewImplied(TTCalculatedorDisseminated)Pricesonly: IAsk IBidQty IBid IAskQty

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

50

MergingImplieds
ToviewtheBestPrice,whetherDirectorImplied:

MIAsk MIBidQty MIBid

MIAskQty

CalculateTTImplieds hasnoeffectonMergingImpliedandDirect quantities.However,onlyExchangedisseminatedImpliedquantitieswill bemergedifCalculateTTImplieds isOFF.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

51

MergingImplieds Examples
WhentheImplied BidistheBestBid: MIBid = IBid MIBidQty = IBidQty WhentheDirect BidistheBestBid: MIBid = Bid MIBidQty = BidQty WhenImpliedBid andDirect Bid pricesareequal: MIBid = Bid MIBid =IBid MIBidQty = BidQty +IBidQty

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

52

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
53

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

InstrNotify

YoucanattachmultipleInstrumentstoasingleInstrumentNotifyobject:

Nowbothinstrumentswillusethesameeventhandler

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

54

InstrNotify
Benefits
Couldresultinlesscode Singlepointofprocessing LotsofIFstatementsandcomparisons Lessevents=lesscontextswitching

Risks
Processingonecontractmayleadto missedmessages

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

55

OrderProfile
ATTOrderProfile objectisusedtopopulatetheattributesofan order.AneworderiscreatedbycallingtheOrderSet.SendOrder() method,passingtheOrderProfileobjectasaparameter. SomethingstokeepinmindaboutOrderProfiles: IsWriteOnly ToquerypropertiesofaTTOrderProfile object,useGetLast instead ofGet. TheobjectspropertiesarenotfullycreateduntiltheOrderProfile isconvertedtoaTTOrderObj bycalling TTOrderSet::SendOrder(myOrderProfile);

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

56

TTHotKeyNotify TheLostObject
YoucanusetheTTHotKeyNotify objecttoreceiveaneventcallbackwhen akeycombinationispressed.YoucanmapXTAPIfunctionalitytothisevent

Forexample,userscancreateaHotKeythatwillfireanevent whentheSpaceBarispressed.Thiswouldbeaquickand convenientwaytoimplementaDeleteAllOrderspanicbutton

WARNING! TheHotKeyisregisteredwithWindows. Thereforeanyuseofthekeyoutsidetheapplicationwillresultin yourapplicationreceivingthecallbackandpossiblytakingaction.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

57

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
58

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

OrderSet Overview
XTAPIallowsthesegregationofworkingordersandfills intologicalgroupingscalledOrderSets PropertiessuchasP&L,NetPosition,BuyCount,etc arecalculatedattheOrderSetlevel OrderStatuseventsfirefromOrderSets ThereisalwaysatleastoneOrderSet,butausercan createmore

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

59

ToomanyOrderSets
WhilethereisnohardcodedlimittothenumberofOrderSets ausermaycreate,youshouldunderstandthateachOrderSet comeswithacost. WhenaFillRecordorotherUpdateisreceivedbyXTAPI,it mustevaluateeachOrderSettodetermineifanOrderSet Updatenotificationisrequiredtobesenttoyourapplication. ThemoreOrderSetsthatneedtobeevaluated,themore performancewillbeimpacted. BeconsciousofthecostincurredwitheveryOrderSetthatyou create.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

60

UsingmultipleOrderSets
Maybeadvantageousbecause: Youcanlogicallygrouporders,suchasbuyorders inoneordersetandsell ordersinanother. ForeachOrderUpdate,everyorderintheOrder Setmustbeevaluated.Bylimitingthenumberof ordersineachOrderSet,youmayexperience performancegains.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

61

OrdersinOrderSetsareOrdered
WhenrequestingthelistoforderscontainedwithinanOrderSet thereturnedarrayisalreadyorderedsuchthatthegreatertheindex, thefurtherawayfromtheInsideMarket.

WorkingorderswithinanOrderSetare orderedsuchthatWorkingSellscome beforeWorkingBuys

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

62

OrdersinOrderSet areOrdered
Asimpleexample:
Ifyouhave10workingorders,andthefirst5areSells,to gettheBuyorderclosesttotheinsidemarket: TTInstrObj myInstr =(TTInstrObj)m_TTOrderSet[5];

Amoredynamicexample:
UseXTAPIpropertiestodeterminethenumberofworkingSellorders, AndthenoffsetthearraytojumptothefirstBuyorder: int workingSells =(int)m_TTOrderSet.get_Get(WrkSell); TTInstrObj myFirstBuy =(TTInstrObj)m_TTOrderSet[workingSells];

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

63

OrdersinOrderSet areOrdered
Forasingleorderoneithersideofthemarket:
TTInstrObj mySell =(TTInstrObj)m_TTOrderSet[0]; TTInstrObj myBuy =(TTInstrObj)m_TTOrderSet[1];

WithonlyasingleBuyandsingleSell inthemarket,theSellorderwill always bethefirstinthearray,and theBuyorderthesecond.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

64

TickPrice
Usethismethodtodeterminethetrueticksize
Starting Price

TheoneTickstringwillnowcontainthe pricedifferencebetween0ticksand1tick, effectivelygivingyouthecontractsticksize.

Increment

Output Format

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

65

IteratinganOrderSet
Warning! TheOrderSetcanchangewhileyouareiterating
IfyoumustiteratethroughtheOrderSet,usethe.Net foreachinsteadoftheCstylefor Theforloop,relyingonanindextomovethroughacollection,must firstloadallofthecollectionmembersintomemory.foreachimplements TheIEnumerable interface,whichisanativeconstructin.Netallowingthe iterationthroughacollectionwithouthavingtoloadthecontentsofthe collectioninmemory. Withforeach,youcancatchaspecificexception System.InvalidOperationException thatwilloccurifthecollectionis modifiedduringyourprocessing.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

66

UseTickstospecifyprice
Internally,XTAPIwillconvertallpricestoTicks.Specifyingatick priceforanorderwillsavethetimespentwithaconversion.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

67

Agenda
1. XTAPIOverview 2. TheCOMBarrier 3. DataConversions 4. MarketDataUpdates 5. Filters 6. RapidFillDelivery 7. Properties 8. ImpliedPrices 9. EventNotifications 10. OrderSets 11. SeriesKeys
68

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

SeriesKeys
ASeriesKeyisanumericidentifierforaFinancialInstrument withintheTTenvironment.

Notes:

Serieskeysareguaranteed tobevalidonlywithin asingleexchangesession IfyourapplicationstoresSeriesKeys,youshould rerequestthekeyatthebeginningofeach exchangesession.

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

69

WorkingwithSeriesKeys
Torequesttheserieskey,openaninstrumentbyspecifyingthe Gateway/Product/ProductType/Contract. ThenrequesttheSeriesKeyfromtheInstrumentobject:

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

70

WorkingwithSeriesKeys
YoucanalsoopenaninstrumentwithaSeriesKey,andthenextractthe Gateway/Product/ProductType/Contractproperties:

Exampleofa previously extracted SeriesKey

Copyright2009TradingTechnologiesInternational,Inc.ProprietaryandConfidentialInformation

71

Você também pode gostar