Exemplo n.º 1
0
 def buyCoin(self, msg, db, api, currencyPair, triggerAmount):
     coinInfo = coin.coinInfo()
     resp = api.buy(coinInfo.fitUnit(currencyPair, triggerAmount),
                    coinInfo.getBuyingAmount(currencyPair), currencyPair)
     korbit_status.updateLastBalance(api, db)
     if (resp.text != ""):
         jsonObj = json.loads(resp.text)
         if (jsonObj['status'] == 'success'):
             db.updateTriggerAmount(currencyPair, jsonObj['orderId'])
     msg.sendMsg(
         myProperty.getMyChatId(), "[룰1] 구입 결과! " +
         str(coinInfo.fitUnit(currencyPair, triggerAmount)) + ", 결과:" +
         resp.text)
     msg.sendMsg(
         myProperty.getMyChatId(), "[룰1] 구입 결과! " +
         str(coinInfo.fitUnit(currencyPair, triggerAmount)) + ", header:" +
         str(resp.headers))
Exemplo n.º 2
0
#!/usr/bin/env python

from pytz import utc

#from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.executors.pool import ProcessPoolExecutor

import json
import collect
import korbit
import korbit_rule
import coin

sched = BlockingScheduler()
coinInfo = coin.coinInfo()
currency_pair_list = coinInfo.getCurrentPairList()

db = collect.TradingDB()
api = korbit.KorbitApi('', '', db)
rule1 = korbit_rule.korbitRule1()


@sched.scheduled_job('interval', seconds=60)
def collectTick():
    # 각 코인 마다 api 호출해서 가격 얻어오고 db 에 저장
    for i, currencyPair in enumerate(currency_pair_list):
        resp = api.getTick(currencyPair)
        print("tick resp:" + resp)
        tickData = json.loads(resp)
        db.insertTick(currencyPair, tickData)