Upgrade to Pro — share decks privately, control downloads, hide ads and more …

zaifbotのlt

6dbe360915689b269ab4fa510743762b?s=47 英 谷口
May 07, 2017
92

 zaifbotのlt

6dbe360915689b269ab4fa510743762b?s=128

英 谷口

May 07, 2017
Tweet

Transcript

  1. Ծ૝௨՟ͷ औҾϥΠϒϥϦΛ ࡞ͬͯΈͨ

  2. Ծ૝௨՟औҾॴɾ;BJG

  3. ˢ ɹ͜ˠ Ε

  4. ؀ڥߏங

  5. QZWFOWWFOW TPVSDFWFOWCJOBDUJWBUF WFOW QJQJOTUBMM[BJGCPU WFOW JOJU@EBUBCBTF

  6. ѻ͑Δ௨՟ϖΞΛ औಘ͍ͨ͠

  7. ௨՟ϖΞͱ͸ʁ औҾ͢Δ௨՟ͷ૊Έ߹Θͤ

  8. ϏοτίΠϯ ԁ ˣ CUD@KQZ

  9. .0/" ԁ ˣ NPOB@KQZ

  10. 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' >> }
  11. ऴ஋Λऔಘ͍ͨ͠

  12. 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’}
  13. ҠಈฏۉઢΛ औಘ͍ͨ͠

  14. Ҡಈฏۉઢͱ͸ʁ ҰఆظؒͷฏۉՁ֨Λ ೔ʑܭࢉͯ͠ग़ͨ͠ʮ౴͑ʯΛ ઢͰͭͳ͍ͩ΋ͷ

  15. ৄ͘͠͸Πϯϕελʔ;Ͱ

  16. 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}]
  17. ࣮ࡍʹτϨʔυ͍ͨ͠

  18. None
  19. 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 >> } >> }
  20. ϝϦοτ Τϥʔ࣌ࣗಈϦτϥΠ OPODFࣗಈ෇༩

  21. ༨ܭͳ஫จΛࣗಈͰ Ωϟϯηϧ͍ͨ͠

  22. DBTF ࠓ͙͢ചΓ͍ͨͷʹ ஫จ͕ྲྀΕ͍ͯͬͯ͠·͏ DBTF ࠷ऴ஋ͱ཭Ε͗ͯ͢ɺ ͍ͭ·Ͱͨͬͯ΋໿ఆ͠ͳ͍

  23. 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'])
  24. ৄ͘͠͸͜͜ (JU)VCɿIUUQTHJUIVCDPNUFDICVSFBV[BJGCPU "1*υΩϡϝϯτɿ IUUQTUFDICVSFBVBQJEPDVNFOUSFBEUIFEPDTJPKB MBUFTUJOEFYIUNM

  25. ࠓ೥΋1Z$PO΍Γ·͢

  26. τʔΫٴͼϙελʔืू