Skip to content
Permalink
Browse files

1) Add ABCD/DD Basic automation tools

2) Some Orderman bug fixes
  • Loading branch information...
SpiffSpaceman committed Feb 28, 2016
1 parent cad6beb commit 51608e8268078dd8c44aa5a8742c969079f81999
@@ -31,6 +31,8 @@ errorLog.txt
# BackfillMan - Ignore ABBackFill, AHK Binaries
BackfillMan/ABBackFill/
AHK/
*.exe
*.ico

# External Header - License unclear
BackfillMan/Lib/__ExternalHeaderLib.ahk
@@ -16,6 +16,7 @@
// Delete second quotes, just leave last 30 mins ( configurable )
// Remove Volume Skip option
// Open Minute - Still import if no data in AB and volume available
// Volume Merge - Distribute difference to all ticks in proportion of their volume. should not be -ve

// TODO - Allow overriding ini parameters using input args. param=value.
// put args key value in map. Use common funtion in settings.ini to check args before ini.
@@ -10,6 +10,8 @@
// Util::getLong / getDouble - Use Try Catch when converting from string
// Also check references - handle bad data

// Preopen Volume?

// RTD Callback - Use array and construct bars in AB thread
// More accurate mins - some data gets shifted now
// Immediate update - use events instead of sleep. Manage minute change
@@ -1,45 +1,52 @@

Data loading check
Move to ABBackfill + Return code - esp for Datatable
verify scrip name
verify scrip name ** // Data corruption

Better Volume, Price Merge
Export data from RTDMan
Merge data in ABBackfill
Merge Price, Volume
Pre open backfill ? Volume?







Archive Intrday data - EOD backfill
Datatable
- Get Date Time column position instead of assuming 2
Better Error Handling
Make list of Failed Scrips and prompt to retry with both VWAP / DT
GUI
- option to cancel/skip Scrip
- option to run manually for selected scrips, even EOD
MultiDay Backfill + Filter out outside market time quotes
Allow Input Date Range for DataTable
- button for intraday / 15 day intraday / Bhavcopy 1 day or archive + scrips/scrips groups selection
- Integrated GUI with RTDMan - choose active intraday stocks




Google Backfill
Allow using as primary / backup
AHK - UrlDownloadToFile
http://www.google.com/finance/historical?q=AAPL&startdate=Nov 1, 2011&enddate=Nov 30, 2011&output=csv
http://www.google.com/finance/historical?q=NASDAQ%3AMSFT&startdate=Jan+1%2C+2012&enddate=Sep+1%2C+2013&output=csv
http://www.google.com/finance/historical?output=csv&q=[Symbol name]

http://www.google.com/finance/historical?output=csv&q=[Symbol name]
BhavCopy Download + filter scrips
Also option to use existing data
Option for some scrips to have say 15 days intraday data - get intraday data from archive / google
1st backfill with daily + tick mode 1. Then backfill intraday data with tickmode 1
Datatable intrdaday MultiDay Backfill + Filter out outside market time quotes
Allow Input Date Range for DataTable - or just backfill all using tickmode 1
Can use to fill missing archive data









Daily Backfill?
Handle Hostorical Charts, including for index
Shows text "Historical Chart" instead of "IntraDay Chart" - Will have to switch using menu
Scrip Manager
Manage active/inactive intraday/Daily Scrips across RTDMan/Backfillman and accross NOW/google/Bhavcopy


DT - Shift-D also causes separate d keystroke. So if Marketwatch has a scrip starting with D, it gets selected
@@ -66,7 +66,7 @@ getTargetPriceFromAB(){
_guessDirection( entry, stop ){
global contextObj

if( !contextObj.getCurrentTrade().isEntryLinked() ){ // Guess Direction if No order linked
if( !contextObj.getCurrentTrade().isEntryOrderExecuted() ){ // Guess Direction only if not entered yet
setDirection( entry > stop ? "B" : "S")
}
}
@@ -342,6 +342,11 @@ setQty( inQty ){
GuiControl, 1:Text, Qty, %Qty%
}

setDefaultQty(){
global DefaultQty
setQty( DefaultQty )
}

/* EntryPriceActual should contain the original values taken from AB
*/
setEntryPrice( inEntry, inEntryPriceActual){
@@ -73,12 +73,10 @@ onUpdate(){
{
stop := StopPrice
}
if( hasOrderChanged( trade.targetOrder, TargetPrice, positionSize ) ) // Target Order size is always = completed Entry orders' size
{
target := TargetPrice
}
// Target Order size is always = completed Entry orders' size
target := hasOrderChanged( trade.targetOrder, TargetPrice, positionSize ) ? TargetPrice : -1

if( entry != "" || stop != "" || target != "" ){
if( entry != "" || stop != "" || target != -1 ){
trade.update( selectedScrip, EntryOrderType, "SLM", Qty, ProdType, entry, stop, target )
}
else{
@@ -342,15 +340,15 @@ validateInput(){
return false
}

if( checkEntry && !UtilClass.isNumber(EntryPrice) ){
if( checkEntry && (!UtilClass.isNumber(EntryPrice) || EntryPrice<=0 ) ){
MsgBox, 262144,, Invalid Entry Price
return false
}
if( !UtilClass.isNumber(StopPrice) ){
if( !UtilClass.isNumber(StopPrice) || StopPrice<=0 ){
MsgBox, 262144,, Invalid Stop Trigger Price
return false
}
if( TargetPrice!= "" && !UtilClass.isNumber(TargetPrice) ){
if( TargetPrice!= "" && (!UtilClass.isNumber(TargetPrice) || TargetPrice<0) ){ // target price can be 0 => No Target
MsgBox, 262144,, Invalid Target Price
return false
}
@@ -4,7 +4,7 @@
Scrip = NSE,EQ,SBIN,XX,,1

; Default Order quantity
Qty = 1
Qty = 2

; Default Entry OrderType - L/SLM/SL/M
EntryOrderType = SL
@@ -21,13 +21,13 @@ MaxSlippage = 0.05
; To trigger - Double click on stop static text area
; Similarly use DefaultTargetSize
DefaultStopSize = 0.5
DefaultTargetSize = 1
DefaultTargetSize = 1.5
; Both Target and stop orders can be triggered if they are too close together and market moves quickly.
; It May take a few seconds to cancel other when one triggers. So prefer to have them a minimum distance apart else warn
MinTargetStopDiff = 1

; Enable Automatic submission of Order. User will have to click on Submit in Order window manually if disabled
AutoSubmit = false
AutoSubmit = true

; Hotkeys for AB integration. These will trigger copy of price at cursor to Entry price / Stop Trigger
; The price is taken from start price of Line at cursor ( should be horizontal TL or Horizontal line )
@@ -45,5 +45,5 @@ TickSize = 0.05
; Ignore from here
LastWindowPosition=
; EntryOpenOrderNo:StopOrderNo,isPending,PendingPrice:ExecutedEntryList:TargetOrderNo,TargetPrice
SavedOrders=
SavedOrders=:,0,::,

@@ -175,7 +175,7 @@ class OrderbookClass{
return this.CompletedOrders.size
}

/* Get Order ID of newly opened orders, searches both open and completed orders
/* Get Order ID of newly opened orders, searches both open and completed orders
Assuming only 1 opened/completed since last read
So readOpenOrders(),readCompletedOrders() should be called before creating new order and
getNewOrder() should be immediately called after creating new order
@@ -20,8 +20,7 @@
loadSettings(){

local value // All variables global by default

IniRead, Qty, OrderMan.ini, OrderMan, Qty

IniRead, ProdType, OrderMan.ini, OrderMan, ProdType
IniRead, DefaultStopSize, OrderMan.ini, OrderMan, DefaultStopSize
IniRead, DefaultTargetSize, OrderMan.ini, OrderMan, DefaultTargetSize
@@ -35,13 +34,16 @@ loadSettings(){
IniRead, EntryOrderType, OrderMan.ini, OrderMan, EntryOrderType
IniRead, MaxSlippage, OrderMan.ini, OrderMan, MaxSlippage
IniRead, SavedOrders, OrderMan.ini, OrderMan, SavedOrders

IniRead, value, OrderMan.ini, OrderMan, AutoSubmit
AutoSubmit := value=="true"

IniRead, value, OrderMan.ini, OrderMan, Scrip
IniRead, value, OrderMan.ini, OrderMan, Scrip
local fields := StrSplit( value , ",")

IniRead, DefaultQty, OrderMan.ini, OrderMan, Qty
Qty := DefaultQty

selectedScrip := new ScripClass
selectedScrip.setInput( fields[1], fields[2], fields[3], fields[4], fields[5], fields[6] )
}
@@ -24,7 +24,7 @@ class TradeClass{
targetOrder := -1

isStopPending := false // Is Stop Waiting for Entry/Add order to trigger?
positionSize := 0
positionSize := 0 // Open Position Size

executedEntryOrderList := [] // List of executed entry/add orders
// entryOrder contains details of current unexecuted order shown in GUI and _entryOrderList has all of executed orders
@@ -89,7 +89,8 @@ class TradeClass{
}

this._updateStop( inScrip, stopOrderType, qty, prodType, stopPrice )
this._handleTargetOrder( targetPrice )
if( targetPrice !=-1 ) // -1 indicates no change. Else create/delete target order
this._handleTargetOrder( targetPrice )

this.save()
updateStatus()
@@ -134,11 +135,13 @@ class TradeClass{
}

if( this.stopOrder.isComplete() && this.targetOrder.isOpen() ){ // OCO Stop, Target Order
this.targetOrder.cancel()
this.targetOrder.cancel() // If position closed, then cancel Add order if open
this.newEntryOrder.cancel()
}
else if( this.targetOrder.isComplete() && this.stopOrder.isOpen() ){
this.stopOrder.cancel()
}
this.newEntryOrder.cancel()
}

if( this.stopOrder.isClosed() ){ // Unlink After close
MsgBox, 262144,, Trade Closed - Verify
@@ -403,6 +406,8 @@ class TradeClass{
this.executedEntryOrderList := [] // List of successfully executed Orders

this.save()

setDefaultQty() // Reset Qty in GUI to Default Size
}

/* Reload order details from orderbook
@@ -418,7 +423,7 @@ class TradeClass{
if( this.isTargetLinked() )
this.targetOrder.reloadDetails()
}

/* New Entry Order Open ? - Returns true if newEntryOrder is an object and is linked with an order in orderbook
*/
isNewEntryLinked(){
@@ -488,7 +493,7 @@ class TradeClass{

this._mergeStopSize()

if( this.stopOrder.isCreated ){ // If stop order already exists ( ie Entry Order was add )
if( this.stopOrder.isCreated ){ // If stop order already exists ( ie Entry Order was an add order )
this.stopOrder.update() // then take added qty from entry order and add to stop order
}
else{
@@ -654,8 +659,10 @@ class TradeClass{
_handleTargetOrder( targetPrice ){
global ORDER_TYPE_GUI_LIMIT

if( (targetPrice == 0 || targetPrice = "" || this.positionSize == 0) && this.targetOrder.isOpen() ){
this.targetOrder.cancel() // Can happen for adds, If target cleared, cancel it
if( (targetPrice == 0 || targetPrice = "" || this.positionSize == 0) ){
if( this.targetOrder.isOpen() ){
this.targetOrder.cancel() // Can happen for adds, If target cleared, cancel it
}
return
}

Oops, something went wrong.

0 comments on commit 51608e8

Please sign in to comment.
You can’t perform that action at this time.