Пример #1
0
def run_main(data):
    vessel = Vessel()
    vessel.add_data(data)
    stra = get_a_strategy()
    vessel.add_strategy(stra)
    vessel.set_params({"looper":
                           {"initial_capital": 100000,
                            "commission": 0.005,
                            "deal_pattern": "price",
                            "size_map": {"ag1912.SHFE": 15},
                            "today_commission": 0.005,
                            "yesterday_commission": 0.02,
                            "close_commission": 0.005,
                            "slippage_sell": 0,
                            "slippage_cover": 0,
                            "slippage_buy": 0,
                            "slippage_short": 0,
                            "close_pattern": "yesterday",
                            },
                       "strategy": {}
                       })
    vessel.run()
    from pprint import pprint
    result = vessel.get_result()
    pprint(result)
Пример #2
0
def run_main(data):
    vessel = Vessel()
    vessel.add_data(data)
    # vessel.add_data(dat)
    stra = DoubleMaStrategy("ma")
    vessel.add_strategy(stra)
    vessel.set_params({
        "looper": {
            "initial_capital": 100000,
            "commission": 0.005,
            "deal_pattern": "price",
            "size_map": {
                "rb2001.SHFE": 15
            },
            "today_commission": 0.005,
            "yesterday_commission": 0.05,
            "close_commission": 0.005,
            "slippage_sell": 0,
            "slippage_cover": 0,
            "slippage_buy": 0,
            "slippage_short": 0,
            "close_pattern": "yesterday",
        },
        "strategy": {}
    })
    vessel.run()
    from pprint import pprint
    result = vessel.get_result(report=True, auto_open=True)
Пример #3
0
def run_main(result):
    vessel = Vessel()
    result = list(result.values())
    for x in result:
        x['datetime'] = x['datetime'].to_pydatetime()
    print(len(result))
    vessel.add_data(result)
    vessel.add_strategy(double_ma)
    vessel.set_params({"looper":
                           {"initial_capital": 2000000,
                            "commission": 0.005,
                            "deal_pattern": "price",
                            "size_map": {"cu2001.SHFE": 15},
                            "today_commission": 0.005,
                            "yesterday_commission": 0.02,
                            "close_commission": 0.005,
                            "slippage_sell": 0,
                            "slippage_cover": 0,
                            "slippage_buy": 0,
                            "slippage_short": 0,
                            "close_pattern": "yesterday",
                            },
                       "strategy": {}
                       })
    vessel.run()
    from pprint import pprint
    result = vessel.get_result()
    pprint(result)
Пример #4
0
 def run(self):
     # try:
     vessel = Vessel()
     for i in self.data:
         vessel.add_data(i)
     for i in self.strategy:
         vessel.add_strategy(i)
     vessel.set_params({"looper": self.params, "strategy": {}})
     vessel.run()
     result = vessel.get_result(report=True)
     error = ""
     # except Exception as e:
     #     result = ""
     #     error = str(e)
     self.sig.emit({
         "name": self.name,
         "url": result,
         "error": error,
     })