Slide 1

Slide 1 text

zipline ͷΧελϜ σʔλόϯυϧΛࣗ࡞͢Δ 2017/12/17 (Sun) Fin-py Fintech LTେձ & ๨೥ձ

Slide 2

Slide 2 text

ࣗݾ঺հ connpass/github: 2casa Twitter : @moscow_II ʻຊ৬ʼ ূ݊ձࣾ޲͚σΟʔϦϯάγεςϜͷ։ൃɾاը Quantopian ͱ͸ແؔ܎Ͱ͕͢ɺ࢓ࣄฑڵຯ͋Γ

Slide 3

Slide 3 text

ຊ೔ͷςʔϚ • ೔ຊגͰziplineʢQuantopianͷΦʔϓϯιʔε ൛ʣͷΧελϜσʔλόϯυϧΛ࡞੒ͯ͠Έ͕ͨɺ མͱ͕͍͔݀ͭ͋͘͠Γ·ͨ͠ • ͕࣌ؒগͳ͍ͷͰɺߏஙͷ֓ཁͱ޻ఔ͝ͱͷϙΠ ϯτΛ͔͍ͭ·ΜͰ͓࿩͠·͢ • ίʔυ΍ΑΓৄࡉͳղઆ͸ޙ೔·ͱΊͯެ։͢Δ ༧ఆͰ͢

Slide 4

Slide 4 text

Quantopian ถࠃQuantopianࣾʹΑΔΫϥ΢υϕʔεͷΞϧΰϦζϜτϨʔσΟϯάʢʹࣗಈചങʣ؀ڥ ΞϧΰϦζϜͷهड़ݴޠ͸pythonɻ ڵຯ͕͋ΔํɿTokyo Quantopian User Group (connpass)΁

Slide 5

Slide 5 text

Quantopian ͷಛ௃ •PROS •IDE͕͋Γɺૢ࡞ੑ͕ྑ͍ •גՁ৘ใΛແྉͰར༻Ͱ͖Δ(ͨͩ͠DLෆՄ) •CONS •ถࠃגࣜݶఆ •ݱঢ়Python2 ͷΈ

Slide 6

Slide 6 text

zipline ͬͯʁ •Quantopian ͷΦʔϓϯιʔε൛ •python3 ରԠʢਖ਼֬ʹ͸3.5ʣ •QuantopianͷΑ͏ͳIDE͸ͳ͍͕ɺjupyter notebook্ Ͱಈ͔͢͜ͱ΋Ͱ͖Δɻ •גՁσʔλϕʔεʢʹσʔλόϯυϧʣΛಠࣗʹߏங͢ Δ͜ͱ͕Ͱ͖Δ ೔ຊגσʔλͰΧελϜσʔλόϯυϧΛ࡞ͬͯΈΑ͏ʂ ؀ڥɿpython3.5 + zipline 1.1.1 (pip install -e ) ʢmacos + conda ʹΑΔԾ૝؀ڥʣ

Slide 7

Slide 7 text

ͬ͘͟Γߏஙखॱ 1. גՁσʔλͷௐୡͱOHLCVσʔλ࡞੒ 2. औҾॴ৘ใΛఆٛ 3. σʔλόϯυϧ΁ͷσʔλͷऔΓࠐΈ 4. όοΫςετΛ૸ΒͤΔ

Slide 8

Slide 8 text

1. גՁσʔλͷௐୡͱOHLCVσʔλ࡞੒ 2. औҾॴ৘ใΛఆٛ 3. σʔλόϯυϧ΁ͷσʔλͷऔΓࠐΈ 4. όοΫςετΛ૸ΒͤΔ OHLCVɿ̐ຊ஋ʢOpen / High / Low / Closeʣʴग़དྷߴʢVolumeʣ

Slide 9

Slide 9 text

גՁσʔλͷௐୡ JPX Data Cloud Ͱߪೖͷ৔߹ ౦ূגࣜશ໿ఆσʔλɿ̍ϲ݄෼ 1,404ԁ (ݸਓར༻) ೥ؒɿ1,404ԁ * 12ϲ݄ = 16,848 ԁ

Slide 10

Slide 10 text

OHLCVϑΝΠϧ࡞੒࣌ͷ ͭ·͖ͮϙΠϯτ open, high, low, close, volume ͷϔομ໊Ͱ࡞੒͢Δඞཁ͕͋Δɻ ̐ຊ஋ͷج४࣌ࠁΛɺJST ͔Β UTC ʹมߋ͢Δɻมߋ͠ͳ͍ͱσʔλऔΓࠐΈ࣌ʹࣦഊ͢Δɻ Before After ݩͱͳΔλΠϜκʔϯ ม׵ઌλΠϜκʔϯ

Slide 11

Slide 11 text

1. גՁσʔλͷௐୡͱOHLCVσʔλ࡞੒ 2. औҾॴ৘ใΛఆٛ 3. σʔλόϯυϧ΁ͷσʔλͷऔΓࠐΈ 4. όοΫςετΛ૸ΒͤΔ

Slide 12

Slide 12 text

औҾॴ৘ใͷߏங ΧελϜΧϨϯμʔΛ৽ن࡞੒͢Δɻ • औҾॴجຊΫϥε • औҾॴ໊ • λΠϜκʔϯ • ཱձ͍։࢝࣌ࠁ • ཱձ͍ऴྃ࣌ࠁ • ٳ೔৘ใ • ౔೔Ҏ֎ͷٳ৔೔෇Λఆٛ exchange_calendar_tse.py ൈਮ

Slide 13

Slide 13 text

ٳ೔ΧϨϯμʔߏங࣌ͷ ϙΠϯτ japandas ʹ౦ূٳ೔ΧϨϯμʔ͕͋Δɻ͜ΕΛ׆༻͢Δ͜ͱͰख͕ؒল͚·͢ɻ tse_holidays.py ൈਮ japandasͷTSEHolidayCalendar ʹ ͸ɺ1970 ೥ʔ2030೥ͷ౦ূٳ৔೔ ʢॕ೔ʴ೥຤೥࢝ʣ͕༻ҙ͞Ε͍ͯΔ

Slide 14

Slide 14 text

1. גՁσʔλͷௐୡͱOHLCVσʔλ࡞੒ 2. औҾॴ৘ใΛఆٛ 3. σʔλόϯυϧ΁ͷσʔλͷऔΓࠐΈ 4. όοΫςετΛ૸ΒͤΔ

Slide 15

Slide 15 text

σʔλόϯυϧ΁ͷऔΓࠐΈ “csvdir” ͱ͍͏ΧελϜσʔλόϯυϧΛ࡞੒͢Δπʔϧ͕༻ҙ͞Ε͍ͯΔɻ σʔλόϯυϧ΁ͷऔΓࠐΈεΫϦϓτΛɺ~/.zipline/extension.py ʹهࡌ͢Δ ΧελϜσʔλόϯυϧ࡞੒ πʔϧ”csvdir” Λݺͼग़͢ઃ ఆ ౦ূ༻ΧελϜΧϨϯμʔΛ ༧Ίziplineʹ௥Ճొ࿥

Slide 16

Slide 16 text

σʔλऔΓࠐΈͷ஫ҙࣄ߲ “csvdir”͸ɺ೔଍ʢ”daily”ʣ͓Αͼ෼଍ʢ”minute”ʣσʔλΛΧελϜσʔλόϯυϧͱͯ͠ొ࿥͢Δ ͜ͱ͕Ͱ͖Δ͕ɺಉ࣌ʹొ࿥͠Α͏ͱ͢Δͱ໏ฑͷೋॏొ࿥ʹΑΔϢχʔΫΩʔ੍໿ҧ൓͕ग़Δόά ͕͋Δʢ2017/12ݱࡏʣɻ zipline ingest [-b bundle-name] Ͱ csvϑΝΠϧΛσʔλόϯυϧʹొ࿥ csvdir.py ൈਮ

Slide 17

Slide 17 text

1. גՁσʔλͷௐୡͱOHLCVσʔλ࡞੒ 2. औҾॴ৘ใΛఆٛ 3. σʔλόϯυϧ΁ͷσʔλͷऔΓࠐΈ 4. όοΫςετΛ૸ΒͤΔ

Slide 18

Slide 18 text

όοΫςετ(on jupyter) [όοΫςετظؒ] 2017/01/01 - 2017/01/11 [σʔλͷස౓] minute(෼଍) 00:00 ͔Β෼଍Ͱ஋ஈ͕औಘͰ͖͍ͯΔ ʢJST = UTC + 9ʣ ॕ೔੍ޚͷ͓͔͛Ͱ ਖ਼݄ࡾ͕೔ʢॕ೔Ͱ͸ͳ͍͕ٳ৔ʣ ੒ਓͷ೔ʢॕ೔ʣ ΛεΩοϓͰ͖͍ͯΔ

Slide 19

Slide 19 text

jupyter notebook্Ͱ όοΫςετ͢Δࡍͷ஫ҙ఺ “%load_ext zipline” ͱɺ“%%zipline —start= …” ͸ηϧΛ෼͚ͳ͍ͱਖ਼͘͠ಈ࡞͠ͳ͍ —trading-calendar=TSE ͷࢦఆΛ๨ΕΔͱɺΧϨϯμʔ͕NYSEʢถࠃגࣜࢢ৔ʣͱͯ͠Ξϧΰ͕ಈ ͨ͘ΊגՁσʔλ͕र͑ͳ͍ɻ ηϧΛ෼͚Δ —trading-calendarͷࢦఆΛ๨Εͳ͍ όοΫςετظؒࢦఆ όοΫςετ࣌ؒ࣠ʢσϑΥϧτɿdailyʣ

Slide 20

Slide 20 text

࠷ޙʹ • ࣮ࡍʹόοΫςετΛ͢ΔͨΊʹ͸ɺ࣮͸͜ΕͰ͸ෆे෼ • גࣜ෼ׂ΍഑౰ࢧ෷͍ͳͲͷʮݖརམͪʯʹΑΔגՁमਖ਼͕ඞཁ • csvdir ʹ͸ิਖ਼ػೳ΋͍͍ͭͯΔ͕ɺσʔλΛ༻ҙ͠ͳ͍ͱ͍͚ͳ͍ • खܰʹ೔ຊגͰΞϧΰϦζϜτϨʔυΛࢼ͍ͨ͠ͷͰ͋Ε͹ɺ SmartTrade ͷ QuantX ͱ͍͏αʔϏε͕͋Δʢͨͩ͠ݱঢ়೔଍ͷ Έʣɻ • ࠓճ঺հͨ͠खॱ͸bitcoin ʹ΋Ԡ༻Ͱ͖Δɻݖརམͪͷ৺഑͕ͳ ͘ɺσʔλऔಘ΋Ͱ͖ͦ͏ͳͷͰɺͬͪ͜঺հͨ͠ํ͕࣮༻ੑ͕ߴ ͔ͬͨͷͰ͸ʁͱܰ͘ޙչ͍ͯ͠Δ