python html table is only getting first row - python-3.x

I'm trying to parse historical data for Bitcoin. Instead of getting 30 in 30 rows, I'm getting one days repeated 30 times.
import requests
import urllib.request
from bs4 import BeautifulSoup
url = "https://coinmarketcap.com/currencies/bitcoin/historical-data/"
r = requests.get(url)
html_content = r.text
soup = BeautifulSoup(html_content,"html.parser")
for tr in soup.find_all('tr')[6]:
tds = soup.find_all('td')
print ("date: %s, Open: %s, High:%s, Low: %s, Close: %s, Volume: %s, Marketcap: %s\n" % \
(tds[0].text,tds[1].text,tds[2].text,tds[3].text,tds[4].text, tds[5].text, tds[6].text))
Here's the output:
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
date: May 29, 2018, Open: 7129.46, High:7526.42, Low: 7090.68, Close: 7472.59, Volume: 5,662,660,000, Marketcap: 121,636,000,000
I should be getting data for the dates, Apr 30 - May 29
What am I missing?

You can apply a variable for all data like this:
soup = BeautifulSoup(html_content,"html.parser")
i=1
for trs in soup.find('table'):
# tds = soup.find_all('td')
i=i+1
print(trs.text)
print(i)

Related

Binance API: How do I get the quantity precision of a futures asset?

I want to get the price precision of any futures asset.
What I tried:
client.get_symbol_info(symbol='My Symbol')
But this returns the precision of the Spot and I need the precision of the futures.
So theres this Command:
client.futures_exchange_info()
Which return this:
{'timezone': 'UTC', 'serverTime': 1630437033153, 'futuresType': 'U_MARGINED', 'rateLimits': [{'rateLimitType': 'REQUEST_WEIGHT', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 2400},
{'rateLimitType': 'ORDERS', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 1200},
{'rateLimitType': 'ORDERS', 'interval': 'SECOND', 'intervalNum': 10, 'limit': 300}],
'exchangeFilters': [],
'assets': [{'asset': 'USDT', 'marginAvailable': True, 'autoAssetExchange': '-10000'},
{'asset': 'BTC', 'marginAvailable': True, 'autoAssetExchange': '-0.00100000'},
{'asset': 'BNB', 'marginAvailable': True, 'autoAssetExchange': '-10'},
{'asset': 'ETH', 'marginAvailable': True, 'autoAssetExchange': '-5'},
{'asset': 'BUSD', 'marginAvailable': True, 'autoAssetExchange': '-10000'}],
'symbols': [{'symbol': 'BTCUSDT', 'pair': 'BTCUSDT', 'contractType': 'PERPETUAL', 'deliveryDate': 4133404800000, 'onboardDate': 1569398400000, 'status': 'TRADING', 'maintMarginPercent': '2.5000', 'requiredMarginPercent': '5.0000', 'baseAsset': 'BTC', 'quoteAsset': 'USDT', 'marginAsset': 'USDT', 'pricePrecision': 2, 'quantityPrecision': 3, 'baseAssetPrecision': 8, 'quotePrecision': 8, 'underlyingType': 'COIN', 'underlyingSubType': [], 'settlePlan': 0, 'triggerProtect': '0.0500', 'liquidationFee': '0.012000', 'marketTakeBound': '0.05', 'filters': [{'minPrice': '556.72', 'maxPrice': '4529764', 'filterType': 'PRICE_FILTER', 'tickSize': '0.01'}, {'stepSize': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '1000', 'minQty': '0.001'}, {'stepSize': '0.001', 'filterType': 'MARKET_LOT_SIZE', 'maxQty': '200', 'minQty': '0.001'}, {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'}, {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'}, {'notional': '5', 'filterType': 'MIN_NOTIONAL'}, {'multiplierDown': '0.9500', 'multiplierUp': '1.0500', 'multiplierDecimal': '4', 'filterType': 'PERCENT_PRICE'}], 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'TRAILING_STOP_MARKET'], 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX']},
{'symbol': 'ETHUSDT', 'pair': 'ETHUSDT', 'contractType': 'PERPETUAL', 'deliveryDate': 4133404800000, 'onboardDate': 1569398400000, 'status': 'TRADING', 'maintMarginPercent': '2.5000', 'requiredMarginPercent': '5.0000', 'baseAsset': 'ETH', 'quoteAsset': 'USDT', 'marginAsset': 'USDT', 'pricePrecision': 2, 'quantityPrecision': 3, 'baseAssetPrecision': 8, 'quotePrecision': 8, 'underlyingType': 'COIN', 'underlyingSubType': [], 'settlePlan': 0, 'triggerProtect': '0.0500', 'liquidationFee': '0.005000', 'marketTakeBound': '0.05', 'filters': [{'minPrice': '39.86', 'maxPrice': '306177', 'filterType': 'PRICE_FILTER', 'tickSize': '0.01'}, {'stepSize': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '10000', 'minQty': '0.001'}, {'stepSize': '0.001', 'filterType': 'MARKET_LOT_SIZE', 'maxQty': '2000', 'minQty': '0.001'}, {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'}, {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'}, {'notional': '5', 'filterType': 'MIN_NOTIONAL'}, {'multiplierDown': '0.9500', 'multiplierUp': '1.0500', 'multiplierDecimal': '4', 'filterType': 'PERCENT_PRICE'}], 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'TRAILING_STOP_MARKET'], 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX']}...
and so on.
I need to access the Value of 'quantityPrecision':.
Is there a way to like filter this list for the symbol value like 'BTCUSDT' and then return the Value of 'quantityPrecision':?
Thanks in Advance for any help.
info = client.futures_exchange_info()
def get_precision(symbol):
for x in info['symbols']:
if x['symbol'] == symbol:
return x['quantityPrecision']
print(get_precision('LTCUSDT'))
async function getLimits(asset) {
var filtered = await client.futures_exchange_info()
return Object.values( filtered.symbols).filter(O => O.symbol===asset)[0]
}
getLimits("BTCUSDT")

Get value in Nested Dictionary Python Odoo

I have a problem...again. It is related to my previous question in Cron. I've got JSON value and I want to enter it in database. I need help in getting values in this nested dict. Plz help!
JSON
{'folders': [{'id': 94, 'name': 'Retargeting January 2021', 'totalBlacklisted': 606, 'uniqueSubscribers': 19988, 'totalSubscribers': 19382},
{'id': 90, 'name': 'Leads', 'totalBlacklisted': 0, 'uniqueSubscribers': 0, 'totalSubscribers': 0},
{'id': 84, 'name': 'Retargeting Year End', 'totalBlacklisted': 1367, 'uniqueSubscribers': 18847, 'totalSubscribers': 17480},
{'id': 79, 'name': 'CRM Folder', 'totalBlacklisted': 0, 'uniqueSubscribers': 3, 'totalSubscribers': 3},
{'id': 56, 'name': 'Curioo P', 'totalBlacklisted': 282, 'uniqueSubscribers': 3279, 'totalSubscribers': 2997}]}
Python
res = simplejson.loads(response.text)
self.env['get.folders'].create({
'id' : self.id,
'name': res['name'],
'email_blacklist': res['totalBlacklisted'],
'email_subscribers': res['totalSubscribers'],
'unique_subscribers': res['uniqueSubscribers'],
'foldersId': res['id'],
})
EDIT
At last it works. I try to spell out the values and I don't know how but it works this way. Thanks #Jack Dane for your help.
for folder in folders.get("folders"):
names = folder['name']
ids = folder['id']
blacklist = folder['totalBlacklisted']
subscribe = folder['totalSubscribers']
unique = folder['uniqueSubscribers']
self.env['sendinblue.get_folders'].create({
# 'id' : folder['id'],
'name_folder': names,
'email_blacklist': blacklist,
'email_subscribers': subscribe,
'unique_subscribers': unique,
'foldersId': ids,
})
You can loop through the folders using a foreach loop call the create function:
folders = {'folders': [{'id': 94, 'name': 'Retargeting January 2021', 'totalBlacklisted': 606, 'uniqueSubscribers': 19988, 'totalSubscribers': 19382},
{'id': 90, 'name': 'Leads', 'totalBlacklisted': 0, 'uniqueSubscribers': 0, 'totalSubscribers': 0},
{'id': 84, 'name': 'Retargeting Year End', 'totalBlacklisted': 1367, 'uniqueSubscribers': 18847, 'totalSubscribers': 17480},
{'id': 79, 'name': 'CRM Folder', 'totalBlacklisted': 0, 'uniqueSubscribers': 3, 'totalSubscribers': 3},
{'id': 56, 'name': 'Curioo P', 'totalBlacklisted': 282, 'uniqueSubscribers': 3279, 'totalSubscribers': 2997}]}
for folder in folders.get("folders"):
self.env['get.folders'].create({
'id' : self.id,
'name': folder['name'],
'email_blacklist': folder['totalBlacklisted'],
'email_subscribers': folder['totalSubscribers'],
'unique_subscribers': folder['uniqueSubscribers'],
'foldersId': folder['id'],
})
In my case, I have used folders as the variable which will be returned as a JSON.
If you need any clarification let me know,
Thanks,

ffmpeg audio channel layout unknown to stereo/mono

I have one audio file, below I have attached the audio metadata,
the audio layout is "unknown", how to set the audio layout "Stereo" or "mono"?
now I am using the FFmpeg tool in NodeJs,
please suggest any other media customization tool also comfortable to the NodeJs
{ streams:
[ { index: 0,
codec_name: 'pcm_s16le',
codec_long_name: 'PCM signed 16-bit little-endian',
profile: 'unknown',
codec_type: 'audio',
codec_time_base: '1/24000',
codec_tag_string: '[1][0][0][0]',
codec_tag: '0x0001',
sample_fmt: 's16',
sample_rate: 24000,
channels: 1,
channel_layout: 'unknown',
bits_per_sample: 16,
id: 'N/A',
r_frame_rate: '0/0',
avg_frame_rate: '0/0',
time_base: '1/24000',
start_pts: 'N/A',
start_time: 'N/A',
duration_ts: 34546,
duration: 1.439417,
bit_rate: 384000,
max_bit_rate: 'N/A',
bits_per_raw_sample: 'N/A',
nb_frames: 'N/A',
nb_read_frames: 'N/A',
nb_read_packets: 'N/A',
disposition: [Object] } ],
format:
{ filename: './Audios/temp/1607064049732/1607064049732-2.wav',
nb_streams: 1,
nb_programs: 0,
format_name: 'wav',
format_long_name: 'WAV / WAVE (Waveform Audio)',
start_time: 'N/A',
duration: 1.439417,
size: 69136,
bit_rate: 384244,
probe_score: 99 },
chapters: [] }]
in your case, based on channels property with value 1, I would just fallback to mono in the application code. It unlikely to have any other channel_layout than mono while having only one channel in the stream.
From my experience, ffmpeg/ffprobe reports limited set of information when working with WAV/raw PCM formats.

how to convert data to standard json

messages=%5B%7B%22values%22%3A+%7B%22momentum%22%3A+%220.00%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22momentum%22%2C+%22indicator_number%22%3A+0%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22signal%22%3A+%5B%22momentum%22%5D%2C+%22hot%22%3A+0%2C+%22cold%22%3A+0%2C+%22candle_period%22%3A+%224h%22%2C+%22period_count%22%3A+10%7D%2C+%22status%22%3A+%22hot%22%7D%2C+%22status%22%3A+%22hot%22%2C+%22last_status%22%3A+%22hot%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22%22%2C+%22indicator_label%22%3A+%22%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%2C+%7B%22values%22%3A+%7B%22leading_span_a%22%3A+%220.00%22%2C+%22leading_span_b%22%3A+%220.00%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22ichimoku%22%2C+%22indicator_number%22%3A+1%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22signal%22%3A+%5B%22leading_span_a%22%2C+%22leading_span_b%22%5D%2C+%22hot%22%3A+true%2C+%22cold%22%3A+true%2C+%22candle_period%22%3A+%224h%22%2C+%22hot_label%22%3A+%22Bullish+Alert%22%2C+%22cold_label%22%3A+%22Bearish+Alert%22%2C+%22indicator_label%22%3A+%22ICHIMOKU+4+hr%22%2C+%22mute_cold%22%3A+false%7D%2C+%22status%22%3A+%22cold%22%7D%2C+%22status%22%3A+%22cold%22%2C+%22last_status%22%3A+%22cold%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22Bearish+Alert%22%2C+%22indicator_label%22%3A+%22ICHIMOKU+4+hr%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%2C+%7B%22values%22%3A+%7B%22bbp%22%3A+%220.96%22%2C+%22mfi%22%3A+%2298.05%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22bbp%22%2C+%22indicator_number%22%3A+1%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22candle_period%22%3A+%224h%22%2C+%22period_count%22%3A+20%2C+%22hot%22%3A+0.09%2C+%22cold%22%3A+0.8%2C+%22std_dev%22%3A+2%2C+%22signal%22%3A+%5B%22bbp%22%2C+%22mfi%22%5D%2C+%22hot_label%22%3A+%22Lower+Band%22%2C+%22cold_label%22%3A+%22Upper+Band+BB%22%2C+%22indicator_label%22%3A+%22Bollinger+4+hr%22%2C+%22mute_cold%22%3A+false%7D%2C+%22status%22%3A+%22cold%22%7D%2C+%22status%22%3A+%22cold%22%2C+%22last_status%22%3A+%22cold%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22Upper+Band+BB%22%2C+%22indicator_label%22%3A+%22Bollinger+4+hr%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%5D
i need to convert this data in python3 to standard json for post json api
any solution ?
thanks
That looks like it's been URL form encoded.
Try
import urllib.parse
import json
# note **without** the message= part
stuff = "%5B%7B%22values%22%3A+%7B%22momentum%22%3A+%220.00%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22momentum%22%2C+%22indicator_number%22%3A+0%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22signal%22%3A+%5B%22momentum%22%5D%2C+%22hot%22%3A+0%2C+%22cold%22%3A+0%2C+%22candle_period%22%3A+%224h%22%2C+%22period_count%22%3A+10%7D%2C+%22status%22%3A+%22hot%22%7D%2C+%22status%22%3A+%22hot%22%2C+%22last_status%22%3A+%22hot%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22%22%2C+%22indicator_label%22%3A+%22%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%2C+%7B%22values%22%3A+%7B%22leading_span_a%22%3A+%220.00%22%2C+%22leading_span_b%22%3A+%220.00%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22ichimoku%22%2C+%22indicator_number%22%3A+1%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22signal%22%3A+%5B%22leading_span_a%22%2C+%22leading_span_b%22%5D%2C+%22hot%22%3A+true%2C+%22cold%22%3A+true%2C+%22candle_period%22%3A+%224h%22%2C+%22hot_label%22%3A+%22Bullish+Alert%22%2C+%22cold_label%22%3A+%22Bearish+Alert%22%2C+%22indicator_label%22%3A+%22ICHIMOKU+4+hr%22%2C+%22mute_cold%22%3A+false%7D%2C+%22status%22%3A+%22cold%22%7D%2C+%22status%22%3A+%22cold%22%2C+%22last_status%22%3A+%22cold%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22Bearish+Alert%22%2C+%22indicator_label%22%3A+%22ICHIMOKU+4+hr%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%2C+%7B%22values%22%3A+%7B%22bbp%22%3A+%220.96%22%2C+%22mfi%22%3A+%2298.05%22%7D%2C+%22exchange%22%3A+%22binance%22%2C+%22market%22%3A+%22BNT%2FETH%22%2C+%22base_currency%22%3A+%22BNT%22%2C+%22quote_currency%22%3A+%22ETH%22%2C+%22indicator%22%3A+%22bbp%22%2C+%22indicator_number%22%3A+1%2C+%22analysis%22%3A+%7B%22config%22%3A+%7B%22enabled%22%3A+true%2C+%22alert_enabled%22%3A+true%2C+%22alert_frequency%22%3A+%22once%22%2C+%22candle_period%22%3A+%224h%22%2C+%22period_count%22%3A+20%2C+%22hot%22%3A+0.09%2C+%22cold%22%3A+0.8%2C+%22std_dev%22%3A+2%2C+%22signal%22%3A+%5B%22bbp%22%2C+%22mfi%22%5D%2C+%22hot_label%22%3A+%22Lower+Band%22%2C+%22cold_label%22%3A+%22Upper+Band+BB%22%2C+%22indicator_label%22%3A+%22Bollinger+4+hr%22%2C+%22mute_cold%22%3A+false%7D%2C+%22status%22%3A+%22cold%22%7D%2C+%22status%22%3A+%22cold%22%2C+%22last_status%22%3A+%22cold%22%2C+%22prices%22%3A+%22+Open%3A+0.000989+High%3A+0.000998+Low%3A+0.000980+Close%3A+0.000998%22%2C+%22lrsi%22%3A+%22%22%2C+%22creation_date%22%3A+%222020-05-10+16%3A16%3A23%22%2C+%22hot_cold_label%22%3A+%22Upper+Band+BB%22%2C+%22indicator_label%22%3A+%22Bollinger+4+hr%22%2C+%22price_value%22%3A+%7B%22open%22%3A+0.000989%2C+%22high%22%3A+0.000998%2C+%22low%22%3A+0.00098%2C+%22close%22%3A+0.000998%7D%2C+%22decimal_format%22%3A+%22%25.6f%22%7D%5D"
parsed = urllib.parse.unquote_plus(stuff) # <<< encoded form, get rid of +
as_json = json.loads(parsed)
print(as_json)
gives me
[{'values': {'momentum': '0.00'}, 'exchange': 'binance', 'market': 'BNT/ETH', 'base_currency': 'BNT', 'quote_currency': 'ETH', 'indicator': 'momentum', 'indicator_number': 0, 'analysis': {'config': {'enabled': True, 'alert_enabled': True, 'alert_frequency': 'once', 'signal': ['momentum'], 'hot': 0, 'cold': 0, 'candle_period': '4h', 'period_count': 10}, 'status': 'hot'}, 'status': 'hot', 'last_status': 'hot', 'prices': ' Open: 0.000989 High: 0.000998 Low: 0.000980 Close: 0.000998', 'lrsi': '', 'creation_date': '2020-05-10 16:16:23', 'hot_cold_label': '', 'indicator_label': '', 'price_value': {'open': 0.000989, 'high': 0.000998, 'low': 0.00098, 'close': 0.000998}, 'decimal_format': '%.6f'}, {'values': {'leading_span_a': '0.00', 'leading_span_b': '0.00'}, 'exchange': 'binance', 'market': 'BNT/ETH', 'base_currency': 'BNT', 'quote_currency': 'ETH', 'indicator': 'ichimoku', 'indicator_number': 1, 'analysis': {'config': {'enabled': True, 'alert_enabled': True, 'alert_frequency': 'once', 'signal': ['leading_span_a', 'leading_span_b'], 'hot': True, 'cold': True, 'candle_period': '4h', 'hot_label': 'Bullish Alert', 'cold_label': 'Bearish Alert', 'indicator_label': 'ICHIMOKU 4 hr', 'mute_cold': False}, 'status': 'cold'}, 'status': 'cold', 'last_status': 'cold', 'prices': ' Open: 0.000989 High: 0.000998 Low: 0.000980 Close: 0.000998', 'lrsi': '', 'creation_date': '2020-05-10 16:16:23', 'hot_cold_label': 'Bearish Alert', 'indicator_label': 'ICHIMOKU 4 hr', 'price_value': {'open': 0.000989, 'high': 0.000998, 'low': 0.00098, 'close': 0.000998}, 'decimal_format': '%.6f'}, {'values': {'bbp': '0.96', 'mfi': '98.05'}, 'exchange': 'binance', 'market': 'BNT/ETH', 'base_currency': 'BNT', 'quote_currency': 'ETH', 'indicator': 'bbp', 'indicator_number': 1, 'analysis': {'config': {'enabled': True, 'alert_enabled': True, 'alert_frequency': 'once', 'candle_period': '4h', 'period_count': 20, 'hot': 0.09, 'cold': 0.8, 'std_dev': 2, 'signal': ['bbp', 'mfi'], 'hot_label': 'Lower Band', 'cold_label': 'Upper Band BB', 'indicator_label': 'Bollinger 4 hr', 'mute_cold': False}, 'status': 'cold'}, 'status': 'cold', 'last_status': 'cold', 'prices': ' Open: 0.000989 High: 0.000998 Low: 0.000980 Close: 0.000998', 'lrsi': '', 'creation_date': '2020-05-10 16:16:23', 'hot_cold_label': 'Upper Band BB', 'indicator_label': 'Bollinger 4 hr', 'price_value': {'open': 0.000989, 'high': 0.000998, 'low': 0.00098, 'close': 0.000998}, 'decimal_format': '%.6f'}]
Whereas if you want a JSON string to POST somewhere, call as_string = json.dumps(parsed)

How to get historical stock data between two dates?

Im trying to get historical data for Apple from google finance.
but the start and end time is always the same.
in google-finance module sending a get request with these params to http://www.google.com/finance/historical should result in historical data between the dates but it returns last year instead.
var params = { q: 'AAPL',
startdate: '2014-01-01',
enddate: '2014-12-31',
output: 'csv'
};
google-finance module example :
gFinance.historical({
symbol: 'NASDAQ:AAPL',
from: '2014-01-01',
to: '2014-12-31'
}, function (err, quotes) {
console.log(quotes);
});
result is always from today (8 oct 2017) to one year earlier(8 oct 2016):
...
{ date: 2017-02-22T20:30:00.000Z,
open: 137.38,
high: 137.48,
low: 136.3,
close: 136.53,
volume: 20788186,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-02-23T20:30:00.000Z,
open: 135.91,
high: 136.66,
low: 135.28,
close: 136.66,
volume: 21776585,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-02-26T20:30:00.000Z,
open: 137.14,
high: 137.44,
low: 136.28,
close: 136.93,
volume: 20257426,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-02-27T20:30:00.000Z,
open: 137.08,
high: 137.44,
low: 136.7,
close: 136.99,
volume: 23482860,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-02-28T20:30:00.000Z,
open: 137.89,
high: 140.15,
low: 137.6,
close: 139.79,
volume: 36414585,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-03-01T20:30:00.000Z,
open: 140,
high: 140.28,
low: 138.76,
close: 138.96,
volume: 26210984,
symbol: 'NASDAQ:AAPL' },
{ date: 2017-03-02T20:30:00.000Z,
open: 138.78,
high: 139.83,
low: 138.59,
close: 139.78,
volume: 21571121,
symbol: 'NASDAQ:AAPL' },
... 151 more items ]
I dont know if they changed something or they closed it like yahoo did or Im doing something wrong.
I searched for a week and everything seems outdated.
how can I get historical data between custom times with http request?
Gogle finance works as expected :
http://finance.google.com/finance/historical?q=AAPL&startdate=2014-01-01&enddate=2014-12-31&output=csv
You didn't put any source code.

Resources