Skip to content

This repo's intent is to allow users to autonomously predict and make stock price actions.

License

Notifications You must be signed in to change notification settings

ryanpinnock10/Trading-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django

GET:

positions endpoint: http://127.0.0.1:8000/api/positions/

account endpoint: http://127.0.0.1:8000/api/account/

order history: http://127.0.0.1:8000/api/order_history/

POST:

create order endpoint: http://127.0.0.1:8000/api/create_order/

Available Scripts

This project was bootstrapped with Create React App.

In the project directory, you can run:

yarn startor npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

yarn build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

react-plotly.js

plotly-react-logo

A plotly.js React component from Plotly. The basis of Plotly's React component suite.

👉 DEMO

👉 Demo source code


Contents

Installation

$ npm install react-plotly.js plotly.js

Quick start

The easiest way to use this component is to import and pass data to a plot component:

import React from 'react';
import Plot from 'react-plotly.js';

class App extends React.Component {
  render() {
    return (
      <Plot
        data={[
          {
            x: [1, 2, 3],
            y: [2, 6, 3],
            type: 'scatter',
            mode: 'lines+markers',
            marker: {color: 'red'},
          },
          {type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
        ]}
        layout={{width: 320, height: 240, title: 'A Fancy Plot'}}
      />
    );
  }
}

You should see a plot like this:

Example plot

For a full description of Plotly chart types and attributes see the following resources:

State management

This is a "dumb" component that doesn't merge its internal state with any updates. This means that if a user interacts with the plot, by zooming or panning for example, any subsequent re-renders will lose this information unless it is captured and upstreamed via the onUpdate callback prop.

Here is a simple example of how to capture and store state in a parent object:

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = { data: [], layout: {}, frames: [], config: {} };
    }

    render() {
        return (
            <Plot
                data={this.state.data}
                layout={this.state.layout}
                frames={this.state.frames}
                config={this.state.config}
                onInitialized={(figure) => this.setState(figure)}
                onUpdate={(figure) => this.setState(figure)}
            />
        );
    }
}

Refreshing the Plot

This component will refresh the plot via Plotly.react if any of the following are true:

  • The revision prop is defined and has changed, OR;
  • One of data, layout or config has changed identity as checked via a shallow ===, OR;
  • The number of elements in frames has changed

Furthermore, when called, Plotly.react will only refresh the data being plotted if the identity of the data arrays (e.g. x, y, marker.color etc) has changed, or if layout.datarevision has changed.

In short, this means that simply adding data points to a trace in data or changing a value in layout will not cause a plot to update unless this is done immutably via something like immutability-helper if performance considerations permit it, or unless revision and/or layout.datarevision are used to force a rerender.

API Reference

Basic Props

Warning: for the time being, this component may mutate its layout and data props in response to user input, going against React rules. This behaviour will change in the near future once plotly/plotly.js#2389 is completed.

Prop Type Default Description
data Array [] list of trace objects (see https://plot.ly/javascript/reference/)
layout Object undefined layout object (see https://plot.ly/javascript/reference/#layout)
frames Array undefined list of frame objects (see https://plot.ly/javascript/reference/)
config Object undefined config object (see https://plot.ly/javascript/configuration-options/)
revision Number undefined When provided, causes the plot to update when the revision is incremented.
onInitialized Function(figure, graphDiv) undefined Callback executed after plot is initialized. See below for parameter information.
onUpdate Function(figure, graphDiv) undefined Callback executed when when a plot is updated due to new data or layout, or when user interacts with a plot. See below for parameter information.
onPurge Function(figure, graphDiv) undefined Callback executed when component unmounts, before Plotly.purge strips the graphDiv of all private attributes. See below for parameter information.
onError Function(err) undefined Callback executed when a plotly.js API method rejects
divId string undefined id assigned to the <div> into which the plot is rendered.
className string undefined applied to the <div> into which the plot is rendered
style Object {position: 'relative', display: 'inline-block'} used to style the <div> into which the plot is rendered
debug Boolean false Assign the graph div to window.gd for debugging
useResizeHandler Boolean false When true, adds a call to Plotly.Plot.resize() as a window.resize event handler

Note: To make a plot responsive, i.e. to fill its containing element and resize when the window is resized, use style or className to set the dimensions of the element (i.e. using width: 100%; height: 100% or some similar values) and set useResizeHandler to true while setting layout.autosize to true and leaving layout.height and layout.width undefined. This can be seen in action in this CodePen and will implement the behaviour documented here: https://plot.ly/javascript/responsive-fluid-layout/

Callback signature: Function(figure, graphDiv)

The onInitialized, onUpdate and onPurge props are all functions which will be called with two arguments: figure and graphDiv.

  • figure is a serializable object with three keys corresponding to input props: data, layout and frames.
    • As mentioned above, for the time being, this component may mutate its layout and data props in response to user input, going against React rules. This behaviour will change in the near future once plotly/plotly.js#2389 is completed.
  • graphDiv is a reference to the (unserializable) DOM node into which the figure was rendered.

Event handler props

Event handlers for specific plotly.js events may be attached through the following props:

Prop Type Plotly Event
onAfterExport Function plotly_afterexport
onAfterPlot Function plotly_afterplot
onAnimated Function plotly_animated
onAnimatingFrame Function plotly_animatingframe
onAnimationInterrupted Function plotly_animationinterrupted
onAutoSize Function plotly_autosize
onBeforeExport Function plotly_beforeexport
onButtonClicked Function plotly_buttonclicked
onClick Function plotly_click
onClickAnnotation Function plotly_clickannotation
onDeselect Function plotly_deselect
onDoubleClick Function plotly_doubleclick
onFramework Function plotly_framework
onHover Function plotly_hover
onLegendClick Function plotly_legendclick
onLegendDoubleClick Function plotly_legenddoubleclick
onRelayout Function plotly_relayout
onRestyle Function plotly_restyle
onRedraw Function plotly_redraw
onSelected Function plotly_selected
onSelecting Function plotly_selecting
onSliderChange Function plotly_sliderchange
onSliderEnd Function plotly_sliderend
onSliderStart Function plotly_sliderstart
onTransitioning Function plotly_transitioning
onTransitionInterrupted Function plotly_transitioninterrupted
onUnhover Function plotly_unhover

Customizing the plotly.js bundle

By default, the Plot component exported by this library loads a precompiled version of all of plotly.js, so plotly.js must be installed as a peer dependency. This bundle is around 6Mb unminified, and minifies to just over 2Mb.

If you do not wish to use this version of plotly.js, e.g. if you want to use a different precompiled bundle or if your wish to assemble you own customized bundle, or if you wish to load plotly.js from a CDN, you can skip the installation of as a peer dependency (and ignore the resulting warning) and use the createPlotComponent method to get a Plot component, instead of importing it:

// simplest method: uses precompiled complete bundle from `plotly.js`
import Plot from 'react-plotly.js';

// customizable method: use your own `Plotly` object
import createPlotlyComponent from 'react-plotly.js/factory';
const Plot = createPlotlyComponent(Plotly);

Loading from a <script> tag

For quick one-off demos on CodePen or JSFiddle, you may wish to just load the component directly as a script tag. We don't host the bundle directly, so you should never rely on this to work forever or in production, but you can use a third-party service to load the factory version of the component from, for example, https://unpkg.com/react-plotly.js@latest/dist/create-plotly-component.js.

You can load plotly.js and the component factory with:

<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://unpkg.com/react-plotly.js@latest/dist/create-plotly-component.js"></script>

And instantiate the component with

const Plot = createPlotlyComponent(Plotly);

ReactDOM.render(
  React.createElement(Plot, {
    data: [{x: [1, 2, 3], y: [2, 1, 3]}],
  }),
  document.getElementById('root')
);

You can see an example of this method in action here.

Development

To get started:

$ npm install

To transpile from ES2015 + JSX into the ES5 npm-distributed version:

$ npm run prepublishOnly

To run the tests:

$ npm run test

License

© 2017 Plotly, Inc. MIT License.

About

This repo's intent is to allow users to autonomously predict and make stock price actions.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published