Beispiel #1
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import traceback
import time
import hbClient as hbc
from liveApi.liveUtils import *
from liveApi import liveLogger

logger = liveLogger.getLiveLogger("strategy")

broker = hbc.hbTradeClient()
client = broker.getClient()

OrderBuy = 0
OrderBuyed = 1
OrderSelled = 2
OrderCancel = 3


def timestamp():
    return int(time.time())


def showOrders(coin):
    order = coin['execOrder']
    symbol = coin['symbol']
    logger.info("------symbol:%s-%d------" % (symbol, timestamp()))
    logger.info('Order: %s' % order)

Beispiel #2
0
from pyalgotrade import strategy
from pyalgotrade import broker
from pyalgotrade.bar import Frequency
from pyalgotrade.technical import ma
from pyalgotrade.technical import cross
#from pyalgotrade import plotter
from pyalgotrade.stratanalyzer import returns
from liveApi.livebarfeed import LiveFeed
from liveApi.livebroker import LiveBroker
from liveApi import liveLogger

from hbClient import hbTradeClient as hbClient
from hbClient import hbCoinType

logger = liveLogger.getLiveLogger("MyStrategy")

COIN_TYPE = hbCoinType('ltc', 'usdt')
K_PERIOD = 60
REQ_DELAY = 0

#COIN_TYPE='ltc'


class MyStrategy(strategy.BaseStrategy):
    def __init__(self, feed, instrument, brk):
        super(MyStrategy, self).__init__(feed, brk)
        self.__position = None
        self.__instrument = instrument
        # We'll use adjusted close values instead of regular close values.
        self.__prices = feed[instrument].getPriceDataSeries()
        self.__sma = {}
Beispiel #3
0
from liveApi.TradeClientBase import *
from liveApi.liveUtils import *
from pyalgotrade.utils import dt
from liveApi import liveLogger

from hbsdk import ApiClient, ApiError

from ApiKey import API_KEY
from ApiKey import API_SECRET

logger = liveLogger.getLiveLogger("hbClient")


def Str2float(func):
    def waper(*args, **kwargs):
        return float(func(*args, **kwargs))

    return waper


class hbOrderType():
    BuyLimit = 'buy-limit'
    BuyMarket = 'buy-market'
    SellLimit = 'sell-limit'
    SellMarket = 'sell-market'


class hbOrderState():
    OrderFilled = 'filled'
    OrderCanceled = 'canceled'
    OrderSubmited = 'submitted'