Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
zaifbotのlt
Search
英 谷口
May 07, 2017
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
zaifbotのlt
英 谷口
May 07, 2017
More Decks by 英 谷口
See All by 英 谷口
plasma.pdf
akira_taniguchi
1
700
pycon mini osaka 発表資料:ethereum
akira_taniguchi
1
920
How_To_ Introduce_TradingView
akira_taniguchi
1
900
OAuth2の資料
akira_taniguchi
0
4.9k
pycon2016_zaif
akira_taniguchi
0
290
pyconjp 2016 ライトニング用(未確定)
akira_taniguchi
1
260
test pdf
akira_taniguchi
0
110
PyConJP 2015 スライド資料
akira_taniguchi
0
160
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
160
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
4 Signs Your Business is Dying
shpigford
187
22k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
The Curse of the Amulet
leimatthew05
1
13k
Embracing the Ebb and Flow
colly
88
5.1k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
320
Transcript
Ծ௨՟ͷ औҾϥΠϒϥϦΛ ࡞ͬͯΈͨ
Ծ௨՟औҾॴɾ;BJG
ˢ ɹ͜ˠ Ε
ڥߏங
QZWFOWWFOW TPVSDFWFOWCJOBDUJWBUF WFOW QJQJOTUBMM[BJGCPU WFOW JOJU@EBUBCBTF
ѻ͑Δ௨՟ϖΞΛ औಘ͍ͨ͠
௨՟ϖΞͱʁ औҾ͢Δ௨՟ͷΈ߹Θͤ
ϏοτίΠϯ ԁ ˣ CUD@KQZ
.0/" ԁ ˣ NPOB@KQZ
from zaifbot.modules.api.cache import ZaifCurrencyPairs zaif = ZaifCurrencyPairs() print(zaif.all) #ZaifͰѻ͑Δͯ͢ͷ௨՟ϖΞใΛऔಘ
print(zaif[‘btc_jpy']) #௨՟ϖΞΛࢦఆ͢Εɺ୯ମͷใΛऔಘ >> [{‘aux_unit_step': 5.0 ʙʙʙ͍ͷͰলུʙʙʙ 'currency_pair': ‘btc_jpy'}] >> { >> 'aux_unit_step': 5.0, >> 'event_number': 0, >> 'item_unit_step': 0.0001, >> 'description': 'ϏοτίΠϯɾຊԁͷऔҾΛߦ͏͜ͱ͕Ͱ͖·͢', >> 'name': 'BTC/JPY', >> 'is_token': False, >> 'aux_unit_min': 5.0, >> 'title': 'BTC/JPY', >> 'item_unit_min': 0.0001, >> 'currency_pair': ‘btc_jpy' >> }
ऴΛऔಘ͍ͨ͠
from time import sleep from zaifbot.modules.utils import get_current_last_price print(get_current_last_price('btc_jpy'))
#औಘ͍ͨ͠currency_pairΛࢦఆ print(get_current_last_price('mona_jpy')) sleep(30) print(get_current_last_price('btc_jpy')) #ϦΞϧλΠϜͰऔಘՄೳ print(get_current_last_price('mona_jpy')) >> {'last_price': 165800.0, 'timestamp': '2017-05-02 18:17:55.322019'} >> {'last_price': 15.3, 'timestamp': '2017-05-02 18:17:56.533959’} ʙʙ30ඵޙʙʙ >> {'last_price': 165830.0, 'timestamp': '2017-05-02 18:18:26.415696'} >> {'last_price': 15.3, 'timestamp': '2017-05-02 18:18:22.328562’}
ҠಈฏۉઢΛ औಘ͍ͨ͠
Ҡಈฏۉઢͱʁ ҰఆظؒͷฏۉՁ֨Λ ʑܭࢉͯ͠ग़ͨ͠ʮ͑ʯΛ ઢͰͭͳ͍ͩͷ
ৄ͘͠Πϯϕελʔ;Ͱ
from zaifbot.moving_average import get_sma, get_ema print(get_sma()) #୯७Ҡಈฏۉઢऔಘ print(get_ema()) #ࢦҠಈฏۉઢऔಘ
>> [{'time_stamp': 1408719600, 'close': 53000.0, 'moving_average': 53410.0, 'closed': True}, {'time_stamp': 1408806000, 'close': 53900.0, 'moving_average': 54090.0, 'closed': True}] >> [{'time_stamp': 1408287600, 'close': 47001.0, 'moving_average': 50702.24516926622, 'closed': True}, {'time_stamp': 1408374000, 'close': 50500.0, 'moving_average': 50634.83011284415, 'closed': True}]
࣮ࡍʹτϨʔυ͍ͨ͠
None
from zaifbot.modules.api.wrapper import BotTradeApi key = '࡞ͨ͠key' secret
= '࡞ͨ͠secret' api = BotTradeApi(key, secret) trade_result = api.trade(currency_pair='btc_jpy', action='bid', price=180000, amount=2) print(trade_result) >> { >> "received": 0.1, >> "remains": 0, >> "order_id": 354323, >> "funds": { >> "jpy": 325, >> "btc": 1.392, >> "mona": 2600 >> } >> }
ϝϦοτ Τϥʔ࣌ࣗಈϦτϥΠ OPODFࣗಈ༩
༨ܭͳจΛࣗಈͰ Ωϟϯηϧ͍ͨ͠
DBTF ࠓ͙͢ചΓ͍ͨͷʹ จ͕ྲྀΕ͍ͯͬͯ͠·͏ DBTF ࠷ऴͱΕ͗ͯ͢ɺ ͍ͭ·Ͱͨͬͯఆ͠ͳ͍
from zaifbot.modules.api.wrapper import BotTradeApi from zaifbot.modules.api.order import AutoCancelClient
key = '࡞ͨ͠key' secret = '࡞ͨ͠secret' api = BotTradeApi(key, secret) trade_result = api.trade(currency_pair='btc_jpy', action='bid', price=180000, amount=2) order_id = trade_result['order_id'] auto_canceler = AutoCancelClient(api) # ࠷ऴஈ͔Β10000ԁΕͨΒࣗಈͰΦʔμʔऔΓফ͠ auto_canceler.cancel_by_price(order_id, 'btc_jpy', 10000) # ̍࣌ؒఆ͠ͳ͔ͬͨΒࣗಈͰΦʔμʔऔΓফ͠ auto_canceler.cancel_by_time(order_id, 'btc_jpy', 3600) # ΞΫςΟϒͳࣗಈऔΓফ͠ઃఆͷΦʔμʔҰཡ active_cancel_orders = auto_canceler.get_active_cancel_orders() for active_cancel_order in active_cancel_orders: print(active_cancel_order) >> {‘id’: ‘583hjf7whj345’, ‘cancel_type’: ‘by_time’ ʙলུʙ} # ࣗಈऔΓফ͠ΛΩϟϯηϧ auto_canceler.stop_cancel(active_cancel_orders[0]['id'])
ৄ͘͜͜͠ (JU)VCɿIUUQTHJUIVCDPNUFDICVSFBV[BJGCPU "1*υΩϡϝϯτɿ IUUQTUFDICVSFBVBQJEPDVNFOUSFBEUIFEPDTJPKB MBUFTUJOEFYIUNM
ࠓ1Z$POΓ·͢
τʔΫٴͼϙελʔืू