Skip to content

Commit

Permalink
0.0.1 added files
Browse files Browse the repository at this point in the history
  • Loading branch information
jookie committed Sep 30, 2024
1 parent b43db3e commit a176fb2
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/api/run-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { exec } from 'child_process';
import type { NextApiRequest, NextApiResponse } from 'next';

export default function handler(req: NextApiRequest, res: NextApiResponse) {
exec('python ./../../scripts/train.py', (error, stdout, stderr) => {
exec('python t1.py', (error, stdout, stderr) => {
if (error) {
res.status(500).json({ error: stderr });
} else {
Expand Down
10 changes: 6 additions & 4 deletions components/jojoTrade/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Button } from '@vercel/examples-ui'

export function Chatbot() {
const [input, setInput] = useState('')
const [result, setResult] = useState('')
const [result, setResult] = useState('Results will appear here')

const handleSubmit = async () => {
const res = await fetch('/api/run-script', {
const res = await fetch('run-script', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand All @@ -20,14 +20,16 @@ export function Chatbot() {

return (
<div>
{/* <input
{<input
type="text"
value={input}
onChange={e => setInput(e.target.value)}
placeholder="Enter your message"
/> */}
/> }
<Button>Run Script</Button>

<div>{result ? `Result: ${result}` : 'Waiting for result...'}</div>

</div>
)
}
4 changes: 2 additions & 2 deletions components/jojoTrade/ColabNotebooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const notebooks = [
link: 'https://colab.research.google.com/github/alpacahq/alpaca-py/blob/master/examples/crypto-trading-basic.ipynb'
},
{
name: 'Stock Trading 1',
name: 'Stock Ensemble',
file: 'FinRL_Ensemble_StockTrading_ICAIF_2020.ipynb',
link: 'https://colab.research.google.com/github/AI4Finance-Foundation/FinRL-Tutorials/blob/master/2-Advance/FinRL_Ensemble_StockTrading_ICAIF_2020.ipynb'
},
}
]
import { cn } from '@/lib/utils'

Expand Down
80 changes: 80 additions & 0 deletions components/jojoTrade/ExampleMsg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Description: This file contains utility functions that are used across the project.

// Importing the useState and useEffect hooks from React.
"use client";

import * as React from 'react'
import { useState, useEffect } from 'react'
import { Button } from '@/components/ui/button'
import { PromptForm } from '@/components/prompt-form'
import { ButtonScrollToBottom } from '@/components/button-scroll-to-bottom'
import { IconShare } from '@/components/ui/icons'
import { FooterText } from '@/components/footer'
import { useAIState, useActions, useUIState } from 'ai/rsc'
import type { AI } from '@/lib/chat/actions'
import { nanoid } from 'nanoid'
import { ColabNotebooks } from '@/components/jojoTrade/ColabNotebooks'

export function ExampleMessage() {

interface ExampleMessage {
heading: string
subheading: string
message: string
}

const exampleMessages = [
{
heading: 'What is the price',
subheading: 'of Apple Inc.?',
message: 'What is the price of Apple stock?'
},
{
heading: 'Show me a stock chart',
subheading: 'for $GOOGL',
message: 'Show me a stock chart for $GOOGL'
},
{
heading: 'What are some recent',
subheading: `events about Amazon?`,
message: `What are some recent events about Amazon?`
},
{
heading: `What are Microsoft's`,
subheading: 'latest financials?',
message: `What are Microsoft's latest financials?`
},
{
heading: 'How is the stock market',
subheading: 'performing today by sector?',
message: `How is the stock market performing today by sector?`
},
{
heading: 'Show me a screener',
subheading: 'to find new stocks',
message: 'Show me a screener to find new stocks'
}
]

const [randExamples, setRandExamples] = useState<ExampleMessage[]>([])

useEffect(() => {
const shuffledExamples = [...exampleMessages].sort(
() => 0.5 - Math.random()
)
setRandExamples(shuffledExamples)
}, [])

return (
<div>
{/* {randExamples.map((example, index) => (
<div key={index}>
<h4>{example.heading}</h4>
<p>{example.subheading}</p>
<p>{example.message}</p>
</div>
))} */}
</div>
)
}

File renamed without changes.
35 changes: 35 additions & 0 deletions components/jojoTrade/StockTrade.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ToggleSwitch.js (React)
"use client";

import React, { useState } from 'react'

export function ToggleSwitch() {
const [isToggled, setIsToggled] = useState(false)
const [output, setOutput] = useState('')

const handleToggle = async () => {
setIsToggled(!isToggled)

if (!isToggled) {
// Fetch backtest result from Python backend
const response = await fetch('/run-backtest')
const data = await response.json()
setOutput(data.output) // Display backtest result in the browser
} else {
setOutput('')
}
}

return (
<div>
<label>
<input type="checkbox" checked={isToggled} onChange={handleToggle} />
Run Backtest
</label>
<div>
<pre>{output}</pre>
</div>
</div>
)
}

2 changes: 1 addition & 1 deletion pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
git push --set-upstream origin main
git branch -M main
git add .
git commit -m "vercel-fix"
git commit -m "0.0.1 added files"
git push -u origin main
# -----------Go to GitHub and log in.
# 1. Click on the "New" button to create a new repository.
Expand Down

0 comments on commit a176fb2

Please sign in to comment.