예제 #1
0
 def __init__(self,
              api_key,
              bar_type='minutes',
              interval= 1,
              endpoint_type=None):
     self.api_key = api_key
     self.bar_type = bar_type
     self.interval = interval
     self.bars_per_day = 60*24 if bar_type != 'daily'  else 1 
     endpoint_to_use = BcHist.endpoints['paid_url'] if endpoint_type is None else BcHist.endpoints[endpoint_type]
     self.od =  ondemand.OnDemandClient(api_key=api_key, end_point=endpoint_to_use)
"""
python test_free.py my-api-key
"""

import ondemand
import sys

od = ondemand.OnDemandClient(
    api_key=sys.argv[1],
    end_point='https://marketdata.websol.barchart.com/',
    format='csv')
od.debug = True

# Get a Quote
resp = od.quote('AAPL', 'bid,ask')
print('')
print(resp)
print('')

for q in resp['results']:
    print('Symbol: %s, Last Price: %s' % (q['symbol'], q['lastPrice']))

# Get Historical Data
resp = od.history('AAPL', historical_type='daily')
print('')
print('getHistory', resp)
print('')
예제 #3
0
# -*- coding: utf-8 -*-
from datetime import datetime
import calendar
import requests
import ondemand
import pandas as pd
from pandas.compat import StringIO
od = ondemand.OnDemandClient(api_key='barcharthackathon')
states = {
    "AL": "Alabama",
    "AK": "Alaska",
    "AS": "American Samoa",
    "AZ": "Arizona",
    "AR": "Arkansas",
    "CA": "California",
    "CO": "Colorado",
    "CT": "Connecticut",
    "DE": "Delaware",
    "DC": "District Of Columbia",
    "FM": "Federated States Of Micronesia",
    "FL": "Florida",
    "GA": "Georgia",
    "GU": "Guam",
    "HI": "Hawaii",
    "ID": "Idaho",
    "IL": "Illinois",
    "IN": "Indiana",
    "IA": "Iowa",
    "KS": "Kansas",
    "KY": "Kentucky",
    "LA": "Louisiana",
예제 #4
0
Get data from barchart for futures

"""

from sysdata.futures.contracts import futuresContract
from sysdata.futures.futures_per_contract_prices import futuresContractPriceData, futuresContractPrices
from syscore.fileutils import get_filename_for_package
from sysdata.barchart.barchart_utils import load_private_key

import ondemand
import pandas as pd

BARCHART_FUTURES_CONFIG_FILE = get_filename_for_package(
    "sysdata.barchart.barchartFuturesConfig.csv")

od = ondemand.OnDemandClient(api_key=load_private_key())  # ondemand API key
# od = ondemand.OnDemandClient(api_key=load_private_key(), end_point='https://marketdata.websol.barchart.com/') # ondemand demo endpoint API key

# quotes=od.history('GCG19', historical_type = 'daily')['results']
# pd.DataFrame(quotes)


class barchartFuturesConfiguration(object):
    def __init__(self, config_file=BARCHART_FUTURES_CONFIG_FILE):

        self._config_file = config_file

    def get_list_of_instruments(self):
        config_data = self._get_config_information()

        return list(config_data.index)
예제 #5
0
ts.plot()

#syntax for getting simply 1 stock, Intel
stocks = ['INTC']
listStocks = quantiacsToolbox.loadData(
    marketList=stocks,
    dataToLoad=['DATE', 'OPEN', 'HIGH', 'LOW', 'CLOSE', 'VOL'],
    beginInSample='20130326',
    endInSample='20180829')

#from quantopian.pipeline import Pipeline

#barchart
import ondemand

od = ondemand.OnDemandClient(api_key='cf6e893a8324a661f82c65da1a79df0a')

# or if you are using a free sandbox API

od = ondemand.OnDemandClient(
    api_key='cf6e893a8324a661f82c65da1a79df0a',
    end_point='https://marketdata.websol.barchart.com/')

# get quote data for Apple and Microsoft
quotes = od.quote('AAPL,MSFT')['results']

for q in quotes:
    print('Symbol: %s, Last Price: %s' % (q['symbol'], q['lastPrice']))

# get 1 minutes bars for Apple
resp = od.history('AAPL', 'minutes', maxRecords=50, interval=1)
"""
python test.py my-api-key
"""

import ondemand
import sys

od = ondemand.OnDemandClient(api_key=sys.argv[1])
od.debug = True

# Get that Crypto
resp = od.crypto('^BTCUSD,^LTCUSD')
print('')
print(resp)
print('')

# Get a Quote
resp = od.quote('AAPL', 'bid,ask')
print('')
print(resp)
print('')

for q in resp['results']:
    print('Symbol: %s, Last Price: %s' % (q['symbol'], q['lastPrice']))

# Get Historical Data
resp = od.history('AAPL', 'minutes', maxRecords=50, interval=1)
# print('')
# print('getHistory', resp)
# print('')
예제 #7
0
def getStockLiveData(stock):
    od = ondemand.OnDemandClient(
        api_key=apikey, end_point='https://marketdata.websol.barchart.com/')
    quote = od.quote(stock)['results']
    print(quote)
    return (quote)
예제 #8
0
import ondemand
from Stock import Stock
from Industry import Industry
import datetime

od = ondemand.OnDemandClient(
    api_key='5dbee5d0272ae52936a8cabbdcef6ea6',
    end_point='https://marketdata.websol.barchart.com/')
#The stocks i use are just random picked from the stock exchange
quotes = od.quote('DDD,MMM,WBAI,WUBA,EGHT,AHC,ATEN,AAC,AIR,AAN,ABB,ABT',
                  'dividendRateAnnual')['results']
nyseSymbolsCsv = open('NYSE.csv', 'r')
industriTxt = open('Betas.txt', 'r')

resp = od.get('getQuote', symbols='AAPL,EXC', fields='bid,ask')
#Lists i user
stocks = []
industries = []
nyseStockSymbols = []
#Reads from the NYSE STOCK FILE

#
for line in nyseSymbolsCsv:
    currentSymbol = line.split(
        ","
    )  #Function for making a list with all the stock symbols from the NYSE.CSV

    for i in range(len(currentSymbol)):
        nyseStockSymbols.append(currentSymbol[i])

    #will have to make a string which includes all the 100 tickers i want to check out