Okex uses 4h mark candle timeframe
This commit is contained in:
parent
ddce28c12d
commit
a557451eee
@ -1841,6 +1841,8 @@ class Exchange:
|
|||||||
if self.funding_fee_cutoff(open_date):
|
if self.funding_fee_cutoff(open_date):
|
||||||
open_date += timedelta(hours=1)
|
open_date += timedelta(hours=1)
|
||||||
timeframe = self._ft_has['mark_ohlcv_timeframe']
|
timeframe = self._ft_has['mark_ohlcv_timeframe']
|
||||||
|
timeframe_ff = self._ft_has.get('funding_fee_timeframe',
|
||||||
|
self._ft_has['mark_ohlcv_timeframe'])
|
||||||
open_date = timeframe_to_prev_date(timeframe, open_date)
|
open_date = timeframe_to_prev_date(timeframe, open_date)
|
||||||
|
|
||||||
fees: float = 0
|
fees: float = 0
|
||||||
@ -1852,7 +1854,7 @@ class Exchange:
|
|||||||
mark_comb: PairWithTimeframe = (
|
mark_comb: PairWithTimeframe = (
|
||||||
pair, timeframe, CandleType.from_string(self._ft_has["mark_ohlcv_price"]))
|
pair, timeframe, CandleType.from_string(self._ft_has["mark_ohlcv_price"]))
|
||||||
|
|
||||||
funding_comb: PairWithTimeframe = (pair, timeframe, CandleType.FUNDING_RATE)
|
funding_comb: PairWithTimeframe = (pair, timeframe_ff, CandleType.FUNDING_RATE)
|
||||||
candle_histories = self.refresh_latest_ohlcv(
|
candle_histories = self.refresh_latest_ohlcv(
|
||||||
[mark_comb, funding_comb],
|
[mark_comb, funding_comb],
|
||||||
since_ms=open_timestamp,
|
since_ms=open_timestamp,
|
||||||
|
@ -16,6 +16,8 @@ class Okex(Exchange):
|
|||||||
|
|
||||||
_ft_has: Dict = {
|
_ft_has: Dict = {
|
||||||
"ohlcv_candle_limit": 100,
|
"ohlcv_candle_limit": 100,
|
||||||
|
"mark_ohlcv_timeframe": "4h",
|
||||||
|
"funding_fee_timeframe": "8h",
|
||||||
}
|
}
|
||||||
|
|
||||||
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
|
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
|
||||||
|
@ -202,7 +202,9 @@ class TestCCXTExchange():
|
|||||||
|
|
||||||
pair = EXCHANGES[exchangename].get('futures_pair', EXCHANGES[exchangename]['pair'])
|
pair = EXCHANGES[exchangename].get('futures_pair', EXCHANGES[exchangename]['pair'])
|
||||||
since = int((datetime.now(timezone.utc) - timedelta(days=5)).timestamp() * 1000)
|
since = int((datetime.now(timezone.utc) - timedelta(days=5)).timestamp() * 1000)
|
||||||
pair_tf = (pair, '1h', CandleType.FUNDING_RATE)
|
timeframe_ff = exchange._ft_has.get('funding_fee_timeframe',
|
||||||
|
exchange._ft_has['mark_ohlcv_timeframe'])
|
||||||
|
pair_tf = (pair, timeframe_ff, CandleType.FUNDING_RATE)
|
||||||
|
|
||||||
funding_ohlcv = exchange.refresh_latest_ohlcv(
|
funding_ohlcv = exchange.refresh_latest_ohlcv(
|
||||||
[pair_tf],
|
[pair_tf],
|
||||||
@ -212,9 +214,8 @@ class TestCCXTExchange():
|
|||||||
assert isinstance(funding_ohlcv, dict)
|
assert isinstance(funding_ohlcv, dict)
|
||||||
rate = funding_ohlcv[pair_tf]
|
rate = funding_ohlcv[pair_tf]
|
||||||
|
|
||||||
expected_tf = exchange._ft_has['mark_ohlcv_timeframe']
|
this_hour = timeframe_to_prev_date(timeframe_ff)
|
||||||
this_hour = timeframe_to_prev_date(expected_tf)
|
prev_hour = timeframe_to_prev_date(timeframe_ff, this_hour - timedelta(minutes=1))
|
||||||
prev_hour = timeframe_to_prev_date(expected_tf, this_hour - timedelta(minutes=1))
|
|
||||||
assert rate[rate['date'] == this_hour].iloc[0]['open'] != 0.0
|
assert rate[rate['date'] == this_hour].iloc[0]['open'] != 0.0
|
||||||
assert rate[rate['date'] == prev_hour].iloc[0]['open'] != 0.0
|
assert rate[rate['date'] == prev_hour].iloc[0]['open'] != 0.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user