質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

API

APIはApplication Programming Interfaceの略です。APIはプログラムにリクエストされるサービスがどのように動作するかを、デベロッパーが定めたものです。

Q&A

0回答

1663閲覧

bitflyerFXのSell/BuyのVolume算出

raonarud

総合スコア88

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

API

APIはApplication Programming Interfaceの略です。APIはプログラムにリクエストされるサービスがどのように動作するかを、デベロッパーが定めたものです。

0グッド

0クリップ

投稿2018/06/22 14:41

以下の約定データを使って、過去20秒間のsellおよびbuyのvolumeを算出したい。
しかしエラーになってしまう。

from pubnub.callbacks import SubscribeCallback from pubnub.enums import PNStatusCategory from pubnub.pnconfiguration import PNConfiguration from pubnub.pubnub_tornado import PubNubTornado from pubnub.pnconfiguration import PNReconnectionPolicy import pandas as pd from datetime import datetime, timezone, timedelta config = PNConfiguration() config.subscribe_key = 'sub-c-52a9ab50-291b-11e5-baaa-0619f8945a4f' config.reconnect_policy = PNReconnectionPolicy.LINEAR pubnub = PubNubTornado(config) from tornado import gen df_all = pd.DataFrame(index=['datetime'], columns=['id', 'side', 'price', 'size', 'exec_date', 'buy_child_order_acceptance_id', 'sell_child_order_acceptance_id']) @gen.coroutine #非同期処理 def main(channels): class BitflyerSubscriberCallback(SubscribeCallback): def presence(self, pubnub, presence): pass # handle incoming presence data def status(self, pubnub, status): if status.category == PNStatusCategory.PNUnexpectedDisconnectCategory: pass # This event happens when radio / connectivity is lost elif status.category == PNStatusCategory.PNConnectedCategory: # Connect event. You can do stuff like publish, and know you'll get it. # Or just use the connected event to confirm you are subscribed for # UI / internal notifications, etc pass elif status.category == PNStatusCategory.PNReconnectedCategory: pass # Happens as part of our regular operation. This event happens when # radio / connectivity is lost, then regained. elif status.category == PNStatusCategory.PNDecryptionErrorCategory: pass # Handle message decryption error. Probably client configured to # encrypt messages and on live data feed it received plain text. def message(self, pubnub, message): # Handle new message stored in message.message task(message.channel, message.message) listener = BitflyerSubscriberCallback() pubnub.add_listener(listener) pubnub.subscribe().channels(channels).execute() def task(channel, message): for i in message: # print(i['exec_date'], i['side'], i['price'], i['size']) print(i['side'], i['size']) df_new = pd.DataFrame(message) df_new['exec_date'] = pd.to_datetime(df_new['exec_date']) global df_all df_all = df_all.append(df_new) df_all.index = df_all['exec_date'] date_now = df_all.index[len(df_all)-1] df_lim = df_all.ix[df_all.index >= (date_now - timedelta(seconds=20))] buy_vol = df_lim[df_lim.apply(lambda x: x['side'], axis=1) == "BUY"]['size'].sum(axis=0) sell_vol = df_lim[df_lim.apply(lambda x: x['side'], axis=1) == "SELL"]['size'].sum(axis=0) print(df_lim.index[0].strftime('%Y-%m-%d %H:%M:%S'), df_lim.index[len(df_lim)-1].strftime('%H:%M:%S'), "BUY_VOL", format(buy_vol, '.2f'), "SELL_VOL", format(sell_vol, '.2f')) if __name__ == '__main__': main(['lightning_executions_FX_BTC_JPY']) pubnub.start()

エラー内容

line

1 pubnub = PubNubTornado(config) 2 File "/Users/ほげほげ/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pubnub/pubnub_tornado.py", line 83, in __init__ 3 self._telemetry_manager = TornadoTelemetryManager(self.ioloop) 4 File "/Users/ほげほげ/.pyenv/versions/3.6.0/lib/python3.6/site-packages/pubnub/pubnub_tornado.py", line 676, in __init__ 5 self.ioloop) 6TypeError: __init__() takes 3 positional arguments but 4 were given 7コード

よろしくお願いいたします。
このサイトを参考にしてます。
http://r17u.hatenablog.com/entry/2017/12/05/211451

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問