Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 SHARE PYTHON FILE
#1
I have a python file and it consists of modules such as pandas,numpy,matplotlib and quandl. However, I need to share the file so the user can directly see the results after running the file

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 28 03:30:19 2019

@author: sai
"""
import quandl
import pandas as pd 
import matplotlib.pyplot as plt
import numpy as np


equitydata = quandl.get("HKEX/02382",authtoken='Jjz7SvMpapFPhoZPAzga',pagination = True)
print(equitydata)
#plotting nominal prices
equitydata['Nominal Price'].plot(grid=True)
plt.title("Sunny optical closing price")
plt.show()

#making short and long windows
short_window = 40
long_window = 100
signals = pd.DataFrame(index=equitydata.index)
signals['signal'] = 0.0

#SMA of Short window

signals['short_mavg'] = equitydata['Nominal Price'].rolling(window=short_window,min_periods=1,center=False).mean()

#SMA of Long WIndow
signals['long_mavg'] = equitydata['Nominal Price'].rolling(window=long_window,min_periods=1,center=False).mean()


# Create signals
signals['signal'][short_window:] = np.where(signals['short_mavg'][short_window:] > signals['long_mavg'][short_window:],1.0,0.0)

#Generate trading orders

signals['positions'] = signals['signal'].diff()
print(signals)

 

import matplotlib.pyplot as plt

# Initialize the plot figure
fig = plt.figure(figsize=(20,15))

# Add a subplot and label for y—axis
ax1 = fig.add_subplot(111, ylabel='Price in $')

# Plot the closing price
equitydata['Nominal Price'].plot(ax=ax1, color='black', lw=2.)

# Plot the short and long moving averages
signals[['short_mavg', 'long_mavg']].plot(ax=ax1, lw=2.)

# Plot the buy signals

ax1.plot(signals.loc[signals.positions == 1.0].index,signals.short_mavg[signals.positions == 1.0],'^', markersize=20, color='g')

# Plot the sell signals
ax1.plot(signals.loc[signals.positions == -1.0].index,signals.short_mavg[signals.positions == -1.0],'v', markersize=20, color='r')

# Show the plot
plt.show()







Quote
#2
If users need to run your code the easiest way is eg Google CoLab, Azure Notebooks, Binder(yet a new way).
So then there is no installation for users as all run in cloud,and you can just share your code.

There are other way that can vary in difficulty.
I have build all this stuff to a single .exe file with pyinstaller,
then have to understand error that's gone come in build process and fix them.

nbviewer is an other way,but the view is static and show the render output of NoteBook.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Copy info of 2 files with share information AngelRuizM 1 1,009 Aug-14-2017, 07:31 PM
Last Post: buran
  Properly share logger objects CardBoy 2 1,132 Jun-27-2017, 08:33 PM
Last Post: Ofnuts

Forum Jump:


Users browsing this thread: 1 Guest(s)