[Mod] convert coin volume to contract volume for inverse contract
This commit is contained in:
parent
8781aa72d5
commit
7a72d5f63f
@ -268,6 +268,11 @@ class SpreadData:
|
|||||||
)
|
)
|
||||||
return tick
|
return tick
|
||||||
|
|
||||||
|
def is_inverse(self, vt_symbol: str) -> bool:
|
||||||
|
""""""
|
||||||
|
inverse_contract = self.inverse_contracts[vt_symbol]
|
||||||
|
return inverse_contract
|
||||||
|
|
||||||
|
|
||||||
def calculate_inverse_volume(original_volume: float, price: float) -> float:
|
def calculate_inverse_volume(original_volume: float, price: float) -> float:
|
||||||
""""""
|
""""""
|
||||||
|
@ -8,7 +8,7 @@ from vnpy.trader.object import TickData, TradeData, OrderData, ContractData
|
|||||||
from vnpy.trader.constant import Direction, Status, Offset
|
from vnpy.trader.constant import Direction, Status, Offset
|
||||||
from vnpy.trader.utility import virtual
|
from vnpy.trader.utility import virtual
|
||||||
|
|
||||||
from .base import SpreadData
|
from .base import SpreadData, calculate_inverse_volume
|
||||||
|
|
||||||
|
|
||||||
class SpreadAlgoTemplate:
|
class SpreadAlgoTemplate:
|
||||||
@ -177,6 +177,11 @@ class SpreadAlgoTemplate:
|
|||||||
direction: Direction,
|
direction: Direction,
|
||||||
):
|
):
|
||||||
""""""
|
""""""
|
||||||
|
# For inverse contract:
|
||||||
|
# contract trading volume = coin trading volume * trading price
|
||||||
|
if self.spread.is_inverse(vt_symbol):
|
||||||
|
volume = volume * price
|
||||||
|
|
||||||
vt_orderids = self.algo_engine.send_order(
|
vt_orderids = self.algo_engine.send_order(
|
||||||
self,
|
self,
|
||||||
vt_symbol,
|
vt_symbol,
|
||||||
|
Loading…
Reference in New Issue
Block a user