Skip to content

Commit

Permalink
add option for post market price
Browse files Browse the repository at this point in the history
  • Loading branch information
rssnyder committed Mar 2, 2021
1 parent 6d43215 commit 0daf922
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ The bots above are hosted in bulk. They are free to use on any discord server.

You can have private instances only for your servers, with real time price updates. There is a full logging stack that includes loki & promtail with grafana for visualization. See contact info below for private bot inquiries.

If you encounter any issues with the bots please see the support options at the bottom of this page.

![Really cool grafana dashboard](https://s3.oc0.rileysnyder.org/public/assets/grafana.png)

### Self-Hosting
Expand Down Expand Up @@ -120,15 +118,23 @@ export SET_NICKNAME=1
export FREQUENCY=3
```

Other options:

```
export LOG_FILE=log.log # log to file instead of stdout
export POST_MARKET_PRICE=3 # display post market price instead of difference
```

Once all your options are set, simply install the dependencies and run the bot (virtual environments might be a smart idea):

```
pip3 install -r requirements.txt
python3 main.py
```

### Docker

You can also run these bots using docker. This can make running multiple bots esier. Here is an example docker compose file:
You can also run these bots using docker. This can make running multiple bots esier. Here is an example docker compose file (please check for the latest release and update the tags accordingly):

```
---
Expand Down
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,19 @@ async def stock_update_activity(self, ticker: str, name: str, change_nick: bool

# If after hours, get change
if price_data.get('postMarketChange'):
raw_diff = price_data.get('postMarketChange', {}).get('raw', 0.00)

# Get difference or new price
if getenv('POST_MARKET_PRICE'):
post_market_target = 'postMarketPrice'
else:
post_market_target = 'postMarketChange'

raw_diff = price_data.get(post_market_target, {}).get('raw', 0.00)
diff = round(raw_diff, 2)
if diff > 0:
diff = '+' + str(diff)

if not getenv('POST_MARKET_PRICE'):
if diff > 0:
diff = '+' + str(diff)

activity_content = f'After Hours: {diff}'
logging.info(f'stock activity after hours price retrived: {activity_content}')
Expand Down

0 comments on commit 0daf922

Please sign in to comment.