A basic algorithmic trading framework# Stock
m*h
1 楼
This is an abstract toy system. A lot work to do for a real algorithmic
trading system.
This is not for high frequency trading. It is for swing trading.
two threads:
the first is data manager or retreiver.
the second is trading thread.
the first one is related to broker and API. please check your broker's
documents.
the following is trading thread. suppose all data, positions and order
status are up to
date.
like a game, a trading thread is mainly an infinite loop.
while(true)
{
update timer;
check trend alert conditions;
send alert to users if triggered;
check current positions and live orders;
check trading requirements;
check trading entry or exit conditions;
place or cancel orders if all conditions are satisfied;
sleep 10 milliseconds;
}
trading system.
This is not for high frequency trading. It is for swing trading.
two threads:
the first is data manager or retreiver.
the second is trading thread.
the first one is related to broker and API. please check your broker's
documents.
the following is trading thread. suppose all data, positions and order
status are up to
date.
like a game, a trading thread is mainly an infinite loop.
while(true)
{
update timer;
check trend alert conditions;
send alert to users if triggered;
check current positions and live orders;
check trading requirements;
check trading entry or exit conditions;
place or cancel orders if all conditions are satisfied;
sleep 10 milliseconds;
}