Spaces:
Running
Running
Upload pages/index.js with huggingface_hub
Browse files3 unmodified lines456789102 unmodified lines1314151617183 unmodified lines22232425262733 unmodified lines61626364656615 unmodified lines82838485868712 unmodified lines10010110210310410510615 unmodified lines1221231241251261271282 unmodified lines1311321331341351363 unmodified linesimport KnowledgePanel from '../components/KnowledgePanel'import MarketChart from '../components/MarketChart'import SignalPanel from '../components/SignalPanel'import { getKnowledgeBase } from '../lib/knowledge-base'import { initializeMarket, getMarketTick, analyzeMarket } from '../lib/market-simulator'export default function Home() {2 unmodified linesconst [currentTick, setCurrentTick] = useState({ price: 0, rsi: 0, volume: 0, trend: 'UP' })const [signals, setSignals] = useState([])const [isRunning, setIsRunning] = useState(false)// Keep only last 50 points for chartconst MAX_DATA_POINTS = 503 unmodified lines// Load Knowledge Baseconst kb = getKnowledgeBase()setKnowledgeBase(kb)// Initialize Market SimulatorinitializeMarket()33 unmodified linessetIsRunning(!isRunning)}return (<><Head>15 unmodified lines<p className="text-sm text-dark-400">Real-time analysis based on loaded JSON rules</p></div><div className="flex items-center space-x-4"><buttononClick={toggleSimulation}className={`px-6 py-2 rounded-lg font-medium transition-all ${12 unmodified lines{/* Left Column: Knowledge Base (1/4 width) */}<div className="lg:col-span-1 h-[600px]"><KnowledgePanel rules={knowledgeBase} /></div>{/* Right Column: Trading Interface (3/4 width) */}15 unmodified lines<div><h4 className="text-sm font-medium text-primary-300">How it works</h4><p className="text-sm text-dark-400 mt-1">This application loads trading strategies from a JSON knowledge base. It simulates real-time market data and compares current indicators (RSI, Volume, Price) against your rules to generate Long/Short signals automatically.</p></div></div>2 unmodified lines</div></main></div></>)}3 unmodified lines45678910112 unmodified lines14151617181920213 unmodified lines2526272829303133 unmodified lines656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510615 unmodified lines12212312412512612712812913013113213313412 unmodified lines14714814915015115215315415515615715815 unmodified lines1741751761771781791802 unmodified lines1831841851861871881891901911921931943 unmodified linesimport KnowledgePanel from '../components/KnowledgePanel'import MarketChart from '../components/MarketChart'import SignalPanel from '../components/SignalPanel'import JsonUploadModal from '../components/JsonUploadModal'import { getKnowledgeBase, addKnowledgeBaseRules, removeCustomRule, clearAllCustomRules, getCustomRulesCount } from '../lib/knowledge-base'import { initializeMarket, getMarketTick, analyzeMarket } from '../lib/market-simulator'export default function Home() {2 unmodified linesconst [currentTick, setCurrentTick] = useState({ price: 0, rsi: 0, volume: 0, trend: 'UP' })const [signals, setSignals] = useState([])const [isRunning, setIsRunning] = useState(false)const [isModalOpen, setIsModalOpen] = useState(false)const [customRulesCount, setCustomRulesCount] = useState(0)// Keep only last 50 points for chartconst MAX_DATA_POINTS = 503 unmodified lines// Load Knowledge Baseconst kb = getKnowledgeBase()setKnowledgeBase(kb)setCustomRulesCount(getCustomRulesCount())// Initialize Market SimulatorinitializeMarket()33 unmodified linessetIsRunning(!isRunning)}const handleFileUpload = (event) => {const file = event.target.files[0]if (!file) returnconst reader = new FileReader()reader.onload = (e) => {try {const rules = JSON.parse(e.target.result)if (Array.isArray(rules)) {const added = addKnowledgeBaseRules(rules)setKnowledgeBase(getKnowledgeBase())setCustomRulesCount(getCustomRulesCount())}} catch (error) {console.error('Invalid JSON file:', error)}}reader.readAsText(file)}const handleTextUpload = (rules) => {addKnowledgeBaseRules(rules)setKnowledgeBase(getKnowledgeBase())setCustomRulesCount(getCustomRulesCount())}const handleRemoveRule = (ruleId) => {if (ruleId === 'all') {clearAllCustomRules()} else {removeCustomRule(ruleId)}setKnowledgeBase(getKnowledgeBase())setCustomRulesCount(getCustomRulesCount())}return (<><Head>15 unmodified lines<p className="text-sm text-dark-400">Real-time analysis based on loaded JSON rules</p></div><div className="flex items-center space-x-4"><buttononClick={() => setIsModalOpen(true)}className="btn-secondary flex items-center space-x-2"><span>📄</span><span>Add JSON Rules</span></button><buttononClick={toggleSimulation}className={`px-6 py-2 rounded-lg font-medium transition-all ${12 unmodified lines{/* Left Column: Knowledge Base (1/4 width) */}<div className="lg:col-span-1 h-[600px]"><KnowledgePanelrules={knowledgeBase}onUpload={handleFileUpload}onRemoveRule={handleRemoveRule}customRulesCount={customRulesCount}/></div>{/* Right Column: Trading Interface (3/4 width) */}15 unmodified lines<div><h4 className="text-sm font-medium text-primary-300">How it works</h4><p className="text-sm text-dark-400 mt-1">This application loads trading strategies from a JSON knowledge base. You can add your own custom rules by uploading JSON files or pasting JSON directly. The system simulates real-time market data and compares current indicators (RSI, Volume, Price) against your rules to generate Long/Short signals automatically.</p></div></div>2 unmodified lines</div></main></div><JsonUploadModalisOpen={isModalOpen}onClose={() => setIsModalOpen(false)}onUpload={handleTextUpload}/></>)}
pages/index.js+61-3