Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delta: fetchSettlementHistory, createExpiredOptionMarket #18675

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

Dan-krm
Copy link
Contributor

@Dan-krm Dan-krm commented Jul 27, 2023

Added fetchSettlementHistory and createExpiredOptionMarket to Delta:
https://www.delta.exchange/app/expired_futures_and_options

delta.fetchSettlementHistory (BTC/USDT:USDT-130723-29000-C)
2023-07-27T03:16:20.747Z iteration 0 passed in 4150 ms

                      symbol |             price |     timestamp |             datetime
---------------------------------------------------------------------------------------
BTC/USDT:USDT-130723-29000-C | 1555.784058200865 | 1689249600000 | 2023-07-13T12:00:00Z
1 objects
delta.fetchSettlementHistory (C-BTC-29000-130723)
2023-07-27T03:17:03.101Z iteration 0 passed in 4590 ms

                      symbol |             price |     timestamp |             datetime
---------------------------------------------------------------------------------------
BTC/USDT:USDT-130723-29000-C | 1555.784058200865 | 1689249600000 | 2023-07-13T12:00:00Z
1 objects

Added fetchSettlementHistory and createExpiredOptionMarket to Delta:
```
delta.fetchSettlementHistory (BTC/USDT:USDT-130723-29000-C)
2023-07-27T03:16:20.747Z iteration 0 passed in 4150 ms

                      symbol |             price |     timestamp |             datetime
---------------------------------------------------------------------------------------
BTC/USDT:USDT-130723-29000-C | 1555.784058200865 | 1689249600000 | 2023-07-13T12:00:00Z
1 objects
```
```
delta.fetchSettlementHistory (C-BTC-29000-130723)
2023-07-27T03:17:03.101Z iteration 0 passed in 4590 ms

                      symbol |             price |     timestamp |             datetime
---------------------------------------------------------------------------------------
BTC/USDT:USDT-130723-29000-C | 1555.784058200865 | 1689249600000 | 2023-07-13T12:00:00Z
1 objects
```
const result = this.safeValue (response, 'result', []);
const settlements = this.parseSettlements (result, market);
const sorted = this.sortBy (settlements, 'timestamp');
return this.filterBySymbolSinceLimit (sorted, market['symbol'], since, limit);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum for some reason, the python version returns an empty array

@carlosmiei
Copy link
Collaborator

LGTM

p delta fetchSettlementHistory 'ETH/USDT:USDT-260723-1910-C'    
Python v3.10.9
CCXT v4.0.40
delta.fetchSettlementHistory(ETH/USDT:USDT-260723-1910-C)
[{'datetime': '2023-07-26T12:00:00Z',
  'info': {'annualized_funding': '10.95',
           'auction_finish_time': None,
           'auction_start_time': None,
           'barrier_price': None,
           'basis_factor_max_limit': '10.95',
           'contract_type': 'call_options',
           'contract_unit_currency': 'ETH',
           'contract_value': '0.01',
           'default_leverage': '100.000000000000000000',
           'description': 'ETH call option expiring on 26-7-2023',
           'disruption_reason': None,
           'funding_method': 'mark_price',
           'id': '118514',
           'impact_size': '300',
           'initial_margin': '1',
           'initial_margin_scaling_factor': '0.000004',
           'insurance_fund_margin_contribution': '1',
           'is_quanto': False,
           'launch_time': '2023-07-25T13:55:05Z',
           'liquidation_penalty_factor': '0.5',
           'maintenance_margin': '0.5',
           'maintenance_margin_scaling_factor': '0.000002',
           'maker_commission_rate': '0.0003',
           'max_leverage_notional': '200000',
           'notional_type': 'vanilla',
           'position_size_limit': '173467',
           'price_band': '2',
           'product_specs': {'backup_vol_expiry_time': '31536000',
                             'max_deviation_from_external_vol': '0.75',
                             'max_lower_deviation_from_external_vol': '0.75',
                             'max_upper_deviation_from_external_vol': '0.5',
                             'max_volatility': '3',
                             'min_volatility': '0.1',
                             'premium_commission_rate': '0.1',
                             'settlement_index_price': '1851.893722204851',
                             'vol_calculation_method': 'orderbook',
                             'vol_expiry_time': '31536000'},
           'quoting_asset': {'base_withdrawal_fee': '10.000000000000000000',
                             'id': '5',
                             'interest_credit': False,
                             'interest_slabs': None,
                             'kyc_deposit_limit': '100000.000000000000000000',
                             'kyc_withdrawal_limit': '10000.000000000000000000',
                             'min_withdrawal_amount': '30.000000000000000000',
                             'minimum_precision': '2',
                             'name': 'Tether',
                             'networks': [{'base_withdrawal_fee': '10',
                                           'deposit_status': 'enabled',
                                           'memo_required': False,
                                           'min_withdrawal_amount': '30.000000000000000000',
                                           'minimum_deposit_confirmations': '12',
                                           'network': 'ERC20',
                                           'variable_withdrawal_fee': '0',
                                           'withdrawal_status': 'enabled'},
                                          {'base_withdrawal_fee': '1',
                                           'deposit_status': 'enabled',
                                           'memo_required': False,
                                           'min_withdrawal_amount': '30.000000000000000000',
                                           'minimum_deposit_confirmations': '15',
                                           'network': 'BEP20(BSC)',
                                           'variable_withdrawal_fee': '0',
                                           'withdrawal_status': 'enabled'},
                                          {'base_withdrawal_fee': '1',
                                           'deposit_status': 'enabled',
                                           'memo_required': False,
                                           'min_withdrawal_amount': '30.000000000000000000',
                                           'minimum_deposit_confirmations': '1',
                                           'network': 'TRC20(TRON)',
                                           'variable_withdrawal_fee': '0',
                                           'withdrawal_status': 'enabled'},
                                          {'base_withdrawal_fee': '0.5',
                                           'deposit_status': 'enabled',
                                           'memo_required': False,
                                           'min_withdrawal_amount': '10.000000000000000000',
                                           'minimum_deposit_confirmations': '1',
                                           'network': 'POLYGON',
                                           'variable_withdrawal_fee': '0',
                                           'withdrawal_status': 'enabled'}],
                             'precision': '8',
                             'sort_priority': '1',
                             'symbol': 'USDT',
                             'variable_withdrawal_fee': '0.000000000000000000'},
           'settlement_price': '0',
           'settlement_time': '2023-07-26T12:00:00Z',
           'settling_asset': {'base_withdrawal_fee': '10.000000000000000000',
                              'id': '5',
                              'interest_credit': False,
                              'interest_slabs': None,
                              'kyc_deposit_limit': '100000.000000000000000000',
                              'kyc_withdrawal_limit': '10000.000000000000000000',
                              'min_withdrawal_amount': '30.000000000000000000',
                              'minimum_precision': '2',
                              'name': 'Tether',
                              'networks': [{'base_withdrawal_fee': '10',
                                            'deposit_status': 'enabled',
                                            'memo_required': False,
                                            'min_withdrawal_amount': '30.000000000000000000',
                                            'minimum_deposit_confirmations': '12',
                                            'network': 'ERC20',
                                            'variable_withdrawal_fee': '0',
                                            'withdrawal_status': 'enabled'},
                                           {'base_withdrawal_fee': '1',
                                            'deposit_status': 'enabled',
                                            'memo_required': False,
                                            'min_withdrawal_amount': '30.000000000000000000',
                                            'minimum_deposit_confirmations': '15',
                                            'network': 'BEP20(BSC)',
                                            'variable_withdrawal_fee': '0',
                                            'withdrawal_status': 'enabled'},
                                           {'base_withdrawal_fee': '1',
                                            'deposit_status': 'enabled',
                                            'memo_required': False,
                                            'min_withdrawal_amount': '30.000000000000000000',
                                            'minimum_deposit_confirmations': '1',
                                            'network': 'TRC20(TRON)',
                                            'variable_withdrawal_fee': '0',
                                            'withdrawal_status': 'enabled'},
                                           {'base_withdrawal_fee': '0.5',
                                            'deposit_status': 'enabled',
                                            'memo_required': False,
                                            'min_withdrawal_amount': '10.000000000000000000',
                                            'minimum_deposit_confirmations': '1',
                                            'network': 'POLYGON',
                                            'variable_withdrawal_fee': '0',
                                            'withdrawal_status': 'enabled'}],
                              'precision': '8',
                              'sort_priority': '1',
                              'symbol': 'USDT',
                              'variable_withdrawal_fee': '0.000000000000000000'},
           'short_description': 'ETH  Call',
           'spot_index': {'config': {'impact_size': {'max_impact_size': '150000',
                                                     'min_impact_size': '5000',
                                                     'step_value': '5000'},
                                     'quoting_asset': 'USDT',
                                     'service_id': '1',
                                     'underlying_asset': 'ETH'},
                          'constituent_exchanges': [{'exchange': 'binance',
                                                     'health_interval': '60',
                                                     'health_priority': '1',
                                                     'weight': '1'},
                                                    {'exchange': 'huobi',
                                                     'health_interval': '60',
                                                     'health_priority': '2',
                                                     'weight': '1'},
                                                    {'exchange': 'okex',
                                                     'health_interval': '60',
                                                     'health_priority': '3',
                                                     'weight': '1'}],
                          'constituent_indices': None,
                          'description': 'ETH/USDT price on Binance, Huobi and '
                                         'Okex',
                          'health_interval': '300',
                          'id': '49',
                          'impact_size': '10.000000000000000000',
                          'index_type': 'spot_pair',
                          'is_composite': False,
                          'price_method': 'orderbook',
                          'quoting_asset_id': '5',
                          'symbol': '.DEETHUSDT',
                          'tick_size': '0.050000000000000000',
                          'underlying_asset_id': '1'},
           'state': 'expired',
           'strike_price': '1910',
           'symbol': 'C-ETH-1910-260723',
           'taker_commission_rate': '0.0003',
           'tick_size': '0.01',
           'trading_status': 'operational',
           'ui_config': {'default_trading_view_candle': '15',
                         'leverage_slider_values': ['1',
                                                    '2',
                                                    '5',
                                                    '10',
                                                    '20',
                                                    '50',
                                                    '100'],
                         'price_clubbing_values': ['0.01',
                                                   '0.05',
                                                   '0.1',
                                                   '0.5',
                                                   '1',
                                                   '5',
                                                   '10'],
                         'show_bracket_orders': False,
                         'sort_priority': '39',
                         'tags': []},
           'underlying_asset': {'base_withdrawal_fee': '0.005000000000000000',
                                'id': '1',
                                'interest_credit': False,
                                'interest_slabs': None,
                                'kyc_deposit_limit': '0.000000000000000000',
                                'kyc_withdrawal_limit': '0.000000000000000000',
                                'min_withdrawal_amount': '0.010000000000000000',
                                'minimum_precision': '4',
                                'name': 'Ethereum',
                                'networks': [{'base_withdrawal_fee': '0.0025',
                                              'deposit_status': 'enabled',
                                              'memo_required': False,
                                              'min_withdrawal_amount': '0.010000000000000000',
                                              'minimum_deposit_confirmations': '12',
                                              'network': 'ERC20',
                                              'variable_withdrawal_fee': '0',
                                              'withdrawal_status': 'enabled'},
                                             {'base_withdrawal_fee': '0.0001',
                                              'deposit_status': 'enabled',
                                              'memo_required': False,
                                              'min_withdrawal_amount': '0.010000000000000000',
                                              'minimum_deposit_confirmations': '15',
                                              'network': 'BEP20(BSC)',
                                              'variable_withdrawal_fee': '0',
                                              'withdrawal_status': 'enabled'}],
                                'precision': '18',
                                'sort_priority': '3',
                                'symbol': 'ETH',
                                'variable_withdrawal_fee': '0.000000000000000000'}},
  'price': 0.0,
  'symbol': 'ETH/USDT:USDT-260723-1910-C',
  'timestamp': 1690372800000}]

@carlosmiei carlosmiei self-assigned this Jul 27, 2023
@kroitor kroitor merged commit 7fce1ad into ccxt:master Jul 27, 2023
2 checks passed
kroitor pushed a commit that referenced this pull request Jul 27, 2023
Delta: fetchSettlementHistory, createExpiredOptionMarket

[ci skip]
} else if (symbol in this.markets_by_id) {
const markets = this.markets_by_id[symbol];
return markets[0];
} else if ((symbol.indexOf ('-C') > -1) || (symbol.indexOf ('-P') > -1) || (symbol.indexOf ('C')) || (symbol.indexOf ('P'))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dan-krm This logic isn't good for a few reasons.

  • first, symbol.indexOf ('C') evaluates to -1 so the boolean version of this is true, so this evaluates to true whenever the letter C or P is not present, but it also evaluates to true whenever C/P is at any index other than 0, the only time symbol.indexOf ('C') evaluates to false is when C is the first letter of symbol, but then because we also have symbol.indexOf ('P') right after, this line will always evaluate to true, because the first letter of symbol can't be both C and P.

you can test this in node

const symbol = "market";
undefined
> Boolean(symbol.indexOf ('P'))
true
  • second, you can't just test for the presence of C or P to see if the symbol is an option symbol, by this logic, this symbol would be an option symbol ETH/BTC

can you update this line to use some logic that is correct? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samgermain Yeah definitely, I'll adjust this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants