This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is messy, still needs work. it will calculate the correct value with over 100points. | |
// lower v | |
///! Converted from the offical examples from. | |
/// https://www.tradingview.com/pine-script-reference/v6/ | |
#[derive(Debug, Clone)] | |
struct Series { | |
closes: Vec<f64>, | |
period: f64, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add to echarts struct | |
// graphic: Vec<Graphic> | |
// add graphic: vec![], | |
// to chart > new | |
// add to implementation | |
pub fn graphic<I>(mut self, graphic: I) -> Self | |
where | |
I: IntoIterator<Item = Graphic>, | |
{ | |
self.graphic.extend(graphic); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q | |
/// Guard pattern with let-else | |
/// e.g., "my_key: 123" | |
pub fn key_num_guard_1(item: &str) -> Result<(&str, i32), &'static str> { | |
let Some((key, val)) = item.split_once(':') else { | |
return Err("Invalid item"); | |
}; | |
let Ok(val) = val.trim().parse::<i32>() else { | |
return Err("Invalid item"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use leptos::*; | |
#[component] | |
pub fn TradingView(symbol: String) -> impl IntoView { | |
// Creates a reactive value to update the button | |
view! { | |
<div class="tradingview-container" style="width:100%;"> | |
<div class="tradingview-widget-container" style="height:100%;width:100%"> | |
<div class="tradingview-widget-container__widget" style="height:calc(100% - 32px);width:100%"></div> | |
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js" async inner_html=r#" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
from numpy import array | |
from numpy import argmax | |
from pandas import concat | |
from pandas import DataFrame | |
from keras.models import Sequential | |
from keras.layers import LSTM | |
from keras.layers import Dense | |
# generate a sequence of random numbers in [0, 99] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function() { | |
const canvas = document.getElementById('canvas'); | |
const ctx = canvas.getContext('2d'); | |
// Set canvas dimensions | |
canvas.width = 800; | |
canvas.height = 400; | |
let wave = { | |
y: canvas.height / 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="Access-Control-Allow-Origin" content="*" /> | |
<!-- Disable zooming: --> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1.0, user-scalable=no" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[unstable] | |
codegen-backend = true | |
[build] | |
rustc-wrapper = '/home/sangel/.cargo/bin/sccache' | |
rustflags = ["-Z", "threads=16"] | |
[target.x86_64-unknown-linux-gnu] | |
linker = "clang" | |
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server-Sent Events (SSE) with tokio broadcast channel - with cors | |
// Note: seems to be cors error still while connecting. | |
use async_stream::stream; | |
use axum:: { | |
extract::State, response::{sse::{Event, KeepAlive, Sse}, IntoResponse}, routing::get, Json, Router | |
}; | |
use std::{ | |
convert::Infallible, sync::Arc, time::Duration | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server-Sent Events (SSE) with tokio broadcast channel | |
// Update: removed arc/mutex. | |
use async_stream::stream; | |
use axum:: { | |
extract::State, response::{sse::{Event, KeepAlive, Sse}, IntoResponse}, routing::get, Json, Router | |
}; | |
use std::{ | |
convert::Infallible, sync::Arc, time::Duration | |
}; |
NewerOlder