Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/apex-omni'
Browse files Browse the repository at this point in the history
  • Loading branch information
saleh-mir committed Oct 26, 2024
2 parents a94c094 + 8c44673 commit 7c35ffd
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 6 deletions.
2 changes: 2 additions & 0 deletions jesse/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class exchanges:
DYDX_PERPETUAL_TESTNET = "Dydx Perpetual Testnet"
APEX_PRO_PERPETUAL_TESTNET = 'Apex Pro Perpetual Testnet'
APEX_PRO_PERPETUAL = 'Apex Pro Perpetual'
APEX_OMNI_PERPETUAL_TESTNET = 'Apex Omni Perpetual Testnet'
APEX_OMNI_PERPETUAL = 'Apex Omni Perpetual'
GATE_USDT_PERPETUAL = 'Gate USDT Perpetual'
GATE_SPOT = 'Gate Spot'

Expand Down
28 changes: 28 additions & 0 deletions jesse/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,34 @@
'required_live_plan': 'premium'
},

exchanges_enums.APEX_OMNI_PERPETUAL_TESTNET: {
'name': exchanges_enums.APEX_OMNI_PERPETUAL_TESTNET,
'url': 'https://testnet.omni.apex.exchange/trade/BTCUSD',
'fee': 0.0005,
'type': 'futures',
'supported_leverage_modes': ['cross'],
'supported_timeframes': APEX_PRO_TIMEFRAMES,
'modes': {
'backtesting': False,
'live_trading': False,
},
'required_live_plan': 'premium'
},

exchanges_enums.APEX_OMNI_PERPETUAL: {
'name': exchanges_enums.APEX_OMNI_PERPETUAL,
'url': 'https://omni.apex.exchange/trade/BTCUSD',
'fee': 0.0005,
'type': 'futures',
'supported_leverage_modes': ['cross'],
'supported_timeframes': APEX_PRO_TIMEFRAMES,
'modes': {
'backtesting': False,
'live_trading': True,
},
'required_live_plan': 'premium'
},

exchanges_enums.GATE_USDT_PERPETUAL: {
'name': exchanges_enums.GATE_USDT_PERPETUAL,
'url': 'https://jesse.trade/gate',
Expand Down
10 changes: 10 additions & 0 deletions jesse/modes/import_candles_mode/drivers/Apex/ApexOmniPerpetual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .ApexProMain import ApexProMain
from jesse.enums import exchanges


class ApexOmniPerpetual(ApexProMain):
def __init__(self) -> None:
super().__init__(
name=exchanges.APEX_OMNI_PERPETUAL,
rest_endpoint='https://omni.apex.exchange/api/v3'
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .ApexProMain import ApexProMain
from jesse.enums import exchanges


class ApexOmniPerpetualTestnet(ApexProMain):
def __init__(self) -> None:
super().__init__(
name=exchanges.APEX_OMNI_PERPETUAL_TESTNET,
rest_endpoint='https://testnet.omni.apex.exchange/api/v3'
)
14 changes: 10 additions & 4 deletions jesse/modes/import_candles_mode/drivers/Apex/ApexProMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_starting_time(self, symbol: str) -> int:
'start': 1514811660
}

response = requests.get(self.endpoint + '/v2/klines', params=payload)
response = requests.get(self.endpoint + '/klines', params=payload)
self.validate_response(response)

if 'data' not in response.json():
Expand All @@ -48,14 +48,14 @@ def fetch(self, symbol: str, start_timestamp: int, timeframe: str = '1m') -> Uni
'limit': self.count
}

response = requests.get(self.endpoint + '/v2/klines', params=payload)
response = requests.get(self.endpoint + '/klines', params=payload)
# check data exist in response.json

if 'data' not in response.json():
raise exceptions.ExchangeInMaintenance(response.json()['msg'])
elif response.json()['data'] == {}:
raise exceptions.InvalidSymbol('Exchange does not support the entered symbol. Please enter a valid symbol.')

data = response.json()['data'][dashless_symbol]

return [
Expand All @@ -74,10 +74,16 @@ def fetch(self, symbol: str, start_timestamp: int, timeframe: str = '1m') -> Uni
]

def get_available_symbols(self) -> list:
response = requests.get(self.endpoint + '/v2/symbols')
response = requests.get(self.endpoint + '/symbols')
self.validate_response(response)
data = response.json()['data']

if 'usdtConfig' not in data:
symbols = []
for p in data['contractConfig']['perpetualContract']:
symbols.append(p['symbol'])
return list(sorted(symbols))

usdt_pairs = []
for p in data['usdtConfig']['perpetualContract']:
usdt_pairs.append(p['symbol'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class ApexProPerpetual(ApexProMain):
def __init__(self) -> None:
super().__init__(
name=exchanges.APEX_PRO_PERPETUAL,
rest_endpoint='https://pro.apex.exchange/api'
rest_endpoint='https://pro.apex.exchange/api/v2'
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class ApexProPerpetualTestnet(ApexProMain):
def __init__(self) -> None:
super().__init__(
name=exchanges.APEX_PRO_PERPETUAL_TESTNET,
rest_endpoint='https://testnet.pro.apex.exchange/api'
rest_endpoint='https://testnet.pro.apex.exchange/api/v2'
)
4 changes: 4 additions & 0 deletions jesse/modes/import_candles_mode/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from jesse.modes.import_candles_mode.drivers.Bybit.BybitSpot import BybitSpot
from jesse.modes.import_candles_mode.drivers.Apex.ApexProPerpetualTestnet import ApexProPerpetualTestnet
from jesse.modes.import_candles_mode.drivers.Apex.ApexProPerpetual import ApexProPerpetual
from jesse.modes.import_candles_mode.drivers.Apex.ApexOmniPerpetualTestnet import ApexOmniPerpetualTestnet
from jesse.modes.import_candles_mode.drivers.Apex.ApexOmniPerpetual import ApexOmniPerpetual
from jesse.modes.import_candles_mode.drivers.Gate.GateUSDTPerpetual import GateUSDTPerpetual
from jesse.modes.import_candles_mode.drivers.Gate.GateSpot import GateSpot

Expand All @@ -39,6 +41,8 @@
exchanges.BITGET_USDT_PERPETUAL_TESTNET: BitgetUSDTPerpetualTestnet,
exchanges.APEX_PRO_PERPETUAL_TESTNET: ApexProPerpetualTestnet,
exchanges.APEX_PRO_PERPETUAL: ApexProPerpetual,
exchanges.APEX_OMNI_PERPETUAL_TESTNET: ApexOmniPerpetualTestnet,
exchanges.APEX_OMNI_PERPETUAL: ApexOmniPerpetual,
exchanges.GATE_USDT_PERPETUAL: GateUSDTPerpetual,
exchanges.GATE_SPOT: GateSpot,

Expand Down

0 comments on commit 7c35ffd

Please sign in to comment.