algo2t / alphatrade

Python APIs for SAS Online Alpha Trade Web platform for creating algo trading using python
https://algo2t.github.io/alphatrade
MIT License
44 stars 23 forks source link

Not able to get historical candle for index #34

Open agrsanjay opened 2 years ago

agrsanjay commented 2 years ago
    PARAMS = {
        'candletype': 1,
        'data_duration': interval,
        'starttime': start_time,
        'endtime': end_time,
        'exchange': exchange + idx,
        'type': 'all',
        'token': instrument.token,
        'name': instrument.symbol
    }

in you package in the function get_historical_candles params value should be in this format

darshshravge commented 2 years ago

sas = AlphaTrade(login_id=config.login_id, password=config.password, twofa=config.twofa, access_token=config.access_token, master_contracts_to_download=['NSE'])

    nifty_bank_nse_index = sas.get_instrument_by_symbol('NSE', 'Nifty Bank')
    df = sas.get_historical_candles(nifty_bank_nse_index.exchange, nifty_bank_nse_index.symbol,
                                    datetime(2022, 3, 7, 9, 15, 0), datetime(2022, 3, 8, 15, 29, 0), interval=1,
                                    is_index=True)