[Mod] make flake8 happy
This commit is contained in:
parent
d805ed043c
commit
9aa90f538f
@ -1,22 +1,11 @@
|
||||
import json
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from threading import Lock
|
||||
from typing import Dict, List, Optional, TYPE_CHECKING, Tuple
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from requests import ConnectionError
|
||||
|
||||
from vnpy.api.rest import Request
|
||||
from vnpy.trader.constant import Direction, Exchange, Interval, Offset, Product, Status
|
||||
from vnpy.trader.object import AccountData, BarData, CancelRequest, ContractData, OrderRequest, \
|
||||
PositionData, OrderData
|
||||
from .oanda_common import (INTERVAL_VT2OANDA, ORDER_TYPE_VT2OANDA,
|
||||
STATUS_OANDA2VT, parse_time, INTERVAL_VT2OANDA_DELTA, parse_datetime)
|
||||
from vnpy.api.rest import Request, RestClient
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vnpy.gateway.oanda import OandaGateway
|
||||
from vnpy.api.rest import RestClient
|
||||
|
||||
_ = lambda x: x # noqa
|
||||
|
||||
@ -25,6 +14,7 @@ class OandaApiBase(RestClient):
|
||||
"""
|
||||
Oanda Base API
|
||||
"""
|
||||
|
||||
def __init__(self, gateway: "OandaGateway"):
|
||||
super().__init__()
|
||||
self.gateway = gateway
|
||||
@ -62,4 +52,3 @@ class OandaApiBase(RestClient):
|
||||
sys.stderr.write(
|
||||
self.exception_detail(exception_type, exception_value, tb, request)
|
||||
)
|
||||
|
||||
|
@ -6,7 +6,7 @@ from vnpy.trader.constant import Direction, Interval, OrderType, Status
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# noinspection PyUnresolvedReferences
|
||||
from vnpy.gateway.oanda import OandaGateway
|
||||
from vnpy.gateway.oanda import OandaGateway # noqa
|
||||
|
||||
STATUS_OANDA2VT = {
|
||||
"PENDING": Status.NOTTRADED,
|
||||
|
@ -5,21 +5,18 @@ todo:
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Any, Tuple, Optional
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
from vnpy.event import Event
|
||||
from vnpy.trader.constant import (Exchange, OrderType, Interval, Direction, Offset, Status)
|
||||
from vnpy.trader.constant import (Direction, Exchange, Interval, Offset, OrderType, Status)
|
||||
from vnpy.trader.event import EVENT_TIMER
|
||||
from vnpy.trader.gateway import BaseGateway
|
||||
from vnpy.trader.object import (CancelRequest, HistoryRequest, OrderData, OrderRequest,
|
||||
PositionData, SubscribeRequest, TickData, BarData)
|
||||
from .oanda_common import DIRECTION_OANDA2VT, OPPOSITE_DIRECTION, ORDER_TYPE_OANDA2VT, \
|
||||
STOP_ORDER_STATUS_OANDA2VT, parse_datetime, STATUS_OANDA2VT, INTERVAL_VT2OANDA, local_tz, \
|
||||
utc_tz, INTERVAL_VT2OANDA_INT, parse_time, INTERVAL_VT2OANDA_DELTA
|
||||
from .oanda_rest_api import OandaRestApi, HistoryDataNextInfo
|
||||
from vnpy.trader.object import (BarData, CancelRequest, HistoryRequest, OrderData, OrderRequest,
|
||||
SubscribeRequest)
|
||||
from .oanda_common import INTERVAL_VT2OANDA_DELTA, ORDER_TYPE_OANDA2VT, local_tz, parse_time, utc_tz
|
||||
from .oanda_rest_api import HistoryDataNextInfo, OandaRestApi
|
||||
from .oanda_stream_api import OandaStreamApi
|
||||
|
||||
|
||||
_ = lambda x: x # noqa
|
||||
|
||||
|
||||
@ -205,4 +202,3 @@ class OandaGateway(BaseGateway):
|
||||
)
|
||||
self.orders[order_id] = order
|
||||
return order
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import json
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from threading import Lock
|
||||
@ -11,10 +9,9 @@ from vnpy.api.rest import Request
|
||||
from vnpy.gateway.oanda.oanda_api_base import OandaApiBase
|
||||
from vnpy.trader.constant import Direction, Exchange, Interval, Offset, Product, Status
|
||||
from vnpy.trader.object import AccountData, BarData, CancelRequest, ContractData, OrderRequest, \
|
||||
PositionData, OrderData
|
||||
from .oanda_common import (INTERVAL_VT2OANDA, ORDER_TYPE_VT2OANDA,
|
||||
STATUS_OANDA2VT, parse_time, INTERVAL_VT2OANDA_DELTA, parse_datetime,
|
||||
utc_tz, local_tz)
|
||||
PositionData
|
||||
from .oanda_common import (INTERVAL_VT2OANDA, INTERVAL_VT2OANDA_DELTA, ORDER_TYPE_VT2OANDA,
|
||||
STATUS_OANDA2VT, local_tz, parse_datetime, parse_time, utc_tz)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vnpy.gateway.oanda import OandaGateway
|
||||
@ -122,7 +119,6 @@ class OandaRestApi(OandaApiBase):
|
||||
order.time = parse_time(datetime.now().isoformat())
|
||||
|
||||
# Only add price for limit order.
|
||||
str_price = str(req.price)
|
||||
data["type"] = ORDER_TYPE_VT2OANDA[req.type]
|
||||
data["price"] = str(req.price)
|
||||
self.gateway.orders[order.orderid] = order
|
||||
@ -240,7 +236,7 @@ class OandaRestApi(OandaApiBase):
|
||||
|
||||
def on_send_order(self, raw_data: dict, request: Request):
|
||||
""""""
|
||||
order: OrderData = request.extra
|
||||
# order: OrderData = request.extra
|
||||
# creation = raw_data.get('orderCreateTransaction', None)
|
||||
# if creation is not None:
|
||||
# order.status = Status.NOTTRADED
|
||||
@ -347,7 +343,8 @@ class OandaRestApi(OandaApiBase):
|
||||
|
||||
def parse_position_data(self, pos_data) -> Tuple[PositionData, PositionData]:
|
||||
symbol = pos_data['instrument']
|
||||
pos_long, pos_short = [PositionData(
|
||||
pos_long, pos_short = [
|
||||
PositionData(
|
||||
gateway_name=self.gateway_name,
|
||||
symbol=symbol,
|
||||
exchange=Exchange.OANDA,
|
||||
|
@ -1,5 +1,4 @@
|
||||
from copy import copy
|
||||
from copy import copy
|
||||
from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from http.client import IncompleteRead, RemoteDisconnected
|
||||
|
@ -119,6 +119,7 @@ class Exchange(Enum):
|
||||
BINANCE = "BINANCE"
|
||||
COINBASE = "COINBASE"
|
||||
|
||||
|
||||
class Currency(Enum):
|
||||
"""
|
||||
Currency.
|
||||
|
Loading…
Reference in New Issue
Block a user