symbolindex = contractExchange + "|Z|" + contractSymbol + "|INDEX"  # 基准合约
symbol01 = contractExchange + "|F|" + contractSymbol + "|2101"
symbol05 = contractExchange + "|F|" + contractSymbol + "|2005"
symbol09 = contractExchange + "|F|" + contractSymbol + "|2010"

spotFileName = os.path.abspath(
    os.path.join(os.getcwd(), "..", 'files', contractSymbol,
                 contractSymbol + "_spotprice.csv"))
contractCfgPath = os.path.abspath(
    os.path.join(os.getcwd(), "..", 'files', "contractConfig.json"))

barInteval = 30
barType = 'M'

spotdata = None
spotSeries = NumericSeries(name="spotSeries")

# symbolset = set([symbol01, symbol05, symbol09])

m01CloseSeries = NumericSeries(name="m01CloseSeries")
m05CloseSeries = NumericSeries(name="m05CloseSeries")
m09CloseSeries = NumericSeries(name="m09CloseSeries")

#m01VolSeries = NumericSeries(name="m01VolSeries")
#m05VolSeries = NumericSeries(name="m05VolSeries")
#m09VolSeries = NumericSeries(name="m09VolSeries")

m01HoldingSeries = NumericSeries(name="m01HoldingSeries")
m05HoldingSeries = NumericSeries(name="m05HoldingSeries")
m09HoldingSeries = NumericSeries(name="m09HoldingSeries")
Exemple #2
0
import talib
from EsSeries import NumericSeries

aa = NumericSeries()
bb = NumericSeries()
cc = NumericSeries()


def initialize(context):
    SetBarInterval("NYMEX|Z|CL|MAIN", 'M', 1, 2000)


def handle_data(context):
    global aa, bb, cc
    aa[-1] = Close()[-1]
    bb[-1] = Open()[-1]
    cc[-1] = min(aa[-1], bb[-1])
    PlotNumeric("cc", cc[-3])
Exemple #3
0
import talib
import EsTalib
import EsTalib2
from EsSeries import NumericSeries

ue_sma = NumericSeries()
ue_sma2 = NumericSeries()


def initialize(context):
    SetBarInterval('DCE|F|I|1909', 'M', 3, 2000)


def handle_data(context):
    global ue_sma
    ta_sma = talib.SMA(Close(), timeperiod=5)
    es_sma = SMA(Close(), 5, 5)
    ue_sma[-1] = EsTalib.U_SMA(ue_sma, Close(), 5, 5)
    ue_sma2[-1] = EsTalib2.U_SMA(Close(), 5, 5)

    LogInfo("SMA", ta_sma[-1], es_sma[-1], ue_sma[-1], ue_sma2[-1])

    PlotNumeric('ta_sma', ta_sma[-1], color=RGB_Red())
    PlotNumeric('es_sma', es_sma[-1], color=RGB_Blue())
    PlotNumeric('ue_sma', ue_sma[-1], color=RGB_Green())
    PlotNumeric('ue_sma2', ue_sma2[-1], color=RGB_Purple())
Exemple #4
0
 def __init__(self):
     self.Af = NumericSeries()
     self.ParOpen = NumericSeries()
     self.Position = NumericSeries()
     self.HHValue = NumericSeries()
     self.LLValue = NumericSeries()
Exemple #5
0
import talib
from EsTaClass import UC_SAR
from EsSeries import NumericSeries

runsVar = 4

mySAR = UC_SAR()

OParCl2 = NumericSeries()
OParOp2 = NumericSeries()
OPosition2 = NumericSeries()
OTRansition2 = NumericSeries()


def initialize(context):
    SetBarInterval("NYMEX|F|CL|1909", 'M', 1, 2000)


def handle_data(context):
    global mySAR, OParCl2, OParOp2, OPosition2, OTRansition2
    afStep = runsVar / 100
    afLimit = afStep * 10
    sar = talib.SAR(High(), Low(), afStep, afLimit)

    OParCl, OParOp, OPosition, OTRansition = ParabolicSAR(
        High(), Low(), afStep, afLimit)

    #OParCl2[-1], OParOp2[-1], OPosition2[-1], OTRansition2[-1] = mySAR.U_SAR(High(), Low(), afStep, afLimit)
    OParCl3, OParOp3, OPosition3, OTRansition3 = mySAR.U_SAR(
        High(), Low(), afStep, afLimit)