Skip to content

Commit

Permalink
DOC: update docs to the currnet alignment to crypto left labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
lenak25 committed Aug 30, 2018
1 parent 3072bc2 commit b6ad6aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Table of Contents
install
beginner-tutorial
live-trading
intervals
example-algos
utilities
videos
Expand Down
48 changes: 23 additions & 25 deletions docs/source/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Simpler case for daily data
record(price=price, volume=volume)
def analyze(context=None, results=None):
# Generate DataFrame with Price and Volume only
data = results[['price','volume']]
Expand Down Expand Up @@ -114,35 +113,34 @@ More versatile case for minute data
# Portfolio assets list
context.asset = symbol('btc_usdt') # Bitcoin on Poloniex
# Creates a .CSV file with the same name as this script to store results
context.csvfile = open(os.path.splitext(
os.path.basename(__file__))[0]+'.csv', 'w+')
context.csvwriter = csv.writer(context.csvfile)
# Create an empty DataFrame to store results
context.pricing_data = pd.DataFrame()
def handle_data(context, data):
# Variables to record for a given asset: price and volume
# Other options include 'open', 'high', 'open', 'close'
# Please note that 'price' equals 'close'
date = context.blotter.current_dt # current time in each iteration
price = data.current(context.asset, 'price')
volume = data.current(context.asset, 'volume')
current = data.history(context.asset, ['price', 'volume'], 1, '1T')
# Writes one line to CSV on each iteration with the chosen variables
context.csvwriter.writerow([date,price,volume])
# Append the current information to the pricing_data DataFrame
context.pricing_data = context.pricing_data.append(current)
def analyze(context=None, results=None):
# Close open file properly at the end
context.csvfile.close()
# Bitcoin data is available from 2015-3-2. Dates vary for other tokens.
start = datetime(2017, 7, 30, 0, 0, 0, 0, pytz.utc)
end = datetime(2017, 7, 31, 0, 0, 0, 0, pytz.utc)
results = run_algorithm(initialize=initialize,
handle_data=handle_data,
analyze=analyze,
start=start,
end=end,
exchange_name='poloniex',
data_frequency='minute',
quote_currency ='usdt',
capital_base=10000 )
# Save pricing data to a CSV file
filename = os.path.splitext(os.path.basename(__file__))[0]
context.pricing_data.to_csv(filename + '.csv')
''' Bitcoin data is available on Poloniex since 2015-3-1.
Dates vary for other tokens.
'''
start = datetime(2017, 7, 30, 0, 0, 0, 0, pytz.utc)
end = datetime(2017, 7, 31, 0, 0, 0, 0, pytz.utc)
results = run_algorithm(initialize=initialize,
handle_data=handle_data,
analyze=analyze,
start=start,
end=end,
exchange_name='poloniex',
data_frequency='minute',
quote_currency ='usdt',
capital_base=10000 )

0 comments on commit b6ad6aa

Please sign in to comment.