For example, check back with a policy (whether using a public server or using your own host, check back is fine).
import types
def main():
STATE_IDLE = -1
state = STATE_IDLE
initAccount = ext.GetAccount()
while True:
if state == STATE_IDLE :
n = ext.Cross(FastPeriod,SlowPeriod) # 指标交叉函数
if abs(n) >= EnterPeriod :
opAmount = _N(initAccount.Stocks * PositionRatio,3)
Dict = ext.Buy(opAmount) if n > 0 else ext.Sell(opAmount)
if Dict :
opAmount = Dict['amount']
state = PD_LONG if n > 0 else PD_SHORT
Log("开仓详情",Dict,"交叉周期",n)
else:
n = ext.Cross(ExitFastPeriod,ExitSlowPeriod) # 指标交叉函数
if abs(n) >= ExitPeriod and ((state == PD_LONG and n < 0) or (state == PD_SHORT and n > 0)) :
nowAccount = ext.GetAccount()
Dict2 = ext.Sell(nowAccount.Stocks - initAccount.Stocks) if state == PD_LONG else ext.Buy(initAccount.Stocks - nowAccount.Stocks)
state = STATE_IDLE
nowAccount = ext.GetAccount()
LogProfit(nowAccount.Balance - initAccount.Balance,'钱:',nowAccount.Balance,'币:',nowAccount.Stocks,'平仓详情:',Dict2,'交叉周期:',n)
Sleep(Interval * 1000)
You can download it directly on Strategy Square.
import types
import talib # 改动 引用 talib 库
def main():
STATE_IDLE = -1
state = STATE_IDLE
initAccount = ext.GetAccount()
while True:
records = exchange.GetRecords()
ma = talib.MA(records.Close) # 改动 ,调用 talib 库的 MA 函数 即 均线指标计算
LogStatus("均值" + str(ma))
if state == STATE_IDLE :
n = ext.Cross(FastPeriod,SlowPeriod) # 指标交叉函数
if abs(n) >= EnterPeriod :
opAmount = _N(initAccount.Stocks * PositionRatio,3)
Dict = ext.Buy(opAmount) if n > 0 else ext.Sell(opAmount)
if Dict :
opAmount = Dict['amount']
state = PD_LONG if n > 0 else PD_SHORT
Log("开仓详情",Dict,"交叉周期",n)
else:
n = ext.Cross(ExitFastPeriod,ExitSlowPeriod) # 指标交叉函数
if abs(n) >= ExitPeriod and ((state == PD_LONG and n < 0) or (state == PD_SHORT and n > 0)) :
nowAccount = ext.GetAccount()
Dict2 = ext.Sell(nowAccount.Stocks - initAccount.Stocks) if state == PD_LONG else ext.Buy(initAccount.Stocks - nowAccount.Stocks)
state = STATE_IDLE
nowAccount = ext.GetAccount()
LogProfit(nowAccount.Balance - initAccount.Balance,'钱:',nowAccount.Balance,'币:',nowAccount.Stocks,'平仓详情:',Dict2,'交叉周期:',n)
Sleep(Interval * 1000)
Call in policytalib.MAThe following errors are reported when using your own hosted review or real-time run policy:
I'm using a public server to retrieve it, and it's okay! Yes, because the talib library is already installed on the public server.
For the Python environment of your host, you can simply install talib manually. The following demonstration is about installing the talib library in the Python 2.7 environment under windows XP systems (i.e. 32-bit windows). There are many online methods, but here we use a simpler one.
Note that the win32 version of Python 2.7 is shown below.
When installing, note that the pip component is already installed by default. Select the Autoconfig environment variable option.
Below is a search on the Internet for information:
python wheel怎么安装?
小灰机289 | 浏览 14404 次
推荐于2016-01-19 03:17:24 最佳答案
你装了pip吗,建议先装pip,后面安装各种python库就很方便了。
打开命令行窗口,输入下面的命令:
pip install wheel
这时pip会自动在网络上下载安装wheel。
安装完成后可以敲下面的命令查看是否安装成功:
pip freeze
Downloaded from:http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
To find the talib file that corresponds to the version and the system, see:
After downloading, install as shown below:
Download numpy Downloaded from:http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
Installed:
The output of LogStatus can be displayed.
After compression
MAIKEOThank you!