Comments (3)
I have no such simple options (except -A, -E, -O to get account status, etc.). Adding all possible contracts and order fields would be overkill.
But you could use an order template to it fill up. Below an example how I use it in a shell script using sed
. I guess php should even have a built-in "sed" or you could use sprintf
to replace placeholders "%s" by ordered list of variables.
IFS=$'\n' read -r -d '' order_tmpl <<-'EOF'
<?xml version="1.0"?>
<TWSXML>
<request type="place_order">
<query>
<contract secType="FUT" exchange=":exchange:" localSymbol=":localSymbol:"/>
<order
account=":account:"
action=":action:" totalQuantity=":totalQuantity:"
orderType=":orderType:" tif=":tif:"
goodAfterTime=":goodAfterTime:" goodTillDate=":goodTillDate:"
transmit=":transmit:"
/>
</query>
</request>
</TWSXML>
EOF
echo "${order_tmpl}" | sed \
-e "s/:exchange:/${ex}/g" \
-e "s/:localSymbol:/${loc_sym}/g" \
-e "s/:account:/${TWS_ACC_NAME}/g" \
-e "s/:action:/${act}/g" \
-e "s/:totalQuantity:/${qty}/g" \
-e "s/:orderType:/${ot}/g" \
-e "s/:tif:/${tif}/g" \
-e "s,:goodAfterTime:,${time_order},g" \
-e "s,:goodTillDate:,${time_cancel},g" \
-e "s/:transmit:/${transmit}/g" \
> order_file
Note you could also pipe the order string without writing to a file (echo $order | twsdo ...
). But usually I want to keep all the orders for logging and debugging.
from twstools.
Ah sorry I haven't read carefully that you want to create "history jobs". In shell I do this using dseq
from http://www.fresse.org/dateutils/ to get good date sequences. twsgen
can generate history jobs.
# the contract or more contracts are in a file
cat /tmp/con_example.xml
<?xml version="1.0"?>
<TWSXML>
<request type="contract_details">
<query>
<reqContract symbol="16E" secType="IND"/>
</query>
<response>
<ContractDetails>
<summary symbol="16E" secType="IND" exchange="GLOBEX" currency="USD" localSymbol="16E" tradingClass="16E"/>
</ContractDetails>
</response>
</request>
</TWSXML>
# itereate over intervals of 34 business days (which is good for 30min data)
for i in `dseq --compute-from-last -f "%Y%m%d" 2012-01-01 34b 2013-05-15` ;do
cat /tmp/con_example | twsgen -H -e "$i 00:00:00" -b "30 mins" -w "BID,ASK,TRADES"
done > /tmp/jobfile.xml
from twstools.
Hi, thanks rudimeier I will have to study carefully what you've given me, since sed and dseq commands are totally new for me, and have to see how they operate.
But right now, if I understood right, what you've given me is a shell script, but I don't get what's the content of the file /tmp/con_example.xml ?
Also are u interested in developing a simple command to achieve what I need for me if we find a economic agreement for the job?, I'm really not any good at unix shell script or C++ programming.
Thank you.
from twstools.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twstools.