Пример #1
0
    def getDailyTrends(self, stockData):

        trends = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

        dailyTrends = {}
        tr = {}

        allStocks = self.getAllStocksArr()

        for stocks in allStocks:
            cn = lpl.ConnectEtrade(self.c, stocks, 1, 1, "intraday", False, 1)

            for stock in stocks:
                tr[stock] = lpl.Trends(self.d, self.l, cn, 0, 0, stock)

                stockValues = cn.setStockValues(0, 0, "")

                print("stockData[stock] len\n" + str(len(stockData[stock])) +
                      " " + str(stock))

                tr[stock].setTrendLimits(stockData[stock],
                                         len(stockData[stock]), 0, 0)

                trends[self.bearS] = tr[stock].isBearShortTrend()
                trends[self.bearM] = tr[stock].isBearMidTrend()
                trends[self.bearL] = tr[stock].isBearLongTrend()
                trends[self.bearE] = tr[stock].isBearMegaTrend()
                trends[self.bearU] = tr[stock].isBearSuperTrend()

                trends[self.bullS] = tr[stock].isBullShortTrend()
                trends[self.bullM] = tr[stock].isBullMidTrend()
                trends[self.bullL] = tr[stock].isBullLongTrend()
                trends[self.bullE] = tr[stock].isBullMegaTrend()
                trends[self.bullU] = tr[stock].isBullSuperTrend()

                print("trends " + str("trends\n" + str(trends)))

                dailyTrends[stock] = trends
                trends = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

        print("dailyTrends " + str(dailyTrends))

        return dailyTrends
Пример #2
0
    cn.connectPublic()
elif service == "bitfinex":
    cn = lpl.ConnectBitFinex()
elif service == "eTrade":
    symbol = stock
    cn = lpl.ConnectEtrade(c, stocks, debug, verbose, marketDataType, sandBox,
                           offLine)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initialize algorithm,  barcharts objects

stocks = stocks.split(",")

for stock in stocks:
    ba[stock] = lpl.Barchart()
    tr[stock] = lpl.Trends(d, lg[stock], cn, ba[stock], offLine, stock)
    lm[stock] = lpl.Limits(d, lg[stock], cn, ba[stock], offLine, stock)
    a[stock] = lpl.Algorithm(d, lg[stock], cn, ba[stock], tr[stock], lm[stock],
                             offLine, stock)
    pr[stock] = lpl.Price(a[stock], cn, usePricesFromFile, offLine,
                          a[stock].getMarketBeginTime())

print(str(ba))
print(str(a))

lg1 = lg[stocks[0]]
a1 = a[stocks[0]]
tr1 = tr[stocks[0]]
lm1 = lm[stocks[0]]
pr1 = pr[stocks[0]]
Пример #3
0
if service == "bitstamp":
    cn = lpl.ConnectBitStamp(service, currency, alt)
    cn.connectPublic()
elif service == "bitfinex":
    cn = lpl.ConnectBitFinex()
elif service == "eTrade":
    symbol = stock
    cn = lpl.ConnectEtrade(c, stock, debug, verbose, marketDataType, sandBox,
                           offLine)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initialize algorithm,  barcharts objects

bc = lpl.Barchart()
tr = lpl.Trends(d, lg, cn, bc, offLine)
lm = lpl.Limits(d, lg, cn, bc, offLine)
pa = lpl.Pattern()
a = lpl.Algorithm(d, lg, cn, bc, tr, lm, pa, offLine, stock)
pr = lpl.Price(a, cn, usePricesFromFile, offLine, a.getMarketBeginTime())

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initialize files

lg.info("Using " + pricesPath + " as prices file")

with open(debugPath, "a+", encoding="utf-8") as debugFile:
    debugFile.write(
        lg.infoStamp(a.getLiveProfileValues(d,
                                            clOptions.profileTradeDataPath)))
    debugFile.write(lg.header(tm.now(), stock))
Пример #4
0
if service == "bitstamp":
    cn = lpl.ConnectBitStamp(service, currency, alt)
    cn.connectPublic()
elif service == "bitfinex":
    cn = lpl.ConnectBitFinex()
elif service == "eTrade":
    symbol = stock
    stockArr.append(stock)
    cn = lpl.ConnectEtrade(c, stockArr, debug, verbose, marketDataType,
                           sandBox, offLine)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initialize algorithm,  barcharts objects

bc = lpl.Barchart()
tr = lpl.Trends(d, lg, cn, bc, slave)
lm = lpl.Limits(d, lg, cn, bc, pf, symbol)
pa = lpl.Pattern(d, bc, lg)
#pr = lpl.Price(cn, slave)
pr = lpl.Price(cn, offLine)
#ac = lpl.Account(c)
dc = lpl.Dailychart()

dy = lpl.Dynamic(timeBar, dcPath, dc)

a = lpl.Algorithm(d, lg, cn, bc, tr, lm, pa, pr, dy, offLine, stock)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Initialize files

lg.info("Using " + pricesPath + " as prices file")
Пример #5
0
#stocks = stocks.split(",")

# find best profile to run against list of stocks
for stock in stocks:
#   if preMarketAnalysis:
#      if genProfile(algoData[stock], stock):
#         exit (1)
#      profileData[stock] = loadProfileData(clOptions.profileTradeDataPath)
#   else:
#      # Use default list
#      profileData[stock] = d

   profileData[stock] = pf.readProfile(clOptions.profileTradeDataPath)
   #profileData[stock] = loadProfileData(clOptions.profileTradeDataPath)
   ba[stock] = lpl.Barchart()
   tr[stock] = lpl.Trends(profileData[stock], lg[stock], cn, ba[stock], offLine, stock)
   lm[stock] = lpl.Limits(profileData[stock], lg[stock], cn, ba[stock], pf, stock)
   pr[stock] = lpl.Price(cn, offLine)
   pa[stock] = lpl.Pattern(profileData[stock], ba[stock], lg[stock])
   dc = lpl.Dailychart()
   dy = lpl.Dynamic(timeBar, dcPath, dc)
   a[stock] = lpl.Algorithm(profileData[stock], lg[stock], cn, ba[stock], tr[stock], lm[stock], pa[stock], pr[stock], dy, offLine, stock)
   ut = lpl.Util()
   th = lpl.Thred(ut, offLine, cwd, wcwd)

lg1 = lg[stocks[0]]
a1 = a[stocks[0]]
tr1 = tr[stocks[0]]
lm1 = lm[stocks[0]]
pr1 = pr[stocks[0]]
pa1 = pa[stocks[0]]