From b417efb2418bb0168ab62b0ce1167a536e1fe0b8 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 8 Nov 2019 13:09:27 +0800 Subject: [PATCH] [Fix] add TRADER_DIR to environment variables --- examples/vn_trader/run.py | 4 ++-- vnpy/gateway/bybit/bybit_gateway.py | 2 +- vnpy/trader/utility.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/vn_trader/run.py b/examples/vn_trader/run.py index 55ca8949..bcc8366d 100644 --- a/examples/vn_trader/run.py +++ b/examples/vn_trader/run.py @@ -31,7 +31,7 @@ from vnpy.gateway.bitmex import BitmexGateway # from vnpy.gateway.coinbase import CoinbaseGateway # from vnpy.gateway.bitstamp import BitstampGateway # from vnpy.gateway.gateios import GateiosGateway -# from vnpy.gateway.bybit import BybitGateway +from vnpy.gateway.bybit import BybitGateway from vnpy.app.cta_strategy import CtaStrategyApp # from vnpy.app.csv_loader import CsvLoaderApp @@ -79,7 +79,7 @@ def main(): # main_engine.add_gateway(CoinbaseGateway) # main_engine.add_gateway(BitstampGateway) # main_engine.add_gateway(GateiosGateway) - # main_engine.add_gateway(BybitGateway) + main_engine.add_gateway(BybitGateway) main_engine.add_app(CtaStrategyApp) main_engine.add_app(CtaBacktesterApp) diff --git a/vnpy/gateway/bybit/bybit_gateway.py b/vnpy/gateway/bybit/bybit_gateway.py index d405d2e3..78461aee 100644 --- a/vnpy/gateway/bybit/bybit_gateway.py +++ b/vnpy/gateway/bybit/bybit_gateway.py @@ -541,7 +541,7 @@ class BybitRestApi(RestClient): exchange=req.exchange, datetime=dt, interval=req.interval, - volume=int(d["volume"]), + volume=float(d["volume"]), open_price=float(d["open"]), high_price=float(d["high"]), low_price=float(d["low"]), diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index 256a26f8..279d9410 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -4,6 +4,7 @@ General utility functions. import json import logging +import sys from pathlib import Path from typing import Callable, Dict from decimal import Decimal @@ -58,6 +59,7 @@ def _get_trader_dir(temp_name: str): TRADER_DIR, TEMP_DIR = _get_trader_dir(".vntrader") +sys.path.append(str(TRADER_DIR)) def get_file_path(filename: str):