rate limit DCA

This commit is contained in:
tim
2025-03-19 20:27:10 -04:00
parent cd84e7c3c9
commit 8750951de5
14 changed files with 651 additions and 325 deletions

View File

@@ -1,6 +1,6 @@
import {useChartOrderStore} from "@/orderbuild.js";
import {invokeCallbacks, prototype} from "@/common.js";
import {DataFeed, feelessTickerKey, getAllSymbols, lookupSymbol} from "@/charts/datafeed.js";
import {DataFeed, defaultSymbol, feelessTickerKey, getAllSymbols, lookupSymbol} from "@/charts/datafeed.js";
import {intervalToSeconds, SingletonCoroutine} from "@/misc.js";
import {usePrefStore, useStore} from "@/store/store.js";
import {tvCustomThemes} from "../../theme.js";
@@ -24,9 +24,10 @@ export function removeSymbolChangedCallback(cb) {
}
function symbolChanged(symbol) {
const info = symbol===null ? null : lookupSymbol(symbol.ticker)
const info = symbol===null ? (defaultSymbol===null?'default':defaultSymbol) : lookupSymbol(symbol.ticker)
co.selectedSymbol = info
prefs.selectedTicker = info?.ticker
console.log('setting prefs ticker', info.ticker)
prefs.selectedTicker = info.ticker
symbolChangedCbs.forEach((cb) => cb(info))
updateFeeDropdown()
console.log('symbol changed', info)
@@ -149,6 +150,7 @@ export function initWidget(el) {
drawings_access: {type: 'white', tools: [],}, // show no tools
custom_themes: tvCustomThemes,
theme: useStore().theme,
timezone: prefs.timezone,
// Chart Overrides
// https://www.tradingview.com/charting-library-docs/latest/customization/overrides/chart-overrides
@@ -182,8 +184,7 @@ function initChart() {
chart.onIntervalChanged().subscribe(null, changeInterval)
chart.onDataLoaded().subscribe(null, dataLoaded)
const tzapi = chart.getTimezoneApi();
tzapi.onTimezoneChanged().subscribe(null, (tz)=>{if (tz==='exchange') tz='Etc/UTC'; s.timeZone=tz})
s.timeZone = tzapi.getTimezone().id
tzapi.onTimezoneChanged().subscribe(null, (tz)=>{if (tz==='exchange') tz='Etc/UTC'; prefs.timezone=tz;})
// chart.onHoveredSourceChanged().subscribe(null, ()=>console.log('hovered source changed', arguments))
// chart.selection().onChanged().subscribe(null, s => console.log('selection', chart.selection().allSources()));
const symbolExt = chart.symbolExt();
@@ -358,7 +359,7 @@ function doHandleCrosshairMovement(point) {
const lpbe = shape._model._linePointBeingEdited
points[lpbe] = point
// console.log('drag calling onPoints', points, shape, lpbe)
invokeCallbacks(shapeCallbacks[shapeId], 'onPoints', shapeId, shape, points)
invokeCallbacks(shapeCallbacks[shapeId], 'onDrag', shapeId, shape, points)
}
}
else if (draggingShapeIds.length > 0) {