例えば,戦略的な反省 (公共のサーバーの反省でも,自分の管理者の反省でも問題ない。)
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)
公式サイトで直接コピーできます.
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)
策略の中で talib.MA (つまり talib 庫を使用する) を呼び出すと,自身のホストの反省またはリールディスクで実行する策略を使用すると,次のエラーが表示されます.

公開サーバーの反復は問題ない! 公開サーバーの反復は問題ない! タリバのデータベースが 公開サーバーにインストールされているからです.
管理者のPython環境では, talibをインストールするだけで済みます. 下のデモンストレーションは,windows XPシステム (つまり32ビット windows) のPython 2.7環境で talibライブラリをインストールします. オンラインの方法はもっとたくさんあるが,ここではもっとシンプルな方法を使っている.

注意 win32 バージョンの Python 2.7 インストールパックをダウンロードしてください.
インストール時に注意してください. 設定は,環境変数の自動設定で, pip コンポーネントは,既定でインストールされています.


オンライン検索で得た情報です
python wheel怎么安装?
小灰机289 | 浏览 14404 次
推荐于2016-01-19 03:17:24 最佳答案
你装了pip吗,建议先装pip,后面安装各种python库就很方便了。
打开命令行窗口,输入下面的命令:
pip install wheel
这时pip会自动在网络上下载安装wheel。
安装完成后可以敲下面的命令查看是否安装成功:
pip freeze
ダウンロードアドレス: http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
バージョンとシステムに対応する talib ファイルを探します.

ダウンロード完了後,インストールする手順は以下の通りです.


numpyをダウンロードする ダウンロードアドレス: http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib

インストール:


#### 策略は talib の指数関数を使用します.
検索結果が表示されます.


圧縮された後
