में आईब्राकरों का उपयोग करके ब्रैकेट ऑर्डर में एकाधिक मात्राएं मैं आर में ibrokers पैकेज के साथ काम कर रहा हूं और एक व्यापार के लिए कई बंद कीमतों को सेट करने की कोशिश कर रहा हूं। उदाहरण के लिए, $ 106 पर एएपीएल के 100 शेयर खरीदें, 105 डॉलर की कीमत के साथ $ 107 और 50 $ 108 पर 50 डॉलर बेचें।आर
जब मैं एकाधिक लाभ लेने वाले आदेश भेजता हूं, ऐसा लगता है कि 50 की मात्रा को अनदेखा किया जाता है, इसके बजाय मुझे प्रत्येक के 100 शेयरों के लिए दो विक्रय आदेश मिलते हैं।
इस कोड मैं
tws <- twsConnect()
stock <- twsEquity("AAPL")
parentLongId <- reqIds(tws)
parentLongOrder <- twsOrder(parentLongId, action="BUY", totalQuantity = 100,
orderType = "LMT", lmtPrice = 106,
transmit=TRUE)
placeOrder(tws, stock, parentLongOrder)
childLongProfitId <- reqIds(tws)
childLongProfitOrder <- twsOrder(childLongProfitId, action="SELL", totalQuantity = 50,
orderType = "LMT", lmtPrice = 107,
transmit=TRUE, parentId = parentLongId)
placeOrder(tws, stock, childLongProfitOrder)
childLongProfitId2 <- reqIds(tws)
childLongProfitOrder2 <- twsOrder(childLongProfitId2, action="SELL", totalQuantity = 50,
orderType = "LMT", lmtPrice = 108,
transmit=TRUE, parentId = parentLongId)
placeOrder(tws, stock, childLongProfitOrder2)
childLongStopId <- reqIds(tws)
childLongStopOrder <- twsOrder(childLongStopId, action="SELL", totalQuantity = 100,
orderType = "STP", auxPrice = 105,
transmit=TRUE, parentId = parentLongId, account=accountNum)
placeOrder(tws, stock, childLongStopOrder)
twsDisconnect(tws)
चला रहा हूँ आप देख सकते हैं कि मात्रा के बजाय बेचने के आदेश से प्रत्येक के लिए खरीदने के लिए 100 सभी 3 आदेश के लिए 100 और 50 है।
क्या कोई जानता है कि इसे कैसे ठीक किया जा सकता है?
एक सैनिटी चेक के रूप में, मैंने माता-पिता के बिना आदेश में प्रवेश किया और यह काम किया।
tws <- twsConnect() #open connection, R automatically pauses until manually accepted on IB.
stock <- twsEquity("AAPL")
parentLongId <- reqIds(tws)
parentLongOrder <- twsOrder(parentLongId, action="BUY", totalQuantity = 100,
orderType = "LMT", lmtPrice = 106,
transmit=TRUE)
placeOrder(tws, stock, parentLongOrder)
childLongProfitId <- reqIds(tws)
childLongProfitOrder <- twsOrder(childLongProfitId, action="SELL", totalQuantity = 50,
orderType = "LMT", lmtPrice = 107,
transmit=TRUE)
placeOrder(tws, stock, childLongProfitOrder)
childLongProfitId2 <- reqIds(tws)
childLongProfitOrder2 <- twsOrder(childLongProfitId2, action="SELL", totalQuantity = 50,
orderType = "LMT", lmtPrice = 108,
transmit=TRUE)
placeOrder(tws, stock, childLongProfitOrder2)
childLongStopId <- reqIds(tws)
childLongStopOrder <- twsOrder(childLongStopId, action="SELL", totalQuantity = 100,
orderType = "STP", auxPrice = 105,
transmit=TRUE, parentId = parentLongId, account=accountNum)
placeOrder(tws, stock, childLongStopOrder)
twsDisconnect(tws)
इस हालांकि यह बाद से व्यवहार में काम नहीं करेगा मैं लाभ चाहते हैं और आदेश रोक दूसरों एक बार हिट रद्द करने के लिए: यहाँ उस के लिए कोड है।
धन्यवाद।
मैं 2 ब्रैकेट ऑर्डर या ओसीए क्लोजिंग ऑर्डर के 2 बैचों के साथ केवल एक का सुझाव दूंगा। अनिवार्य रूप से आधे राशि के लिए दो ब्रैकेट ऑर्डर दें लेकिन विभिन्न लाभ राशि के साथ। – brian
हाय ब्रायन। आदेशों के 2 सेट बनाना काम करेगा, लेकिन अगर मैं स्टॉप को भी स्थानांतरित करना चाहता हूं तो इससे समस्याएं पैदा हो सकती हैं। मुझे इसे दो बार स्थानांतरित करने की आवश्यकता होगी। मैं हमेशा आदेशों को "सेट और भूलना" नहीं चाहता हूं। – mks212
मैंने अभी यह देखा है। यदि आप 6 घंटे तक बक्षीस का विस्तार कर सकते हैं तो मैं आपके लिए इसका ख्याल रख सकता हूं। –