diff --git a/app/api/run-script.ts b/app/api/run-script.ts index bd545cd..61c858b 100644 --- a/app/api/run-script.ts +++ b/app/api/run-script.ts @@ -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 { diff --git a/components/jojoTrade/Chatbot.tsx b/components/jojoTrade/Chatbot.tsx index 3f27913..b22946a 100644 --- a/components/jojoTrade/Chatbot.tsx +++ b/components/jojoTrade/Chatbot.tsx @@ -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' @@ -20,14 +20,16 @@ export function Chatbot() { return (
- {/* setInput(e.target.value)} placeholder="Enter your message" - /> */} + /> } +
{result ? `Result: ${result}` : 'Waiting for result...'}
+
) } diff --git a/components/jojoTrade/ColabNotebooks.tsx b/components/jojoTrade/ColabNotebooks.tsx index 74c1369..3edb32d 100644 --- a/components/jojoTrade/ColabNotebooks.tsx +++ b/components/jojoTrade/ColabNotebooks.tsx @@ -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' diff --git a/components/jojoTrade/ExampleMsg.tsx b/components/jojoTrade/ExampleMsg.tsx new file mode 100644 index 0000000..b629620 --- /dev/null +++ b/components/jojoTrade/ExampleMsg.tsx @@ -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([]) + + useEffect(() => { + const shuffledExamples = [...exampleMessages].sort( + () => 0.5 - Math.random() + ) + setRandExamples(shuffledExamples) + }, []) + + return ( +
+ {/* {randExamples.map((example, index) => ( +
+

{example.heading}

+

{example.subheading}

+

{example.message}

+
+ ))} */} +
+ ) +} + diff --git a/components/RunDrlButton.tsx b/components/jojoTrade/RunDrlButton.tsx similarity index 100% rename from components/RunDrlButton.tsx rename to components/jojoTrade/RunDrlButton.tsx diff --git a/components/jojoTrade/StockTrade.tsx b/components/jojoTrade/StockTrade.tsx new file mode 100644 index 0000000..1c2a08d --- /dev/null +++ b/components/jojoTrade/StockTrade.tsx @@ -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 ( +
+ +
+
{output}
+
+
+ ) +} + diff --git a/pub.sh b/pub.sh index 2c8e1da..c37b62c 100755 --- a/pub.sh +++ b/pub.sh @@ -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.