techbureau/zaifbot

[報告] チュートリアルコードを実行するとエラーが発生します。

ntapp opened this issue · 2 comments

ntapp commented

@rhosoi

次のようなチュートリアルにあるコードを実行するとエラーが発生しました。

''' チュートリアル1 firstbot.py '''

from zaifbot.config import set_keys
from zaifbot.rules.entry import BuyLowerEntry
from zaifbot.rules.exit import SellHigherExit
from zaifbot.trade import Strategy

import zaif_config  # APIキーが書かれたファイル

set_keys(
    key=zaif_config.key,
    secret=zaif_config.secret
)
myentry = BuyLowerEntry(currency_pair='xem_jpy',
                        amount=1,
                        buy_price=20)

myexit = SellHigherExit(exit_price=30)
mystrategy = Strategy(entry_rule=myentry,
                      exit_rule=myexit)
mystrategy.start(sec_wait=3)

単純に実行します。

> python3 firstbot.py

次のようなエラーが発生します。

最下行のみ
FileNotFoundError: [Errno 2] No such file or directory: '/Users/naokits/github/zaifbot-demo/venv/lib/python3.6/site-packages/zaifbot/logs/zaifbot.log'

このように log ディレクトリごと存在しておりません。

(venv) ➜  zaifbot-demo git:(develop) ✗ ls -al /Users/naokits/github/zaifbot-demo/venv/lib/python3.6/site-packages/zaifbot/
total 64
drwxr-xr-x  18 naokits  staff   612 Aug  3 17:34 .
drwxr-xr-x  57 naokits  staff  1938 Aug  3 17:25 ..
-rw-r--r--@  1 naokits  staff  6148 Aug  3 17:34 .DS_Store
-rw-r--r--   1 naokits  staff  2024 Aug  3 15:57 __init__.py
drwxr-xr-x   8 naokits  staff   272 Aug  3 16:56 __pycache__
drwxr-xr-x   5 naokits  staff   170 Aug  3 16:56 analysis
drwxr-xr-x   6 naokits  staff   204 Aug  3 16:56 backtest
-rw-r--r--   1 naokits  staff   369 Jul 31 16:40 config.py
drwxr-xr-x   8 naokits  staff   272 Aug  3 17:03 db
-rw-r--r--   1 naokits  staff   154 Jul 31 16:40 errors.py
drwxr-xr-x  10 naokits  staff   340 Aug  3 16:56 exchange
drwxr-xr-x  10 naokits  staff   340 Aug  3 16:56 indicators
-rw-r--r--   1 naokits  staff  2474 Aug  3 15:55 logger.py
-rw-r--r--   1 naokits  staff  1100 Jul 31 16:40 notifyer.py
drwxr-xr-x   8 naokits  staff   272 Aug  3 16:56 rules
drwxr-xr-x  12 naokits  staff   408 Aug  3 16:56 setup
drwxr-xr-x   7 naokits  staff   238 Aug  3 16:56 trade
-rw-r--r--   1 naokits  staff   326 Aug  3 15:55 utils.py

pipでのライブラリインストール、次のコマンドは仮想環境にて実行済みです。

$ install_ta_lib
$ init_database

なお、実行環境は次のとおりです。

  • macOS Sierra 10.12.6 (16G29)
  • python 3.6.2(pyenvにて導入)
  • 仮想環境は python3 -m venv venv で生成しています。
  • zaifbot v0.0.6

ご確認をよろしくお願いします。

パッケージにlogsディレクトリを含めるのを忘れてますね。
しばらくは自分でディレクトリ作って動かしてもらえますか?

次のバージョンで修正しておきます。

ntapp commented

@RossyWhite

了解しました。