jupyter-notebookからpythonを学ぶ
notebookからpythonを学ぶプロジェクトはjupyter-notebookをよく使うので、jupyter-notebookのソースコードをよく見に行きます.python自体は読みやすさが強いうえ、jupyter-notebookソースコードの注釈が非常に完備しているので、分かりやすいです. jupyter-notebookのソースコードを読むことで、pythonの書き方や論理をたくさん学び、ここで共有します. 未完待機・・・
# init
class VolumeShareSlippage(SlippageModel):
"""
Model slippage as a function of the volume of contracts traded.
"""
def __init__(self, volume_limit=DEFAULT_EQUITY_VOLUME_SLIPPAGE_BAR_LIMIT,
price_impact=0.1):
super(VolumeShareSlippage, self).__init__()
self.volume_limit = volume_limit
self.price_impact = price_impact
# lambda ,
if not future.done():
self.log.debug("Waiting for pending kernel_info request")
future.add_done_callback(lambda f: self._finish_kernel_info(f.result()))
# del ,
now = IOLoop.current().time()
while len(self._iopub_window_byte_queue) > 0:
queued = self._iopub_window_byte_queue[0]
if (now >= queued[0]):
self._iopub_window_byte_count -= queued[1]
self._iopub_window_msg_count -= 1
del self._iopub_window_byte_queue[0]
else:
# This part of the queue hasn't be reached yet, so we can
# abort the loop.
break
# not in
if channel == 'iopub' and msg_type not in {'status', 'comm_open', 'execute_input'}: