stonk-ticker
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Stonk Ticker npm

Price ticker from Robinhood for React apps

See it in action

Install

npm install stonk-ticker

Example

import React, { useState } from "react";
import Ticker, { toMoneyString } from "stonk-ticker";

function App() {
    const [value, setValue] = useState({
        price: 1000,
        movement: "up",
    });

    useEffect(() => {
        const int = setInterval(() => {
            const nextPriceDiff = Math.random() * 10 - 5;

            setValue(({ price: prevPrice }) => ({
                price: prevPrice + nextPriceDiff,
                movement: nextPriceDiff <= 0 ? "down" : "up",
            }));
        }, 1000);

        return () => clearInterval(int);
    });

    return (
        <Ticker
            value={ toMoneyString(value.price) }
            movement={ value.movement }
        />
    );
}

Props

Prop Type
value `string number`
direction `"up" "down"`
dictionary string[] The set of characters the ticker cycles through. Default dictionary covers characters for USD money representation
constants string[] Characters that stay constant, but left-relative to the string ($) for example in a USD string.
colors string[] colors[0] is the color of text for an up movement, and the colors[1] is the down color

Package Sidebar

Install

npm i stonk-ticker

Weekly Downloads

13

Version

1.0.1

License

MIT

Unpacked Size

14.5 kB

Total Files

12

Last publish

Collaborators

  • sizzling-porcupine