Par exemple, un retour d’expérience stratégique ((que ce soit avec un serveur public ou avec votre propre hôte, il n’y a pas de problème。)
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)
Les images peuvent être copiées et téléchargées directement sur le site.
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)
L’appel de talib.MA dans la stratégie (c’est-à-dire l’utilisation de la bibliothèque talib) génère l’erreur suivante lors de l’exécution de la stratégie en utilisant la rétroaction de votre propre hôte ou sur le disque:
Si vous avez un problème avec le serveur public, vous pourriez vous demander: “Est-ce que cela pose un problème ?” C’est vrai, la base de données talib est installée sur le serveur public.
Pour les environnements Python de vos hôtes, il suffit d’installer talib. La démonstration ci-dessous est une démonstration d’installation de la bibliothèque talib dans un environnement Python 2.7 sous un système Windows XP (c’est-à-dire 32 bits Windows). Il existe de nombreuses méthodes en ligne, mais nous avons utilisé une méthode plus simple.
Attention, la version Win32 de Python 2.7 est en cours de téléchargement.
Lors de l’installation, veillez à sélectionner l’option de configuration automatique des variables environnementales, car le composant pip est installé par défaut.
Voici un extrait de la recherche en ligne
python wheel怎么安装?
小灰机289 | 浏览 14404 次
推荐于2016-01-19 03:17:24 最佳答案
你装了pip吗,建议先装pip,后面安装各种python库就很方便了。
打开命令行窗口,输入下面的命令:
pip install wheel
这时pip会自动在网络上下载安装wheel。
安装完成后可以敲下面的命令查看是否安装成功:
pip freeze
Pour plus d’informations, consultez le site officiel de l’UICI.
Pour trouver le fichier talib correspondant à la version et au système, voir:
Si vous souhaitez télécharger le logiciel, vous pouvez le télécharger et l’installer.
Télécharger numpy Pour plus d’informations, consultez le site officiel de l’UICI.
Pour installer:
#### Essayez de quantifier l’inventeur de la stratégie en utilisant la fonction de pointeur de talib
Les résultats de LogStatus peuvent être affichés.
Après la compression