def main() -> None: parser: ArgumentParser = ArgumentParser(description='Stock Trader program.') parser.add_argument('symbol', type=str, help='The stock symbol.') file_path: str = path.dirname(__file__) dotenv_path = path.join(path.dirname(__file__), f'env/.{parser.parse_args().symbol}') load_dotenv(path.join(file_path, f'env/.{parser.parse_args().symbol}')) load_dotenv(path.join(file_path, f'env/.COMMON')) project_id: Optional[str] = environ.get(PROJECT_ID) alpha_vantage_id: Optional[str] = environ.get(ALPHA_VANTAGE_ID) symbol: Optional[str] = environ.get(SYMBOL) web_hook_url: Optional[str] = environ.get(WEB_HOOK_URL) fb_api_key: Optional[str] = environ.get(FB_API_KEY) fb_auth_domain: Optional[str] = environ.get(FB_AUTH_DOMAIN) fb_db_url: Optional[str] = environ.get(FB_DB_URL) fb_service_account: Optional[str] = environ.get(FB_SERVICE_ACCOUNT) fb_storage_bucket: Optional[str] = environ.get(FB_STORAGE_BUCKET) if symbol and alpha_vantage_id and web_hook_url and project_id and \ fb_api_key and fb_auth_domain and fb_db_url and fb_service_account and fb_storage_bucket: firebase_config: Dict[str, str] = { 'apiKey': fb_api_key, 'authDomain': fb_auth_domain, 'databaseURL': fb_db_url, 'storageBucket': fb_storage_bucket, 'serviceAccount': fb_service_account } print(f'Running Process {getpid()}...') start_app(symbol, project_id, alpha_vantage_id, web_hook_url, firebase_config)
def setUp(self): """Roda antes de todos os testes.""" self.app = start_app() self.app.testing = True self.app_context = self.app.test_request_context() self.app_context.push() self.client = self.app.test_client()
def show(self): self.fig.data = [] basket = self._calc_basket() for s, n in zip(self.stocks + [basket], self.n_shares + [1]): if not s.vis: continue name = s.name x = [self.dates[t] for t in s.times] self.fig.add_trace( go.Scatter(x=x, y=100.0 * s.yields, name=name, text=[name for _ in range(len(x))], customdata=np.vstack( (s.prices, s.basket_contribution(n, basket))).T, hovertemplate='<b>%{text}: %{y:.1f}%</b>, ' + '$%{customdata[0]:.1f}, ' + '%{customdata[1]:.1f}% of basket' + '<extra></extra>', **s.vis_kwargs)) tick_times, tick_dates = self._segment_dates() self.fig.update_layout( xaxis=dict( tickmode='array', tickvals=tick_dates, ticktext=tick_dates, ), legend=dict( xanchor='left', x=0, yanchor='bottom', y=1.02, orientation='h', ), title= 'Yields relative to start date, prices, and basket portions. {:s} to {:s}' .format(self.start_date, self.end_date), xaxis_title='Date', yaxis_title='Yield (%)') start_app(self.fig)
from app import start_app if __name__ == '__main__': app = start_app() app.run()
# # Andrew Dibble - 001467899 # from app import start_app from wgups.schedule import schedule_delivery packages, trucks = schedule_delivery() start_app(packages, trucks)
import os import sys current_dir = os.path.dirname(os.path.abspath(__file__)) source_dir = os.path.dirname(current_dir) sys.path.append(source_dir) from app import app, start_app start_app() import newrelic.agent newrelic.agent.initialize(os.path.join(current_dir, 'newrelic.ini'), 'staging') application = newrelic.agent.wsgi_application()(app)
import pytest from flask import json from app import app, start_app import os.path from os import path from api.storage_utils import delete flask_app = app start_app(flask_app) def test_download(): """ GET /api/files/download Requirements: F-34 """ # A test client configured for testing with flask_app.test_client() as test_client: response = test_client.get('/api/files/download', json={"file": "data.json"}) assert response.status_code == 200 assert response.status == "200 OK" assert path.exists("data.json") if path.exists("data.json"): os.remove("data.json") def test_download_negative(): """ GET /api/files/download
from bokeh.plotting import figure from app import create_app, start_app # init a basic bar chart: # http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#bars fig = figure(plot_width=600, plot_height=600) fig.vbar(x=[1, 2, 3, 4], width=0.5, bottom=0, top=[1.7, 2.2, 4.6, 3.9], color='navy') #store required figures as a list figures = [fig] #create the flask app app = create_app(figures) #Run the app start_app(app, debug=True)